From 358083d759e4142a0a003fd361d332f8912ccae7 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Fri, 19 Dec 2025 13:50:20 +0530 Subject: [PATCH] fix: include entries with null finance book --- erpnext/accounts/utils.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 9009aef40a9..b1858db4772 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -303,14 +303,23 @@ def get_balance_on( if finance_book: if default_finance_book and include_default_fb_balances: cond.append( - f"gle.finance_book IN ({frappe.db.escape(finance_book)}, {frappe.db.escape(default_finance_book)})" + f"""(gle.finance_book IN ( + {frappe.db.escape(finance_book)}, + {frappe.db.escape(default_finance_book)} + )OR gle.finance_book IS NULL + )""" ) else: - cond.append(f"gle.finance_book = {frappe.db.escape(finance_book)}") + cond.append(f"(gle.finance_book = {frappe.db.escape(finance_book)} OR gle.finance_book IS NULL)") elif default_finance_book and include_default_fb_balances: # No finance book passed → fall back to default - cond.append(f"gle.finance_book = {frappe.db.escape(default_finance_book)}") + cond.append( + f"""( + gle.finance_book = {frappe.db.escape(default_finance_book)} + OR gle.finance_book IS NULL + )""" + ) if account or (party_type and party) or account_type: precision = get_currency_precision()