Skip to content

Commit

Permalink
BugFix: Fetching exchange rate for last date except for same day (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shwetabhk authored Apr 20, 2023
1 parent fe28a90 commit 0f1f4b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions qbosdk/apis/exchange_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ExchangeRates(ApiBase):

GET_EXCHANGE_RATES = "/query?query=select * from ExchangeRate where AsOfDate = '{0}' STARTPOSITION " \
"{1} MAXRESULTS 1000"
GET_EXCHANGE_RATES_BY_SOURCE = "/exchangerate?sourcecurrencycode={0}"
GET_EXCHANGE_RATES_BY_SOURCE = "/exchangerate?sourcecurrencycode={0}&asofdate={1}"

def get(self, as_of_date: str = None):
"""
Expand All @@ -30,5 +30,6 @@ def get_by_source(self, source_currency_code: str):
:param as_of_date: date to get rates for (1 day prior if left empty)
:return: List of Dicts for exchange rates
"""
as_of_date = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
return self._get_request(
'ExchangeRate', self.GET_EXCHANGE_RATES_BY_SOURCE.format(source_currency_code))
'ExchangeRate', self.GET_EXCHANGE_RATES_BY_SOURCE.format(source_currency_code, as_of_date))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='qbosdk',
version='0.16.0',
version='0.16.1',
author='Shwetabh Kumar',
author_email='[email protected]',
description='Python SDK for accessing Quickbooks Online APIs',
Expand Down

0 comments on commit 0f1f4b8

Please sign in to comment.