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
|
? Math.round(((ivaDisplay - ivaAnterior) / Math.abs(ivaAnterior)) * 10000) / 100
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const utilidadDisplay = ingresosDisplay - egresosDisplay;
|
// Utilidad ajustada por notas de crédito:
|
||||||
const margenDisplay = ingresosDisplay > 0
|
// Ingresos netos = Ingresos − NCs emitidas
|
||||||
? Math.round((utilidadDisplay / ingresosDisplay) * 10000) / 100
|
// 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;
|
: 0;
|
||||||
|
|
||||||
const formatCurrency = (value: number) =>
|
const formatCurrency = (value: number) =>
|
||||||
@@ -254,11 +260,11 @@ export default function DashboardPage() {
|
|||||||
trendValue="Notas de crédito recibidas"
|
trendValue="Notas de crédito recibidas"
|
||||||
/>
|
/>
|
||||||
<KpiCard
|
<KpiCard
|
||||||
title="Utilidad"
|
title={regimenSeleccionado ? `Utilidad Neta (${regimenSeleccionado})` : 'Utilidad Neta'}
|
||||||
value={utilidadDisplay}
|
value={utilidadDisplay}
|
||||||
icon={<Wallet className="h-4 w-4" />}
|
icon={<Wallet className="h-4 w-4" />}
|
||||||
trend={utilidadDisplay > 0 ? 'up' : 'down'}
|
trend={utilidadDisplay > 0 ? 'up' : 'down'}
|
||||||
trendValue={`${margenDisplay}% margen`}
|
trendValue={`${margenDisplay}% margen · incluye NCs`}
|
||||||
/>
|
/>
|
||||||
<KpiCard
|
<KpiCard
|
||||||
title={regimenSeleccionado ? `Balance IVA (${regimenSeleccionado})` : 'Balance IVA'}
|
title={regimenSeleccionado ? `Balance IVA (${regimenSeleccionado})` : 'Balance IVA'}
|
||||||
|
|||||||
Reference in New Issue
Block a user