rounding
This commit is contained in:
@@ -430,9 +430,16 @@ async function getTaxSummary({ startDate, endDate, accountingMethod = 'Accrual'
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nontaxableSales = totalSales - totalTaxable;
|
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 rows = Object.entries(agg).map(([rateId, amounts]) => {
|
||||||
const info = rateMap[rateId] || { name: `Tax Rate ${rateId}`, rateValue: 0 };
|
const info = rateMap[rateId] || { name: `Tax Rate ${rateId}`, rateValue: 0 };
|
||||||
const ratePct = info.rateValue.toFixed(3).replace(/0+$/, '').replace(/\.$/, '');
|
const ratePct = info.rateValue.toFixed(3).replace(/0+$/, '').replace(/\.$/, '');
|
||||||
|
const roundTaxable = Math.round(amounts.taxableSales);
|
||||||
|
const roundNontaxableJurisdiction = roundTotalSales - roundTaxable;
|
||||||
return {
|
return {
|
||||||
type: 'Section',
|
type: 'Section',
|
||||||
Header: {
|
Header: {
|
||||||
@@ -448,9 +455,9 @@ async function getTaxSummary({ startDate, endDate, accountingMethod = 'Accrual'
|
|||||||
Summary: {
|
Summary: {
|
||||||
ColData: [
|
ColData: [
|
||||||
{ value: 'Total' },
|
{ value: 'Total' },
|
||||||
{ value: totalSales.toFixed(2) },
|
{ value: String(roundTotalSales) },
|
||||||
{ value: nontaxableSales.toFixed(2) },
|
{ value: String(roundNontaxableJurisdiction) },
|
||||||
{ value: amounts.taxableSales.toFixed(2) },
|
{ value: String(roundTaxable) },
|
||||||
{ value: amounts.taxCollected.toFixed(2) },
|
{ value: amounts.taxCollected.toFixed(2) },
|
||||||
{ value: `${ratePct}%` }
|
{ value: `${ratePct}%` }
|
||||||
]
|
]
|
||||||
@@ -478,9 +485,9 @@ async function getTaxSummary({ startDate, endDate, accountingMethod = 'Accrual'
|
|||||||
Summary: {
|
Summary: {
|
||||||
ColData: [
|
ColData: [
|
||||||
{ value: 'Total' },
|
{ value: 'Total' },
|
||||||
{ value: totalSales.toFixed(2) },
|
{ value: String(roundTotalSales) },
|
||||||
{ value: nontaxableSales.toFixed(2) },
|
{ value: String(roundNontaxable) },
|
||||||
{ value: totalTaxable.toFixed(2) },
|
{ value: String(roundTotalTaxable) },
|
||||||
{ value: grandTaxCollected.toFixed(2) },
|
{ value: grandTaxCollected.toFixed(2) },
|
||||||
{ value: '' }
|
{ value: '' }
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user