Initial commit - Horux Despachos NL

This commit is contained in:
2026-05-03 16:47:53 -06:00
commit b00b677c54
647 changed files with 133843 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
import type { Request, Response, NextFunction } from 'express';
import * as reportesService from '../services/reportes.service.js';
export async function getEstadoResultados(req: Request, res: Response, next: NextFunction) {
try {
const { fechaInicio, fechaFin, contribuyenteId } = req.query;
const now = new Date();
const inicio = (fechaInicio as string) || `${now.getFullYear()}-01-01`;
const fin = (fechaFin as string) || now.toISOString().split('T')[0];
const data = await reportesService.getEstadoResultados(req.tenantPool!, inicio, fin, req.user!.tenantId, contribuyenteId as string | undefined || null);
res.json(data);
} catch (error) {
console.error('[reportes] Error en getEstadoResultados:', error);
next(error);
}
}
export async function getFlujoEfectivo(req: Request, res: Response, next: NextFunction) {
try {
const { fechaInicio, fechaFin, contribuyenteId } = req.query;
const now = new Date();
const inicio = (fechaInicio as string) || `${now.getFullYear()}-01-01`;
const fin = (fechaFin as string) || now.toISOString().split('T')[0];
const data = await reportesService.getFlujoEfectivo(req.tenantPool!, inicio, fin, contribuyenteId as string | undefined || null);
res.json(data);
} catch (error) {
next(error);
}
}
export async function getComparativo(req: Request, res: Response, next: NextFunction) {
try {
const { contribuyenteId } = req.query;
const año = parseInt(req.query.año as string) || new Date().getFullYear();
const data = await reportesService.getComparativo(req.tenantPool!, año, contribuyenteId as string | undefined || null);
res.json(data);
} catch (error) {
next(error);
}
}
export async function getCuentasXPagar(req: Request, res: Response, next: NextFunction) {
try {
const { fechaInicio, fechaFin, regimen, contribuyenteId } = req.query;
const now = new Date();
const inicio = (fechaInicio as string) || `${now.getFullYear()}-01-01`;
const fin = (fechaFin as string) || now.toISOString().split('T')[0];
const data = await reportesService.getCuentasXPagar(req.tenantPool!, inicio, fin, regimen as string, contribuyenteId as string | undefined || null);
res.json(data);
} catch (error) {
next(error);
}
}
export async function getCuentasXCobrar(req: Request, res: Response, next: NextFunction) {
try {
const { fechaInicio, fechaFin, regimen, contribuyenteId } = req.query;
const now = new Date();
const inicio = (fechaInicio as string) || `${now.getFullYear()}-01-01`;
const fin = (fechaFin as string) || now.toISOString().split('T')[0];
const data = await reportesService.getCuentasXCobrar(req.tenantPool!, inicio, fin, regimen as string, contribuyenteId as string | undefined || null);
res.json(data);
} catch (error) {
next(error);
}
}
export async function getConcentradoRfc(req: Request, res: Response, next: NextFunction) {
try {
const { fechaInicio, fechaFin, tipo, contribuyenteId } = req.query;
const now = new Date();
const inicio = (fechaInicio as string) || `${now.getFullYear()}-01-01`;
const fin = (fechaFin as string) || now.toISOString().split('T')[0];
const tipoRfc = (tipo as 'cliente' | 'proveedor') || 'cliente';
const data = await reportesService.getConcentradoRfc(req.tenantPool!, inicio, fin, tipoRfc, contribuyenteId as string | undefined || null);
res.json(data);
} catch (error) {
next(error);
}
}