Merge branch 'development' into feature/process-invoices

This commit is contained in:
2026-03-12 10:52:17 -05:00
2 changed files with 35 additions and 1 deletions

View File

@@ -31,6 +31,11 @@
const selectedPedimento = pedimentos.find((p) => p.id === parseInt(pedimentoId));
if (!selectedPedimento) return;
// Si el tipo de operación está vacío, llenarlo con el del pedimento
if (selectedPedimento.operation_type && !formData.operation_type) {
formData.operation_type = selectedPedimento.operation_type;
}
// Actualizar los campos del pedimento en formData
formData.fecha_pedimento_del = selectedPedimento.pedimento_dates?.start_date || '';
formData.fecha_pedimento_al = selectedPedimento.pedimento_dates?.end_date || '';
@@ -121,6 +126,24 @@
}
}
});
// Limpiar pedimento seleccionado si ya no está en la lista filtrada (p. ej. al cambiar tipo de factura)
$effect(() => {
const pid = formData?.pedimento_id;
const list = pedimentos || [];
if (pid == null || pid === '') return;
const id = typeof pid === 'string' ? parseInt(pid, 10) : pid;
if (Number.isNaN(id)) return;
const found = list.some((p) => p.id === id);
if (!found) {
formData.pedimento_id = null;
formData.pedimento = '';
formData.fecha_pedimento_del = '';
formData.fecha_pedimento_al = '';
formData.clave_pedimento = '';
formData.regimen_pedimento = '';
}
});
</script>
<!-- Datos Principales en una fila compacta (reusable across tabs) -->

View File

@@ -472,6 +472,17 @@
return 'bg-muted text-muted-foreground border-border';
});
// Pedimentos filtrados por tipo de operación: vacío → todos; imp/exp → solo los que coinciden
let filteredPedimentos = $derived.by(() => {
const list = data.pedimentos || [];
const opType =
InvoiceTopFieldsFormData?.operation_type ||
data.invoice?.operation_type ||
data.filters?.operation_type;
if (!opType || opType === '') return list;
return list.filter((p: { operation_type?: string }) => p.operation_type === opType);
});
async function checkExchangeRate(date: string): Promise<boolean> {
if (!date || !companyStore?.activeCompany?.id) return true;
@@ -859,7 +870,7 @@
invoice={data.invoice}
bind:formData={InvoiceTopFieldsFormData}
invoiceTypes={data.invoiceTypes || []}
pedimentos={data.pedimentos || []}
pedimentos={filteredPedimentos}
defaultOperationType={data.filters?.operation_type ?? undefined}
defaultInvoiceType={data.filters?.invoice_type ?? undefined}
{invoiceType}