From e3d854e02ba7b3e609b13ea917de37150af20952 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Wed, 21 May 2025 17:53:33 -0700 Subject: [PATCH] IO-3243 Job Costing TOW Signed-off-by: Allan Carr --- server/graphql-client/queries.js | 2 ++ server/job/job-costing.js | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index d61d814b9..386e21a9f 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -1596,6 +1596,7 @@ query QUERY_JOB_COSTING_DETAILS($id: uuid!) { ca_customer_gst dms_allocation cieca_pfl + cieca_stl materials joblines(where: { removed: { _eq: false } }) { id @@ -1712,6 +1713,7 @@ exports.QUERY_JOB_COSTING_DETAILS_MULTI = ` query QUERY_JOB_COSTING_DETAILS_MULT ca_customer_gst dms_allocation cieca_pfl + cieca_stl materials joblines(where: {removed: {_eq: false}}) { id diff --git a/server/job/job-costing.js b/server/job/job-costing.js index 1210b92e9..29c9dbfce 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -567,6 +567,29 @@ function GenerateCostingData(job) { ); } + if (InstanceManager({ imex: false, rome: true })) { + const stlTowing = job.cieca_stl?.data.find((c) => c.ttl_type === "OTTW"); + const stlStorage = job.cieca_stl?.data.find((c) => c.ttl_type === "OTST"); + + if (!jobLineTotalsByProfitCenter.additional[defaultProfits["TOW"]]) + jobLineTotalsByProfitCenter.additional[defaultProfits["TOW"]] = Dinero(); + + jobLineTotalsByProfitCenter.additional[defaultProfits["TOW"]] = stlTowing + ? Dinero({ amount: Math.round(stlTowing.ttl_amt * 100) }) + : Dinero({ + amount: Math.round((job.towing_payable || 0) * 100) + }); + + if (!jobLineTotalsByProfitCenter.additional[defaultProfits["STO"]]) + jobLineTotalsByProfitCenter.additional[defaultProfits["STO"]] = Dinero(); + + jobLineTotalsByProfitCenter.additional[defaultProfits["STO"]] = stlStorage + ? Dinero({ amount: Math.round(stlStorage.ttl_amt * 100) }) + : Dinero({ + amount: Math.round((job.storage_payable || 0) * 100) + }); + } + //Is it a DMS Setup? const selectedDmsAllocationConfig = (job.bodyshop.md_responsibility_centers.dms_defaults &&