- Updated the "Nueva Sección" button in customs_sections, customs_warehouses, incoterms, invoice_types, material_types, payment_methods, pedimento_codes, pedimento_regimens, sectors, states, transport_modes, and transport_types pages to use the Plus icon from Lucide. - Updated the "Actualizar" button in the same pages to use the RefreshCw icon from Lucide. - Added a new edit dialog component for customs brokers with a comprehensive form for editing broker details, including validation and loading states.
145 lines
3.7 KiB
TypeScript
145 lines
3.7 KiB
TypeScript
/**
|
|
* API Client para Agentes Aduanales (Customs Brokers)
|
|
* Gestiona las operaciones CRUD para agentes aduanales
|
|
*/
|
|
import { api } from '$lib/api';
|
|
|
|
export interface CustomsBroker {
|
|
type?: string | null;
|
|
broker_key: string;
|
|
name?: string | null;
|
|
address?: string | null;
|
|
postal_code?: string | null;
|
|
city?: string | null;
|
|
state?: string | null;
|
|
phone?: string | null;
|
|
fax?: string | null;
|
|
email?: string | null;
|
|
country?: string | null;
|
|
tax_id?: string | null;
|
|
personal_id?: string | null;
|
|
position?: string | null;
|
|
license: string;
|
|
company?: string | null;
|
|
contact?: string | null;
|
|
tenant_id: string;
|
|
company_id: string;
|
|
}
|
|
|
|
export interface CustomsBrokerVU {
|
|
certificate_path?: string | null;
|
|
key_path?: string | null;
|
|
access_key?: string | null;
|
|
fiel_format?: string | null;
|
|
signature_read_path?: string | null;
|
|
archive_path?: string | null;
|
|
fiel_access_key?: string | null;
|
|
web_service_user?: string | null;
|
|
web_service_access_key?: string | null;
|
|
vu_email?: string | null;
|
|
vu_figure_type?: string | null;
|
|
xml_files_path?: string | null;
|
|
query_tax_id?: string | null;
|
|
doda_certificate_path?: string | null;
|
|
doda_key_path?: string | null;
|
|
doda_web_service_user?: string | null;
|
|
doda_web_service_access_key?: string | null;
|
|
doda_fiel_access_key?: string | null;
|
|
doda_xml_files_path?: string | null;
|
|
}
|
|
|
|
export interface CustomsBrokerPersonnel {
|
|
broker_key: string;
|
|
line: number;
|
|
name?: string | null;
|
|
tax_id?: string | null;
|
|
personal_id?: string | null;
|
|
position?: string | null;
|
|
license?: string | null;
|
|
first_name?: string | null;
|
|
last_name?: string | null;
|
|
middle_name?: string | null;
|
|
email?: string | null;
|
|
}
|
|
|
|
export interface CreateCustomsBrokerData {
|
|
type?: string | null;
|
|
broker_key: string;
|
|
name?: string | null;
|
|
address?: string | null;
|
|
postal_code?: string | null;
|
|
city?: string | null;
|
|
state?: string | null;
|
|
phone?: string | null;
|
|
fax?: string | null;
|
|
email?: string | null;
|
|
country?: string | null;
|
|
tax_id?: string | null;
|
|
personal_id?: string | null;
|
|
position?: string | null;
|
|
license?: string | null;
|
|
company?: string | null;
|
|
contact?: string | null;
|
|
tenant_id: string;
|
|
company_id: string;
|
|
}
|
|
|
|
/**
|
|
* API para Agentes Aduanales
|
|
*/
|
|
export const customsBrokersApi = {
|
|
/**
|
|
* Lista todos los agentes aduanales
|
|
*/
|
|
list: (companyId: string) => {
|
|
return api.get<CustomsBroker[]>(`/v1/a76/customs-brokers?company_id=${companyId}`);
|
|
},
|
|
|
|
/**
|
|
* Obtiene un agente aduanal por su clave
|
|
*/
|
|
get: (brokerKey: string) => {
|
|
return api.get<CustomsBroker>(`/v1/a76/customs-brokers/${brokerKey}`);
|
|
},
|
|
|
|
/**
|
|
* Crea un nuevo agente aduanal
|
|
*/
|
|
create: (data: CreateCustomsBrokerData) => {
|
|
const companyId = data.company_id;
|
|
return api.post<CustomsBroker>(`/v1/a76/customs-brokers?company_id=${companyId}`, data);
|
|
},
|
|
|
|
/**
|
|
* Elimina un agente aduanal
|
|
*/
|
|
delete: (brokerKey: string, companyId: string) => {
|
|
return api.delete<CustomsBroker>(`/v1/a76/customs-brokers/${brokerKey}?company_id=${companyId}`);
|
|
},
|
|
|
|
/**
|
|
* Actualiza la información de un agente aduanal
|
|
*/
|
|
update: (brokerKey: string, data: CreateCustomsBrokerData) => {
|
|
const companyId = data.company_id;
|
|
return api.put<CustomsBroker>(`/v1/a76/customs-brokers/${brokerKey}?company_id=${companyId}`, data);
|
|
},
|
|
|
|
/**
|
|
* Actualiza la información de VU de un agente aduanal
|
|
*/
|
|
updateVU: (brokerKey: string, data: CustomsBrokerVU) => {
|
|
return api.put<CustomsBrokerVU>(`/v1/a76/customs-broker-vu/${brokerKey}`, data);
|
|
},
|
|
|
|
/**
|
|
* Actualiza el personal de un agente aduanal
|
|
*/
|
|
updatePersonnel: (brokerKey: string, line: number, data: CustomsBrokerPersonnel) => {
|
|
return api.put<CustomsBrokerPersonnel>(
|
|
`/v1/a76/customs-broker-personnel/${brokerKey}/${line}`,
|
|
data
|
|
);
|
|
}
|
|
};
|