mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-12 17:51:20 +00:00
fix: Finance book filtering in financial statements (#20411)
* fix: Finance book filtering in financial statements * fix: Use IS NULL instead of ifnull
This commit is contained in:
@@ -14,6 +14,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
frappe.query_reports["Balance Sheet"]["filters"].push({
|
frappe.query_reports["Balance Sheet"]["filters"].push({
|
||||||
"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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
{
|
{
|
||||||
"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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -130,11 +130,11 @@ def get_account_type_based_gl_data(company, start_date, end_date, account_type,
|
|||||||
filters = frappe._dict(filters)
|
filters = frappe._dict(filters)
|
||||||
|
|
||||||
if filters.finance_book:
|
if filters.finance_book:
|
||||||
cond = " and finance_book = %s" %(frappe.db.escape(filters.finance_book))
|
cond = " AND (finance_book in (%s, '') OR finance_book IS NULL)" %(frappe.db.escape(filters.finance_book))
|
||||||
if filters.include_default_book_entries:
|
if filters.include_default_book_entries:
|
||||||
company_fb = frappe.db.get_value("Company", company, 'default_finance_book')
|
company_fb = frappe.db.get_value("Company", company, 'default_finance_book')
|
||||||
|
|
||||||
cond = """ and finance_book in (%s, %s)
|
cond = """ AND (finance_book in (%s, %s, '') OR finance_book IS NULL)
|
||||||
""" %(frappe.db.escape(filters.finance_book), frappe.db.escape(company_fb))
|
""" %(frappe.db.escape(filters.finance_book), frappe.db.escape(company_fb))
|
||||||
|
|
||||||
gl_sum = frappe.db.sql_list("""
|
gl_sum = frappe.db.sql_list("""
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ frappe.query_reports["Consolidated Financial Statement"] = {
|
|||||||
{
|
{
|
||||||
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,9 +389,9 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
|||||||
|
|
||||||
if filters.get("finance_book"):
|
if filters.get("finance_book"):
|
||||||
if filters.get("include_default_book_entries"):
|
if filters.get("include_default_book_entries"):
|
||||||
additional_conditions.append("finance_book in (%(finance_book)s, %(company_fb)s)")
|
additional_conditions.append("(finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)")
|
||||||
else:
|
else:
|
||||||
additional_conditions.append("finance_book in (%(finance_book)s)")
|
additional_conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
|
||||||
|
|
||||||
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
||||||
|
|
||||||
|
|||||||
@@ -408,9 +408,9 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
|||||||
|
|
||||||
if filters.get("finance_book"):
|
if filters.get("finance_book"):
|
||||||
if filters.get("include_default_book_entries"):
|
if filters.get("include_default_book_entries"):
|
||||||
additional_conditions.append("finance_book in (%(finance_book)s, %(company_fb)s)")
|
additional_conditions.append("(finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)")
|
||||||
else:
|
else:
|
||||||
additional_conditions.append("finance_book in (%(finance_book)s)")
|
additional_conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
|
||||||
|
|
||||||
if accounting_dimensions:
|
if accounting_dimensions:
|
||||||
for dimension in accounting_dimensions:
|
for dimension in accounting_dimensions:
|
||||||
|
|||||||
@@ -154,7 +154,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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
if filters.get("finance_book"):
|
if filters.get("finance_book"):
|
||||||
if filters.get("include_default_book_entries"):
|
if filters.get("include_default_book_entries"):
|
||||||
conditions.append("finance_book in (%(finance_book)s, %(company_fb)s)")
|
conditions.append("(finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)")
|
||||||
else:
|
else:
|
||||||
conditions.append("finance_book in (%(finance_book)s)")
|
conditions.append("finance_book in (%(finance_book)s)")
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
{
|
{
|
||||||
"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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
{
|
{
|
||||||
"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
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"formatter": erpnext.financial_statements.formatter,
|
"formatter": erpnext.financial_statements.formatter,
|
||||||
|
|||||||
@@ -103,9 +103,9 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
where lft >= %s and rgt <= %s)""" % (lft, rgt)
|
where lft >= %s and rgt <= %s)""" % (lft, rgt)
|
||||||
|
|
||||||
if filters.finance_book:
|
if filters.finance_book:
|
||||||
fb_conditions = " and finance_book = %(finance_book)s"
|
fb_conditions = " AND finance_book = %(finance_book)s"
|
||||||
if filters.include_default_book_entries:
|
if filters.include_default_book_entries:
|
||||||
fb_conditions = " and (finance_book in (%(finance_book)s, %(company_fb)s))"
|
fb_conditions = " AND (finance_book in (%(finance_book)s, %(company_fb)s, '') OR finance_book IS NULL)"
|
||||||
|
|
||||||
additional_conditions += fb_conditions
|
additional_conditions += fb_conditions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user