Convert everything to Decimal
This commit is contained in:
parent
9fc5d2f4d7
commit
781de3c772
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue