diff --git a/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue b/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue index 9f39e6e0e..3e4d7d615 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue @@ -72,7 +72,7 @@ const columns = computed(() => [ ]); const getTotal = (data, key) => - data.reduce((acc, cur) => acc + +String(cur[key]).replace(',', '.'), 0); + data.reduce((acc, cur) => acc + +String(cur[key] || 0).replace(',', '.'), 0); const formatOpt = (row, { model, options }, prop) => { const obj = row[model]; diff --git a/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js b/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js index 7863d6bfa..6a8c847b9 100644 --- a/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js @@ -8,12 +8,17 @@ describe('InvoiceInCorrective', () => { it('should create a correcting invoice', () => { cy.viewport(1280, 720); cy.login('developer'); - cy.visit(`/#/invoice-in/1/summary?limit=10`); + cy.visit(`/#/invoice-in/1/summary`); + cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective'); cy.openActionsDescriptor(); cy.get(createRectificative).click(); cy.get(saveDialog).click(); + cy.wait('@corrective').then((interception) => { + const correctingId = interception.response.body; + cy.url().should('include', `/invoice-in/${correctingId}/summary`); + }); cy.get(rectificativeSection).click(); cy.get('tbody > tr:visible').should('have.length', 1); }); diff --git a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js index c87fd4315..a297a60f4 100644 --- a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js @@ -11,25 +11,29 @@ describe('InvoiceInIntrastat', () => { it('should edit the first line', () => { cy.selectOption(firstLineCode, 'Plantas vivas: Esqueje/injerto, Vid'); - cy.get(inputBtns).eq(1).click(); - cy.saveCard(); - cy.visit(`/#/invoice-in/1/intrastat`); - - cy.getValue(firstLineCode).should('equal', 'Plantas vivas: Esqueje/injerto, Vid'); + cy.get(`${firstLineCode} span`).should( + 'have.text', + '6021010:Plantas vivas: Esqueje/injerto, Vid' + ); }); it('should add a new row', () => { - const rowData = [false, 'Plantas vivas: Esqueje/injerto, Vid', 30, 10, 5, 'FR']; - cy.addRow(); - cy.fillRow(thirdRow, rowData); + cy.fillRow(thirdRow, [ + false, + 'Plantas vivas: Esqueje/injerto, Vid', + 30, + 10, + 5, + 'FR', + ]); cy.saveCard(); cy.get('.q-notification__message').should('have.text', 'Data saved'); }); it('should remove the first line', () => { - cy.removeRow(2); + cy.removeRow(1); }); }); diff --git a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js index 63e99eac1..932aca96d 100644 --- a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js @@ -16,9 +16,7 @@ describe('InvoiceInVat', () => { it('should edit the sage iva', () => { cy.selectOption(firstLineVat, 'H.P. IVA 21% CEE'); cy.saveCard(); - cy.visit(`/#/invoice-in/1/vat`); - - cy.getValue(firstLineVat).should('equal', '8'); + cy.get(`${firstLineVat} span`).should('have.text', '8:H.P. IVA 21% CEE'); }); it('should add a new row', () => { diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 38a23f71c..fbb07daf6 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -191,11 +191,14 @@ Cypress.Commands.add('validateRow', (rowSelector, expectedValues) => { }); Cypress.Commands.add('removeRow', (rowIndex) => { + const trEls = 'tbody > tr:visible'; let rowsBefore; - cy.get('tbody > tr:visible') + cy.get('tbody > tr') .its('length') .then((length) => { - cy.get('.q-checkbox').eq(rowIndex).click(); + cy.get(`${trEls} .q-checkbox`) + .eq(rowIndex - 1) + .click(); cy.removeCard(); cy.get('.q-dialog button').eq(2).click(); rowsBefore = length; @@ -204,7 +207,7 @@ Cypress.Commands.add('removeRow', (rowIndex) => { // Check the existence of tbody before performing the second assertion. cy.get('tbody').then(($tbody) => { if ($tbody.length > 0) - cy.get('tbody > tr:visible').should('have.length', rowsBefore - 1); + cy.get('tbody > tr').should('have.length', rowsBefore - 1); }); }); });