Merge branch 'develop' into patch-5
diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
index c5c01c5..4ff2dd7 100644
--- a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
+++ b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
@@ -62,12 +62,12 @@
 
 		exchange_rate = get_exchange_rate("USD", "INR", "2016-01-30", "for_selling")
 		self.assertEqual(exchange_rate, 62.9)
-		
-		# Exchange rate as on 15th Dec, 2015, should be fetched from fixer.io
+
+		# Exchange rate as on 15th Dec, 2015
 		self.clear_cache()
 		exchange_rate = get_exchange_rate("USD", "INR", "2015-12-15", "for_selling")
 		self.assertFalse(exchange_rate == 60)
-		self.assertEqual(flt(exchange_rate, 3), 66.894)
+		self.assertEqual(flt(exchange_rate, 3), 66.999)
 
 	def test_exchange_rate_strict(self):
 		# strict currency settings
@@ -77,28 +77,17 @@
 		exchange_rate = get_exchange_rate("USD", "INR", "2016-01-01", "for_buying")
 		self.assertEqual(exchange_rate, 60.0)
 
-		# Will fetch from fixer.io
 		self.clear_cache()
 		exchange_rate = get_exchange_rate("USD", "INR", "2016-01-15", "for_buying")
-		self.assertEqual(flt(exchange_rate, 3), 67.79)
+		self.assertEqual(flt(exchange_rate, 3), 67.235)
 
 		exchange_rate = get_exchange_rate("USD", "INR", "2016-01-30", "for_selling")
 		self.assertEqual(exchange_rate, 62.9)
 
-		# Exchange rate as on 15th Dec, 2015, should be fetched from fixer.io
+		# Exchange rate as on 15th Dec, 2015
 		self.clear_cache()
 		exchange_rate = get_exchange_rate("USD", "INR", "2015-12-15", "for_buying")
-		self.assertEqual(flt(exchange_rate, 3), 66.894)
-
-		exchange_rate = get_exchange_rate("INR", "NGN", "2016-01-10", "for_selling")
-		self.assertEqual(exchange_rate, 65.1)
-
-		# NGN is not available on fixer.io so these should return 0
-		exchange_rate = get_exchange_rate("INR", "NGN", "2016-01-09", "for_selling")
-		self.assertEqual(exchange_rate, 0)
-
-		exchange_rate = get_exchange_rate("INR", "NGN", "2016-01-11", "for_selling")
-		self.assertEqual(exchange_rate, 0)
+		self.assertEqual(flt(exchange_rate, 3), 66.999)
 
 	def test_exchange_rate_strict_switched(self):
 		# Start with allow_stale is True
@@ -111,4 +100,4 @@
 		# Will fetch from fixer.io
 		self.clear_cache()
 		exchange_rate = get_exchange_rate("USD", "INR", "2016-01-15", "for_buying")
-		self.assertEqual(flt(exchange_rate, 3), 67.79)
+		self.assertEqual(flt(exchange_rate, 3), 67.235)
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index d5dbd4c..e49259e 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -93,21 +93,21 @@
 
 	try:
 		cache = frappe.cache()
-		key = "currency_exchange_rate_{0}:{1}:{2}".format(transaction_date,from_currency, to_currency)
+		key = "currency_exchange_rate_{0}:{1}:{2}".format(transaction_date, from_currency, to_currency)
 		value = cache.get(key)
 
 		if not value:
 			import requests
-			api_url = "https://frankfurter.app/{0}".format(transaction_date)
+			api_url = "https://api.exchangerate.host/convert"
 			response = requests.get(api_url, params={
-				"base": from_currency,
-				"symbols": to_currency
+				"date": transaction_date,
+				"from": from_currency,
+				"to": to_currency
 			})
 			# expire in 6 hours
 			response.raise_for_status()
-			value = response.json()["rates"][to_currency]
-
-			cache.set_value(key, value, expires_in_sec=6 * 60 * 60)
+			value = response.json()["result"]
+			cache.setex(name=key, time=21600, value=flt(value))
 		return flt(value)
 	except:
 		frappe.log_error(title="Get Exchange Rate")