- Add bulk XML CFDI upload support (up to 300MB) - Add period selector component for month/year navigation - Fix session persistence on page refresh (Zustand hydration) - Fix income/expense classification based on tenant RFC - Fix IVA calculation from XML (correct Impuestos element) - Add error handling to reportes page - Support multiple CORS origins - Update reportes service with proper Decimal/BigInt handling - Add RFC to tenant view store for proper CFDI classification - Update README with changelog and new features Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { apiClient } from './client';
|
|
import type { CfdiListResponse, CfdiFilters, Cfdi } from '@horux/shared';
|
|
|
|
export async function getCfdis(filters: CfdiFilters): Promise<CfdiListResponse> {
|
|
const params = new URLSearchParams();
|
|
|
|
if (filters.tipo) params.set('tipo', filters.tipo);
|
|
if (filters.estado) params.set('estado', filters.estado);
|
|
if (filters.fechaInicio) params.set('fechaInicio', filters.fechaInicio);
|
|
if (filters.fechaFin) params.set('fechaFin', filters.fechaFin);
|
|
if (filters.rfc) params.set('rfc', filters.rfc);
|
|
if (filters.search) params.set('search', filters.search);
|
|
if (filters.page) params.set('page', filters.page.toString());
|
|
if (filters.limit) params.set('limit', filters.limit.toString());
|
|
|
|
const response = await apiClient.get<CfdiListResponse>(`/cfdi?${params}`);
|
|
return response.data;
|
|
}
|
|
|
|
export async function getCfdiById(id: string): Promise<Cfdi> {
|
|
const response = await apiClient.get<Cfdi>(`/cfdi/${id}`);
|
|
return response.data;
|
|
}
|
|
|
|
export async function getResumenCfdi(año?: number, mes?: number) {
|
|
const params = new URLSearchParams();
|
|
if (año) params.set('año', año.toString());
|
|
if (mes) params.set('mes', mes.toString());
|
|
|
|
const response = await apiClient.get(`/cfdi/resumen?${params}`);
|
|
return response.data;
|
|
}
|
|
|
|
export interface CreateCfdiData {
|
|
uuidFiscal: string;
|
|
tipo: 'ingreso' | 'egreso' | 'traslado' | 'nomina' | 'pago';
|
|
serie?: string;
|
|
folio?: string;
|
|
fechaEmision: string;
|
|
fechaTimbrado: string;
|
|
rfcEmisor: string;
|
|
nombreEmisor: string;
|
|
rfcReceptor: string;
|
|
nombreReceptor: string;
|
|
subtotal: number;
|
|
descuento?: number;
|
|
iva?: number;
|
|
isrRetenido?: number;
|
|
ivaRetenido?: number;
|
|
total: number;
|
|
moneda?: string;
|
|
tipoCambio?: number;
|
|
metodoPago?: string;
|
|
formaPago?: string;
|
|
usoCfdi?: string;
|
|
estado?: string;
|
|
}
|
|
|
|
export async function createCfdi(data: CreateCfdiData): Promise<Cfdi> {
|
|
const response = await apiClient.post<Cfdi>('/cfdi', data);
|
|
return response.data;
|
|
}
|
|
|
|
export async function createManyCfdis(cfdis: CreateCfdiData[]): Promise<{ count: number }> {
|
|
const response = await apiClient.post<{ count: number; message: string }>('/cfdi/bulk', { cfdis });
|
|
return response.data;
|
|
}
|
|
|
|
export async function deleteCfdi(id: string): Promise<void> {
|
|
await apiClient.delete(`/cfdi/${id}`);
|
|
}
|