From ed6cfed312dfb4dea0ca90a1d50baf53961e7730 Mon Sep 17 00:00:00 2001 From: Horux Dev Date: Sat, 13 Jun 2026 21:04:25 +0000 Subject: [PATCH] =?UTF-8?q?feat(dashboard):=20utilidad=20neta=20ajustada?= =?UTF-8?q?=20por=20notas=20de=20cr=C3=A9dito?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - La utilidad del dashboard ahora descuenta NCs emitidas de ingresos y NCs recibidas de gastos. - El margen se calcula sobre ingresos netos. - Solo afecta la UI del dashboard; no modifica el backend ni otros reportes. --- apps/web/app/(dashboard)/dashboard/page.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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`} />