From d3a06198ad6d7fb04384cd5dafff48130198cdac Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Wed, 10 Jun 2026 17:41:08 -0500 Subject: [PATCH] rounding --- src/services/accounting-service.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/services/accounting-service.js b/src/services/accounting-service.js index dec635f..2f9333a 100644 --- a/src/services/accounting-service.js +++ b/src/services/accounting-service.js @@ -430,9 +430,16 @@ async function getTaxSummary({ startDate, endDate, accountingMethod = 'Accrual' } const nontaxableSales = totalSales - totalTaxable; + + const roundTotalSales = Math.round(totalSales); + const roundTotalTaxable = Math.round(totalTaxable); + const roundNontaxable = roundTotalSales - roundTotalTaxable; // derived, prevents drift + const rows = Object.entries(agg).map(([rateId, amounts]) => { const info = rateMap[rateId] || { name: `Tax Rate ${rateId}`, rateValue: 0 }; const ratePct = info.rateValue.toFixed(3).replace(/0+$/, '').replace(/\.$/, ''); + const roundTaxable = Math.round(amounts.taxableSales); + const roundNontaxableJurisdiction = roundTotalSales - roundTaxable; return { type: 'Section', Header: { @@ -448,9 +455,9 @@ async function getTaxSummary({ startDate, endDate, accountingMethod = 'Accrual' Summary: { ColData: [ { value: 'Total' }, - { value: totalSales.toFixed(2) }, - { value: nontaxableSales.toFixed(2) }, - { value: amounts.taxableSales.toFixed(2) }, + { value: String(roundTotalSales) }, + { value: String(roundNontaxableJurisdiction) }, + { value: String(roundTaxable) }, { value: amounts.taxCollected.toFixed(2) }, { value: `${ratePct}%` } ] @@ -478,9 +485,9 @@ async function getTaxSummary({ startDate, endDate, accountingMethod = 'Accrual' Summary: { ColData: [ { value: 'Total' }, - { value: totalSales.toFixed(2) }, - { value: nontaxableSales.toFixed(2) }, - { value: totalTaxable.toFixed(2) }, + { value: String(roundTotalSales) }, + { value: String(roundNontaxable) }, + { value: String(roundTotalTaxable) }, { value: grandTaxCollected.toFixed(2) }, { value: '' } ]