From a04f5600483fea35cec317b16027df930475a48b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 24 Dec 2025 13:11:28 +0530 Subject: [PATCH] =?UTF-8?q?fix(accounts-payable-summary):=20add=20Show=20G?= =?UTF-8?q?L=20Balance=20check=20similar=20to=20A=E2=80=A6=20(backport=20#?= =?UTF-8?q?50802)=20(#50805)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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..19d2faddf44 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(credit - debit) AS balance"] + else: + balance_calc_fields = ["party", "SUM(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,