From 9a7f4cdd8c70e21299cbfb740bee314622ffea2b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 19 May 2025 15:05:45 +0200 Subject: [PATCH 1/2] fix: minor issue and add test --- .../Ticket/components/TicketNewPayment.vue | 42 ++++++++++++++----- .../integration/ticket/ticketList.spec.js | 19 +++++++++ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/pages/Ticket/components/TicketNewPayment.vue b/src/pages/Ticket/components/TicketNewPayment.vue index 4951e5249..15a018b82 100644 --- a/src/pages/Ticket/components/TicketNewPayment.vue +++ b/src/pages/Ticket/components/TicketNewPayment.vue @@ -52,30 +52,50 @@ const filterBanks = { const state = useState(); const user = state.getUser(); +const originalDescription = ref(''); const initialData = ref({ ...$props.formData, companyFk: user.value.companyFk, payed: Date.vnNew(), + originalDescription: '', }); function setPaymentType(data, accounting) { - data.bankFk = accounting.id; if (!accounting) return; + + data.bankFk = accounting.id; accountingType.value = accounting.accountingType; + 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); - maxAmount.value = accountingType.value && accountingType.value.maxAmount; - if (accountingType.value.code == 'compensation') return (data.description = ''); - let descriptions = []; - if (accountingType.value.receiptDescription) - descriptions.push(accountingType.value.receiptDescription); - if (data.description > 0) descriptions.push(data.description); - data.description = descriptions.join(', '); + switch (accountingType.value.code) { + case 'compensation': + data.description.push($props.formData.description); + break; + + default: + if ( + accountingType.value.receiptDescription != null && + accountingType.value.receiptDescription != '' + ) { + data.description.push(accountingType.value.receiptDescription); + } + const originalDescription = + data.originalDescription || $props.formData.description; + if (originalDescription) { + data.description.push(originalDescription); + } + } + + data.description = data.description.join(', '); + data.payed = Date.vnNew(); + if (accountingType.value.daysInFuture) { + data.payed.setDate(data.payed.getDate() + accountingType.value.daysInFuture); + } + + maxAmount.value = accountingType.value && accountingType.value.maxAmount; } const calculateFromAmount = (event) => { diff --git a/test/cypress/integration/ticket/ticketList.spec.js b/test/cypress/integration/ticket/ticketList.spec.js index ae0e0ff10..67a1c29e2 100644 --- a/test/cypress/integration/ticket/ticketList.spec.js +++ b/test/cypress/integration/ticket/ticketList.spec.js @@ -26,6 +26,25 @@ describe('TicketList', () => { cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/); }); + it.only('should create payment ticket', () => { + cy.get('[data-cy="vnFilterPanel_search"] > .q-btn__content > .q-icon').click(); + + const rowSelected = + 'tbody > :nth-child(2) > :nth-child(1) > .q-checkbox > .q-checkbox__inner '; + cy.get(rowSelected).click(); + cy.get( + '[style="transform: translate(-256px, 0px); margin: 140px 20px; z-index: 2;"] > div > .q-btn', + ).click(); + const description = 'Albaran: 31'; + cy.dataCy('Reference_input').should('have.value', description); + cy.selectOption('[data-cy="paymentBank"]', 'Cash').click(); + cy.get('[data-cy="Delivered amount_input"]').clear(); + cy.get('[data-cy="Delivered amount_input"]').type('41.62'); + cy.dataCy('Reference_input').should('have.value', `Cash, ${description}`); + cy.get('[aria-label="View recipt"]').click(); + cy.get('.q-btn--standard > .q-btn__content > .block').click(); + }); + it('should open ticket summary', () => { searchResults(); cy.getRow().find('.q-btn:last').click(); From 33eb77864f308f536fba1a6748d6e858fc9c5abb Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 20 May 2025 08:38:24 +0200 Subject: [PATCH 2/2] test: minor changes --- test/cypress/integration/ticket/ticketBasicData.spec.js | 4 ++-- test/cypress/integration/ticket/ticketList.spec.js | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/cypress/integration/ticket/ticketBasicData.spec.js b/test/cypress/integration/ticket/ticketBasicData.spec.js index 443e9569b..6ad4d4518 100644 --- a/test/cypress/integration/ticket/ticketBasicData.spec.js +++ b/test/cypress/integration/ticket/ticketBasicData.spec.js @@ -6,7 +6,7 @@ describe('TicketBasicData', () => { cy.visit('/#/ticket/31/basic-data'); }); - it('Should redirect to customer basic data', () => { + it.skip('Should redirect to customer basic data', () => { cy.get('.q-page').should('be.visible'); cy.get(':nth-child(2) > div > .text-primary').click(); cy.dataCy('Address_select').click(); @@ -16,7 +16,7 @@ describe('TicketBasicData', () => { ).click(); cy.url().should('include', '/customer/1104/basic-data'); }); - it.only('stepper', () => { + it('stepper', () => { cy.get('.q-stepper__tab--active').should('have.class', 'q-stepper__tab--active'); cy.get('.q-stepper__nav > .q-btn--standard').click(); diff --git a/test/cypress/integration/ticket/ticketList.spec.js b/test/cypress/integration/ticket/ticketList.spec.js index 67a1c29e2..f113494dc 100644 --- a/test/cypress/integration/ticket/ticketList.spec.js +++ b/test/cypress/integration/ticket/ticketList.spec.js @@ -26,8 +26,8 @@ describe('TicketList', () => { cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/); }); - it.only('should create payment ticket', () => { - cy.get('[data-cy="vnFilterPanel_search"] > .q-btn__content > .q-icon').click(); + it('should create payment ticket', () => { + cy.searchInFilterPanel().click(); const rowSelected = 'tbody > :nth-child(2) > :nth-child(1) > .q-checkbox > .q-checkbox__inner '; @@ -37,9 +37,8 @@ describe('TicketList', () => { ).click(); const description = 'Albaran: 31'; cy.dataCy('Reference_input').should('have.value', description); - cy.selectOption('[data-cy="paymentBank"]', 'Cash').click(); - cy.get('[data-cy="Delivered amount_input"]').clear(); - cy.get('[data-cy="Delivered amount_input"]').type('41.62'); + cy.selectOption('[data-cy="paymentBank"]', 'Cash'); + cy.dataCy('Delivered amount_input').clear().type('41.62'); cy.dataCy('Reference_input').should('have.value', `Cash, ${description}`); cy.get('[aria-label="View recipt"]').click(); cy.get('.q-btn--standard > .q-btn__content > .block').click();