fix: handle finance book properly in trial balance and general ledger (#35136)
fix: handle finance book properly in trial balance and general ledger [v14] (#35136)
fix: handle FBs properly in general ledger and trial balance
(cherry picked from commit 344c339484)
Co-authored-by: Anand Baburajan <anandbaburajan@gmail.com>
This commit is contained in:
@@ -524,11 +524,22 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
|||||||
additional_conditions.append("cost_center in %(cost_center)s")
|
additional_conditions.append("cost_center in %(cost_center)s")
|
||||||
|
|
||||||
if filters.get("include_default_book_entries"):
|
if filters.get("include_default_book_entries"):
|
||||||
additional_conditions.append(
|
if filters.get("finance_book"):
|
||||||
"(finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)"
|
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:
|
||||||
|
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)")
|
||||||
else:
|
else:
|
||||||
additional_conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
|
if filters.get("finance_book"):
|
||||||
|
additional_conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
|
||||||
|
else:
|
||||||
|
additional_conditions.append("(finance_book IS NULL)")
|
||||||
|
|
||||||
if accounting_dimensions:
|
if accounting_dimensions:
|
||||||
for dimension in accounting_dimensions:
|
for dimension in accounting_dimensions:
|
||||||
|
|||||||
@@ -176,7 +176,8 @@ frappe.query_reports["General Ledger"] = {
|
|||||||
{
|
{
|
||||||
"fieldname": "include_default_book_entries",
|
"fieldname": "include_default_book_entries",
|
||||||
"label": __("Include Default Book Entries"),
|
"label": __("Include Default Book Entries"),
|
||||||
"fieldtype": "Check"
|
"fieldtype": "Check",
|
||||||
|
"default": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "show_cancelled_entries",
|
"fieldname": "show_cancelled_entries",
|
||||||
|
|||||||
@@ -287,13 +287,23 @@ def get_conditions(filters):
|
|||||||
if filters.get("project"):
|
if filters.get("project"):
|
||||||
conditions.append("project in %(project)s")
|
conditions.append("project in %(project)s")
|
||||||
|
|
||||||
if filters.get("finance_book"):
|
if filters.get("include_default_book_entries"):
|
||||||
if filters.get("include_default_book_entries"):
|
if filters.get("finance_book"):
|
||||||
conditions.append(
|
if filters.get("company_fb") and cstr(filters.get("finance_book")) != cstr(
|
||||||
"(finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)"
|
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:
|
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"):
|
if not filters.get("show_cancelled_entries"):
|
||||||
conditions.append("is_cancelled = 0")
|
conditions.append("is_cancelled = 0")
|
||||||
|
|||||||
@@ -157,12 +157,23 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
if filters.project:
|
if filters.project:
|
||||||
additional_conditions += " and project = %(project)s"
|
additional_conditions += " and project = %(project)s"
|
||||||
|
|
||||||
|
company_fb = frappe.db.get_value("Company", filters.company, "default_finance_book")
|
||||||
|
|
||||||
if filters.get("include_default_book_entries"):
|
if filters.get("include_default_book_entries"):
|
||||||
additional_conditions += (
|
if filters.get("finance_book"):
|
||||||
" AND (finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)"
|
if company_fb and cstr(filters.get("finance_book")) != cstr(company_fb):
|
||||||
)
|
frappe.throw(
|
||||||
|
_("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)"
|
||||||
|
else:
|
||||||
|
additional_conditions += " AND (finance_book in (%(company_fb)s) OR finance_book IS NULL)"
|
||||||
else:
|
else:
|
||||||
additional_conditions += " AND (finance_book in (%(finance_book)s, '') OR finance_book IS NULL)"
|
if filters.get("finance_book"):
|
||||||
|
additional_conditions += " AND (finance_book in (%(finance_book)s) OR finance_book IS NULL)"
|
||||||
|
else:
|
||||||
|
additional_conditions += " AND (finance_book IS NULL)"
|
||||||
|
|
||||||
accounting_dimensions = get_accounting_dimensions(as_list=False)
|
accounting_dimensions = get_accounting_dimensions(as_list=False)
|
||||||
|
|
||||||
@@ -174,7 +185,7 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
"year_start_date": filters.year_start_date,
|
"year_start_date": filters.year_start_date,
|
||||||
"project": filters.project,
|
"project": filters.project,
|
||||||
"finance_book": filters.finance_book,
|
"finance_book": filters.finance_book,
|
||||||
"company_fb": frappe.db.get_value("Company", filters.company, "default_finance_book"),
|
"company_fb": company_fb,
|
||||||
}
|
}
|
||||||
|
|
||||||
if accounting_dimensions:
|
if accounting_dimensions:
|
||||||
|
|||||||
Reference in New Issue
Block a user