feat(dashboard): utilidad neta ajustada por notas de crédito
- 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.
This commit is contained in:
@@ -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"
|
||||
/>
|
||||
<KpiCard
|
||||
title="Utilidad"
|
||||
title={regimenSeleccionado ? `Utilidad Neta (${regimenSeleccionado})` : 'Utilidad Neta'}
|
||||
value={utilidadDisplay}
|
||||
icon={<Wallet className="h-4 w-4" />}
|
||||
trend={utilidadDisplay > 0 ? 'up' : 'down'}
|
||||
trendValue={`${margenDisplay}% margen`}
|
||||
trendValue={`${margenDisplay}% margen · incluye NCs`}
|
||||
/>
|
||||
<KpiCard
|
||||
title={regimenSeleccionado ? `Balance IVA (${regimenSeleccionado})` : 'Balance IVA'}
|
||||
|
||||
Reference in New Issue
Block a user