From 9b8d6fe4119ae6cb7b913ef800e99d9c5d739518 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 1 Dec 2022 13:38:41 +0530 Subject: [PATCH 1/3] fix: key error while filtering on date range and different currency --- erpnext/accounts/report/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index eed5836773..81fea28515 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -28,7 +28,7 @@ def get_currency(filters): filters["presentation_currency"] if filters.get("presentation_currency") else company_currency ) - report_date = filters.get("to_date") + report_date = filters.get("period_end_date") if not report_date: fiscal_year_to_date = get_from_and_to_date(filters.get("to_fiscal_year"))["to_date"] From 19db7e2989f36d3dd2f6fce1ea03e21199665b21 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 6 Dec 2022 13:42:33 +0530 Subject: [PATCH 2/3] fix: replace sql code with fields list in get_cached_value --- erpnext/accounts/doctype/fiscal_year/fiscal_year.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index 4592421304..c3e83ad168 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -169,5 +169,6 @@ def auto_create_fiscal_year(): def get_from_and_to_date(fiscal_year): - fields = ["year_start_date as from_date", "year_end_date as to_date"] - return frappe.get_cached_value("Fiscal Year", fiscal_year, fields, as_dict=1) + fields = ["year_start_date", "year_end_date"] + cached_results = frappe.get_cached_value("Fiscal Year", fiscal_year, fields, as_dict=1) + return dict(from_date=cached_results.year_start_date, to_date=cached_results.year_end_date) From a6794c36062acb7963a387271e2f4b4800643a68 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 6 Dec 2022 13:44:54 +0530 Subject: [PATCH 3/3] fix: key error on p/l and balance sheet reports on foreign currency --- erpnext/accounts/report/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py index 81fea28515..d3cd29013f 100644 --- a/erpnext/accounts/report/utils.py +++ b/erpnext/accounts/report/utils.py @@ -28,7 +28,7 @@ def get_currency(filters): filters["presentation_currency"] if filters.get("presentation_currency") else company_currency ) - report_date = filters.get("period_end_date") + report_date = filters.get("to_date") or filters.get("period_end_date") if not report_date: fiscal_year_to_date = get_from_and_to_date(filters.get("to_fiscal_year"))["to_date"]