Merged in release/2024-06-21 (pull request #1497)
IO-2820 Adjustment to Bottom Line
This commit is contained in:
@@ -747,9 +747,7 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
MAPA: Dinero(),
|
MAPA: Dinero(),
|
||||||
MASH: Dinero(),
|
MASH: Dinero(),
|
||||||
TOW: 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.
|
//For each line, determine if it's taxable, and if it is, add the line amount to the taxable amounts total.
|
||||||
@@ -818,8 +816,6 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
amount: Math.round(stlStorage.t_amt * 100)
|
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;
|
const pfp = job.parts_tax_rates;
|
||||||
|
|
||||||
//For any profile level markups/discounts, add them in now as well.
|
//For any profile level markups/discounts, add them in now as well.
|
||||||
@@ -907,26 +903,31 @@ 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) {
|
} catch (error) {
|
||||||
console.error("Key with issue", key);
|
console.error("Key with issue", key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
|
if (job.adjustment_bottom_line) {
|
||||||
if (taxableAmountsByTier[taxTierKey].lessThan(Dinero({ amount: 0 }))) {
|
const subtotal_before_adjustment = subtotal.add(Dinero({ amount: Math.round(job.adjustment_bottom_line * -100) }));
|
||||||
taxableAmountsByTier[taxTierKey] = Dinero({ amount: 0 });
|
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);
|
||||||
|
console.log("🚀 ~ taxableAmountsByTier ~ taxable_adjustment:", taxable_adjustment)
|
||||||
|
if (job.adjustment_bottom_line > 0) {
|
||||||
|
taxableAmountsByTier[taxTierKey] = taxableAmountsByTier[taxTierKey].add(taxable_adjustment);
|
||||||
|
} else {
|
||||||
|
taxableAmountsByTier[taxTierKey] = taxableAmountsByTier[taxTierKey].subtract(taxable_adjustment);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const remainingTaxableAmounts = taxableAmountsByTier;
|
const remainingTaxableAmounts = taxableAmountsByTier;
|
||||||
console.log("*** Taxable Amounts by Tier***");
|
console.log("*** Taxable Amounts by Tier***");
|
||||||
console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
|
||||||
|
|||||||
Reference in New Issue
Block a user