Update: nueva version Horux Despachos
This commit is contained in:
69
apps/web/lib/api/reportes.ts
Normal file
69
apps/web/lib/api/reportes.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { apiClient } from './client';
|
||||
import type { EstadoResultados, FlujoEfectivo, ComparativoPeriodos, ConcentradoRfc } from '@horux/shared';
|
||||
|
||||
export async function getEstadoResultados(fechaInicio?: string, fechaFin?: string, contribuyenteId?: string): Promise<EstadoResultados> {
|
||||
const params = new URLSearchParams();
|
||||
if (fechaInicio) params.set('fechaInicio', fechaInicio);
|
||||
if (fechaFin) params.set('fechaFin', fechaFin);
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
const response = await apiClient.get<EstadoResultados>(`/reportes/estado-resultados?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getFlujoEfectivo(fechaInicio?: string, fechaFin?: string, contribuyenteId?: string): Promise<FlujoEfectivo> {
|
||||
const params = new URLSearchParams();
|
||||
if (fechaInicio) params.set('fechaInicio', fechaInicio);
|
||||
if (fechaFin) params.set('fechaFin', fechaFin);
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
const response = await apiClient.get<FlujoEfectivo>(`/reportes/flujo-efectivo?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getComparativo(año?: number, contribuyenteId?: string): Promise<ComparativoPeriodos> {
|
||||
const params = new URLSearchParams();
|
||||
if (año) params.set('año', String(año));
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
const qs = params.toString();
|
||||
const response = await apiClient.get<ComparativoPeriodos>(`/reportes/comparativo${qs ? `?${qs}` : ''}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getConcentradoRfc(
|
||||
tipo: 'cliente' | 'proveedor',
|
||||
fechaInicio?: string,
|
||||
fechaFin?: string,
|
||||
contribuyenteId?: string,
|
||||
): Promise<ConcentradoRfc[]> {
|
||||
const params = new URLSearchParams({ tipo });
|
||||
if (fechaInicio) params.set('fechaInicio', fechaInicio);
|
||||
if (fechaFin) params.set('fechaFin', fechaFin);
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
const response = await apiClient.get<ConcentradoRfc[]>(`/reportes/concentrado-rfc?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export interface CuentasPendientes {
|
||||
cantidadCfdis: number;
|
||||
saldoTotal: number;
|
||||
detalle: { rfc: string; nombre: string; cantidad: number; saldo: number }[];
|
||||
}
|
||||
|
||||
export async function getCuentasXPagar(fechaInicio: string, fechaFin: string, regimen?: string, contribuyenteId?: string): Promise<CuentasPendientes> {
|
||||
const params = new URLSearchParams();
|
||||
params.set('fechaInicio', fechaInicio);
|
||||
params.set('fechaFin', fechaFin);
|
||||
if (regimen) params.set('regimen', regimen);
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
const response = await apiClient.get<CuentasPendientes>(`/reportes/cuentas-x-pagar?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getCuentasXCobrar(fechaInicio: string, fechaFin: string, regimen?: string, contribuyenteId?: string): Promise<CuentasPendientes> {
|
||||
const params = new URLSearchParams();
|
||||
params.set('fechaInicio', fechaInicio);
|
||||
params.set('fechaFin', fechaFin);
|
||||
if (regimen) params.set('regimen', regimen);
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
const response = await apiClient.get<CuentasPendientes>(`/reportes/cuentas-x-cobrar?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
Reference in New Issue
Block a user