From 510dc60bf0875e6595403195b0b0029de965fbea Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 16 May 2019 17:28:39 +0530 Subject: [PATCH 1/2] fix: GL Entry for opening stock reconciliation --- erpnext/controllers/stock_controller.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index af689808c07..7d92bdda49b 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -80,6 +80,7 @@ class StockController(AccountsController): "cost_center": item_row.cost_center, "remarks": self.get("remarks") or "Accounting Entry for Stock", "debit": flt(sle.stock_value_difference, 2), + "is_opening": item_row.get("is_opening"), }, warehouse_account[sle.warehouse]["account_currency"])) # to target warehouse / expense account @@ -89,7 +90,8 @@ class StockController(AccountsController): "cost_center": item_row.cost_center, "remarks": self.get("remarks") or "Accounting Entry for Stock", "credit": flt(sle.stock_value_difference, 2), - "project": item_row.get("project") or self.get("project") + "project": item_row.get("project") or self.get("project"), + "is_opening": item_row.get("is_opening") })) elif sle.warehouse not in warehouse_with_no_account: warehouse_with_no_account.append(sle.warehouse) @@ -123,8 +125,17 @@ class StockController(AccountsController): def get_voucher_details(self, default_expense_account, default_cost_center, sle_map): if self.doctype == "Stock Reconciliation": - return [frappe._dict({ "name": voucher_detail_no, "expense_account": default_expense_account, - "cost_center": default_cost_center }) for voucher_detail_no, sle in sle_map.items()] + reconciliation_purpose = frappe.db.get_value(self.doctype, self.name, "purpose") + is_opening = "Yes" if reconciliation_purpose == "Opening Stock" else "No" + details = [] + for voucher_detail_no, sle in sle_map.items(): + details.append(frappe._dict({ + "name": voucher_detail_no, + "expense_account": default_expense_account, + "cost_center": default_cost_center, + "is_opening": is_opening + })) + return details else: details = self.get("items") From 19901c14c929c76859bb59068dc5a527594b5eca Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 17 May 2019 14:30:45 +0530 Subject: [PATCH 2/2] fix: Removed unused variable --- erpnext/controllers/stock_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 7d92bdda49b..9a490a7edb0 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -128,7 +128,7 @@ class StockController(AccountsController): reconciliation_purpose = frappe.db.get_value(self.doctype, self.name, "purpose") is_opening = "Yes" if reconciliation_purpose == "Opening Stock" else "No" details = [] - for voucher_detail_no, sle in sle_map.items(): + for voucher_detail_no in sle_map: details.append(frappe._dict({ "name": voucher_detail_no, "expense_account": default_expense_account,