RubyMoney/money

[FEATURE REQUEST] Per-instance rounding_mode

asavageiv opened this issue · 1 comments

This request is the same as RubyMoney/money-rails#694

Our company operates in multiple countries performing transactions with Money with different rounding modes per country. Right now, our code is littered with blocks like this:

Money.with_rounding_mode(country.rounding_mode) do
money_instance.format # or some other money calculation
end
This is error prone and tedious. It's easy to forget to add the block everywhere and it's not safe for async code because with_rounding_mode uses Thread.current.

I think a solution to this would be to have per-instance rounding modes on Money objects and support for with_model_rounding_mode on monetize.

It could be an error to perform an operation on two values with different rounding modes.

What do you think about this approach? Is there a better one?

seems reasonable to me. go ahead and whip up a PR if you haven't already.