From e2fa5a87eb213e75945be8c276d22d0f8ae9995a Mon Sep 17 00:00:00 2001 From: carlossa <carlossa@verdnatura.es> Date: Fri, 7 Mar 2025 13:19:58 +0100 Subject: [PATCH 1/5] fix: refs #8731 customerBalance and test --- .../components/CustomerNewPayment.vue | 66 +++++++++---------- .../integration/client/clientBalance.spec.js | 6 ++ 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/pages/Customer/components/CustomerNewPayment.vue b/src/pages/Customer/components/CustomerNewPayment.vue index 6ecccc544..2295b922b 100644 --- a/src/pages/Customer/components/CustomerNewPayment.vue +++ b/src/pages/Customer/components/CustomerNewPayment.vue @@ -74,26 +74,27 @@ onBeforeMount(() => { urlCreate.value = `Clients/${route.params.id}/createReceipt`; }); -function setPaymentType(accounting) { +function setPaymentType(data, accounting) { + data.bankFk = accounting.id; + console.log('accounting: ', accounting); if (!accounting) return; accountingType.value = accounting.accountingType; - initialData.description = []; - initialData.payed = Date.vnNew(); + console.log('accountingType.value: ', accountingType.value); + data.description = []; + data.payed = 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, - ); + data.payed.setDate(data.payed.getDate() + accountingType.value.daysInFuture); + console.log('data.payed', data.payed); maxAmount.value = accountingType.value && accountingType.value.maxAmount; - if (accountingType.value.code == 'compensation') - return (initialData.description = ''); + if (accountingType.value.code == 'compensation') return (data.description = ''); let descriptions = []; if (accountingType.value.receiptDescription) descriptions.push(accountingType.value.receiptDescription); - if (initialData.description) descriptions.push(initialData.description); - initialData.description = descriptions.join(', '); + if (data.description) descriptions.push(data.description); + data.description = descriptions.join(', '); } const calculateFromAmount = (event) => { @@ -113,7 +114,8 @@ function onBeforeSave(data) { if (isCash.value && shouldSendEmail.value && !data.email) return notify(t('There is no assigned email for this client'), 'negative'); - data.bankFk = data.bankFk?.id; + // data.bankFk = data.bankFk?.id; + return data; } @@ -184,11 +186,10 @@ async function getAmountPaid() { <FormModel ref="formModelRef" :form-initial-data="initialData" - :observe-form-changes="false" :url-create="urlCreate" :mapper="onBeforeSave" @on-data-saved="onDataSaved" - prevent-submit + :prevent-submit="true" > <template #form="{ data, validate }"> <span ref="closeButton" class="row justify-end close-icon" v-close-popup> @@ -196,27 +197,9 @@ async function getAmountPaid() { </span> <h5 class="q-mt-none">{{ t('New payment') }}</h5> - - <VnRow> - <VnInputDate - :label="t('Date')" - :required="true" - v-model="data.payed" - /> - <VnSelect - :label="t('Company')" - :options="companyOptions" - :required="true" - :rules="validate('entry.companyFk')" - hide-selected - option-label="code" - option-value="id" - v-model="data.companyFk" - @update:model-value="getAmountPaid()" - /> - </VnRow> <VnRow> <VnSelect + autofocus :label="t('Bank')" v-model="data.bankFk" url="Accountings" @@ -225,9 +208,10 @@ async function getAmountPaid() { sort-by="id" :limit="0" @update:model-value=" - (value, options) => setPaymentType(value, options) + (value, options) => setPaymentType(data, value, options) " :emit-value="false" + data-cy="paymentBank" > <template #option="scope"> <QItem v-bind="scope.itemProps"> @@ -245,8 +229,24 @@ async function getAmountPaid() { @update:model-value="calculateFromAmount($event)" clearable v-model.number="data.amountPaid" + data-cy="paymentAmount" /> </VnRow> + <VnRow> + <VnInputDate :label="t('Date')" v-model="data.payed" /> + <VnSelect + :label="t('Company')" + :options="companyOptions" + :required="true" + :rules="validate('entry.companyFk')" + hide-selected + option-label="code" + option-value="id" + v-model="data.companyFk" + @update:model-value="getAmountPaid()" + /> + </VnRow> + <div v-if="data.bankFk?.accountingType?.code == 'compensation'"> <div class="text-h6"> {{ t('Compensation') }} diff --git a/test/cypress/integration/client/clientBalance.spec.js b/test/cypress/integration/client/clientBalance.spec.js index abfa74cec..8f8296264 100644 --- a/test/cypress/integration/client/clientBalance.spec.js +++ b/test/cypress/integration/client/clientBalance.spec.js @@ -8,4 +8,10 @@ describe('Client balance', () => { it('Should load layout', () => { cy.get('.q-page').should('be.visible'); }); + it('Should create a mandate', () => { + cy.get('.q-page-sticky > div > .q-btn').click(); + cy.dataCy('paymentBank').type({ arroyDown }); + cy.dataCy('paymentAmount').type('100'); + cy.saveCard(); + }); }); From 1c48a6d504919c0c32bb229d91de89989c0141a9 Mon Sep 17 00:00:00 2001 From: carlossa <carlossa@verdnatura.es> Date: Mon, 10 Mar 2025 08:14:35 +0100 Subject: [PATCH 2/5] fix: refs #8731 customerBalance --- .../components/CustomerNewPayment.vue | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/pages/Customer/components/CustomerNewPayment.vue b/src/pages/Customer/components/CustomerNewPayment.vue index 2295b922b..5c1e4044b 100644 --- a/src/pages/Customer/components/CustomerNewPayment.vue +++ b/src/pages/Customer/components/CustomerNewPayment.vue @@ -5,7 +5,7 @@ import { useRoute } from 'vue-router'; import axios from 'axios'; import { getClientRisk } from '../composables/getClientRisk'; import { useDialogPluginComponent } from 'quasar'; - +import FormModelPopup from 'components/FormModelPopup.vue'; import { usePrintService } from 'composables/usePrintService'; import useNotify from 'src/composables/useNotify.js'; import FetchData from 'components/FetchData.vue'; @@ -183,7 +183,7 @@ async function getAmountPaid() { auto-load url="Clients/findOne" /> - <FormModel + <FormModelPopup ref="formModelRef" :form-initial-data="initialData" :url-create="urlCreate" @@ -191,11 +191,7 @@ async function getAmountPaid() { @on-data-saved="onDataSaved" :prevent-submit="true" > - <template #form="{ data, validate }"> - <span ref="closeButton" class="row justify-end close-icon" v-close-popup> - <QIcon name="close" size="sm" /> - </span> - + <template #form-inputs="{ data, validate }"> <h5 class="q-mt-none">{{ t('New payment') }}</h5> <VnRow> <VnSelect @@ -287,27 +283,8 @@ async function getAmountPaid() { <QCheckbox v-model="shouldSendEmail" :label="t('Send email')" /> </VnRow> </div> - <div class="q-mt-lg row justify-end"> - <QBtn - :disabled="formModelRef.isLoading" - :label="t('globals.cancel')" - :loading="formModelRef.isLoading" - class="q-ml-sm" - color="primary" - flat - type="reset" - v-close-popup - /> - <QBtn - :disabled="formModelRef.isLoading" - :label="t('globals.save')" - :loading="formModelRef.isLoading" - color="primary" - @click="formModelRef.save()" - /> - </div> </template> - </FormModel> + </FormModelPopup> </QDialog> </template> From dc600a568b9191b4338c2a937948a58fbd01ca11 Mon Sep 17 00:00:00 2001 From: carlossa <carlossa@verdnatura.es> Date: Mon, 10 Mar 2025 08:42:14 +0100 Subject: [PATCH 3/5] fix: refs #8731 remove logs --- src/pages/Customer/components/CustomerNewPayment.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/Customer/components/CustomerNewPayment.vue b/src/pages/Customer/components/CustomerNewPayment.vue index 5c1e4044b..49ed99d3c 100644 --- a/src/pages/Customer/components/CustomerNewPayment.vue +++ b/src/pages/Customer/components/CustomerNewPayment.vue @@ -76,17 +76,14 @@ onBeforeMount(() => { function setPaymentType(data, accounting) { data.bankFk = accounting.id; - console.log('accounting: ', accounting); if (!accounting) return; accountingType.value = accounting.accountingType; - console.log('accountingType.value: ', accountingType.value); data.description = []; data.payed = Date.vnNew(); isCash.value = accountingType.value.code == 'cash'; viewReceipt.value = isCash.value; if (accountingType.value.daysInFuture) data.payed.setDate(data.payed.getDate() + accountingType.value.daysInFuture); - console.log('data.payed', data.payed); maxAmount.value = accountingType.value && accountingType.value.maxAmount; if (accountingType.value.code == 'compensation') return (data.description = ''); From 677477df8d6f3fae95a822eed2a82a4c5fd7d91c Mon Sep 17 00:00:00 2001 From: carlossa <carlossa@verdnatura.es> Date: Mon, 10 Mar 2025 08:43:03 +0100 Subject: [PATCH 4/5] fix: refs #8731 clean code --- src/pages/Customer/components/CustomerNewPayment.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/Customer/components/CustomerNewPayment.vue b/src/pages/Customer/components/CustomerNewPayment.vue index 49ed99d3c..ad120d7ef 100644 --- a/src/pages/Customer/components/CustomerNewPayment.vue +++ b/src/pages/Customer/components/CustomerNewPayment.vue @@ -111,8 +111,6 @@ function onBeforeSave(data) { if (isCash.value && shouldSendEmail.value && !data.email) return notify(t('There is no assigned email for this client'), 'negative'); - // data.bankFk = data.bankFk?.id; - return data; } From 18c927adb23f4c829cc0195c4cbf58f8250897d0 Mon Sep 17 00:00:00 2001 From: carlossa <carlossa@verdnatura.es> Date: Mon, 10 Mar 2025 09:08:36 +0100 Subject: [PATCH 5/5] fix: refs #8731 required Date --- src/pages/Customer/components/CustomerNewPayment.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/Customer/components/CustomerNewPayment.vue b/src/pages/Customer/components/CustomerNewPayment.vue index ad120d7ef..ac80fdaa4 100644 --- a/src/pages/Customer/components/CustomerNewPayment.vue +++ b/src/pages/Customer/components/CustomerNewPayment.vue @@ -224,7 +224,11 @@ async function getAmountPaid() { /> </VnRow> <VnRow> - <VnInputDate :label="t('Date')" v-model="data.payed" /> + <VnInputDate + :label="t('Date')" + v-model="data.payed" + :required="true" + /> <VnSelect :label="t('Company')" :options="companyOptions"