Files
plantillas-proyectos/frontend/src/lib/api/dashboard/a76/customs-brokers.ts
AlexeerCT 12ec8c6dfb feat: enhance invoice saving functionality with new top fields and transport modes
- Added InvoiceTopFieldsFormData to handle additional invoice fields.
- Updated saveInvoice function to validate and process new fields.
- Integrated transport modes fetching in the invoice edit page.
- Refactored financials and compliance data handling to accommodate new structure.
- Improved user feedback with toast notifications instead of alerts.
2026-01-06 11:25:09 -06:00

143 lines
3.6 KiB
TypeScript

import { api } from '$lib/api';
export interface CustomsBroker {
id: number;
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
);
}
};