Initial commit - Horux Despachos NL
This commit is contained in:
67
apps/api/scripts/debug-p-mayo.ts
Normal file
67
apps/api/scripts/debug-p-mayo.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Diseca 2 complementos P de Horux 360 que el usuario espera ver en mayo
|
||||
* pero no aparecen. Verifica fecha_emision vs fecha_pago_p para entender
|
||||
* en qué mes los está sumando el cálculo.
|
||||
*/
|
||||
import { prisma, tenantDb } from '../src/config/database.js';
|
||||
|
||||
async function main() {
|
||||
const tenants = await prisma.tenant.findMany({
|
||||
where: { active: true },
|
||||
select: { id: true, rfc: true, nombre: true, databaseName: true },
|
||||
});
|
||||
|
||||
const UUIDS = [
|
||||
'CFACB97E-5426-48D4-A3B9-06B5D160F307',
|
||||
'384CF943-EFB0-475A-B6B6-240E96088B37',
|
||||
];
|
||||
|
||||
// Loop por todos los tenants
|
||||
for (const t of tenants) {
|
||||
const pool = await tenantDb.getPool(t.id, t.databaseName);
|
||||
console.log(`\n>>> Tenant: ${t.rfc} (${t.nombre}) <<<`);
|
||||
|
||||
for (const uuid of UUIDS) {
|
||||
const { rows: [c] } = await pool.query(`
|
||||
SELECT uuid, type, tipo_comprobante, metodo_pago, forma_pago, uso_cfdi,
|
||||
cfdi_tipo_relacion,
|
||||
total_mxn, monto_pago_mxn, iva_traslado_pago_mxn,
|
||||
rfc_emisor, regimen_fiscal_emisor,
|
||||
rfc_receptor, regimen_fiscal_receptor,
|
||||
fecha_emision, fecha_pago_p, status
|
||||
FROM cfdis WHERE LOWER(uuid) = LOWER($1)
|
||||
`, [uuid]);
|
||||
|
||||
console.log(`\n═══ CFDI ${uuid} ═══`);
|
||||
if (!c) { console.log(' (NO ENCONTRADO en BD de Horux 360)'); continue; }
|
||||
|
||||
console.log(` Tipo: ${c.tipo_comprobante} ${c.metodo_pago || ''}`);
|
||||
console.log(` Status: ${c.status}`);
|
||||
console.log(` type (lado): ${c.type}`);
|
||||
console.log(` rfc_emisor: ${c.rfc_emisor} (régimen ${c.regimen_fiscal_emisor})`);
|
||||
console.log(` rfc_receptor: ${c.rfc_receptor} (régimen ${c.regimen_fiscal_receptor})`);
|
||||
console.log(` total_mxn: $${c.total_mxn}`);
|
||||
console.log(` monto_pago_mxn: $${c.monto_pago_mxn}`);
|
||||
console.log(` iva_traslado_pago: $${c.iva_traslado_pago_mxn}`);
|
||||
console.log(` ──────────────────────────────────────`);
|
||||
console.log(` fecha_emision: ${c.fecha_emision}`);
|
||||
console.log(` fecha_pago_p: ${c.fecha_pago_p}`);
|
||||
console.log(` ──────────────────────────────────────`);
|
||||
|
||||
// Análisis: en qué mes "cae" según el cálculo de ingresos (Grupo 1 — FR_PAGO usa fecha_pago_p)
|
||||
const fecPago = c.fecha_pago_p ? new Date(c.fecha_pago_p) : null;
|
||||
const fecEmi = c.fecha_emision ? new Date(c.fecha_emision) : null;
|
||||
if (fecPago) {
|
||||
console.log(` En cálculo Ingresos: APARECE EN ${fecPago.getFullYear()}-${String(fecPago.getMonth() + 1).padStart(2, '0')}`);
|
||||
console.log(` (filtro: fecha_pago_p)`);
|
||||
}
|
||||
if (fecEmi) {
|
||||
console.log(` En filtros UI fecha: se EMITIÓ en ${fecEmi.getFullYear()}-${String(fecEmi.getMonth() + 1).padStart(2, '0')}`);
|
||||
}
|
||||
}
|
||||
} // close tenant loop
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main().catch(e => { console.error(e); process.exit(1); });
|
||||
Reference in New Issue
Block a user