mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
fix: set operating cost based on bom qty causing incorrect operating costing
This commit is contained in:
@@ -836,7 +836,7 @@ class BOM(WebsiteGenerator):
|
|||||||
self.base_operating_cost = 0
|
self.base_operating_cost = 0
|
||||||
if self.get("with_operations"):
|
if self.get("with_operations"):
|
||||||
for d in self.get("operations"):
|
for d in self.get("operations"):
|
||||||
if d.workstation:
|
if d.workstation or d.workstation_type:
|
||||||
self.update_rate_and_time(d, update_hour_rate)
|
self.update_rate_and_time(d, update_hour_rate)
|
||||||
|
|
||||||
operating_cost = d.operating_cost
|
operating_cost = d.operating_cost
|
||||||
@@ -857,7 +857,13 @@ class BOM(WebsiteGenerator):
|
|||||||
|
|
||||||
def update_rate_and_time(self, row, update_hour_rate=False):
|
def update_rate_and_time(self, row, update_hour_rate=False):
|
||||||
if not row.hour_rate or update_hour_rate:
|
if not row.hour_rate or update_hour_rate:
|
||||||
hour_rate = flt(frappe.get_cached_value("Workstation", row.workstation, "hour_rate"))
|
hour_rate = 0
|
||||||
|
if row.workstation:
|
||||||
|
hour_rate = flt(frappe.get_cached_value("Workstation", row.workstation, "hour_rate"))
|
||||||
|
elif row.workstation_type:
|
||||||
|
hour_rate = flt(
|
||||||
|
frappe.get_cached_value("Workstation Type", row.workstation_type, "hour_rate")
|
||||||
|
)
|
||||||
|
|
||||||
if hour_rate:
|
if hour_rate:
|
||||||
row.hour_rate = (
|
row.hour_rate = (
|
||||||
|
|||||||
@@ -1229,13 +1229,18 @@ class WorkOrder(Document):
|
|||||||
"fixed_time",
|
"fixed_time",
|
||||||
"skip_material_transfer",
|
"skip_material_transfer",
|
||||||
"backflush_from_wip_warehouse",
|
"backflush_from_wip_warehouse",
|
||||||
|
"set_cost_based_on_bom_qty",
|
||||||
],
|
],
|
||||||
order_by="idx",
|
order_by="idx",
|
||||||
)
|
)
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
if not d.fixed_time:
|
if not d.fixed_time:
|
||||||
d.time_in_mins = flt(d.time_in_mins) * flt(qty)
|
if d.set_cost_based_on_bom_qty:
|
||||||
|
d.time_in_mins = flt(d.time_in_mins) * flt(flt(qty) / flt(d.batch_size or 1))
|
||||||
|
else:
|
||||||
|
d.time_in_mins = flt(d.time_in_mins) * flt(qty)
|
||||||
|
|
||||||
d.status = "Pending"
|
d.status = "Pending"
|
||||||
|
|
||||||
if self.track_semi_finished_goods and not d.sequence_id:
|
if self.track_semi_finished_goods and not d.sequence_id:
|
||||||
@@ -1258,7 +1263,7 @@ class WorkOrder(Document):
|
|||||||
operations.extend(_get_operations(node.name, qty=node.exploded_qty / node.bom_qty))
|
operations.extend(_get_operations(node.name, qty=node.exploded_qty / node.bom_qty))
|
||||||
|
|
||||||
bom_qty = frappe.get_cached_value("BOM", self.bom_no, "quantity")
|
bom_qty = frappe.get_cached_value("BOM", self.bom_no, "quantity")
|
||||||
operations.extend(_get_operations(self.bom_no, qty=1.0 / bom_qty))
|
operations.extend(_get_operations(self.bom_no, qty=bom_qty))
|
||||||
|
|
||||||
for correct_index, operation in enumerate(operations, start=1):
|
for correct_index, operation in enumerate(operations, start=1):
|
||||||
operation.idx = correct_index
|
operation.idx = correct_index
|
||||||
|
|||||||
Reference in New Issue
Block a user