rounding
This commit is contained in:
@@ -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: '' }
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user