IO-2820 State Tax & Adjustment to Bottom Line

Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
Allan Carr
2024-06-17 10:13:36 -07:00
parent 7959dc67ce
commit 8386443cb0

View File

@@ -747,7 +747,9 @@ function CalculateTaxesTotals(job, otherTotals) {
MAPA: Dinero(),
MASH: Dinero(),
TOW: Dinero(),
STOR: Dinero()
STOR: Dinero(),
ADJ: Dinero()
};
//For each line, determine if it's taxable, and if it is, add the line amount to the taxable amounts total.
@@ -816,6 +818,8 @@ function CalculateTaxesTotals(job, otherTotals) {
amount: Math.round(stlStorage.t_amt * 100)
});
if (job.adjustment_bottom_line) taxableAmounts.ADJ = Dinero({ amount: Math.round(job.adjustment_bottom_line * 100) });
const pfp = job.parts_tax_rates;
//For any profile level markups/discounts, add them in now as well.
@@ -903,12 +907,26 @@ function CalculateTaxesTotals(job, otherTotals) {
);
}
}
} else if (key === "ADJ") {
for (let tyCounter = 1; tyCounter <= 5; tyCounter++) {
if (IsTrueOrYes(pfp.PAT ? pfp.PAT[`prt_tx_in${tyCounter}`] : pfp.PAN[`prt_tx_in${tyCounter}`])) {
//This amount is taxable for this type.
taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add(
taxableAmounts[key]
);
}
}
}
} catch (error) {
console.error("Key with issue", key);
}
});
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
if (taxableAmountsByTier[taxTierKey].lessThan(Dinero({ amount: 0 }))) {
taxableAmountsByTier[taxTierKey] = Dinero({ amount: 0 });
}
});
const remainingTaxableAmounts = taxableAmountsByTier;
console.log("*** Taxable Amounts by Tier***");
console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));