Update: nueva version Horux Despachos
This commit is contained in:
66
apps/web/lib/api/contribuyentes.ts
Normal file
66
apps/web/lib/api/contribuyentes.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { apiClient } from './client';
|
||||
|
||||
export interface Contribuyente {
|
||||
id: string;
|
||||
tipo: string;
|
||||
nombre: string;
|
||||
identificador: string;
|
||||
supervisorUserId: string | null;
|
||||
active: boolean;
|
||||
createdAt: string;
|
||||
rfc: string;
|
||||
regimenFiscal: string | null;
|
||||
codigoPostal: string | null;
|
||||
domicilio: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
export interface CreateContribuyenteData {
|
||||
rfc: string;
|
||||
razonSocial: string;
|
||||
regimenFiscal?: string;
|
||||
codigoPostal?: string;
|
||||
supervisorUserId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resultado del ajuste automático de overage de Business Cloud al crear o
|
||||
* desactivar un contribuyente. Si `action === 'created'`, el frontend debe
|
||||
* abrir `paymentUrl` en una pestaña para que el usuario autorice el cobro.
|
||||
*/
|
||||
export interface OverageAdjustResult {
|
||||
action: 'none' | 'created' | 'updated' | 'cancelled' | 'skipped';
|
||||
overageCount: number;
|
||||
paymentUrl?: string;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export type ContribuyenteWithOverage = Contribuyente & { overage?: OverageAdjustResult };
|
||||
|
||||
export async function getContribuyentes(): Promise<{ data: Contribuyente[] }> {
|
||||
const { data } = await apiClient.get('/contribuyentes');
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getContribuyente(id: string): Promise<Contribuyente> {
|
||||
const { data } = await apiClient.get(`/contribuyentes/${id}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function createContribuyente(payload: CreateContribuyenteData): Promise<ContribuyenteWithOverage> {
|
||||
const { data } = await apiClient.post('/contribuyentes', payload);
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function updateContribuyente(id: string, payload: Partial<CreateContribuyenteData>): Promise<Contribuyente> {
|
||||
const { data } = await apiClient.put(`/contribuyentes/${id}`, payload);
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function deactivateContribuyente(id: string): Promise<{ message: string; overage?: OverageAdjustResult }> {
|
||||
const { data } = await apiClient.delete(`/contribuyentes/${id}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function addClienteAcceso(contribuyenteId: string, userId: string): Promise<void> {
|
||||
await apiClient.post(`/contribuyentes/${contribuyenteId}/cliente-acceso`, { userId });
|
||||
}
|
||||
Reference in New Issue
Block a user