Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect rate in BOM exploded items #31513

Merged
merged 7 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion erpnext/manufacturing/doctype/bom/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def validate(self):
self.validate_transfer_against()
self.set_routing_operations()
self.validate_operations()
self.update_exploded_items(save=False)
self.calculate_cost()
self.update_exploded_items(save=False)
s-aga-r marked this conversation as resolved.
Show resolved Hide resolved
self.update_stock_qty()
self.update_cost(update_parent=False, from_child_bom=True, update_hour_rate=False, save=False)
self.validate_scrap_items()
Expand Down
28 changes: 28 additions & 0 deletions erpnext/manufacturing/doctype/bom/test_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,34 @@ def test_set_default_bom_for_item_having_single_bom(self):
bom.reload()
self.assertEqual(frappe.get_value("Item", fg_item.item_code, "default_bom"), bom.name)

def test_exploded_items_rate(self):
rm_item = make_item(
properties={"is_stock_item": 1, "valuation_rate": 99, "last_purchase_rate": 89}
).name
fg_item = make_item(properties={"is_stock_item": 1}).name

from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom

bom = make_bom(item=fg_item, raw_materials=[rm_item], do_not_save=True)

bom.rm_cost_as_per = "Last Purchase Rate"
bom.save()
self.assertEqual(bom.items[0].base_rate, 89)
self.assertEqual(bom.exploded_items[0].rate, bom.items[0].base_rate)

bom.rm_cost_as_per = "Price List"
bom.save()
self.assertEqual(bom.items[0].base_rate, 0.0)
self.assertEqual(bom.exploded_items[0].rate, bom.items[0].base_rate)

bom.rm_cost_as_per = "Valuation Rate"
bom.save()
self.assertEqual(bom.items[0].base_rate, 99)
self.assertEqual(bom.exploded_items[0].rate, bom.items[0].base_rate)

bom.submit()
self.assertEqual(bom.exploded_items[0].rate, bom.items[0].base_rate)


def get_default_bom(item_code="_Test FG Item 2"):
return frappe.db.get_value("BOM", {"item": item_code, "is_active": 1, "is_default": 1})
Expand Down
3 changes: 2 additions & 1 deletion erpnext/manufacturing/doctype/bom_item/bom_item.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"in_list_view": 1,
"label": "Rate",
"options": "currency",
"read_only": 1,
"reqd": 1
},
{
Expand Down Expand Up @@ -288,7 +289,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2022-05-19 02:32:43.785470",
"modified": "2022-07-28 10:20:51.559010",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM Item",
Expand Down