mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Add multi currency demo accounts (#530)
This commit is contained in:
parent
90d0cc0c39
commit
ed89ad522d
3 changed files with 72 additions and 9 deletions
|
@ -3,6 +3,12 @@ class ExchangeRate < ApplicationRecord
|
|||
return amount unless EXCHANGE_RATE_ENABLED
|
||||
|
||||
rate = ExchangeRate.find_by(base_currency: from, converted_currency: to)
|
||||
amount * rate.rate
|
||||
|
||||
# TODO: Handle the case where the rate is not found
|
||||
if rate.nil?
|
||||
amount # Silently handle the error by returning the original amount
|
||||
else
|
||||
amount * rate.rate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue