From df3bbfe5e4f2937b095e80fa065d0046d9eb0ac7 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Tue, 11 Mar 2025 13:41:52 +0100
Subject: [PATCH 1/9] fix: refs #8388 update file attachment logic and redirect
 after invoice creation

---
 src/components/common/VnDms.vue       | 4 +++-
 src/pages/InvoiceIn/InvoiceInList.vue | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/components/common/VnDms.vue b/src/components/common/VnDms.vue
index 35308c2c4..03f85f855 100644
--- a/src/components/common/VnDms.vue
+++ b/src/components/common/VnDms.vue
@@ -46,9 +46,11 @@ const dms = ref({});
 
 onMounted(() => {
     defaultData();
-    if (!$props.formInitialData)
+    if (!$props.formInitialData) {
         dms.value.description =
             $props.description ?? t($props.model + 'Description', dms.value);
+        dms.value.hasFile = false;
+    }
 });
 function onFileChange(files) {
     dms.value.hasFileAttached = !!files;
diff --git a/src/pages/InvoiceIn/InvoiceInList.vue b/src/pages/InvoiceIn/InvoiceInList.vue
index 0960d0d6c..8dbee6501 100644
--- a/src/pages/InvoiceIn/InvoiceInList.vue
+++ b/src/pages/InvoiceIn/InvoiceInList.vue
@@ -156,7 +156,7 @@ const cols = computed(() => [
                 :create="{
                     urlCreate: 'InvoiceIns',
                     title: t('globals.createInvoiceIn'),
-                    onDataSaved: ({ id }) => tableRef.redirect(id),
+                    onDataSaved: ({ id }) => tableRef.redirect(`${id}/basic-data`),
                     formInitialData: { companyFk: user.companyFk, issued: Date.vnNew() },
                 }"
                 redirect="invoice-in"

From 01d1ca83ea12fcb02fd00496438694ee1fcb5d61 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Mon, 17 Mar 2025 13:25:40 +0100
Subject: [PATCH 2/9] fix: refs #8388 improve error handling and notification
 for invoice booking

---
 src/pages/InvoiceIn/InvoiceInToBook.vue | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/pages/InvoiceIn/InvoiceInToBook.vue b/src/pages/InvoiceIn/InvoiceInToBook.vue
index 5bdbe197b..7bb465d70 100644
--- a/src/pages/InvoiceIn/InvoiceInToBook.vue
+++ b/src/pages/InvoiceIn/InvoiceInToBook.vue
@@ -56,22 +56,21 @@ async function checkToBook(id) {
             componentProps: {
                 title: t('Are you sure you want to book this invoice?'),
                 message: messages.reduce((acc, msg) => `${acc}<p>${msg}</p>`, ''),
+                promise: () => toBook(id),
             },
-        }).onOk(() => toBook(id));
+        });
 }
 
 async function toBook(id) {
-    let type = 'positive';
-    let message = t('globals.dataSaved');
-
+    let err;
     try {
         await axios.post(`InvoiceIns/${id}/toBook`);
         store.data.isBooked = true;
     } catch (e) {
-        type = 'negative';
-        message = t('It was not able to book the invoice');
+        err = true;
+        throw e;
     } finally {
-        notify({ type, message });
+        if (!err) notify({ type: 'positive', message: t('globals.dataSaved') });
     }
 }
 </script>

From 6546d06f60d62356e86c50d9386a30756b49bab2 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Tue, 18 Mar 2025 12:04:54 +0100
Subject: [PATCH 3/9] refactor: refs #8388 update UI feedback

---
 src/pages/InvoiceIn/Card/InvoiceInDueDay.vue | 36 +++++++++++++++-----
 src/pages/InvoiceIn/locale/en.yml            |  1 +
 src/pages/InvoiceIn/locale/es.yml            |  2 ++
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/pages/InvoiceIn/Card/InvoiceInDueDay.vue b/src/pages/InvoiceIn/Card/InvoiceInDueDay.vue
index 20cc1cc71..59bebcae2 100644
--- a/src/pages/InvoiceIn/Card/InvoiceInDueDay.vue
+++ b/src/pages/InvoiceIn/Card/InvoiceInDueDay.vue
@@ -25,7 +25,8 @@ const invoiceInFormRef = ref();
 const invoiceId = +route.params.id;
 const filter = { where: { invoiceInFk: invoiceId } };
 const areRows = ref(false);
-const totals = ref();
+const totalTaxableBase = ref();
+const noMatch = computed(() => totalAmount.value != totalTaxableBase.value);
 const columns = computed(() => [
     {
         name: 'duedate',
@@ -74,9 +75,12 @@ async function insert() {
     notify(t('globals.dataSaved'), 'positive');
 }
 
-onBeforeMount(async () => {
-    totals.value = (await axios.get(`InvoiceIns/${invoiceId}/getTotals`)).data;
-});
+async function setTaxableBase() {
+    const { data } = await axios.get(`InvoiceIns/${invoiceId}/getTotals`);
+    totalTaxableBase.value = data.totalTaxableBase;
+}
+
+onBeforeMount(async () => await setTaxableBase());
 </script>
 <template>
     <CrudModel
@@ -89,13 +93,14 @@ onBeforeMount(async () => {
         :data-required="{ invoiceInFk: invoiceId }"
         v-model:selected="rowsSelected"
         @on-fetch="(data) => (areRows = !!data.length)"
+        @save-changes="setTaxableBase"
     >
         <template #body="{ rows }">
             <QTable
                 v-model:selected="rowsSelected"
                 selection="multiple"
-                :columns="columns"
-                :rows="rows"
+                :columns
+                :rows
                 row-key="$index"
                 :grid="$q.screen.lt.sm"
             >
@@ -151,7 +156,18 @@ onBeforeMount(async () => {
                         <QTd />
                         <QTd />
                         <QTd>
-                            {{ toCurrency(totalAmount) }}
+                            <QChip
+                                dense
+                                :color="noMatch ? 'negative' : 'transparent'"
+                                class="q-pa-xs"
+                                :title="
+                                    noMatch
+                                        ? t('invoiceIn.noMatch', { totalTaxableBase })
+                                        : ''
+                                "
+                            >
+                                {{ toCurrency(totalAmount) }}
+                            </QChip>
                         </QTd>
                         <QTd>
                             <template v-if="isNotEuro(invoiceIn.currency.code)">
@@ -237,7 +253,7 @@ onBeforeMount(async () => {
                     if (!areRows) insert();
                     else
                         invoiceInFormRef.insert({
-                            amount: (totals.totalTaxableBase - totalAmount).toFixed(2),
+                            amount: (totalTaxableBase - totalAmount).toFixed(2),
                             invoiceInFk: invoiceId,
                         });
                 }
@@ -249,6 +265,10 @@ onBeforeMount(async () => {
 .bg {
     background-color: var(--vn-light-gray);
 }
+
+.q-chip {
+    color: var(--vn-text-color);
+}
 </style>
 <i18n>
     es:
diff --git a/src/pages/InvoiceIn/locale/en.yml b/src/pages/InvoiceIn/locale/en.yml
index 548e6c201..085f351b2 100644
--- a/src/pages/InvoiceIn/locale/en.yml
+++ b/src/pages/InvoiceIn/locale/en.yml
@@ -68,3 +68,4 @@ invoiceIn:
         isBooked: Is booked
         account: Ledger account
         correctingFk: Rectificative
+    noMatch: No match with the vat({totalTaxableBase})
diff --git a/src/pages/InvoiceIn/locale/es.yml b/src/pages/InvoiceIn/locale/es.yml
index 142d95f92..516da1149 100644
--- a/src/pages/InvoiceIn/locale/es.yml
+++ b/src/pages/InvoiceIn/locale/es.yml
@@ -60,9 +60,11 @@ invoiceIn:
         net: Neto
         stems: Tallos
         country: País
+        noMatch: No cuadra
     params:
         search: Id o nombre proveedor
         correctedFk: Rectificada
         isBooked: Contabilizada
         account: Cuenta contable
         correctingFk: Rectificativa
+    noMatch: No cuadra con el iva({totalTaxableBase})

From 517dc49cefc8604ebbb111c72e3d398aa4761f38 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Fri, 21 Mar 2025 15:41:40 +0100
Subject: [PATCH 4/9] fix: refs #8388 update translation for invoice summary
 mismatch message

---
 src/pages/InvoiceIn/Card/InvoiceInSummary.vue | 5 ++++-
 src/pages/InvoiceIn/locale/en.yml             | 1 -
 src/pages/InvoiceIn/locale/es.yml             | 1 -
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue
index f6beecd3d..5af6a94f7 100644
--- a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue
+++ b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue
@@ -305,7 +305,10 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
                                 :color="amountsNotMatch ? 'negative' : 'transparent'"
                                 :title="
                                     amountsNotMatch
-                                        ? t('invoiceIn.summary.noMatch')
+                                        ? t('invoiceIn.noMatch', {
+                                              totalTaxableBase:
+                                                  entity.totals.totalTaxableBase,
+                                          })
                                         : t('invoiceIn.summary.dueTotal')
                                 "
                             >
diff --git a/src/pages/InvoiceIn/locale/en.yml b/src/pages/InvoiceIn/locale/en.yml
index 085f351b2..2f9435b00 100644
--- a/src/pages/InvoiceIn/locale/en.yml
+++ b/src/pages/InvoiceIn/locale/en.yml
@@ -57,7 +57,6 @@ invoiceIn:
         bank: Bank
         foreignValue: Foreign value
         dueTotal: Due day
-        noMatch: Do not match
         code: Code
         net: Net
         stems: Stems
diff --git a/src/pages/InvoiceIn/locale/es.yml b/src/pages/InvoiceIn/locale/es.yml
index 516da1149..9144d6ab1 100644
--- a/src/pages/InvoiceIn/locale/es.yml
+++ b/src/pages/InvoiceIn/locale/es.yml
@@ -60,7 +60,6 @@ invoiceIn:
         net: Neto
         stems: Tallos
         country: País
-        noMatch: No cuadra
     params:
         search: Id o nombre proveedor
         correctedFk: Rectificada

From 028477ecbeb760559f8999aa9f77bdab6f52d01c Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Mon, 24 Mar 2025 11:12:15 +0100
Subject: [PATCH 5/9] feat: refs #8388 add hasFile prop to VnDms component

---
 src/components/common/VnDms.vue | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/components/common/VnDms.vue b/src/components/common/VnDms.vue
index e667e1558..8f5cc73c4 100644
--- a/src/components/common/VnDms.vue
+++ b/src/components/common/VnDms.vue
@@ -35,6 +35,10 @@ const $props = defineProps({
         type: String,
         default: null,
     },
+    hasFile: {
+        type: Boolean,
+        default: false,
+    },
 });
 
 const warehouses = ref();
@@ -49,7 +53,7 @@ onMounted(() => {
     if (!$props.formInitialData) {
         dms.value.description =
             $props.description ?? t($props.model + 'Description', dms.value);
-        dms.value.hasFile = false;
+        dms.value.hasFile = $props.hasFile;
     }
 });
 function onFileChange(files) {

From 2fabff05be50ab957997e7cd371dc4a5e1e9efb3 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Mon, 24 Mar 2025 11:15:59 +0100
Subject: [PATCH 6/9] feat: refs #8388 add hasFile property handling in VnDms
 component

---
 src/components/common/VnDms.vue | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/components/common/VnDms.vue b/src/components/common/VnDms.vue
index 8f5cc73c4..de22e4857 100644
--- a/src/components/common/VnDms.vue
+++ b/src/components/common/VnDms.vue
@@ -50,11 +50,9 @@ const dms = ref({});
 
 onMounted(() => {
     defaultData();
-    if (!$props.formInitialData) {
+    if (!$props.formInitialData)
         dms.value.description =
             $props.description ?? t($props.model + 'Description', dms.value);
-        dms.value.hasFile = $props.hasFile;
-    }
 });
 function onFileChange(files) {
     dms.value.hasFileAttached = !!files;
@@ -96,6 +94,7 @@ function defaultData() {
     if ($props.formInitialData) return (dms.value = $props.formInitialData);
     return addDefaultData({
         reference: route.params.id,
+        hasFile: $props.hasFile,
     });
 }
 

From 65d21c9fe5f6000c9084e449f1a2280e588a4cda Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Mon, 24 Mar 2025 16:15:17 +0100
Subject: [PATCH 7/9] test: refs #8388 update invoice creation test to include
 spinner wait and company field validation

---
 .../integration/invoiceIn/invoiceInList.spec.js        | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/cypress/integration/invoiceIn/invoiceInList.spec.js b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
index 44a61609e..3338684d6 100644
--- a/test/cypress/integration/invoiceIn/invoiceInList.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
@@ -36,17 +36,17 @@ describe('InvoiceInList', () => {
         cy.get(summaryHeaders).eq(4).contains('Vat');
     });
 
-    it('should create a new Invoice', () => {
+    it.only('should create a new Invoice', () => {
         cy.dataCy('vnTableCreateBtn').click();
         cy.fillInForm({ ...mock }, { attr: 'data-cy' });
         cy.dataCy('FormModelPopup_save').click();
         cy.intercept('GET', /\/api\/InvoiceIns\/\d+\/getTotals$/).as('invoice');
-        cy.wait('@invoice').then(() =>
+        cy.wait('@invoice').then(() => {
             cy.validateDescriptor({
                 title: mockInvoiceRef,
                 listBox: { 0: '11/16/2001', 3: 'The farmer' },
-            }),
-        );
-        cy.get('[data-cy="vnLvCompany"]').should('contain.text', 'ORN');
+            });
+            cy.dataCy('invoiceInBasicDataCompanyFk').should('have.value', 'ORN');
+        });
     });
 });

From 0361958b47c47ef94819d0fec2ca67b99a5cc103 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Tue, 25 Mar 2025 09:37:46 +0100
Subject: [PATCH 8/9] test: refs #8388 remove exclusive focus from Invoice
 creation test

---
 test/cypress/integration/invoiceIn/invoiceInList.spec.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/cypress/integration/invoiceIn/invoiceInList.spec.js b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
index 3338684d6..d0d87d9f0 100644
--- a/test/cypress/integration/invoiceIn/invoiceInList.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
@@ -36,7 +36,7 @@ describe('InvoiceInList', () => {
         cy.get(summaryHeaders).eq(4).contains('Vat');
     });
 
-    it.only('should create a new Invoice', () => {
+    it('should create a new Invoice', () => {
         cy.dataCy('vnTableCreateBtn').click();
         cy.fillInForm({ ...mock }, { attr: 'data-cy' });
         cy.dataCy('FormModelPopup_save').click();

From 73c6b7dea9ee720d44411424be758ec95c42012b Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Tue, 25 Mar 2025 17:34:10 +0100
Subject: [PATCH 9/9] fix: refs #8388 update tooltip message in
 InvoiceInSummary to include total taxable base

---
 src/pages/InvoiceIn/Card/InvoiceInSummary.vue | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue
index dad1da8d6..74936f00a 100644
--- a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue
+++ b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue
@@ -304,7 +304,10 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
                                     :color="amountsNotMatch ? 'negative' : 'transparent'"
                                     :title="
                                         amountsNotMatch
-                                            ? t('invoiceIn.summary.noMatch')
+                                            ? t('invoiceIn.noMatch', {
+                                                  totalTaxableBase:
+                                                      entity.totals.totalTaxableBase,
+                                              })
                                             : t('invoiceIn.summary.dueTotal')
                                     "
                                 >