feat: implement exchange rate filtering and validation enhancements in invoice processing
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
codePedimentoRegimens = [],
|
||||
defaultOperationType = undefined,
|
||||
defaultInvoiceType = undefined,
|
||||
operationType = undefined
|
||||
operationType = undefined,
|
||||
exchangeRate = undefined
|
||||
}: {
|
||||
invoice: Invoice | null;
|
||||
formData?: any;
|
||||
@@ -44,7 +45,15 @@
|
||||
defaultOperationType?: number | null;
|
||||
defaultInvoiceType?: string | null;
|
||||
operationType?: number | null;
|
||||
} = $props();
|
||||
exchangeRate?: number | null;
|
||||
} = $props();
|
||||
|
||||
// Sync exchangeRate prop to formData
|
||||
$effect(() => {
|
||||
if (exchangeRate !== undefined && formData) {
|
||||
formData.exchange_rate = exchangeRate;
|
||||
}
|
||||
});
|
||||
|
||||
if (!formData) {
|
||||
if (invoice) {
|
||||
@@ -62,8 +71,9 @@
|
||||
|
||||
// RIGHT fields
|
||||
currency_type: invoice.financials?.currency_type || '',
|
||||
currency: invoice.financials?.currency || 'foreign', // foreign, local, manual
|
||||
weight_type: 'kgs',
|
||||
currency: invoice.financials?.currency || 'foreign', // foreign, local, manual
|
||||
exchange_rate: invoice.financials?.exchange_rate || null, // Added exchange_rate
|
||||
weight_type: 'kgs',
|
||||
iva_factor: invoice.financials?.iva_factor || null,
|
||||
carrier_id: invoice.logistics?.[0]?.carrier_id || null,
|
||||
transport_id: '',
|
||||
@@ -72,8 +82,7 @@
|
||||
transport_num: invoice.logistics?.[0]?.vehicle_num || '',
|
||||
aduana: invoice.compliance_mx?.aduana || '',
|
||||
document_type: invoice.document_type || '',
|
||||
};
|
||||
console.log('FormData cargado para edición:', formData);
|
||||
};
|
||||
} else {
|
||||
// Creando una nueva factura
|
||||
formData = {
|
||||
@@ -90,6 +99,7 @@
|
||||
// RIGHT fields
|
||||
currency_type: '',
|
||||
currency: 'foreign', // foreign, local, manual
|
||||
exchange_rate: null, // Added exchange_rate
|
||||
weight_type: 'kgs',
|
||||
iva_factor: null,
|
||||
carrier_id: null,
|
||||
@@ -410,7 +420,14 @@
|
||||
<div class="border rounded-md p-3 space-y-2">
|
||||
<div class="flex justify-between">
|
||||
<h4 class="text-xs font-semibold text-muted-foreground uppercase">Tipo de Moneda - Pesos Netos y Brutos</h4>
|
||||
<h4 class="text-xs font-semibold text-muted-foreground uppercase">Tipo de cambio: </h4>
|
||||
<h4 class="text-xs font-semibold text-muted-foreground uppercase">
|
||||
Tipo de cambio:
|
||||
<span class="text-primary ml-1">
|
||||
{(exchangeRate !== undefined && exchangeRate !== null)
|
||||
? (exchangeRate === 0 ? 'N/A' : Number(exchangeRate).toFixed(4))
|
||||
: (formData.exchange_rate ? Number(formData.exchange_rate).toFixed(4) : 'N/A')}
|
||||
</span>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<!-- Radio buttons para tipo de moneda -->
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
pedimento: invoice?.compliance_mx?.pedimento || '',
|
||||
remesa: invoice?.compliance_mx?.remesa || '',
|
||||
invoice_number: invoice?.invoice_number || '',
|
||||
invoice_date: invoice?.invoice_date || '',
|
||||
emission_date: '',
|
||||
invoice_date: invoice?.invoice_date || new Date().toISOString().split('T')[0],
|
||||
emission_date: new Date().toISOString().split('T')[0],
|
||||
operation_type: operationType,
|
||||
invoice_type: invoice?.invoice_type || (defaultInvoiceType ?? ''),
|
||||
// Campos del pedimento (se llenarán al seleccionar un pedimento)
|
||||
|
||||
Reference in New Issue
Block a user