import { apiClient } from './client'; import type { EstadoResultados, FlujoEfectivo, ComparativoPeriodos, ConcentradoRfc } from '@horux/shared'; export async function getEstadoResultados(fechaInicio?: string, fechaFin?: string, contribuyenteId?: string): Promise { 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(`/reportes/estado-resultados?${params}`); return response.data; } export async function getFlujoEfectivo(fechaInicio?: string, fechaFin?: string, contribuyenteId?: string): Promise { 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(`/reportes/flujo-efectivo?${params}`); return response.data; } export async function getComparativo(año?: number, contribuyenteId?: string): Promise { 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(`/reportes/comparativo${qs ? `?${qs}` : ''}`); return response.data; } export async function getConcentradoRfc( tipo: 'cliente' | 'proveedor', fechaInicio?: string, fechaFin?: string, contribuyenteId?: string, ): Promise { 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(`/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 { 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(`/reportes/cuentas-x-pagar?${params}`); return response.data; } export async function getCuentasXCobrar(fechaInicio: string, fechaFin: string, regimen?: string, contribuyenteId?: string): Promise { 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(`/reportes/cuentas-x-cobrar?${params}`); return response.data; }