-
+
getCurrentLocalDate()}
+
+ (Opcional por fecha futura en consolidado)
+
+ {/if}
diff --git a/frontend/src/routes/dashboard/pedimentos/edit/[id]/+page.svelte b/frontend/src/routes/dashboard/pedimentos/edit/[id]/+page.svelte
index 6a868691..b901a155 100644
--- a/frontend/src/routes/dashboard/pedimentos/edit/[id]/+page.svelte
+++ b/frontend/src/routes/dashboard/pedimentos/edit/[id]/+page.svelte
@@ -87,6 +87,7 @@
import ExchangeRateDialog from '$lib/components/dashboard/exchange_rate/create-edit-dialog.svelte';
import { companyStore } from '$lib/stores/company.svelte';
import PrerequisitesModal from '$lib/components/dashboard/PrerequisitesModal.svelte';
+ import { getCurrentLocalDate } from '$lib/date-utils';
let { data }: { data: ExtendedPageData } = $props();
@@ -417,12 +418,19 @@
// Verificar tipo de cambio según catalogo de transporte (E/P)
if (generalTabInstance && generalFormData) {
const exchangeRef = getExchangeDateForPedimento(generalFormData);
- const rateExists = await generalTabInstance.checkPaymentDateRate(exchangeRef.date || '');
- if (!rateExists) {
- saving = false;
- // Asegurar que se muestre el tab general
- activeTab = 'general';
- return;
+ const isConsolidated = generalFormData.pedimento_type === 'consolidated';
+ const todayStr = getCurrentLocalDate();
+ const isFutureDate = exchangeRef.date && exchangeRef.date > todayStr;
+
+ // Solo verificar si NO es un consolidado con fecha futura
+ if (!(isConsolidated && isFutureDate)) {
+ const rateExists = await generalTabInstance.checkPaymentDateRate(exchangeRef.date || '');
+ if (!rateExists) {
+ saving = false;
+ // Asegurar que se muestre el tab general
+ activeTab = 'general';
+ return;
+ }
}
}
@@ -454,25 +462,36 @@
if (generalFormData) {
const exchangeRef = getExchangeDateForPedimento(generalFormData);
const rate = generalFormData.exchange_rate;
+ const isConsolidated = generalFormData.pedimento_type === 'consolidated';
+ const todayStr = getCurrentLocalDate();
+ const isFutureDate = exchangeRef.date && exchangeRef.date > todayStr;
+
if (
rate === null ||
rate === undefined ||
String(rate).trim() === '' ||
Number(rate) <= 0
) {
- saving = false;
- activeTab = 'general';
- const date = exchangeRef.date || '';
- toast.error(
- Number(rate) <= 0 && rate !== null && rate !== undefined
- ? `El tipo de cambio debe ser mayor a 0. Registra el tipo de cambio para la ${exchangeRef.label}.`
- : `No hay tipo de cambio registrado para la ${exchangeRef.label}. Por favor, regístralo antes de guardar.`
- );
- if (date) {
- missingExchangeRateDate = date;
- showExchangeRateDialog = true;
+ // Si es consolidado y fecha futura, permitimos continuar con un warning
+ if (isConsolidated && isFutureDate) {
+ toast.warning(
+ `Aviso: No hay tipo de cambio para la ${exchangeRef.label} (${exchangeRef.date}), pero se permite continuar por ser pedimento consolidado.`
+ );
+ } else {
+ saving = false;
+ activeTab = 'general';
+ const date = exchangeRef.date || '';
+ toast.error(
+ Number(rate) <= 0 && rate !== null && rate !== undefined
+ ? `El tipo de cambio debe ser mayor a 0. Registra el tipo de cambio para la ${exchangeRef.label}.`
+ : `No hay tipo de cambio registrado para la ${exchangeRef.label}. Por favor, regístralo antes de guardar.`
+ );
+ if (date) {
+ missingExchangeRateDate = date;
+ showExchangeRateDialog = true;
+ }
+ return;
}
- return;
}
}