feat(reportes): rediseño Estado de Resultados vertical con drill-down, análisis horizontal/vertical y export Excel
- Nuevo endpoint GET /reportes/estado-resultados-detallado con cálculo contable:
* Ventas, Devoluciones, Ventas netas, Costo de ventas, Utilidad bruta,
Gastos operativos, Utilidad de la operación
* Fórmula: subtotal_mxn - descuento_mxn (sin impuestos), nómina usa total_mxn
* Excluye anticipos (uso_cfdi=P01 o clave_prod_serv=84111506)
* Filtro por régimen fiscal opcional
* Año anterior calculado automáticamente
- Nuevo endpoint GET /reportes/estado-resultados/drill-down:
* Nivel 1: resumen agrupado por RFC
* Nivel 2: CFDIs individuales filtrados por categoría
* Categorías: ventas, devoluciones, costo-ventas, gastos-operativos
- Nuevo endpoint GET /reportes/estado-resultados/export:
* Genera Excel con formato condicional (verde/rojo, negritas)
- Frontend:
* Tabla vertical con % vertical, año anterior y variación %
* Filas clickeables para drill-down modal de 2 niveles
* Top 10 Clientes/Proveedores mantenidos debajo
* Selector de régimen conectado al reporte
- Fix: NaN en total de drill-down nivel 2 por numeric como string en pg
* Agregado ::float en queries SQL de CFDIs individuales
This commit is contained in:
@@ -57,3 +57,28 @@ export function useCuentasXCobrar(fechaInicio: string, fechaFin: string, regimen
|
||||
enabled: !!fechaInicio && !!fechaFin,
|
||||
});
|
||||
}
|
||||
|
||||
export function useEstadoResultadosDetallado(fechaInicio?: string, fechaFin?: string, regimen?: string) {
|
||||
const { selectedContribuyenteId } = useContribuyenteStore();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['estado-resultados-detallado', fechaInicio, fechaFin, regimen, selectedContribuyenteId],
|
||||
queryFn: () => reportesApi.getEstadoResultadosDetallado(fechaInicio, fechaFin, regimen || undefined, selectedContribuyenteId || undefined),
|
||||
});
|
||||
}
|
||||
|
||||
export function useEstadoResultadosDrillDown(
|
||||
categoria: string,
|
||||
fechaInicio?: string,
|
||||
fechaFin?: string,
|
||||
regimen?: string,
|
||||
rfc?: string,
|
||||
) {
|
||||
const { selectedContribuyenteId } = useContribuyenteStore();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['estado-resultados-drill-down', categoria, fechaInicio, fechaFin, regimen, rfc, selectedContribuyenteId],
|
||||
queryFn: () => reportesApi.getEstadoResultadosDrillDown(categoria, fechaInicio, fechaFin, regimen || undefined, rfc || undefined, selectedContribuyenteId || undefined),
|
||||
enabled: !!categoria && !!fechaInicio && !!fechaFin,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user