From 1ee3d040a12c0a3a4a4d230fc1c8d149505f3f78 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Sat, 20 Jul 2019 14:46:59 +0530 Subject: [PATCH] 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)