fix(conciliacion): complementos de pago usan fecha_pago_p y campos faltantes en visor
- conciliacion.service.ts: filtros y ordenamiento ahora usan
COALESCE(fecha_pago_p, fecha_emision). Los CFDIs tipo P
(complementos de pago) aparecen en el periodo del pago real,
no de la emision del CFDI.
- conciliacion.service.ts: agrega fechaPagoP al SELECT y a la
interfaz ConciliacionCfdi.
- conciliacion/page.tsx: tablas y export Excel usan
fechaPagoP || fechaEmision para mostrar la fecha.
- cfdi-invoice.tsx: para tipo P con fechaPagoP, muestra
'Pago: {fecha}' en el encabezado.
- conciliacion.ts: actualiza interfaz ConciliacionCfdi con
todos los campos que ya devuelve el backend.
Refs: docs/CAMBIOS-2026-05-09.md secciones 7 y 8
This commit is contained in:
@@ -25,6 +25,7 @@ export interface ConciliacionCfdi {
|
||||
usoCfdi: string | null;
|
||||
status: string | null;
|
||||
fechaCertSat: string | null;
|
||||
fechaPagoP: string | null;
|
||||
ivaTraslado: number;
|
||||
ivaRetencion: number;
|
||||
isrRetencion: number;
|
||||
@@ -66,11 +67,11 @@ export async function getCfdisConConciliacion(
|
||||
}
|
||||
|
||||
if (filters.fechaInicio) {
|
||||
where += ` AND c.fecha_emision >= $${idx++}::date`;
|
||||
where += ` AND COALESCE(c.fecha_pago_p, c.fecha_emision) >= $${idx++}::date`;
|
||||
params.push(filters.fechaInicio);
|
||||
}
|
||||
if (filters.fechaFin) {
|
||||
where += ` AND c.fecha_emision <= ($${idx++}::date + interval '1 day')`;
|
||||
where += ` AND COALESCE(c.fecha_pago_p, c.fecha_emision) <= ($${idx++}::date + interval '1 day')`;
|
||||
params.push(filters.fechaFin);
|
||||
}
|
||||
if (filters.regimen) {
|
||||
@@ -106,6 +107,7 @@ export async function getCfdisConConciliacion(
|
||||
c.uso_cfdi as "usoCfdi",
|
||||
c.status,
|
||||
c.fecha_cert_sat as "fechaCertSat",
|
||||
c.fecha_pago_p as "fechaPagoP",
|
||||
c.iva_traslado as "ivaTraslado",
|
||||
c.iva_retencion as "ivaRetencion",
|
||||
c.isr_retencion as "isrRetencion",
|
||||
@@ -119,7 +121,7 @@ export async function getCfdisConConciliacion(
|
||||
LEFT JOIN conciliaciones con ON con.id_cfdi = c.id
|
||||
LEFT JOIN bancos b ON b.id = con.id_banco
|
||||
${where}
|
||||
ORDER BY c.fecha_emision DESC
|
||||
ORDER BY COALESCE(c.fecha_pago_p, c.fecha_emision) DESC
|
||||
`, params);
|
||||
|
||||
return rows.map((r: any) => ({
|
||||
@@ -150,6 +152,7 @@ export async function getCfdisConConciliacion(
|
||||
usoCfdi: r.usoCfdi,
|
||||
status: r.status,
|
||||
fechaCertSat: r.fechaCertSat,
|
||||
fechaPagoP: r.fechaPagoP,
|
||||
ivaTraslado: Number(r.ivaTraslado || 0),
|
||||
ivaRetencion: Number(r.ivaRetencion || 0),
|
||||
isrRetencion: Number(r.isrRetencion || 0),
|
||||
|
||||
@@ -113,7 +113,7 @@ export default function ConciliacionPage() {
|
||||
exportToExcel(
|
||||
cfdis.map((c) => ({
|
||||
...c,
|
||||
_fecha: new Date(c.fechaEmision).toLocaleDateString('es-MX'),
|
||||
_fecha: new Date(c.fechaPagoP || c.fechaEmision).toLocaleDateString('es-MX'),
|
||||
_totalMxn: getMonto(c),
|
||||
_estado: c.conciliado === 'true' ? 'Conciliado' : 'Pendiente',
|
||||
_fechaPago: c.conciliacion?.fechaDePago || '',
|
||||
@@ -251,7 +251,7 @@ export default function ConciliacionPage() {
|
||||
{cfdi.uuid?.substring(0, 8)}
|
||||
</td>
|
||||
<td className="py-2 text-xs">
|
||||
{new Date(cfdi.fechaEmision).toLocaleDateString('es-MX')}
|
||||
{new Date(cfdi.fechaPagoP || cfdi.fechaEmision).toLocaleDateString('es-MX')}
|
||||
</td>
|
||||
<td className="py-2 font-mono text-xs">{cfdi.rfcEmisor}</td>
|
||||
<td className="py-2 text-xs truncate max-w-[120px]">
|
||||
@@ -347,7 +347,7 @@ export default function ConciliacionPage() {
|
||||
{cfdi.uuid?.substring(0, 8)}
|
||||
</td>
|
||||
<td className="py-2 text-xs">
|
||||
{new Date(cfdi.fechaEmision).toLocaleDateString('es-MX')}
|
||||
{new Date(cfdi.fechaPagoP || cfdi.fechaEmision).toLocaleDateString('es-MX')}
|
||||
</td>
|
||||
<td className="py-2 font-mono text-xs">{cfdi.rfcEmisor}</td>
|
||||
<td className="py-2 text-xs truncate max-w-[120px]">
|
||||
|
||||
@@ -129,7 +129,11 @@ export const CfdiInvoice = forwardRef<HTMLDivElement, CfdiInvoiceProps>(
|
||||
{cfdi.serie && <span className="text-blue-300">{cfdi.serie}-</span>}
|
||||
{cfdi.folio || 'S/N'}
|
||||
</div>
|
||||
<p className="text-blue-200 text-sm mt-1">{formatDate(cfdi.fechaEmision)}</p>
|
||||
<p className="text-blue-200 text-sm mt-1">
|
||||
{cfdi.tipoComprobante === 'P' && cfdi.fechaPagoP
|
||||
? `Pago: ${formatDate(cfdi.fechaPagoP)}`
|
||||
: formatDate(cfdi.fechaEmision)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,17 +4,31 @@ export interface ConciliacionCfdi {
|
||||
id: number;
|
||||
uuid: string;
|
||||
type: string;
|
||||
serie: string | null;
|
||||
folio: string | null;
|
||||
fechaEmision: string;
|
||||
fechaPagoP: string | null;
|
||||
rfcEmisor: string;
|
||||
nombreEmisor: string;
|
||||
rfcReceptor: string;
|
||||
nombreReceptor: string;
|
||||
total: number;
|
||||
totalMxn: number;
|
||||
subtotal: number;
|
||||
descuento: number;
|
||||
moneda: string;
|
||||
tipoCambio: number;
|
||||
tipoComprobante: string | null;
|
||||
montoPagoMxn: number;
|
||||
montoMxn: number;
|
||||
metodoPago: string | null;
|
||||
formaPago: string | null;
|
||||
usoCfdi: string | null;
|
||||
status: string | null;
|
||||
fechaCertSat: string | null;
|
||||
ivaTraslado: number;
|
||||
ivaRetencion: number;
|
||||
isrRetencion: number;
|
||||
conciliado: string | null;
|
||||
idConciliacion: number | null;
|
||||
conciliacion: {
|
||||
|
||||
Reference in New Issue
Block a user