diff --git a/server/job/job-totals.js b/server/job/job-totals.js index e0c069bba..21ca72504 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -189,6 +189,25 @@ function CalculateRatesTotals(ratesList) { } if (item.mod_lbr_ty) { + //Check to see if it has 0 hours and a price instead. + if ( + item.mod_lb_hrs === 0 && + item.act_price > 0 && + item.lbr_op === "OP14" + ) { + //Scenario where SGI may pay out hours using a part price. + if (!ret[item.mod_lbr_ty.toLowerCase()].total) { + ret[item.mod_lbr_ty.toLowerCase()].total = Dinero(); + } + ret[item.mod_lbr_ty.toLowerCase()].total = ret[ + item.mod_lbr_ty.toLowerCase() + ].total.add( + Dinero({ amount: Math.round((item.act_price || 0) * 100) }).multiply( + item.part_qty + ) + ); + } + //There's a labor type, assign the hours. ret[item.mod_lbr_ty.toLowerCase()].hours = ret[item.mod_lbr_ty.toLowerCase()].hours + item.mod_lb_hrs; @@ -212,9 +231,14 @@ function CalculateRatesTotals(ratesList) { (property === "mash" && hasMashLine) ) ) { - ret[property].total = Dinero({ - amount: Math.round((ret[property].rate || 0) * 100), - }).multiply(ret[property].hours); + 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) + ); } subtotal = subtotal.add(ret[property].total); @@ -222,6 +246,7 @@ function CalculateRatesTotals(ratesList) { if (property !== "mapa" && property !== "mash") rates_subtotal = rates_subtotal.add(ret[property].total); } + ret.subtotal = subtotal; ret.rates_subtotal = rates_subtotal;