mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Implement Synth as an exchange rate provider (#574)
* Implement Synth as an exchange rate provider * Add assertions to provider interface test * Assert the correct provider error is raised * Remove unnecessary parens
This commit is contained in:
parent
a1b25f1c5b
commit
7ae25dd6df
16 changed files with 310 additions and 34 deletions
|
@ -26,7 +26,7 @@ class Money
|
|||
# TODO: Replace with injected rate store
|
||||
def exchange_to(other_currency, date = Date.current)
|
||||
return self if @currency == Money::Currency.new(other_currency)
|
||||
rate = ExchangeRate.get_rate(@currency, other_currency, date)
|
||||
rate = ExchangeRate.find_rate(from: @currency, to: other_currency, date: date)
|
||||
return nil if rate.nil?
|
||||
Money.new(@amount * rate.rate, other_currency)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue