fix: Error in consolidated financial statement (#34330)
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 ddee9fc..7b60800 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 @@
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_root_account_name(root_type, company):
- return frappe.get_all(
+ root_account = frappe.get_all(
"Account",
fields=["account_name"],
filters={
@@ -165,7 +166,10 @@
"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):