import { tenantDb } from '../config/database.js';
import { computeMetricaMensual } from '../services/metricas-compute.service.js';

async function main() {
  const tenantId = 'c52c2f5d-b1ae-45c6-8cc8-b11c9611618a';
  const dbName = 'horux_hts240708lja';
  const contribuyenteId = '4a1d6014-f705-424b-b185-7740be6a80c6';
  const pool = await tenantDb.getPool(tenantId, dbName);

  for (const mes of [1, 2, 3]) {
    console.log(`Recalculando 2026-${String(mes).padStart(2, '0')}...`);
    const r = await computeMetricaMensual(pool, tenantId, contribuyenteId, 2026, mes);
    console.log(`  Filas escritas: ${r.filasEscritas}`);
  }

  await pool.end();
  process.exit(0);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
