fix: incorrect number of gl entries issue (#20352)

This commit is contained in:
rohitwaghchaure 2020-01-20 17:53:19 +05:30 committed by Nabin Hait
parent 7653a8b9fa
commit 6ae61a1693
2 changed files with 14 additions and 10 deletions

View File

@ -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):

View File

@ -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,