fix: handle finance book properly in trial balance and general ledger (#35085)

* fix: get default fb properly and handle different fb and default fb case

* chore: minor UX improvement

* fix: handle FBs properly in general ledger
This commit is contained in:
Anand Baburajan
2023-05-02 20:58:22 +05:30
committed by GitHub
parent 7e24215b3a
commit 6864b11f83
4 changed files with 36 additions and 11 deletions

View File

@@ -244,13 +244,23 @@ def get_conditions(filters):
if filters.get("project"):
conditions.append("project in %(project)s")
if filters.get("finance_book"):
if filters.get("include_default_book_entries"):
conditions.append(
"(finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)"
)
if filters.get("include_default_book_entries"):
if filters.get("finance_book"):
if filters.get("company_fb") and cstr(filters.get("finance_book")) != cstr(
filters.get("company_fb")
):
frappe.throw(
_("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)")
else:
conditions.append("finance_book in (%(finance_book)s)")
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)")
else:
conditions.append("(finance_book IS NULL)")
if not filters.get("show_cancelled_entries"):
conditions.append("is_cancelled = 0")