From 73866f4da7487d7f8fdb815d69fbe6d2cb63764e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:03:02 +0530 Subject: [PATCH] fix: Error in consolidated financial statement (#34330) fix: Error in consolidated financial statement (#34330) (cherry picked from commit aae53bb9106401904449b0c5315939e7d1beef1e) Co-authored-by: Deepesh Garg --- .../consolidated_financial_statement.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index 560b79243d7..9a3e82486af 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -138,7 +138,8 @@ def prepare_companywise_opening_balance(asset_data, liability_data, equity_data, for data in [asset_data, liability_data, equity_data]: if data: account_name = get_root_account_name(data[0].root_type, company) - opening_value += get_opening_balance(account_name, data, company) or 0.0 + if account_name: + opening_value += get_opening_balance(account_name, data, company) or 0.0 opening_balance[company] = opening_value @@ -155,7 +156,7 @@ def get_opening_balance(account_name, data, company): def get_root_account_name(root_type, company): - return frappe.get_all( + root_account = frappe.get_all( "Account", fields=["account_name"], filters={ @@ -165,7 +166,10 @@ def get_root_account_name(root_type, company): "parent_account": ("is", "not set"), }, as_list=1, - )[0][0] + ) + + if root_account: + return root_account[0][0] def get_profit_loss_data(fiscal_year, companies, columns, filters):