IO-3503 InstanceManager change

Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
Allan Carr
2026-02-06 15:15:11 -08:00
parent fe7bf684aa
commit d8b400cb8c

View File

@@ -13,6 +13,9 @@ const { DiscountNotAlreadyCounted } = InstanceManager({
// Dinero.globalLocale = "en-CA"; // Dinero.globalLocale = "en-CA";
Dinero.globalRoundingMode = "HALF_EVEN"; Dinero.globalRoundingMode = "HALF_EVEN";
const isImEX = InstanceManager({ imex: true, rome: false });
const isRome = InstanceManager({ imex: false, rome: true });
async function JobCosting(req, res) { async function JobCosting(req, res) {
const { jobid } = req.body; const { jobid } = req.body;
@@ -266,9 +269,7 @@ function GenerateCostingData(job) {
); );
const materialsHours = { mapaHrs: 0, mashHrs: 0 }; const materialsHours = { mapaHrs: 0, mashHrs: 0 };
let mashOpCodes = InstanceManager({ let mashOpCodes = isRome && ParseCalopCode(job.materials["MASH"]?.cal_opcode);
rome: ParseCalopCode(job.materials["MASH"]?.cal_opcode)
});
let hasMapaLine = false; let hasMapaLine = false;
let hasMashLine = false; let hasMashLine = false;
@@ -355,7 +356,7 @@ function GenerateCostingData(job) {
if (val.mod_lbr_ty === "LAR") { if (val.mod_lbr_ty === "LAR") {
materialsHours.mapaHrs += val.mod_lb_hrs || 0; materialsHours.mapaHrs += val.mod_lb_hrs || 0;
} }
if (InstanceManager({ imex: true, rome: false })) { if (isImEX) {
if (val.mod_lbr_ty !== "LAR") { if (val.mod_lbr_ty !== "LAR") {
materialsHours.mashHrs += val.mod_lb_hrs || 0; 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)) { if (val.mod_lbr_ty !== "LAR" && mashOpCodes.includes(val.lbr_op)) {
materialsHours.mashHrs += val.mod_lb_hrs || 0; 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; materialsHours.mashHrs += val.mod_lb_hrs || 0;
} }
} }
@@ -525,14 +526,15 @@ function GenerateCostingData(job) {
} }
} }
if (InstanceManager({ rome: true })) { if (isRome) {
if (convertedKey) { if (convertedKey) {
const correspondingCiecaStlTotalLine = job.cieca_stl?.data.find( const correspondingCiecaStlTotalLine = job.cieca_stl?.data.find(
(c) => c.ttl_typecd === convertedKey.toUpperCase() (c) => c.ttl_typecd === convertedKey.toUpperCase()
); );
if ( if (
correspondingCiecaStlTotalLine && 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); jobLineTotalsByProfitCenter.parts[key] = jobLineTotalsByProfitCenter.parts[key].add(disc).add(markup);
} }
@@ -545,7 +547,7 @@ function GenerateCostingData(job) {
if ( if (
job.materials["MAPA"] && job.materials["MAPA"] &&
job.materials["MAPA"].cal_maxdlr !== undefined && 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. //It has an upper threshhold.
threshold = Dinero({ threshold = Dinero({
@@ -595,7 +597,7 @@ function GenerateCostingData(job) {
if ( if (
job.materials["MASH"] && job.materials["MASH"] &&
job.materials["MASH"].cal_maxdlr !== undefined && 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. //It has an upper threshhold.
threshold = Dinero({ 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 stlTowing = job.cieca_stl?.data.find((c) => c.ttl_type === "OTTW");
const stlStorage = job.cieca_stl?.data.find((c) => c.ttl_type === "OTST"); const stlStorage = job.cieca_stl?.data.find((c) => c.ttl_type === "OTST");