IO-177 Paint/Mat Thresholds
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user