diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py index c831b7876c2..b225aac7b56 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py @@ -98,7 +98,7 @@ def execute(filters=None): chart = get_chart_data(filters, columns, asset, liability, equity) report_summary = get_report_summary( - period_list, asset, liability, equity, provisional_profit_loss, total_credit, currency, filters + period_list, asset, liability, equity, provisional_profit_loss, currency, filters ) return columns, data, message, chart, report_summary @@ -176,7 +176,6 @@ def get_report_summary( liability, equity, provisional_profit_loss, - total_credit, currency, filters, consolidated=False, diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 9bb05fda969..cd01a35c1ab 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -418,23 +418,15 @@ def set_gl_entries_by_account( ignore_closing_entries=False, ): """Returns a dict like { "account": [gl entries], ... }""" - gl_entries = [] - account = frappe.qb.DocType("Account") - accounts = ( - frappe.qb.from_(account) - .select(account.name) - .where(account.lft >= root_lft) - .where(account.rgt <= root_rgt) - .where(account.company == company) - .run(as_dict=True) + accounts_list = frappe.db.get_all( + "Account", + filters={"company": company, "is_group": 0, "lft": (">=", root_lft), "rgt": ("<=", root_rgt)}, + pluck="name", ) - accounts_list = [account.name for account in accounts] - if accounts_list: - # For balance sheet if not from_date: from_date = filters["period_start_date"] @@ -493,8 +485,6 @@ def get_accounting_entries( .where(gl_entry.company == filters.company) ) - query = query.where(gl_entry.account.isin(accounts)) - if doctype == "GL Entry": query = query.select(gl_entry.posting_date, gl_entry.is_opening, gl_entry.fiscal_year) query = query.where(gl_entry.is_cancelled == 0) @@ -504,6 +494,7 @@ def get_accounting_entries( query = query.where(gl_entry.period_closing_voucher == period_closing_voucher) query = apply_additional_conditions(doctype, query, from_date, ignore_closing_entries, filters) + query = query.where(gl_entry.account.isin(accounts)) entries = query.run(as_dict=True)