Merge pull request 'fix/pedimento-consolidado-DOF' (#297) from fix/pedimento-consolidado-DOF into development
Reviewed-on: ADUANASOFT/anexo76#297
This commit is contained in:
@@ -594,7 +594,12 @@
|
||||
|
||||
<!-- Tipo de Cambio -->
|
||||
<div class="space-y-2">
|
||||
<Label for="exchange_rate">Tipo de Cambio <span class="text-red-500">*</span></Label>
|
||||
<Label for="exchange_rate">
|
||||
Tipo de Cambio
|
||||
{#if !(formData.pedimento_type === 'consolidated' && getEffectiveExchangeDate() > getCurrentLocalDate())}
|
||||
<span class="text-red-500">*</span>
|
||||
{/if}
|
||||
</Label>
|
||||
<Input
|
||||
id="exchange_rate"
|
||||
type="text"
|
||||
@@ -608,6 +613,11 @@
|
||||
Tipo de fecha para TC: {getEffectiveDateLabel() === 'fecha de pago'
|
||||
? 'FECHA PAGO'
|
||||
: 'FECHA ENTRADA'}
|
||||
{#if formData.pedimento_type === 'consolidated' && getEffectiveExchangeDate() > getCurrentLocalDate()}
|
||||
<span class="ml-1 block font-medium text-amber-600 dark:text-amber-400">
|
||||
(Opcional por fecha futura en consolidado)
|
||||
</span>
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user