From 755acd24f091f3fd71b027a3d0ef2490a19ad7c6 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Fri, 7 Jun 2024 11:40:39 -0700 Subject: [PATCH] IO-2814 Correct Parts Price and add Console Log Signed-off-by: Allan Carr --- server/graphql-client/queries.js | 1 + server/job/job-costing.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index d26db1405..6d7f447df 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -1534,6 +1534,7 @@ exports.QUERY_JOB_COSTING_DETAILS = ` query QUERY_JOB_COSTING_DETAILS($id: uuid! op_code_desc profitcenter_part profitcenter_labor + act_price_before_ppc } bills { id diff --git a/server/job/job-costing.js b/server/job/job-costing.js index 274012e2f..1fbb92271 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -318,7 +318,7 @@ function GenerateCostingData(job) { if (!partsProfitCenter) console.log("Unknown cost/profit center mapping for parts.", val.line_desc, val.part_type); const partsAmount = Dinero({ - amount: Math.round((val.act_price || 0) * 100) + amount: val.act_price_before_ppc ? Math.round(val.act_price_before_ppc * 100) : Math.round(val.act_price * 100) }) .multiply(val.part_qty || 1) .add( @@ -327,7 +327,7 @@ function GenerateCostingData(job) { ? val.prt_dsmk_m ? Dinero({ amount: Math.round(val.prt_dsmk_m * 100) }) : Dinero({ - amount: Math.round(val.act_price * 100) + amount: val.act_price_before_ppc ? Math.round(val.act_price_before_ppc * 100) : Math.round(val.act_price * 100) }) .multiply(val.part_qty || 0) .percentage(Math.abs(val.prt_dsmk_p || 0)) @@ -396,6 +396,8 @@ function GenerateCostingData(job) { if (!acc.additional[partsProfitCenter]) acc.additional[partsProfitCenter] = Dinero(); acc.additional[partsProfitCenter] = acc.additional[partsProfitCenter].add(partsAmount); + + console.log("line_desc", val.line_desc, "partsProfitCenter", partsProfitCenter, "partsAmount", partsAmount.toUnit(), "acc", acc.additional[partsProfitCenter].add(partsAmount).toUnit()); } return acc;