feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration / RRScratch2 / Math Adjustments / DMS State cleaning on Page load

This commit is contained in:
Dave
2025-11-25 14:58:53 -05:00
parent 2b1836d450
commit ec29a22984
4 changed files with 103 additions and 5 deletions

View File

@@ -584,19 +584,22 @@ function applyRomeProfileAdjustments({
}
});
// Labor / materials adjustments
// Labor / materials adjustments (match CDK semantics: check `adjustment`, add `adjustments`)
Object.keys(rateMap).forEach((key) => {
const rate = rateMap[key];
if (!rate || !rate.adjustment) return;
const adjMoney = Dinero(rate.adjustment);
if (adjMoney.isZero()) return;
const checkMoney = Dinero(rate.adjustment);
if (checkMoney.isZero()) return;
const accountName = selectedDmsAllocationConfig.profits[key.toUpperCase()];
const otherAccount = bodyshop.md_responsibility_centers.profits.find((c) => c.name === accountName);
if (otherAccount) {
const bucket = ensureCenterBucket(profitCenterHash, accountName);
// Note: we intentionally use `rate.adjustments` here to mirror CDK behaviour
const adjMoney = Dinero(rate.adjustments);
bucket.extrasSale = bucket.extrasSale.add(adjMoney);
debugLog("Added rate adjustment", {