diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index b949a0f984..04f6fc66c7 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -783,11 +783,12 @@ def add_non_stock_items_cost(stock_entry, work_order, expense_account): for name in non_stock_items: non_stock_items_cost += flt(items.get(name[0])) * flt(stock_entry.fg_completed_qty) / flt(bom.quantity) - stock_entry.append('additional_costs', { - 'expense_account': expense_account, - 'description': _("Non stock items"), - 'amount': non_stock_items_cost - }) + if non_stock_items_cost: + stock_entry.append('additional_costs', { + 'expense_account': expense_account, + 'description': _("Non stock items"), + 'amount': non_stock_items_cost + }) def add_operations_cost(stock_entry, work_order=None, expense_account=None): from erpnext.stock.doctype.stock_entry.stock_entry import get_operating_cost_per_unit @@ -804,11 +805,12 @@ def add_operations_cost(stock_entry, work_order=None, expense_account=None): additional_operating_cost_per_unit = \ flt(work_order.additional_operating_cost) / flt(work_order.qty) - stock_entry.append('additional_costs', { - "expense_account": expense_account, - "description": "Additional Operating Cost", - "amount": additional_operating_cost_per_unit * flt(stock_entry.fg_completed_qty) - }) + if additional_operating_cost_per_unit: + stock_entry.append('additional_costs', { + "expense_account": expense_account, + "description": "Additional Operating Cost", + "amount": additional_operating_cost_per_unit * flt(stock_entry.fg_completed_qty) + }) @frappe.whitelist() def get_bom_diff(bom1, bom2): diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 02e7abd505..a43ac853dc 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -682,6 +682,8 @@ class StockEntry(StockController): if item_account_wise_additional_cost: for d in self.get("items"): for account, amount in iteritems(item_account_wise_additional_cost.get((d.item_code, d.name), {})): + if not amount: continue + gl_entries.append(self.get_gl_dict({ "account": account, "against": d.expense_account,