From d8b400cb8c34569beb76d4347ed78de3cd5c79f4 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Fri, 6 Feb 2026 15:15:11 -0800 Subject: [PATCH] IO-3503 InstanceManager change Signed-off-by: Allan Carr --- server/job/job-costing.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/server/job/job-costing.js b/server/job/job-costing.js index 0cee8b647..93c62ae75 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -13,6 +13,9 @@ const { DiscountNotAlreadyCounted } = InstanceManager({ // Dinero.globalLocale = "en-CA"; Dinero.globalRoundingMode = "HALF_EVEN"; +const isImEX = InstanceManager({ imex: true, rome: false }); +const isRome = InstanceManager({ imex: false, rome: true }); + async function JobCosting(req, res) { const { jobid } = req.body; @@ -266,9 +269,7 @@ function GenerateCostingData(job) { ); const materialsHours = { mapaHrs: 0, mashHrs: 0 }; - let mashOpCodes = InstanceManager({ - rome: ParseCalopCode(job.materials["MASH"]?.cal_opcode) - }); + let mashOpCodes = isRome && ParseCalopCode(job.materials["MASH"]?.cal_opcode); let hasMapaLine = false; let hasMashLine = false; @@ -355,7 +356,7 @@ function GenerateCostingData(job) { if (val.mod_lbr_ty === "LAR") { materialsHours.mapaHrs += val.mod_lb_hrs || 0; } - if (InstanceManager({ imex: true, rome: false })) { + if (isImEX) { if (val.mod_lbr_ty !== "LAR") { materialsHours.mashHrs += val.mod_lb_hrs || 0; } @@ -363,7 +364,7 @@ function GenerateCostingData(job) { if (val.mod_lbr_ty !== "LAR" && mashOpCodes.includes(val.lbr_op)) { materialsHours.mashHrs += val.mod_lb_hrs || 0; } - if (val.manual_line === true && !mashOpCodes.includes(val.lbr_op) && val.mod_lbr_ty !== "LAR" ) { + if (val.manual_line === true && !mashOpCodes.includes(val.lbr_op) && val.mod_lbr_ty !== "LAR") { materialsHours.mashHrs += val.mod_lb_hrs || 0; } } @@ -525,14 +526,15 @@ function GenerateCostingData(job) { } } - if (InstanceManager({ rome: true })) { + if (isRome) { if (convertedKey) { const correspondingCiecaStlTotalLine = job.cieca_stl?.data.find( (c) => c.ttl_typecd === convertedKey.toUpperCase() ); if ( correspondingCiecaStlTotalLine && - Math.abs(jobLineTotalsByProfitCenter.parts[key].getAmount() - correspondingCiecaStlTotalLine.ttl_amt * 100) > 1 + Math.abs(jobLineTotalsByProfitCenter.parts[key].getAmount() - correspondingCiecaStlTotalLine.ttl_amt * 100) > + 1 ) { jobLineTotalsByProfitCenter.parts[key] = jobLineTotalsByProfitCenter.parts[key].add(disc).add(markup); } @@ -545,7 +547,7 @@ function GenerateCostingData(job) { if ( job.materials["MAPA"] && job.materials["MAPA"].cal_maxdlr !== undefined && - (InstanceManager({ rome: true }) ? job.materials["MAPA"].cal_maxdlr >= 0 : job.materials["MAPA"].cal_maxdlr > 0) + (isRome ? job.materials["MAPA"].cal_maxdlr >= 0 : job.materials["MAPA"].cal_maxdlr > 0) ) { //It has an upper threshhold. threshold = Dinero({ @@ -595,7 +597,7 @@ function GenerateCostingData(job) { if ( job.materials["MASH"] && job.materials["MASH"].cal_maxdlr !== undefined && - (InstanceManager({ rome: true }) ? job.materials["MASH"].cal_maxdlr >= 0 : job.materials["MASH"].cal_maxdlr > 0) + (isRome ? job.materials["MASH"].cal_maxdlr >= 0 : job.materials["MASH"].cal_maxdlr > 0) ) { //It has an upper threshhold. threshold = Dinero({ @@ -641,7 +643,7 @@ function GenerateCostingData(job) { } } - if (InstanceManager({ imex: false, rome: true })) { + if (isRome) { const stlTowing = job.cieca_stl?.data.find((c) => c.ttl_type === "OTTW"); const stlStorage = job.cieca_stl?.data.find((c) => c.ttl_type === "OTST");