From 7f8a259beb22bced6097ff1edef7605b93815b46 Mon Sep 17 00:00:00 2001 From: tundebabzy Date: Thu, 31 Aug 2017 10:00:15 +0100 Subject: [PATCH] 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 --- .../setup/doctype/currency_exchange/test_currency_exchange.py | 3 ++- erpnext/setup/utils.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py index d4c9df380f..a477379ded 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 @@ class TestCurrencyExchange(unittest.TestCase): # 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 888099fc4f..bdbf3f4ec2 100644 --- a/erpnext/setup/utils.py +++ b/erpnext/setup/utils.py @@ -83,7 +83,8 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None): 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 })