Fixer Always Fetches Latest Exchange Rate Even When Date is Specified (#10596) (#10597)
* test that confirms the bug. Same test should pass after fix
* make use of correct api url
diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
index d4c9df3..a477379 100644
--- a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
+++ b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
@@ -44,4 +44,5 @@
# Exchange rate as on 15th Dec, 2015, should be fetched from fixer.io
exchange_rate = get_exchange_rate("USD", "INR", "2015-12-15")
- self.assertFalse(exchange_rate==60)
\ No newline at end of file
+ self.assertFalse(exchange_rate == 60)
+ self.assertEqual(exchange_rate, 66.894)
\ No newline at end of file
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index 888099f..bdbf3f4 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -83,7 +83,8 @@
if not value:
import requests
- response = requests.get("http://api.fixer.io/latest", params={
+ api_url = "http://api.fixer.io/{0}".format(transaction_date)
+ response = requests.get(api_url, params={
"base": from_currency,
"symbols": to_currency
})