diff --git a/apps/web/app/(dashboard)/dashboard/page.tsx b/apps/web/app/(dashboard)/dashboard/page.tsx index fd8d70a..20368db 100644 --- a/apps/web/app/(dashboard)/dashboard/page.tsx +++ b/apps/web/app/(dashboard)/dashboard/page.tsx @@ -137,9 +137,15 @@ export default function DashboardPage() { ? Math.round(((ivaDisplay - ivaAnterior) / Math.abs(ivaAnterior)) * 10000) / 100 : null; - const utilidadDisplay = ingresosDisplay - egresosDisplay; - const margenDisplay = ingresosDisplay > 0 - ? Math.round((utilidadDisplay / ingresosDisplay) * 10000) / 100 + // Utilidad ajustada por notas de crédito: + // Ingresos netos = Ingresos − NCs emitidas + // Egresos netos = Gastos − NCs recibidas + // Utilidad neta = Ingresos netos − Egresos netos + const ingresosNetosDisplay = ingresosDisplay - ncsEmitidasDisplay; + const egresosNetosDisplay = egresosDisplay - ncsRecibidasDisplay; + const utilidadDisplay = ingresosNetosDisplay - egresosNetosDisplay; + const margenDisplay = ingresosNetosDisplay > 0 + ? Math.round((utilidadDisplay / ingresosNetosDisplay) * 10000) / 100 : 0; const formatCurrency = (value: number) => @@ -254,11 +260,11 @@ export default function DashboardPage() { trendValue="Notas de crédito recibidas" /> } trend={utilidadDisplay > 0 ? 'up' : 'down'} - trendValue={`${margenDisplay}% margen`} + trendValue={`${margenDisplay}% margen · incluye NCs`} />