Merge pull request #15986 from rohitwaghchaure/added_currency_filter_in_consolidated_report

Added currency filter in consolidated financial statement report
diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
index 91a06f4..7b373f0 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
@@ -43,6 +43,13 @@
 			"reqd": 1
 		},
 		{
+			"fieldname": "presentation_currency",
+			"label": __("Currency"),
+			"fieldtype": "Select",
+			"options": erpnext.get_presentation_currency_list(),
+			"default": frappe.defaults.get_user_default("Currency")
+		},
+		{
 			"fieldname":"accumulated_in_group_company",
 			"label": __("Accumulated Values in Group Company"),
 			"fieldtype": "Check",
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 2d13469..383d4c0 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
@@ -5,6 +5,7 @@
 import frappe, erpnext
 from frappe import _
 from frappe.utils import flt, cint
+from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency
 from erpnext.accounts.report.financial_statements import get_fiscal_year_data, sort_accounts
 from erpnext.accounts.report.balance_sheet.balance_sheet import (get_provisional_profit_loss,
 	check_opening_balance, get_chart_data)
@@ -48,7 +49,7 @@
 	data.extend(liability or [])
 	data.extend(equity or [])
 
-	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
+	company_currency = get_company_currency(filters)
 	provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
 		companies, filters.get('company'), company_currency, True)
 
@@ -59,7 +60,7 @@
 			"account_name": "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'",
 			"account": "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'",
 			"warn_if_negative": True,
-			"currency": frappe.get_cached_value('Company',  filters.company,  "default_currency")
+			"currency": company_currency
 		}
 		for company in companies:
 			unclosed[company] = opening_balance
@@ -92,7 +93,7 @@
 	return data, None, chart
 
 def get_income_expense_data(companies, fiscal_year, filters):
-	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency")
+	company_currency = get_company_currency(filters)
 	income = get_data(companies, "Income", "Credit", fiscal_year, filters, True)
 
 	expense = get_data(companies, "Expense", "Debit", fiscal_year, filters, True)
@@ -107,7 +108,7 @@
 	income, expense, net_profit_loss = get_income_expense_data(companies, fiscal_year, filters)
 
 	data = []
-	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency")
+	company_currency = get_company_currency(filters)
 
 	for cash_flow_account in cash_flow_accounts:
 		section_data = []
@@ -185,6 +186,7 @@
 			"fieldname": company,
 			"label": company,
 			"fieldtype": "Currency",
+			"options": "currency",
 			"width": 150
 		})
 
@@ -216,7 +218,8 @@
 	return out
 
 def get_company_currency(filters=None):
-	return frappe.get_cached_value('Company',  filters.get('company'),  "default_currency")
+	return (filters.get('presentation_currency')
+		or frappe.get_cached_value('Company',  filters.company,  "default_currency"))
 
 def calculate_values(accounts_by_name, gl_entries_by_account, companies, fiscal_year, filters):
 	for entries in gl_entries_by_account.values():
@@ -346,6 +349,9 @@
 		},
 		as_dict=True)
 
+	if filters and filters.get('presentation_currency'):
+		convert_to_presentation_currency(gl_entries, get_currency(filters))
+
 	for entry in gl_entries:
 		key = entry.account_number or entry.account_name
 		validate_entries(key, entry, accounts_by_name)