Update: nueva version Horux Despachos
This commit is contained in:
41
apps/web/lib/api/dashboard.ts
Normal file
41
apps/web/lib/api/dashboard.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { apiClient } from './client';
|
||||
import type { KpiData, IngresosEgresosData, Alerta } from '@horux/shared';
|
||||
|
||||
export async function getKpis(fechaInicio: string, fechaFin: string, conciliacion?: boolean, contribuyenteId?: string | null): Promise<KpiData> {
|
||||
const params = new URLSearchParams();
|
||||
params.set('fechaInicio', fechaInicio);
|
||||
params.set('fechaFin', fechaFin);
|
||||
if (conciliacion) params.set('conciliacion', 'true');
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
|
||||
const response = await apiClient.get<KpiData>(`/dashboard/kpis?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getIngresosEgresos(año?: number, conciliacion?: boolean, contribuyenteId?: string | null): Promise<IngresosEgresosData[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (año) params.set('año', año.toString());
|
||||
if (conciliacion) params.set('conciliacion', 'true');
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
|
||||
const response = await apiClient.get<IngresosEgresosData[]>(`/dashboard/ingresos-egresos?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getRegimenesDelPeriodo(fechaInicio: string, fechaFin: string, conciliacion?: boolean, contribuyenteId?: string | null): Promise<{ clave: string; descripcion: string }[]> {
|
||||
const params = new URLSearchParams();
|
||||
params.set('fechaInicio', fechaInicio);
|
||||
params.set('fechaFin', fechaFin);
|
||||
if (conciliacion) params.set('conciliacion', 'true');
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
|
||||
const response = await apiClient.get<{ clave: string; descripcion: string }[]>(`/dashboard/regimenes-periodo?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getAlertas(limit = 5, contribuyenteId?: string | null): Promise<Alerta[]> {
|
||||
const params = new URLSearchParams({ limit: String(limit) });
|
||||
if (contribuyenteId) params.set('contribuyenteId', contribuyenteId);
|
||||
const response = await apiClient.get<Alerta[]>(`/dashboard/alertas?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
Reference in New Issue
Block a user