From 893c154b851ac6aba801a2f3fc07bd1a678e2940 Mon Sep 17 00:00:00 2001 From: Galindo97 Date: Mon, 9 Feb 2026 12:57:20 -0600 Subject: [PATCH] feat: Enhance invoice form data handling with new fields and improve invoice report export filter logic and UI. --- .../reports/movements/invoices/csv_utils.py | 2 +- .../invoices/edit/invoice-top-fields.svelte | 386 ++++++++++-------- .../invoices/edit/others-tab-form.svelte | 86 ++-- .../dashboard/invoices/edit/save-invoice.ts | 29 +- .../dashboard/reports/invoices/+page.svelte | 116 +++--- 5 files changed, 348 insertions(+), 271 deletions(-) diff --git a/backend/api/v1/modules/a76/reports/movements/invoices/csv_utils.py b/backend/api/v1/modules/a76/reports/movements/invoices/csv_utils.py index 2c91af6d..4ac1a3c8 100644 --- a/backend/api/v1/modules/a76/reports/movements/invoices/csv_utils.py +++ b/backend/api/v1/modules/a76/reports/movements/invoices/csv_utils.py @@ -120,7 +120,7 @@ def generate_csv_from_movements( def _format_datetime(dt) -> str: """Format datetime for CSV export.""" if isinstance(dt, datetime): - return dt.strftime('%Y-%m-%d %H:%M:%S') + return dt.strftime('%Y-%m-%d') elif isinstance(dt, str): return dt return '' diff --git a/frontend/src/lib/components/dashboard/invoices/edit/invoice-top-fields.svelte b/frontend/src/lib/components/dashboard/invoices/edit/invoice-top-fields.svelte index e3549f05..52de9150 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/invoice-top-fields.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/invoice-top-fields.svelte @@ -1,196 +1,224 @@ -
-
- - { - formData.operation_type = v; - }} - > - - - {formData.operation_type - ? (formData.operation_type === 'exp' ? 'Exp' : 'Imp') - : '...'} - - - - Exportación - Importación - - -
-
- - { - formData.invoice_type = v ?? ''; - }} - > - - - {formData.invoice_type - ? `${formData.invoice_type}` - : '...'} - - - - {#each invoiceTypes as type} - - {type.key} - {type.description} - - {/each} - - -
+
+
+ + { + formData.operation_type = v; + }} + > + + + {formData.operation_type ? (formData.operation_type === 'exp' ? 'Exp' : 'Imp') : '...'} + + + + Exportación + Importación + + +
+
+ + { + formData.invoice_type = v ?? ''; + }} + > + + + {formData.invoice_type ? `${formData.invoice_type}` : '...'} + + + + {#each invoiceTypes as type} + + {type.key} - {type.description} + + {/each} + + +
-
- - { - formData.is_pedimento_pending = checked; - }} - /> -
-
- - { - formData.pedimento_id = v ? parseInt(v) : null; - if (v) { - handlePedimentoChange(v); - } - }} - > - - - {formData.pedimento || 'Selecciona pedimento...'} - - - - {#each pedimentos as pedimento} - - {pedimento.customs_office?.slice(0, 2)}-{pedimento.license}-{pedimento.pedimento_number} - - {/each} - - -
+
+ + { + formData.is_pedimento_pending = checked; + }} + /> +
+
+ + { + formData.pedimento_id = v ? parseInt(v) : null; + if (v) { + handlePedimentoChange(v); + } + }} + > + + + {formData.pedimento || 'Selecciona pedimento...'} + + + + {#each pedimentos as pedimento} + + {pedimento.customs_office?.slice(0, 2)}-{pedimento.license}-{pedimento.pedimento_number} + + {/each} + + +
-
- - -
+
+ + +
-
- - -
+
+ + +
-
- - -
+
+ + +
-
- - -
+
+ + +
+ +
+ + +
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/others-tab-form.svelte b/frontend/src/lib/components/dashboard/invoices/edit/others-tab-form.svelte index c08d1e4f..ca7219fe 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/others-tab-form.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/others-tab-form.svelte @@ -10,12 +10,12 @@ import { Plus, Upload } from 'lucide-svelte'; import type { Invoice } from '$lib/api/dashboard/a76/invoices'; - let { + let { invoice, formData = $bindable(), exists = $bindable(), transportModes = [] - }: { + }: { invoice: Invoice | null; formData?: any; exists?: boolean; @@ -36,11 +36,14 @@ electronic_signature: invoice.compliance_mx?.electronic_signature || '', mandatory_person: '', contingency_mode: invoice.compliance_mx?.contingency_mode || false, - cove: invoice.compliance_mx?.origin_destination_cove || '', + cove: invoice.compliance_mx?.edocument || '', operation_num: invoice.compliance_mx?.vucem_operation_num || '', adendas: invoice.compliance_mx?.addendum_vu || '', observations_vu: invoice.vu_observations || '', - certified_number: invoice.compliance_mx?.certificate_number || '', + certified_number: invoice.compliance_mx?.certificate_number || '', + entry_exit_date: invoice.logistics?.entry_exit_date || '', + payment_date: invoice.logistics?.payment_date || '', + delivery_date: invoice.logistics?.delivery_date || '' }; exists = true; } else if (!formData) { @@ -61,7 +64,10 @@ operation_num: '', adendas: '', observations_vu: '', - certified_number: '', + certified_number: '', + entry_exit_date: '', + payment_date: '', + delivery_date: '' }; exists = false; } @@ -70,7 +76,6 @@ let rfc = $state(''); let curp = $state(''); - function loadInfo() { // Función para cargar información console.log('Cargar información'); @@ -78,18 +83,18 @@
-
- +
- formData.transport_mode = value || 'TRUCK'} + (formData.transport_mode = value || 'TRUCK')} > - {transportModes.find(m => m.key === formData.transport_mode)?.name || 'Seleccionar modo'} + {transportModes.find((m) => m.key === formData.transport_mode)?.name || + 'Seleccionar modo'} {#each transportModes as mode} @@ -116,9 +121,9 @@
- formData.is_mixed = v === 'yes'} + (formData.is_mixed = v === 'yes')} class="flex gap-4" >
@@ -131,7 +136,7 @@
-
+
@@ -145,22 +150,18 @@