From 1da808a125fd69b91dc868e6aec31165a461771d Mon Sep 17 00:00:00 2001 From: dsnetprofitxl <139927603+dsnetprofitxl@users.noreply.github.com> Date: Tue, 3 Oct 2023 20:51:28 -0400 Subject: [PATCH] fix: change currency exchange API to api.frankfurter.app (cherry picked from commit 76919c4af2c127b19339fef9968dc3954e095d4c) --- erpnext/setup/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py index 5a019c68c9d3..5c7a56323741 100644 --- a/erpnext/setup/utils.py +++ b/erpnext/setup/utils.py @@ -113,13 +113,12 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No if not value: import requests - api_url = "https://api.exchangerate.host/convert" - response = requests.get( - api_url, params={"date": transaction_date, "from": from_currency, "to": to_currency} - ) + api_url = f"https://api.frankfurter.app/{transaction_date}" + response = requests.get(api_url, params={"from": from_currency, "to": to_currency}) + # expire in 6 hours response.raise_for_status() - value = response.json()["result"] + value = response.json()["rates"][to_currency] cache.setex(name=key, time=21600, value=flt(value)) return flt(value) except Exception: