Dated Exchange rates
I have requirements to exchange money based on exchange rates on specific dates. This is working fine currently by using manual converting code, rather than the Exchange rate stores. What I'm thinking is if this is something that could/should be brought into Money gem? I'm happy to implement it and raise a PR, but wanted to check first if its likely to be accepted.
I'm thinking that the interface should be extended, for the Store interface
def add_rate(iso_from, iso_to, rate, date: nil); end # Or normal default date = nil defaults
def get_rate(iso_from, iso_to, date: nil); end
And a Money class update
def exchange_to(other_currency, date: nil, &rounding_method)
Of corce lots of other changes will be needed as well, but raising this to get feedback on if the idea is even doable!
i feel this is more the domain of a separate gem. would be happy to host in the RubyMoney project and to contribute.
SE
On Mon, May 24, 2021 at 06:14, Ian Vaughan @.***> wrote:
I have requirements to exchange money based on exchange rates on specific dates. This is working fine currently by using manual converting code, rather than the Exchange rate stores. What I'm thinking is if this is something that could/should be brought into Money gem? I'm happy to implement it and raise a PR, but wanted to check first if its likely to be accepted.
I'm thinking that the interface should be extended, for the Store interface
def add_rate(iso_from, iso_to, rate, date: nil); end # Or normal default date = nil defaults def get_rate(iso_from, iso_to, date: nil); end
And a Money class update
def exchange_to(other_currency, date: nil, &rounding_method)
Of corce lots of other changes will be needed as well, but raising this to get feedback on if the idea is even doable!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I think it's valuable. Different sources could also be considered. (Often times you have not only buy and sell rates but such pairs in a multitude of different banks.) Dunno if it belongs together?
No opinion re. separate gem or not.
I'm not sure how a separate gem would work, as the interface needs to change. It might end up be a fork of this gem, which would need keeping up to date with the core. I will take a look at how that might be done though, as sounds interesting. If that does not seem workable, I will push a branch with ideas about bring it into the core gem.
you can extend the functionality or replace it using the separate gem
I had similar requirements for historical exchange rates, and I decided to extend money with a separate gem: money_with_date Maybe it solves your problems as well.