From 2304e0bf02b85afdad5d0473f0f90fa0a8aa7aae Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 19 Nov 2024 10:59:59 -0800 Subject: [PATCH] IO-3001 Resolve towing totals issue. --- server/job/job-totals-USA.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/server/job/job-totals-USA.js b/server/job/job-totals-USA.js index de1db5802..2ebf5910f 100644 --- a/server/job/job-totals-USA.js +++ b/server/job/job-totals-USA.js @@ -881,17 +881,21 @@ function CalculateTaxesTotals(job, otherTotals) { } }); //Add towing and storage taxable amounts - const stlTowing = job.cieca_stl?.data.find((c) => c.ttl_typecd === "OTTW"); - const stlStorage = job.cieca_stl?.data.find((c) => c.ttl_typecd === "OTST"); + const stlTowing = job.cieca_stl?.data.find((c) => c.ttl_typecd === "OTTW" || c.ttl_type === "OTTW"); + const stlStorage = job.cieca_stl?.data.find((c) => c.ttl_typecd === "OTST" || c.ttl_type === "OTST"); if (stlTowing) - taxableAmounts.TOW = Dinero({ - amount: Math.round(stlTowing.t_amt * 100) - }); + taxableAmounts.TOW = taxableAmounts.TOW.add( + Dinero({ + amount: Math.round(stlTowing.t_amt * 100) + }) + ); if (stlStorage) - taxableAmounts.TOW = Dinero({ - amount: Math.round(stlStorage.t_amt * 100) - }); + taxableAmounts.TOW = taxableAmounts.TOW.add( + (taxableAmounts.TOW = Dinero({ + amount: Math.round(stlStorage.t_amt * 100) + })) + ); const pfp = job.parts_tax_rates; @@ -903,8 +907,8 @@ function CalculateTaxesTotals(job, otherTotals) { } }); - // console.log("*** Taxable Amounts***"); - // console.table(JSON.parse(JSON.stringify(taxableAmounts))); + console.log("*** Taxable Amounts***"); + console.table(JSON.parse(JSON.stringify(taxableAmounts))); //For the taxable amounts, figure out which tax type applies. //Then sum up the total of that tax type and then calculate the thresholds. @@ -1018,8 +1022,8 @@ function CalculateTaxesTotals(job, otherTotals) { } const remainingTaxableAmounts = taxableAmountsByTier; - // console.log("*** Taxable Amounts by Tier***"); - // console.table(JSON.parse(JSON.stringify(taxableAmountsByTier))); + console.log("*** Taxable Amounts by Tier***"); + console.table(JSON.parse(JSON.stringify(taxableAmountsByTier))); Object.keys(taxableAmountsByTier).forEach((taxTierKey) => { try {