Add multi currency demo accounts (#530)

This commit is contained in:
Zach Gollwitzer
2024-03-07 17:46:36 -05:00
committed by GitHub
parent 90d0cc0c39
commit ed89ad522d
3 changed files with 72 additions and 9 deletions

View File

@@ -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