Merged in feature/IO-2814-Job-Costing-Correction (pull request #1465)

IO-2814 Correct Parts Price and add Console Log
This commit is contained in:
Allan Carr
2024-06-07 18:39:43 +00:00
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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;