refactor: refs #8581 update invoiceInCorrective component and add Cypress tests for invoice modification
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jorge Penadés 2025-03-05 17:03:10 +01:00
parent f2a36310b2
commit 389728f41e
3 changed files with 58 additions and 8 deletions

View File

@ -1,22 +1,16 @@
<script setup>
import { ref, computed, capitalize } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useArrayData } from 'src/composables/useArrayData';
import CrudModel from 'src/components/CrudModel.vue';
import FetchData from 'src/components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
const route = useRoute();
const { t } = useI18n();
const arrayData = useArrayData();
const invoiceIn = computed(() => arrayData.store.data);
const invoiceInCorrectionRef = ref();
const filter = {
include: { relation: 'invoiceIn' },
where: { correctingFk: route.params.id },
};
const columns = computed(() => [
{
name: 'origin',
@ -92,7 +86,8 @@ const requiredFieldRule = (val) => val || t('globals.requiredField');
v-if="invoiceIn"
data-key="InvoiceInCorrection"
url="InvoiceInCorrections"
:filter="filter"
:user-filter="{ include: { relation: 'invoiceIn' } }"
:filter="{ where: { correctingFk: $route.params.id } }"
auto-load
primary-key="correctingFk"
:default-remove="false"

View File

@ -0,0 +1,55 @@
describe('invoiceInCorrective', () => {
beforeEach(() => cy.login('administrative'));
it('should modify the invoice', () => {
cy.visit('/#/invoice-in/1/summary');
cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective');
cy.intercept('POST', '/api/InvoiceInCorrections/crud').as('crud');
cy.intercept('GET', /InvoiceInCorrections\?filter=.+/).as('getCorrective');
cy.selectDescriptorOption(4);
cy.selectOption('[data-cy="invoiceInDescriptorMenu_class"]', 'R5');
cy.selectOption('[data-cy="invoiceInDescriptorMenu_type"]', 'diferencias');
cy.selectOption('[data-cy="invoiceInDescriptorMenu_reason"]', 'customer');
cy.dataCy('saveCorrectiveInvoice').click();
cy.wait('@corrective').then(({ response }) => {
const correctingFk = response.body;
cy.url().should('include', `/invoice-in/${correctingFk}/summary`);
cy.visit(`/#/invoice-in/${correctingFk}/corrective`);
cy.selectOption('[data-cy="invoiceInCorrective_class"]', 'r4');
cy.selectOption('[data-cy="invoiceInCorrective_type"]', 'sustitución');
cy.selectOption('[data-cy="invoiceInCorrective_reason"]', 'vat');
cy.dataCy('crudModelDefaultSaveBtn').click();
cy.wait('@crud');
cy.reload();
cy.wait('@getCorrective');
cy.validateRow('tbody > :nth-of-type(1)', [
,
'S Por sustitución',
'R4',
'Error in VAT calculation',
]);
});
});
it('should not be able to modify the invoice if the original invoice is booked', () => {
cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective');
cy.visit('/#/invoice-in/4/summary');
cy.selectDescriptorOption();
cy.dataCy('VnConfirm_confirm').click();
cy.selectDescriptorOption(4);
cy.dataCy('saveCorrectiveInvoice').click();
cy.wait('@corrective').then(({ response }) => {
const correctingFk = response.body;
cy.url().should('include', `/invoice-in/${correctingFk}/summary`);
cy.visit(`/#/invoice-in/${correctingFk}/corrective`);
cy.dataCy('invoiceInCorrective_class').should('be.disabled');
cy.dataCy('invoiceInCorrective_type').should('be.disabled');
cy.dataCy('invoiceInCorrective_reason').should('be.disabled');
});
});
});

View File

@ -40,7 +40,7 @@ describe('InvoiceInDescriptor', () => {
cy.visit('/#/invoice-in/6/summary');
cy.selectDescriptorOption(5);
cy.get('input[data-cy="sendEmailDialog_address"]').type(
cy.get('input[data-cy="sendEmailDialog_address_input"]').type(
'{selectall}jorgito@gmail.mx',
);
cy.clickConfirm();