Convert everything to Decimal

This commit is contained in:
Mark Veidemanis 2022-11-11 07:20:00 +00:00
parent 9fc5d2f4d7
commit 781de3c772
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 2 additions and 2 deletions

View File

@ -73,11 +73,11 @@ def to_currency(direction, account, amount, from_currency, to_currency):
except GenericAPIError as e:
log.error(f"Error getting currencies and inverted currencies: {e}")
return None
price = prices["prices"][0][price_index][0]["price"]
price = D(prices["prices"][0][price_index][0]["price"])
# If we had to flip base and quote, we need to use the reciprocal of the price
if inverted:
price = D(1.0) / D(price)
price = D(1.0) / price
# Convert the amount to the destination currency
converted = D(amount) * price