From 9ee69274ae794f88350d3f71619fbcb111a728cf Mon Sep 17 00:00:00 2001 From: jon Date: Wed, 7 May 2025 12:28:05 +0200 Subject: [PATCH 1/6] fix: make 0 become valid in VnInputNumber when using required from validator --- src/composables/useValidator.js | 4 +++- .../customer/clientCredits.spec.js | 22 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/composables/useValidator.js b/src/composables/useValidator.js index ae6c47d91..e887c0c4f 100644 --- a/src/composables/useValidator.js +++ b/src/composables/useValidator.js @@ -47,7 +47,9 @@ export function useValidator() { return !validator.isEmpty(value ? String(value) : '') || message; }, required: (required, value) => { - return required ? !!value || t('globals.fieldRequired') : null; + return required + ? value === 0 || !!value || t('globals.fieldRequired') + : null; }, length: (value) => { const options = { diff --git a/test/cypress/integration/customer/clientCredits.spec.js b/test/cypress/integration/customer/clientCredits.spec.js index 5f303b40d..f39f3c06c 100644 --- a/test/cypress/integration/customer/clientCredits.spec.js +++ b/test/cypress/integration/customer/clientCredits.spec.js @@ -7,7 +7,27 @@ describe('Client credits', () => { timeout: 5000, }); }); - it('Should load layout', () => { + + it('Should put a new credit', () => { cy.get('.q-page').should('be.visible'); + cy.dataCy('vnTableCreateBtn').click(); + cy.dataCy('Credit_input').type('100'); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data saved'); + }); + + it('Should put a new credit with value 0 to close the client card', () => { + cy.get('.q-page').should('be.visible'); + cy.dataCy('vnTableCreateBtn').click(); + cy.dataCy('Credit_input').type('0'); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data saved'); + }); + + it('Should not create the credit if there is no value in the input', () => { + cy.get('.q-page').should('be.visible'); + cy.dataCy('vnTableCreateBtn').click(); + cy.dataCy('FormModelPopup_save').click(); + cy.get('.q-notification__message').should('not.exist'); }); }); From 85e932a6b96ab0dd025b55102c04a6bc4b05fffb Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 12 May 2025 10:19:48 +0200 Subject: [PATCH 2/6] fix: add required validation depends on verified data checkbox --- .../Customer/Card/CustomerFiscalData.vue | 37 +++++++--- .../customer/clientFiscalData.spec.js | 74 +++++++++++-------- 2 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/pages/Customer/Card/CustomerFiscalData.vue b/src/pages/Customer/Card/CustomerFiscalData.vue index b45df2e0f..fbb155cd3 100644 --- a/src/pages/Customer/Card/CustomerFiscalData.vue +++ b/src/pages/Customer/Card/CustomerFiscalData.vue @@ -62,6 +62,15 @@ 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; + } +}