Merge pull request #36458 from GursheenK/consolidated-financial-statements-roottype

test: balance sheet report 
diff --git a/erpnext/accounts/report/balance_sheet/test_balance_sheet.py b/erpnext/accounts/report/balance_sheet/test_balance_sheet.py
new file mode 100644
index 0000000..3cb6efe
--- /dev/null
+++ b/erpnext/accounts/report/balance_sheet/test_balance_sheet.py
@@ -0,0 +1,51 @@
+# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
+# MIT License. See license.txt
+
+import frappe
+from frappe.tests.utils import FrappeTestCase
+from frappe.utils import today
+
+from erpnext.accounts.report.balance_sheet.balance_sheet import execute
+
+
+class TestBalanceSheet(FrappeTestCase):
+	def test_balance_sheet(self):
+		from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
+		from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import (
+			create_sales_invoice,
+			make_sales_invoice,
+		)
+		from erpnext.accounts.utils import get_fiscal_year
+
+		frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company 6'")
+		frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company 6'")
+		frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 6'")
+
+		pi = make_purchase_invoice(
+			company="_Test Company 6",
+			warehouse="Finished Goods - _TC6",
+			expense_account="Cost of Goods Sold - _TC6",
+			cost_center="Main - _TC6",
+			qty=10,
+			rate=100,
+		)
+		si = create_sales_invoice(
+			company="_Test Company 6",
+			debit_to="Debtors - _TC6",
+			income_account="Sales - _TC6",
+			cost_center="Main - _TC6",
+			qty=5,
+			rate=110,
+		)
+		filters = frappe._dict(
+			company="_Test Company 6",
+			period_start_date=today(),
+			period_end_date=today(),
+			periodicity="Yearly",
+		)
+		result = execute(filters)[1]
+		for account_dict in result:
+			if account_dict.get("account") == "Current Liabilities - _TC6":
+				self.assertEqual(account_dict.total, 1000)
+			if account_dict.get("account") == "Current Assets - _TC6":
+				self.assertEqual(account_dict.total, 550)
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 f1e665a..080e45a 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
@@ -654,11 +654,12 @@
 				& (gle.posting_date <= to_date)
 				& (account.lft >= root_lft)
 				& (account.rgt <= root_rgt)
-				& (account.root_type == root_type)
 			)
 			.orderby(gle.account, gle.posting_date)
 		)
 
+		if root_type:
+			query = query.where(account.root_type == root_type)
 		additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters, d)
 		if additional_conditions:
 			query = query.where(Criterion.all(additional_conditions))