[fix] format fiscal year docname to proper date before using  🤦 (#14955)

diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
index 92da787..a00aebe 100644
--- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
@@ -109,3 +109,14 @@
 			new_fy.insert(ignore_permissions=True)
 		except frappe.NameError:
 			pass
+
+def get_from_and_to_date(fiscal_year):
+	from_and_to_date_tuple = frappe.db.sql("""select year_start_date, year_end_date
+		from `tabFiscal Year` where name=%s""", (fiscal_year))[0]
+
+	from_and_to_date = {
+		"from_date": from_and_to_date_tuple[0],
+		"to_date": from_and_to_date_tuple[1]
+	}
+
+	return from_and_to_date
diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py
index 4490398..0fe80e8 100644
--- a/erpnext/accounts/report/utils.py
+++ b/erpnext/accounts/report/utils.py
@@ -1,7 +1,8 @@
 import frappe
 from erpnext import get_company_currency, get_default_company
 from erpnext.setup.utils import get_exchange_rate
-from frappe.utils import cint
+from erpnext.accounts.doctype.fiscal_year.fiscal_year import get_from_and_to_date
+from frappe.utils import cint, get_datetime_str, formatdate
 
 __exchange_rates = {}
 P_OR_L_ACCOUNTS = list(
@@ -26,7 +27,12 @@
 	company = get_appropriate_company(filters)
 	company_currency = get_company_currency(company)
 	presentation_currency = filters['presentation_currency'] if filters.get('presentation_currency') else company_currency
-	report_date = filters.get('to_date') or filters.get('to_fiscal_year')
+
+	report_date = filters.get('to_date')
+
+	if not report_date:
+		fiscal_year_to_date = get_from_and_to_date(filters.get('to_fiscal_year')).to_date
+		report_date = formatdate(get_datetime_str(fiscal_year_to_date), "dd-MM-yyyy")
 
 	currency_map = dict(company=company, company_currency=company_currency, presentation_currency=presentation_currency, report_date=report_date)
 
@@ -58,6 +64,7 @@
 	:param to_currency: Quote currency
 	:return: Retrieved exchange rate
 	"""
+
 	rate = __exchange_rates.get('{0}-{1}@{2}'.format(from_currency, to_currency, date))
 	if not rate:
 		rate = get_exchange_rate(from_currency, to_currency, date) or 1