From 9121e795335cadbc35f433b46458792735c95db7 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Dec 2024 14:20:03 +0100 Subject: [PATCH] perf: refs #7134 use ForModelPopup --- src/components/common/VnAccountNumber.vue | 9 +- .../Supplier/Card/SupplierFiscalData.vue | 2 - .../Supplier/Card/SupplierNewPayment.vue | 141 +++++++----------- 3 files changed, 63 insertions(+), 89 deletions(-) diff --git a/src/components/common/VnAccountNumber.vue b/src/components/common/VnAccountNumber.vue index c4fa78674..f66684a0f 100644 --- a/src/components/common/VnAccountNumber.vue +++ b/src/components/common/VnAccountNumber.vue @@ -9,7 +9,7 @@ const $props = defineProps({ }, insertable: { type: Boolean, - default: false, + default: true, }, }); @@ -79,5 +79,10 @@ function accountShortToStandard() { diff --git a/src/pages/Supplier/Card/SupplierFiscalData.vue b/src/pages/Supplier/Card/SupplierFiscalData.vue index 1a79be8bc..46e377139 100644 --- a/src/pages/Supplier/Card/SupplierFiscalData.vue +++ b/src/pages/Supplier/Card/SupplierFiscalData.vue @@ -106,8 +106,6 @@ function handleLocation(data, location) { :label="t('supplier.fiscalData.account')" clearable data-cy="supplierFiscalDataAccount" - insertable - :maxlength="10" /> { - urlCreate.value = `Suppliers/${route.params.id}/createReceipt`; + urlCreate.value = `Suppliers/${route.params.id}/createPayment`; }); function setPaymentType(accounting) { if (!accounting) return; accountingType.value = accounting.accountingType; - initialData.description = []; - initialData.payed = Date.vnNew(); + initialData.concept = []; + initialData.received = Date.vnNew(); isCash.value = accountingType.value.code == 'cash'; viewReceipt.value = isCash.value; if (accountingType.value.daysInFuture) - initialData.payed.setDate( - initialData.payed.getDate() + accountingType.value.daysInFuture + initialData.received.setDate( + initialData.received.getDate() + accountingType.value.daysInFuture ); maxAmount.value = accountingType.value && accountingType.value.maxAmount; - if (accountingType.value.code == 'compensation') - return (initialData.description = ''); - if (accountingType.value.receiptDescription) - initialData.description.push(accountingType.value.receiptDescription); - if (initialData.description) initialData.description.push(initialData.description); + if (accountingType.value.code == 'compensation') return (initialData.concept = ''); + if (accountingType.value.receiptconcept) + initialData.concept.push(accountingType.value.receiptconcept); + if (initialData.concept) initialData.concept.push(initialData.concept); - initialData.description = initialData.description.join(', '); + initialData.concept = initialData.concept.join(', '); } const calculateFromAmount = (event) => { @@ -115,17 +120,18 @@ const calculateFromAmount = (event) => { }; const calculateFromDeliveredAmount = (event) => { - initialData.amountToReturn = parseFloat(event) - initialData.amountPaid; + initialData.amountToReturn = parseFloat(event) - initialData.amount; }; function onBeforeSave(data) { - const exceededAmount = data.amountPaid > maxAmount.value; + const exceededAmount = data.amount > maxAmount.value; if (isCash.value && exceededAmount) return notify(t('Amount exceeded', { maxAmount: maxAmount.value }), 'negative'); if (isCash.value && shouldSendEmail.value && !data.email) return notify(t(`There is no assigned email for this supplier`), 'negative'); + data.dueDate = data.received; data.bankFk = data.bankFk.id; return data; } @@ -144,25 +150,7 @@ async function onDataSaved(formData, { id }) { } } -async function accountShortToStandard({ target: { value } }) { - if (!value) return (initialData.description = ''); - initialData.compensationAccount = value.replace('.', '0'.repeat(11 - value.length)); - const params = { bankAccount: initialData.compensationAccount }; - const { data } = await axios(`Clients/getClientOrSupplierReference`, { params }); - if (!data.clientId) { - initialData.description = t('Supplier Compensation Reference', { - supplierId: data.supplierId, - supplierName: data.supplierName, - }); - return; - } - initialData.description = t('Client Compensation Reference', { - clientId: data.clientId, - clientName: data.clientName, - }); -} - -async function getAmountPaid() { +async function getAmount() { const filter = { where: { supplierFk: route.params.id, @@ -170,7 +158,7 @@ async function getAmountPaid() { }, }; const { data } = await getSupplierRisk(filter); - initialData.amountPaid = (data?.length && data[0].amount) || undefined; + initialData.amount = (data?.length && data[0].amount) || undefined; } @@ -195,7 +183,7 @@ async function getAmountPaid() { @on-fetch="(data) => (currenciesOptions = data)" auto-load /> - - - +