Skip to content

Commit

Permalink
fix: handle empty FBs properly in TB and GL [v14] (backport #35189) (#…
Browse files Browse the repository at this point in the history
…35192)

fix: handle empty FBs properly in TB and GL [v14] (#35189)

fix: handle empty FBs properly in TB and GL
(cherry picked from commit ed5f39c)

Co-authored-by: Anand Baburajan <anandbaburajan@gmail.com>
(cherry picked from commit e2af66c)
  • Loading branch information
mergify[bot] committed May 6, 2023
1 parent ef2d4fe commit e14dcdc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
12 changes: 8 additions & 4 deletions erpnext/accounts/report/financial_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,18 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
else:
additional_conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
additional_conditions.append(
"(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
)
else:
additional_conditions.append("(finance_book in (%(company_fb)s) OR finance_book IS NULL)")
additional_conditions.append("(finance_book in (%(company_fb)s, '') OR finance_book IS NULL)")
else:
if filters.get("finance_book"):
additional_conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
additional_conditions.append(
"(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
)
else:
additional_conditions.append("(finance_book IS NULL)")
additional_conditions.append("(finance_book in ('') OR finance_book IS NULL)")

if accounting_dimensions:
for dimension in accounting_dimensions:
Expand Down
8 changes: 4 additions & 4 deletions erpnext/accounts/report/general_ledger/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,14 @@ def get_conditions(filters):
_("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")
Expand Down
10 changes: 6 additions & 4 deletions erpnext/accounts/report/trial_balance/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,16 @@ def get_rootwise_opening_balances(filters, report_type):
_("To use a different finance book, please uncheck 'Include Default Book Entries'")
)
else:
additional_conditions += " AND (finance_book in (%(finance_book)s) OR finance_book IS NULL)"
additional_conditions += (
" AND (finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
)
else:
additional_conditions += " AND (finance_book in (%(company_fb)s) OR finance_book IS NULL)"
additional_conditions += " AND (finance_book in (%(company_fb)s, '') OR finance_book IS NULL)"
else:
if filters.get("finance_book"):
additional_conditions += " AND (finance_book in (%(finance_book)s) OR finance_book IS NULL)"
additional_conditions += " AND (finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
else:
additional_conditions += " AND (finance_book IS NULL)"
additional_conditions += " AND (finance_book in ('') OR finance_book IS NULL)"

accounting_dimensions = get_accounting_dimensions(as_list=False)

Expand Down

0 comments on commit e14dcdc

Please sign in to comment.