[FEATURE REQUEST] monetize with_model_rounding_mode
asavageiv opened this issue · 1 comments
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?
I think this works better in money as you suggested in that repo. I welcome either PR