fix(manufacturing): check remaining qty to calculate operating cost (backport #53983) (#54128)

Co-authored-by: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com>
fix(manufacturing): check remaining qty to calculate operating cost (#53983)
This commit is contained in:
mergify[bot]
2026-04-08 12:15:28 +00:00
committed by GitHub
parent 9d317129f4
commit 856ba24194

View File

@@ -3928,9 +3928,12 @@ def get_operating_cost_per_unit(work_order=None, bom_no=None):
for d in work_order.get("operations"): for d in work_order.get("operations"):
if flt(d.completed_qty): if flt(d.completed_qty):
operating_cost_per_unit += flt( if not (remaining_qty := flt(d.completed_qty - work_order.produced_qty)):
d.actual_operating_cost - get_consumed_operating_cost(work_order.name, bom_no) continue
) / flt(d.completed_qty - work_order.produced_qty) operating_cost_per_unit += (
flt(d.actual_operating_cost - get_consumed_operating_cost(work_order.name, bom_no))
/ remaining_qty
)
elif work_order.qty: elif work_order.qty:
operating_cost_per_unit += flt(d.planned_operating_cost) / flt(work_order.qty) operating_cost_per_unit += flt(d.planned_operating_cost) / flt(work_order.qty)