mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Co-authored-by: Sriram Krishnan <sriram@seafoodsouq.com> Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com>
8 lines
234 B
Ruby
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
|