From 605b867143da589b6ddd623fd65e8ed43db93ca8 Mon Sep 17 00:00:00 2001 From: Diptanil Saha Date: Wed, 9 Jul 2025 15:44:46 +0530 Subject: [PATCH] feat: filter to display trial balance report without group account (#48486) --- .../report/trial_balance/trial_balance.js | 6 ++++++ .../report/trial_balance/trial_balance.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/trial_balance/trial_balance.js b/erpnext/accounts/report/trial_balance/trial_balance.js index 343bb7a3304..28ae1989ae4 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.js +++ b/erpnext/accounts/report/trial_balance/trial_balance.js @@ -111,6 +111,12 @@ frappe.query_reports["Trial Balance"] = { fieldtype: "Check", default: 1, }, + { + fieldname: "show_group_accounts", + label: __("Show Group Accounts"), + fieldtype: "Check", + default: 1, + }, ], formatter: erpnext.financial_statements.formatter, tree: true, diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 6fe28d15d97..a05208075b9 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -81,7 +81,7 @@ def validate_filters(filters): def get_data(filters): accounts = frappe.db.sql( - """select name, account_number, parent_account, account_name, root_type, report_type, lft, rgt + """select name, account_number, parent_account, account_name, root_type, report_type, is_group, lft, rgt from `tabAccount` where company=%s order by lft""", filters.company, @@ -401,6 +401,7 @@ def prepare_data(accounts, filters, parent_children_map, company_currency): "from_date": filters.from_date, "to_date": filters.to_date, "currency": company_currency, + "is_group_account": d.is_group, "account_name": ( f"{d.account_number} - {d.account_name}" if d.account_number else d.account_name ), @@ -417,6 +418,10 @@ def prepare_data(accounts, filters, parent_children_map, company_currency): data.append(row) total_row = calculate_total_row(accounts, company_currency) + + if not filters.get("show_group_accounts"): + data = hide_group_accounts(data) + data.extend([{}, total_row]) return data @@ -496,3 +501,12 @@ def prepare_opening_closing(row): row[valid_col] = 0.0 else: row[reverse_col] = 0.0 + + +def hide_group_accounts(data): + non_group_accounts_data = [] + for d in data: + if not d.get("is_group_account"): + d.update(indent=0) + non_group_accounts_data.append(d) + return non_group_accounts_data -- GitLab