1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00
Maybe/app/models/exchange_rate.rb
Sriram 1968fb0145
Add currency to account form to support multiple currencies (#481)
Co-authored-by: Sriram Krishnan <sriram@seafoodsouq.com>
Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com>
2024-02-26 09:50:38 -05:00

8 lines
234 B
Ruby

class ExchangeRate < ApplicationRecord
def self.convert(from, to, amount)
return amount unless EXCHANGE_RATE_ENABLED
rate = ExchangeRate.find_by(base_currency: from, converted_currency: to)
amount * rate.rate
end
end