Merge pull request 'fix: add required validation depends on verified data checkbox' (!1792) from warmfix_customerFiscalData_dataChecked into test
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1792
Reviewed-by: Pau Rovira <provira@verdnatura.es>
This commit is contained in:
Javier Segarra 2025-05-12 11:21:12 +00:00
commit 96c674eff2
2 changed files with 75 additions and 49 deletions

View File

@ -6,7 +6,6 @@ import { useQuasar } from 'quasar';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
@ -21,9 +20,6 @@ const { t } = useI18n();
const route = useRoute();
const { notify } = useNotify();
const typesTaxes = ref([]);
const typesTransactions = ref([]);
function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {};
data.postcode = code;
@ -39,6 +35,7 @@ function onBeforeSave(formData, originalData) {
}
async function checkEtChanges(data, _, originalData) {
isTaxDataChecked.value = data.isTaxDataChecked;
const equalizatedHasChanged = originalData.isEqualizated != data.isEqualizated;
const hasToInvoiceByAddress =
originalData.hasToInvoiceByAddress || data.hasToInvoiceByAddress;
@ -62,15 +59,18 @@ async function acceptPropagate({ isEqualizated }) {
});
notify(t('Equivalent tax spreaded'), 'warning');
}
const isTaxDataChecked = ref(false);
function isRequired({ isTaxDataChecked: taxDataChecked }) {
if (!isTaxDataChecked.value) {
return false;
} else {
return taxDataChecked;
}
}
</script>
<template>
<FetchData auto-load @on-fetch="(data) => (typesTaxes = data)" url="SageTaxTypes" />
<FetchData
auto-load
@on-fetch="(data) => (typesTransactions = data)"
url="SageTransactionTypes"
/>
<FormModel
:url-update="`Clients/${route.params.id}/updateFiscalData`"
auto-load
@ -80,6 +80,7 @@ async function acceptPropagate({ isEqualizated }) {
@on-data-saved="checkEtChanges"
>
<template #form="{ data, validate, validations }">
{{ isTaxDataChecked }} {{ data.isTaxDataChecked }}
<VnRow>
<VnInput
:label="t('Social name')"
@ -111,21 +112,27 @@ async function acceptPropagate({ isEqualizated }) {
<VnRow>
<VnSelect
:label="t('Sage tax type')"
:options="typesTaxes"
url="SageTaxTypes"
hide-selected
option-label="vat"
option-value="id"
v-model="data.sageTaxTypeFk"
data-cy="sageTaxTypeFk"
:required="isRequired(data)"
:rules="[(val) => validations.required(data.sageTaxTypeFk, val)]"
/>
<VnSelect
:label="t('Sage transaction type')"
:options="typesTransactions"
url="SageTransactionTypes"
hide-selected
option-label="transaction"
option-value="id"
data-cy="sageTransactionTypeFk"
v-model="data.sageTransactionTypeFk"
:required="isRequired(data)"
:rules="[
(val) => validations.required(data.sageTransactionTypeFk, val),
]"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
@ -151,11 +158,11 @@ async function acceptPropagate({ isEqualizated }) {
/>
</VnRow>
<VnRow>
<QCheckbox :label="t('Active')" v-model="data.isActive" />
<QCheckbox :label="t('Frozen')" v-model="data.isFreezed" />
<VnCheckbox :label="t('Active')" v-model="data.isActive" />
<VnCheckbox :label="t('Frozen')" v-model="data.isFreezed" />
</VnRow>
<VnRow>
<QCheckbox :label="t('Has to invoice')" v-model="data.hasToInvoice" />
<VnCheckbox :label="t('Has to invoice')" v-model="data.hasToInvoice" />
<VnCheckbox
v-model="data.isVies"
:label="t('globals.isVies')"
@ -164,8 +171,8 @@ async function acceptPropagate({ isEqualizated }) {
</VnRow>
<VnRow>
<QCheckbox :label="t('Notify by email')" v-model="data.isToBeMailed" />
<QCheckbox
<VnCheckbox :label="t('Notify by email')" v-model="data.isToBeMailed" />
<VnCheckbox
:label="t('Invoice by address')"
v-model="data.hasToInvoiceByAddress"
/>
@ -177,16 +184,18 @@ async function acceptPropagate({ isEqualizated }) {
:label="t('Is equalizated')"
:info="t('inOrderToInvoice')"
/>
<QCheckbox :label="t('Daily invoice')" v-model="data.hasDailyInvoice" />
<VnCheckbox :label="t('Daily invoice')" v-model="data.hasDailyInvoice" />
</VnRow>
<VnRow>
<QCheckbox
<VnCheckbox
:label="t('Electronic invoice')"
v-model="data.hasElectronicInvoice"
/><QCheckbox
/>
<VnCheckbox
:label="t('Verified data')"
v-model="data.isTaxDataChecked"
@update:model-value="isTaxDataChecked = !isTaxDataChecked"
/>
</VnRow>
</template>

View File

@ -1,37 +1,54 @@
/// <reference types="cypress" />
function checkSageFields(isRequired = false) {
const haveAttr = isRequired ? 'have.attr' : 'not.have.attr';
cy.dataCy('sageTaxTypeFk').filter('input').should(haveAttr, 'required');
cy.dataCy('sageTransactionTypeFk').filter('input').should(haveAttr, 'required');
}
describe('Client fiscal data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1107/fiscal-data');
});
it.skip('Should change required value when change customer', () => {
cy.get('.q-card').should('be.visible');
cy.dataCy('sageTaxTypeFk').filter('input').should('not.have.attr', 'required');
cy.get('#searchbar input').clear();
cy.get('#searchbar input').type('1{enter}');
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
cy.dataCy('sageTaxTypeFk').filter('input').should('have.attr', 'required');
describe('#1008', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1108/fiscal-data');
});
it('Should change required value when change customer', () => {
cy.get('.q-card').should('be.visible');
checkSageFields();
cy.get('[data-cy="vnCheckboxVerified data"]').click();
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content').click();
checkSageFields();
cy.get('[data-cy="vnCheckboxVerified data"]').click();
checkSageFields(true);
cy.get('#searchbar input').clear();
cy.get('#searchbar input').type('1{enter}');
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
checkSageFields();
});
});
describe('#1007', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1107/fiscal-data');
});
it('check as equalizated', () => {
cy.get(
':nth-child(1) > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg',
).click();
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content').click();
it('check as equalizated', () => {
cy.dataCy('vnCheckboxIs equalizated').click();
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content').click();
cy.get('.q-card > :nth-child(1) > span').should(
'contain',
'You changed the equalization tax',
);
cy.get('.q-card > :nth-child(1) > span').should(
'contain',
'You changed the equalization tax',
);
cy.get('.q-card > :nth-child(2) > span').should(
'have.text',
'Do you want to spread the change?',
);
cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click();
cy.get(
'.bg-warning > .q-notification__wrapper > .q-notification__content > .q-notification__message',
).should('have.text', 'Equivalent tax spreaded');
cy.get('.q-card > :nth-child(2) > span').should(
'have.text',
'Do you want to spread the change?',
);
cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click();
cy.get(
'.bg-warning > .q-notification__wrapper > .q-notification__content > .q-notification__message',
).should('have.text', 'Equivalent tax spreaded');
});
});
});