IO-177 Paint/Mat Thresholds

This commit is contained in:
Patrick Fic
2022-03-14 10:41:52 -07:00
parent 9a65b6a1ce
commit 148c645f18
11 changed files with 86 additions and 9 deletions

View File

@@ -234,11 +234,30 @@ function CalculateRatesTotals(ratesList) {
if (!ret[property].total) {
ret[property].total = Dinero();
}
ret[property].total = ret[property].total.add(
Dinero({
amount: Math.round((ret[property].rate || 0) * 100),
}).multiply(ret[property].hours)
);
let threshold;
//Check if there is a max for this type.
if (ratesList.materials[property]) {
//
if (
ratesList.materials[property].cal_maxdlr &&
ratesList.materials[property].cal_maxdlr > 0
) {
//It has an upper threshhold.
threshold = Dinero({
amount: Math.round(ratesList.materials[property].cal_maxdlr * 100),
});
}
}
const total = Dinero({
amount: Math.round((ret[property].rate || 0) * 100),
}).multiply(ret[property].hours);
if (threshold && total.greaterThanOrEqual(threshold)) {
ret[property].total = ret[property].total.add(threshold);
} else {
ret[property].total = ret[property].total.add(total);
}
}
subtotal = subtotal.add(ret[property].total);
@@ -252,6 +271,7 @@ function CalculateRatesTotals(ratesList) {
return ret;
}
function CalculatePartsTotals(jobLines) {
const ret = jobLines
.filter((jl) => !jl.removed)