From c31b4fa770e7cc19f778e82429178fd5c0239b01 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 9 Nov 2023 10:29:28 +0100 Subject: [PATCH] ref #5835 e2e & unit tests done --- cypress.config.js | 2 +- src/components/CrudModel.vue | 4 + src/css/app.scss | 2 + src/filters/toCurrency.js | 9 +-- src/i18n/es/index.js | 2 +- .../InvoiceIn/Card/InvoiceInBasicData.vue | 3 +- src/pages/InvoiceIn/Card/InvoiceInDueDay.vue | 30 +++++--- src/pages/InvoiceIn/Card/InvoiceInSummary.vue | 75 ++++++++++++++++--- src/pages/InvoiceIn/Card/InvoiceInVat.vue | 15 ++-- .../{ => claim}/claimDevelopment.spec.js | 0 .../{ => claim}/claimNotes.spec.js | 0 .../{ => claim}/claimPhoto.spec.js | 0 .../invoiceIn/invoiceInBasicData.spec.js | 53 +++++++++++++ .../invoiceIn/invoiceInDueDay.spec.js | 29 +++++++ .../invoiceIn/invoiceInIntrastat.spec.js | 38 ++++++++++ .../{ => invoiceIn}/invoiceInList.spec.js | 0 .../invoiceIn/invoiceInVat.spec.js | 55 ++++++++++++++ .../integration/invoiceInBasicData.spec.js | 24 ------ .../{ => ticket}/ticketBoxing.spec.js | 0 .../{ => wagon}/wagonCreate.spec.js | 0 .../{ => wagonType}/wagonTypeCreate.spec.js | 0 .../{ => worker}/workerList.spec.js | 0 .../workerNotificationsManager.spec.js | 0 .../{ => worker}/workerSummary.spec.js | 0 test/cypress/support/commands.js | 33 +++++++- .../InvoiceIn/InvoiceInBasicData.spec.js | 44 ++++++----- .../InvoiceIn/InvoiceInIntrastat.spec.js | 34 +++++++++ .../pages/InvoiceIn/InvoiceInVat.spec.js | 75 +++++++++++++++++++ 28 files changed, 443 insertions(+), 84 deletions(-) rename test/cypress/integration/{ => claim}/claimDevelopment.spec.js (100%) rename test/cypress/integration/{ => claim}/claimNotes.spec.js (100%) rename test/cypress/integration/{ => claim}/claimPhoto.spec.js (100%) create mode 100644 test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js create mode 100644 test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js create mode 100644 test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js rename test/cypress/integration/{ => invoiceIn}/invoiceInList.spec.js (100%) create mode 100644 test/cypress/integration/invoiceIn/invoiceInVat.spec.js delete mode 100644 test/cypress/integration/invoiceInBasicData.spec.js rename test/cypress/integration/{ => ticket}/ticketBoxing.spec.js (100%) rename test/cypress/integration/{ => wagon}/wagonCreate.spec.js (100%) rename test/cypress/integration/{ => wagonType}/wagonTypeCreate.spec.js (100%) rename test/cypress/integration/{ => worker}/workerList.spec.js (100%) rename test/cypress/integration/{ => worker}/workerNotificationsManager.spec.js (100%) rename test/cypress/integration/{ => worker}/workerSummary.spec.js (100%) create mode 100644 test/vitest/__tests__/pages/InvoiceIn/InvoiceInIntrastat.spec.js create mode 100644 test/vitest/__tests__/pages/InvoiceIn/InvoiceInVat.spec.js diff --git a/cypress.config.js b/cypress.config.js index 2b5b40d08..1934f833e 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -8,7 +8,7 @@ module.exports = defineConfig({ supportFile: 'test/cypress/support/index.js', videosFolder: 'test/cypress/videos', video: false, - specPattern: 'test/cypress/integration/*.spec.js', + specPattern: 'test/cypress/integration/**/*.spec.js', experimentalRunAllSpecs: true, component: { componentFolder: 'src', diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 2a4982fce..bd3a01304 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -135,6 +135,10 @@ async function saveChanges(data) { hasChanges.value = false; isLoading.value = false; emit('saveChanges', data); + quasar.notify({ + type: 'positive', + message: t('globals.dataSaved'), + }); } async function insert() { diff --git a/src/css/app.scss b/src/css/app.scss index 0f04c9ad8..3cc6f55c2 100644 --- a/src/css/app.scss +++ b/src/css/app.scss @@ -33,6 +33,7 @@ body.body--light { --vn-gray: #f5f5f5; --vn-label: #5f5f5f; --vn-dark: white; + --vn-light-gray: #e7e3e3; } body.body--dark { @@ -40,6 +41,7 @@ body.body--dark { --vn-gray: #313131; --vn-label: #a8a8a8; --vn-dark: #292929; + --vn-light-gray: #424242; } .bg-vn-dark { diff --git a/src/filters/toCurrency.js b/src/filters/toCurrency.js index 5005e95bc..f820c0127 100644 --- a/src/filters/toCurrency.js +++ b/src/filters/toCurrency.js @@ -9,13 +9,10 @@ export default function (value, symbol = 'EUR', fractionSize = 2) { style: 'currency', currency: symbol, minimumFractionDigits: fractionSize, - maximumFractionDigits: fractionSize + maximumFractionDigits: fractionSize, }; const lang = locale.value == 'es' ? 'de' : locale.value; - return new Intl.NumberFormat(lang, options) - .format(value); - - -} \ No newline at end of file + return new Intl.NumberFormat(lang, options).format(value); +} diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index b7dc1c132..91ac748ee 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -422,7 +422,7 @@ export default { company: 'Empresa', customerCard: 'Ficha del cliente', ticketList: 'Listado de tickets', - vat: 'Vat', + vat: 'Iva', dueDay: 'Fecha de vencimiento', }, summary: { diff --git a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue index 3419492b7..0aee913a4 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue @@ -144,7 +144,6 @@ async function create() { type: 'positive', }); } catch (error) { - console.log(error); quasar.notify({ message: t(`${error.message}`), type: 'negative', @@ -466,6 +465,8 @@ async function create() { class="full-width q-pa-xs" :label="t('Reference')" v-model="dms.reference" + clearable + clear-icon="close" /> arrayData.store.data); const rowsSelected = ref([]); const banks = ref([]); const invoiceInFormRef = ref(); +const invoiceId = route.params.id; const filter = { where: { - invoiceInFk: route.params.id, + invoiceInFk: invoiceId, }, }; -const isNotEuro = (code) => code != 'EUR'; - const columns = computed(() => [ { name: 'duedate', @@ -63,6 +63,19 @@ const columns = computed(() => [ align: 'left', }, ]); + +const isNotEuro = (code) => code != 'EUR'; +const areRows = ref(null); + +async function insert() { + if (!areRows.value) { + await axios.post('/InvoiceInDueDays/new ', { id: Number(invoiceId) }); + await invoiceInFormRef.value.reload(); + } + if (areRows.value) { + invoiceInFormRef.value.insert(); + } +} diff --git a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue index 79cdab02d..6c3f0838c 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue @@ -29,6 +29,7 @@ const entityId = computed(() => $props.id || route.params.id); const salixUrl = ref(); const invoiceInUrl = ref(); const amountsNotMatch = ref(null); +const intrastatTotals = ref({}); const vatColumns = ref([ { @@ -74,7 +75,7 @@ const vatColumns = ref([ name: 'currency', label: 'invoiceIn.summary.currency', field: (row) => row.foreignValue, - format: (value) => toCurrency(value), + format: (value) => value, sortable: true, align: 'left', }, @@ -138,7 +139,7 @@ const intrastatColumns = ref([ align: 'left', }, { - name: 'amount', + name: 'stems', label: 'invoiceIn.summary.stems', field: (row) => row.stems, format: (value) => value, @@ -155,14 +156,29 @@ const intrastatColumns = ref([ }, ]); -function setAmountNotMatch(entity) { +function getAmountNotMatch(totals) { + return ( + totals.totalDueDay != totals.totalTaxableBase && + totals.totalDueDay != totals.totalVat + ); +} + +function getIntrastatTotals(intrastat) { + const totals = {}; + totals.amount = intrastat.reduce((acc, cur) => acc + cur.amount, 0); + totals.net = intrastat.reduce((acc, cur) => acc + cur.net, 0); + totals.stems = intrastat.reduce((acc, cur) => acc + cur.stems, 0); + + return totals; +} + +function setData(entity) { if (!entity) return false; - const total = entity.totals; + amountsNotMatch.value = getAmountNotMatch(entity.totals); - amountsNotMatch.value = - total.totalDueDay != total.totalTaxableBase && - total.totalDueDay != total.totalVat; + if (entity.invoiceInIntrastat.length) + intrastatTotals.value = { ...getIntrastatTotals(entity.invoiceInIntrastat) }; } @@ -170,12 +186,13 @@ function setAmountNotMatch(entity) {