diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index 5fd698b61..cd707bc0f 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -1539,6 +1539,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;