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.
This commit is contained in:
AlexeerCT
2026-01-06 11:25:09 -06:00
parent 5dce19ebdf
commit 12ec8c6dfb
14 changed files with 446 additions and 866 deletions

View File

@@ -2,6 +2,7 @@
import { api } from '$lib/api';
export interface CustomsBroker {
id: number;
type?: string | null;
broker_key: string;
name?: string | null;
@@ -111,15 +112,15 @@ export const customsBrokersApi = {
* Elimina un agente aduanal
*/
delete: (brokerKey: string, companyId: string) => {
return api.delete<CustomsBroker>(`/v1/a76/customs-brokers/${brokerKey}?company_id=${companyId}`);
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);
return api.put<CustomsBroker>(`/v1/a76/customs-brokers/${brokerKey}/?company_id=${companyId}`, data);
},
/**

View File

@@ -20,22 +20,22 @@ export interface InvoiceComplianceMx {
destination?: string | null;
manifest_number?: string | null;
provider_header?: string | null;
provider_id?: string | null;
provider_id?: number | null;
sold_to_header?: string | null;
sold_to_id?: string | null;
sold_to_id?: number | null;
shipped_to_header?: string | null;
shipped_to_id?: string | null;
shipped_by_header?: string | null;
shipped_by_id?: string | null;
customs_broker_id?: string | null;
customs_broker_us_id?: string | null;
shipped_by_id?: number | null;
customs_broker_id?: number | null;
customs_broker_us_id?: number | null;
broker_invoice_num?: string | null;
broker_invoice_date?: string | null;
is_mixed?: boolean | null;
waste_type?: string | null;
scrap_type?: string | null;
appendix_17?: number | null;
is_regime_change?: string | null;
is_regime_change?: boolean | null;
which_exchange_rate?: string | null;
value_method?: string | null;
act_value?: string | null;
@@ -179,6 +179,7 @@ export interface Invoice {
system?: string | null;
operation_type?: OperationType | null;
invoice_type?: string | null;
document_type?: string | null;
invoice_number?: string | null;
project_number?: string | null;
purchase_order?: string | null;
@@ -195,8 +196,8 @@ export interface Invoice {
capture_user?: string | null;
traffic_light_status?: string | null;
process_log?: string | null;
status_rec?: number | null;
status_rep?: string | null;
is_updated_rec?: number | null;
is_updated_rep?: string | null;
observation_es?: string | null;
observation_en?: string | null;
comments_status?: string | null;
@@ -206,9 +207,9 @@ export interface Invoice {
path_xml?: string | null;
subcompany?: string | null;
party_count?: number | null;
generate_id?: string | null;
generate_id?: boolean | null;
generate_desc_parties?: string | null;
apply_manual_discount?: string | null;
apply_manual_discount?: boolean | null;
is_bulk?: boolean | null;
download_substance?: boolean | null;
download_class?: boolean | null;
@@ -235,6 +236,7 @@ export interface CreateInvoiceData {
system: string;
operation_type: OperationType;
invoice_type: string;
document_type: string;
invoice_number: string;
project_number?: string | null;
purchase_order?: string | null;
@@ -250,8 +252,8 @@ export interface CreateInvoiceData {
capture_user?: string | null;
traffic_light_status?: string | null;
process_log?: string | null;
status_rec?: number | null;
status_rep?: string | null;
is_updated_rec?: number | null;
is_updated_rep?: string | null;
observation_es?: string | null;
observation_en?: string | null;
comments_status?: string | null;
@@ -261,9 +263,9 @@ export interface CreateInvoiceData {
path_xml?: string | null;
subcompany?: string | null;
party_count?: number | null;
generate_id?: string | null;
generate_id?: boolean | null;
generate_desc_parties?: string | null;
apply_manual_discount?: string | null;
apply_manual_discount?: boolean | null;
is_bulk?: boolean | null;
download_substance?: boolean | null;
download_class?: boolean | null;
@@ -282,6 +284,7 @@ export interface CreateInvoiceData {
export interface UpdateInvoiceData {
operation_type?: OperationType | null;
invoice_type?: string | null;
document_type?: string | null;
invoice_number?: string | null;
project_number?: string | null;
purchase_order?: string | null;
@@ -355,7 +358,7 @@ export const invoicesApi = {
const params = new URLSearchParams({
company_id: companyId.toString()
});
return api.put<Invoice>(`/v1/a76/invoices/${invoiceId}?${params.toString()}`, data);
return api.put<Invoice>(`/v1/a76/invoices/${invoiceId}/?${params.toString()}`, data);
},
/**