fix: refs #8731 customerBalance and test
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Carlos Satorres 2025-03-07 13:19:58 +01:00
parent 7c0c1076e9
commit e2fa5a87eb
2 changed files with 39 additions and 33 deletions

View File

@ -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') }}

View File

@ -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();
});
});