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 @@
-
+ />
+
-
-
diff --git a/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts b/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts
index e6f6b550..a7bd85c5 100644
--- a/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts
+++ b/frontend/src/lib/components/dashboard/invoices/edit/save-invoice.ts
@@ -45,7 +45,7 @@ export async function saveInvoice(options: SaveInvoiceOptions): Promise
{
@@ -192,7 +193,8 @@ function buildComplianceMxData(InvoiceTopFieldsFormData: any, generalFormData: a
// Fields from othersFormData
is_mixed: othersFormData?.is_mixed || null,
contingency_mode: othersFormData?.contingency_mode || false,
- origin_destination_cove: othersFormData?.cove || null,
+ origin_destination_cove: null,
+ edocument: othersFormData?.cove || null,
vucem_operation_num: othersFormData?.operation_num || null,
addendum_vu: othersFormData?.adendas || null,
certificate_number: othersFormData?.certified_number || null,
@@ -204,8 +206,9 @@ function buildComplianceMxData(InvoiceTopFieldsFormData: any, generalFormData: a
function buildFinancialsData(generalFormData: any, observationFormData: any, othersFormData: any) {
return {
// Currency from generalFormData
- currency_type: generalFormData?.currency_type || null,
+ currency_type: generalFormData?.currency_type || (generalFormData?.currency === 'foreign' ? 'USD' : null),
currency: generalFormData?.currency || null,
+ exchange_rate: generalFormData?.exchange_rate ? Number(generalFormData.exchange_rate) : null,
iva_factor: generalFormData?.iva_factor || null,
// Costs & increments from observationFormData
freight: observationFormData?.freight || null,
@@ -220,13 +223,15 @@ function buildFinancialsData(generalFormData: any, observationFormData: any, oth
};
}
-function buildLogisticsData(generalFormData: any, observationFormData: any, continuationFormData: any) {
+function buildLogisticsData(generalFormData: any, observationFormData: any, continuationFormData: any, othersFormData: any) {
// Retornar logistics como objeto único con datos de continuación
return {
carrier_id: generalFormData?.carrier_id || null,
+ transport_id: generalFormData?.transport_id || null,
transport_type: generalFormData?.transport_type || 'none',
driver_name: generalFormData?.driver_name || null,
- vehicle_num: generalFormData?.transport_num || continuationFormData?.numero_tipo_transporte || null,
+ license_plate: generalFormData?.transport_num || null,
+ vehicle_num: continuationFormData?.numero_tipo_transporte || null,
incoterm: observationFormData?.incoterm || null,
// Campos de continuación mapeados a logistics
transport_num: continuationFormData?.numero_tipo_transporte || null,
@@ -245,5 +250,9 @@ function buildLogisticsData(generalFormData: any, observationFormData: any, cont
green_light_us: continuationFormData?.semaforo_verde_aduana_americana || false,
red_light_mx: continuationFormData?.semaforo_rojo_aduana_mexicana || false,
red_light_us: continuationFormData?.semaforo_rojo_aduana_americana || false,
+ // Fechas Logísticas de OthersTabForm (se pasan en othersFormData)
+ entry_exit_date: othersFormData?.entry_exit_date || null,
+ payment_date: othersFormData?.payment_date || null,
+ delivery_date: othersFormData?.delivery_date || null,
};
}
diff --git a/frontend/src/routes/dashboard/reports/invoices/+page.svelte b/frontend/src/routes/dashboard/reports/invoices/+page.svelte
index 97dff1c6..874074a7 100644
--- a/frontend/src/routes/dashboard/reports/invoices/+page.svelte
+++ b/frontend/src/routes/dashboard/reports/invoices/+page.svelte
@@ -195,6 +195,39 @@
}
}
+ // --- DERIVED STATE FOR EXPORT VALIDATION ---
+
+ /**
+ * Determine which export additional options should be disabled based on main export type selection.
+ * Rules:
+ * - If REP (Reparación) is selected: disable REEXP, DONAC, SCRAP
+ * - If CREG (C. Régimen) is selected: disable REEXP, DONAC, NODES
+ */
+ const isExportAdditionalDisabled = $derived({
+ REEXP: types.export.main.REP || types.export.main.CREG,
+ DONAC: types.export.main.REP || types.export.main.CREG,
+ SCRAP: types.export.main.REP,
+ NODES: types.export.main.CREG,
+ AFIJO: false,
+ TODAS: false
+ });
+
+ // Auto-uncheck disabled export additional options
+ $effect(() => {
+ if (isExportAdditionalDisabled.REEXP && types.export.additional.REEXP) {
+ types.export.additional.REEXP = false;
+ }
+ if (isExportAdditionalDisabled.DONAC && types.export.additional.DONAC) {
+ types.export.additional.DONAC = false;
+ }
+ if (isExportAdditionalDisabled.SCRAP && types.export.additional.SCRAP) {
+ types.export.additional.SCRAP = false;
+ }
+ if (isExportAdditionalDisabled.NODES && types.export.additional.NODES) {
+ types.export.additional.NODES = false;
+ }
+ });
+
// --- VALIDACIONES ---
function formatDateToYYYYMMDD(dateStr: string): string {
@@ -372,8 +405,7 @@
const filter = buildAllMovementsFilter();
if (!filter) return;
- // Forzar envío de correo para esta acción
- filter.send_email = true;
+ // Email sending is controlled by config.sendEmail checkbox
loading = true;
// Initial toast
@@ -568,6 +600,7 @@
allMovementsFilter.export_rep = true;
allMovementsFilter.operation_type = null;
} else if (types.export.additional.TODAS) {
+ // TODAS for exports: only search export movements
allMovementsFilter.import_temp = false;
allMovementsFilter.import_def = false;
allMovementsFilter.import_rep = false;
@@ -1071,14 +1104,14 @@
-
+
-
+
{#each Object.keys(types.import) as key}
-
+
Exportación
-
- {#each Object.keys(types.other) as key}
-
- {
- if (key === 'TODAS') handleTodasChange(v as boolean);
- }}
- />
-
-
- {/each}
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
{#each Object.keys(types.export.additional) as key}
+
+
+
+
+
+ {#each Object.keys(types.other) as key}
+
+ {
+ if (key === 'TODAS') handleTodasChange(v as boolean);
+ }}
+ />
+
+
+ {/each}
+
+