fix: updated logic
This commit is contained in:
@@ -516,16 +516,14 @@ class BOM(WebsiteGenerator):
|
|||||||
return erpnext.get_company_currency(self.company)
|
return erpnext.get_company_currency(self.company)
|
||||||
|
|
||||||
def add_to_cur_exploded_items(self, args):
|
def add_to_cur_exploded_items(self, args):
|
||||||
if self.cur_exploded_items.get(args.item_code) and self.cur_exploded_items[args.item_code]["operation"] == args.operation:
|
key = (args.item_code)
|
||||||
if args.operation is None:
|
if args.operation:
|
||||||
self.cur_exploded_items[args.item_code]["stock_qty"] += args.stock_qty
|
key = (args.item_code, args.operation)
|
||||||
else:
|
|
||||||
self.cur_exploded_items[args.item_code+":"+args.operation]["stock_qty"] += args.stock_qty
|
if key in self.cur_exploded_items:
|
||||||
|
self.cur_exploded_items[key]["stock_qty"] += args.stock_qty
|
||||||
else:
|
else:
|
||||||
if args.operation is None:
|
self.cur_exploded_items[key] = args
|
||||||
self.cur_exploded_items[args.item_code] = args
|
|
||||||
else:
|
|
||||||
self.cur_exploded_items[args.item_code+":"+args.operation] = args
|
|
||||||
|
|
||||||
def get_child_exploded_items(self, bom_no, stock_qty):
|
def get_child_exploded_items(self, bom_no, stock_qty):
|
||||||
""" Add all items from Flat BOM of child BOM"""
|
""" Add all items from Flat BOM of child BOM"""
|
||||||
@@ -640,16 +638,14 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
|
|||||||
items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
|
items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.item_code in item_dict and ( fetch_scrap_items or item_dict[item.item_code]["operation"] == item.operation):
|
key = (item.item_code)
|
||||||
if item.operation is None:
|
if item.operation:
|
||||||
item_dict[item.item_code]["qty"] += flt(item.qty)
|
key = (item.item_code, item.operation)
|
||||||
else:
|
|
||||||
item_dict[item.item_code+":"+item.operation]["qty"] += flt(item.qty)
|
if key in item_dict:
|
||||||
|
item_dict[key]["qty"] += flt(item.qty)
|
||||||
else:
|
else:
|
||||||
if item.operation is None:
|
item_dict[key] = item
|
||||||
item_dict[item.item_code] = item
|
|
||||||
else:
|
|
||||||
item_dict[item.item_code+":"+item.operation] = item
|
|
||||||
|
|
||||||
for item, item_details in item_dict.items():
|
for item, item_details in item_dict.items():
|
||||||
for d in [["Account", "expense_account", "default_expense_account"],
|
for d in [["Account", "expense_account", "default_expense_account"],
|
||||||
|
|||||||
Reference in New Issue
Block a user