IO-1317
This commit is contained in:
@@ -157,7 +157,28 @@ function CalculateRatesTotals(ratesList) {
|
||||
},
|
||||
};
|
||||
|
||||
//Determine if there are MAPA and MASH lines already on the estimate.
|
||||
//If there are, don't do anything extra (mitchell estimate)
|
||||
//Otherwise, calculate them and add them to the default MAPA and MASH centers.
|
||||
let hasMapaLine = false;
|
||||
let hasMashLine = false;
|
||||
|
||||
jobLines.forEach((item) => {
|
||||
//IO-1317 Use the lines on the estimate if they exist instead.
|
||||
if (item.db_ref === "936008") {
|
||||
//If either of these DB REFs change, they also need to change in job-totals/job-costing calculations.
|
||||
hasMapaLine = true;
|
||||
ret["mapa"].total = Dinero({
|
||||
amount: Math.round((item.act_price || 0) * 100),
|
||||
});
|
||||
}
|
||||
if (item.db_ref === "936007") {
|
||||
hasMashLine = true;
|
||||
ret["mash"].total = Dinero({
|
||||
amount: Math.round((item.act_price || 0) * 100),
|
||||
});
|
||||
}
|
||||
|
||||
if (item.mod_lbr_ty) {
|
||||
//There's a labor type, assign the hours.
|
||||
ret[item.mod_lbr_ty.toLowerCase()].hours =
|
||||
@@ -173,11 +194,24 @@ function CalculateRatesTotals(ratesList) {
|
||||
|
||||
let subtotal = Dinero({ amount: 0 });
|
||||
let rates_subtotal = Dinero({ amount: 0 });
|
||||
|
||||
console.log("Has mapa, mash", hasMapaLine, hasMashLine);
|
||||
|
||||
for (const property in ret) {
|
||||
ret[property].total = Dinero({
|
||||
amount: Math.round((ret[property].rate || 0) * 100),
|
||||
}).multiply(ret[property].hours);
|
||||
//Skip calculating mapa and mash if we got the amounts.
|
||||
if (
|
||||
!(
|
||||
(property === "mapa" && hasMapaLine) ||
|
||||
(property === "mash" && hasMashLine)
|
||||
)
|
||||
) {
|
||||
ret[property].total = Dinero({
|
||||
amount: Math.round((ret[property].rate || 0) * 100),
|
||||
}).multiply(ret[property].hours);
|
||||
}
|
||||
|
||||
subtotal = subtotal.add(ret[property].total);
|
||||
|
||||
if (property !== "mapa" && property !== "mash")
|
||||
rates_subtotal = rates_subtotal.add(ret[property].total);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user