From 1ee3d040a12c0a3a4a4d230fc1c8d149505f3f78 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Sat, 20 Jul 2019 14:46:59 +0530 Subject: [PATCH 1/3] fix: Condition fix in get_balance_on function --- erpnext/accounts/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 8f1dfbc26e..6535e4d75e 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -121,7 +121,12 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company allow_cost_center_in_entry_of_bs_account = get_allow_cost_center_in_entry_of_bs_account() - if cost_center and (allow_cost_center_in_entry_of_bs_account or acc.report_type =='Profit and Loss'): + if acc: + report_type == acc.report_type + else: + report_type = "" + + if cost_center and (allow_cost_center_in_entry_of_bs_account or report_type =='Profit and Loss'): cc = frappe.get_doc("Cost Center", cost_center) if cc.is_group: cond.append(""" exists ( @@ -138,7 +143,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company if not frappe.flags.ignore_account_permission: acc.check_permission("read") - if acc.report_type == 'Profit and Loss': + if report_type == 'Profit and Loss': # for pl accounts, get balance within a fiscal year cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \ % year_start_date) From e097d4f470c53e529693ffd93ec1139b8a6c0042 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Sat, 20 Jul 2019 14:49:32 +0530 Subject: [PATCH 2/3] fix: Assignment fix --- erpnext/accounts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 6535e4d75e..abef2bd6a5 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -122,7 +122,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company allow_cost_center_in_entry_of_bs_account = get_allow_cost_center_in_entry_of_bs_account() if acc: - report_type == acc.report_type + report_type = acc.report_type else: report_type = "" From 2ddbebfae07a285f35d5a916b2155fb2b15b96f8 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Sat, 20 Jul 2019 14:52:59 +0530 Subject: [PATCH 3/3] fix: Condition fix --- erpnext/accounts/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index abef2bd6a5..a617de3ba7 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -121,7 +121,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company allow_cost_center_in_entry_of_bs_account = get_allow_cost_center_in_entry_of_bs_account() - if acc: + if account: report_type = acc.report_type else: report_type = ""