No commit activity in last 3 years
No release in over 3 years
This gem supports money conversions with historic exchange rates. Missing exchange rates are fetched from api.frankfurter.app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.8
~> 0.74.0
~> 0.17
~> 3.7

Runtime

~> 6.14, >= 6.14.0
 Project Readme

DailyExchangeRatesBank

Codeship Status for gapfish/daily_exchange_rates_bank

A bank for the money gem that determines exchange rates for any desired date. Missing exchange rates are fetched from api.frankfurter.app. This is configurable with the RATES_API_URL environment variable.

Installation

Add this line to your application's Gemfile:

gem 'daily_exchange_rates_bank'

and then execute:

$ bundle

Or install it yourself:

$ gem install daily_exchange_rates_bank

Usage

require 'daily_exchange_rates_bank'

bank = DailyExchangeRatesBank.new
Money.default_bank = bank

Money.new(100, 'EUR').exchange_to('USD')  # => Money.new(109, 'USD')
bank.get_rate('EUR', 'USD') # => 1.0935

date = Date.new(2019, 7, 1)
bank.exchange(100, 'EUR', 'USD', date) # => Money.new(113, 'USD')
bank.exchange_with(Money.new(100, 'EUR'), 'USD', date) # => Money.new(113, 'USD')

If you are using the money-rails gem, you can set the default_bank in config/initializers/money.rb:

MoneyRails.configure do |config|
  config.default_bank = DailyExchangeRatesBank.new

  # remaining config
end