From d50ea6f96e948f00eac811edfda48802cd0b3d76 Mon Sep 17 00:00:00 2001 From: Jatin3128 Date: Fri, 28 Nov 2025 21:39:40 +0530 Subject: [PATCH] fix(accounts-payable-summary): add Show GL Balance check similar to Accounts Receivable Summary (cherry picked from commit 8a7e5d062613576f4ebbace3fa4dd67056f4d277) # Conflicts: # erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py --- .../accounts_payable_summary.js | 5 +++++ .../accounts_receivable_summary.py | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js index 18a85af95be..6a043f5e185 100644 --- a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js +++ b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js @@ -102,6 +102,11 @@ frappe.query_reports["Accounts Payable Summary"] = { label: __("Revaluation Journals"), fieldtype: "Check", }, + { + fieldname: "show_gl_balance", + label: __("Show GL Balance"), + fieldtype: "Check", + }, ], onload: function (report) { diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py index 19fd7dc96ef..90358018abd 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py +++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py @@ -53,7 +53,7 @@ class AccountsReceivableSummary(ReceivablePayableReport): ) if self.filters.show_gl_balance: - gl_balance_map = get_gl_balance(self.filters.report_date, self.filters.company) + gl_balance_map = get_gl_balance(self.filters.report_date, self.filters.company, self.account_type) for party, party_dict in self.party_total.items(): if flt(party_dict.outstanding, self.currency_precision) == 0: @@ -206,11 +206,15 @@ class AccountsReceivableSummary(ReceivablePayableReport): ) -def get_gl_balance(report_date, company): +def get_gl_balance(report_date, company, account_type): + if account_type == "Payable": + balance_calc_fields = ["party", {"SUM": [{"SUB": ["credit", "debit"]}], "as": "balance"}] + else: + balance_calc_fields = ["party", {"SUM": [{"SUB": ["debit", "credit"]}], "as": "balance"}] return frappe._dict( frappe.db.get_all( "GL Entry", - fields=["party", "sum(debit - credit)"], + fields=balance_calc_fields, filters={"posting_date": ("<=", report_date), "is_cancelled": 0, "company": company}, group_by="party", as_list=1,