diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index 39f47710c3..380e3a2fbd 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -365,10 +365,10 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters): company_finance_book = erpnext.get_default_finance_book(filters.get("company")) if not filters.get('finance_book') or (filters.get('finance_book') == company_finance_book): - additional_conditions.append("finance_book in ('%s', '')" % + additional_conditions.append("ifnull(finance_book, '') in ('%s', '')" % frappe.db.escape(company_finance_book)) elif filters.get("finance_book"): - additional_conditions.append("finance_book = '%s' " % + additional_conditions.append("ifnull(finance_book, '') = '%s' " % frappe.db.escape(filters.get("finance_book"))) return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else "" diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 7300b9c475..f8eec9ea70 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -380,10 +380,10 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters): company_finance_book = erpnext.get_default_finance_book(filters.get("company")) if not filters.get('finance_book') or (filters.get('finance_book') == company_finance_book): - additional_conditions.append("finance_book in ('%s', '')" % + additional_conditions.append("ifnull(finance_book, '') in ('%s', '')" % frappe.db.escape(company_finance_book)) elif filters.get("finance_book"): - additional_conditions.append("finance_book = '%s' " % + additional_conditions.append("ifnull(finance_book, '') = '%s' " % frappe.db.escape(filters.get("finance_book"))) return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""