diff --git a/server/job/job-totals-USA.js b/server/job/job-totals-USA.js index 3dabed316..ca9a74bca 100644 --- a/server/job/job-totals-USA.js +++ b/server/job/job-totals-USA.js @@ -965,22 +965,17 @@ function CalculateTaxesTotals(job, otherTotals) { } }); - if (job.adjustment_bottom_line) { - const subtotal_before_adjustment = subtotal.add(Dinero({ amount: Math.round(job.adjustment_bottom_line * -100) })); - const percent_of_adjustment = - Math.round( - subtotal_before_adjustment.toUnit() / - (job.adjustment_bottom_line > 0 ? job.adjustment_bottom_line : job.adjustment_bottom_line * -1) - ) / 100; - - Object.keys(taxableAmountsByTier).forEach((taxTierKey) => { - taxable_adjustment = taxableAmountsByTier[taxTierKey].multiply(percent_of_adjustment); - if (job.adjustment_bottom_line > 0) { - taxableAmountsByTier[taxTierKey] = taxableAmountsByTier[taxTierKey].add(taxable_adjustment); - } else { - taxableAmountsByTier[taxTierKey] = taxableAmountsByTier[taxTierKey].subtract(taxable_adjustment); + if (job.adjustment_bottom_line && job.adjustment_bottom_line !== 0) { + for (let tyCounter = 1; tyCounter <= 5; tyCounter++) { + if (IsTrueOrYes(pfp["PAN"][`prt_tx_in${tyCounter}`])) { + //This amount is taxable for this type. + taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add( + Dinero({ + amount: Math.round(job.adjustment_bottom_line * 100) + }) + ); } - }); + } } const remainingTaxableAmounts = taxableAmountsByTier;