Update invoice skeleton to use boolean for is_mixed and add export fields; enhance mergeDefaults function to filter undefined values
This commit is contained in:
@@ -153,7 +153,7 @@
|
||||
const othersSkeleton = {
|
||||
comments_status: '',
|
||||
transport_mode: 'TRUCK',
|
||||
is_mixed: null,
|
||||
is_mixed: false,
|
||||
print_stamp: false,
|
||||
rule_3121_parties_ii: false,
|
||||
related_doc_id: null,
|
||||
@@ -165,7 +165,15 @@
|
||||
operation_num: '',
|
||||
adendas: '',
|
||||
observations_vu: '',
|
||||
certified_number: ''
|
||||
certified_number: '',
|
||||
// Export fields
|
||||
bill_number: '',
|
||||
guide_number: '',
|
||||
shipment_number: '',
|
||||
option_iv18: '',
|
||||
delivered_status: false,
|
||||
received_by: '',
|
||||
delivery_date: ''
|
||||
};
|
||||
|
||||
const continuationSkeleton = {
|
||||
@@ -196,7 +204,11 @@
|
||||
|
||||
function mergeDefaults(skeleton: any, partial: any) {
|
||||
if (!partial) return skeleton;
|
||||
return { ...skeleton, ...partial };
|
||||
// Filter out undefined values from partial to preserve skeleton defaults
|
||||
const filtered = Object.fromEntries(
|
||||
Object.entries(partial).filter(([_, value]) => value !== undefined)
|
||||
);
|
||||
return { ...skeleton, ...filtered };
|
||||
}
|
||||
|
||||
// Referencias a los componentes de formulario para obtener sus datos
|
||||
@@ -503,8 +515,16 @@
|
||||
}
|
||||
|
||||
let isLoadingDefaults = $state(false);
|
||||
let lastLoadedKey = $state(
|
||||
data.defaultSettings
|
||||
|
||||
// Compute initial key from source data to avoid state reference warning
|
||||
const initialLoadedKey = data.defaultSettings?.InvoiceTopFieldsFormData
|
||||
? `${data.defaultSettings.InvoiceTopFieldsFormData.invoice_type || ''}-${data.defaultSettings.InvoiceTopFieldsFormData.operation_type || ''}`
|
||||
: '';
|
||||
let lastLoadedKey = $state(initialLoadedKey);
|
||||
|
||||
// Create a derived value for the current key to track changes reactively
|
||||
let currentKey = $derived(
|
||||
InvoiceTopFieldsFormData?.invoice_type && InvoiceTopFieldsFormData?.operation_type
|
||||
? `${InvoiceTopFieldsFormData.invoice_type}-${InvoiceTopFieldsFormData.operation_type}`
|
||||
: ''
|
||||
);
|
||||
@@ -518,7 +538,6 @@
|
||||
)
|
||||
return;
|
||||
|
||||
const currentKey = `${InvoiceTopFieldsFormData.invoice_type}-${InvoiceTopFieldsFormData.operation_type}`;
|
||||
if (currentKey === lastLoadedKey) return;
|
||||
|
||||
isLoadingDefaults = true;
|
||||
|
||||
Reference in New Issue
Block a user