fix: handle empty FBs properly in TB and GL [develop] (#35190)
fix: handle empty FBs properly in TB and GL
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 76a01db..8a47e1c 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -546,12 +546,13 @@
)
query = query.where(
- (gl_entry.finance_book.isin([cstr(filters.finance_book), cstr(company_fb)]))
+ (gl_entry.finance_book.isin([cstr(filters.finance_book), cstr(company_fb), ""]))
| (gl_entry.finance_book.isnull())
)
else:
query = query.where(
- (gl_entry.finance_book.isin([cstr(filters.finance_book)])) | (gl_entry.finance_book.isnull())
+ (gl_entry.finance_book.isin([cstr(filters.finance_book), ""]))
+ | (gl_entry.finance_book.isnull())
)
if accounting_dimensions:
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index 0b05c11..d47e3da 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -253,14 +253,14 @@
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
else:
- conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
+ conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
else:
- conditions.append("(finance_book in (%(company_fb)s) OR finance_book IS NULL)")
+ conditions.append("(finance_book in (%(company_fb)s, '') OR finance_book IS NULL)")
else:
if filters.get("finance_book"):
- conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
+ conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
else:
- conditions.append("(finance_book IS NULL)")
+ conditions.append("(finance_book in ('') OR finance_book IS NULL)")
if not filters.get("show_cancelled_entries"):
conditions.append("is_cancelled = 0")
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py
index 57dac2a..22bebb7 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.py
+++ b/erpnext/accounts/report/trial_balance/trial_balance.py
@@ -256,12 +256,12 @@
)
opening_balance = opening_balance.where(
- (closing_balance.finance_book.isin([cstr(filters.finance_book), cstr(company_fb)]))
+ (closing_balance.finance_book.isin([cstr(filters.finance_book), cstr(company_fb), ""]))
| (closing_balance.finance_book.isnull())
)
else:
opening_balance = opening_balance.where(
- (closing_balance.finance_book.isin([cstr(filters.finance_book)]))
+ (closing_balance.finance_book.isin([cstr(filters.finance_book), ""]))
| (closing_balance.finance_book.isnull())
)