From 45f347ebefe20520a6cc372220907b8a81604e6d Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Mon, 6 Apr 2026 22:56:31 +0200 Subject: [PATCH] Fix global tax recalculation and fractional cent totals Global percentage taxes are now recalculated when items or discount change, preventing stale tax amounts. Math.round() applied to sub_total, total, and tax in invoice/estimate submit payloads to ensure the backend always receives whole-cent integers. --- .../estimates/views/EstimateCreateView.vue | 6 +-- .../invoices/views/InvoiceCreateView.vue | 12 +++--- .../shared/document-form/DocumentTotals.vue | 41 ++++++++++++++++++- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/resources/scripts-v2/features/company/estimates/views/EstimateCreateView.vue b/resources/scripts-v2/features/company/estimates/views/EstimateCreateView.vue index ad5ddd91..d32a43de 100644 --- a/resources/scripts-v2/features/company/estimates/views/EstimateCreateView.vue +++ b/resources/scripts-v2/features/company/estimates/views/EstimateCreateView.vue @@ -202,9 +202,9 @@ async function submitForm(): Promise { const data: Record = { ...cloneDeep(estimateStore.newEstimate), - sub_total: estimateStore.getSubTotal, - total: estimateStore.getTotal, - tax: estimateStore.getTotalTax, + sub_total: Math.round(estimateStore.getSubTotal), + total: Math.round(estimateStore.getTotal), + tax: Math.round(estimateStore.getTotalTax), } const items = data.items as Array> diff --git a/resources/scripts-v2/features/company/invoices/views/InvoiceCreateView.vue b/resources/scripts-v2/features/company/invoices/views/InvoiceCreateView.vue index 19cd2080..7607de70 100644 --- a/resources/scripts-v2/features/company/invoices/views/InvoiceCreateView.vue +++ b/resources/scripts-v2/features/company/invoices/views/InvoiceCreateView.vue @@ -309,9 +309,9 @@ async function submitForm(): Promise { customFields: invoiceData.customFields, // Calculated totals - sub_total: invoiceStore.getSubTotal, - total: invoiceStore.getTotal, - tax: invoiceStore.getTotalTax, + sub_total: Math.round(invoiceStore.getSubTotal), + total: Math.round(invoiceStore.getTotal), + tax: Math.round(invoiceStore.getTotalTax), } let response @@ -325,9 +325,9 @@ async function submitForm(): Promise { } else { const data: Record = { ...cloneDeep(invoiceStore.newInvoice), - sub_total: invoiceStore.getSubTotal, - total: invoiceStore.getTotal, - tax: invoiceStore.getTotalTax, + sub_total: Math.round(invoiceStore.getSubTotal), + total: Math.round(invoiceStore.getTotal), + tax: Math.round(invoiceStore.getTotalTax), } const items = data.items as Array> diff --git a/resources/scripts-v2/features/shared/document-form/DocumentTotals.vue b/resources/scripts-v2/features/shared/document-form/DocumentTotals.vue index 67a942c2..8bac81c9 100644 --- a/resources/scripts-v2/features/shared/document-form/DocumentTotals.vue +++ b/resources/scripts-v2/features/shared/document-form/DocumentTotals.vue @@ -192,6 +192,9 @@ :store-prop="storeProp" :store="store" :type="taxPopupType" + :tax-types="availableTaxTypes" + :company-currency="companyCurrency" + :can-create-tax-type="canCreateTaxType" @select:tax-type="onSelectTax" /> @@ -228,10 +231,13 @@