Skip to content

Commit 856ba24

Browse files
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)
1 parent 9d31712 commit 856ba24

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

erpnext/stock/doctype/stock_entry/stock_entry.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,9 +3928,12 @@ def get_operating_cost_per_unit(work_order=None, bom_no=None):
39283928

39293929
for d in work_order.get("operations"):
39303930
if flt(d.completed_qty):
3931-
operating_cost_per_unit += flt(
3932-
d.actual_operating_cost - get_consumed_operating_cost(work_order.name, bom_no)
3933-
) / flt(d.completed_qty - work_order.produced_qty)
3931+
if not (remaining_qty := flt(d.completed_qty - work_order.produced_qty)):
3932+
continue
3933+
operating_cost_per_unit += (
3934+
flt(d.actual_operating_cost - get_consumed_operating_cost(work_order.name, bom_no))
3935+
/ remaining_qty
3936+
)
39343937
elif work_order.qty:
39353938
operating_cost_per_unit += flt(d.planned_operating_cost) / flt(work_order.qty)
39363939

0 commit comments

Comments
 (0)