The current default :roundrobin allocator allows pennies to fall in different directions depending on whether the amounts are positive or negative. This is neither incorrect or correct, but could be surprising to money gem clients.
[12] pry(main)> Money.new(100, "USD").allocate([1 - fr, fr])
=> [#<Money value:11.51 currency:USD>, #<Money value:88.49 currency:USD>]
[13] pry(main)> Money.new(-100, "USD").allocate([1 - fr, fr])
=> [#<Money value:-11.50 currency:USD>, #<Money value:-88.50 currency:USD>]
A potential suggestion is introduce a new allocation strategy called :balanced or something :symmetrical that guarantees the same result will be produced with positive and negative amounts.
A bigger question is whether the current default of :roundrobin can be replaced with this new default... this could break the contract that they money gem has with existing customers.
The current default
:roundrobinallocator allows pennies to fall in different directions depending on whether the amounts are positive or negative. This is neither incorrect or correct, but could be surprising to money gem clients.A potential suggestion is introduce a new allocation strategy called
:balancedor something:symmetricalthat guarantees the same result will be produced with positive and negative amounts.A bigger question is whether the current default of
:roundrobincan be replaced with this new default... this could break the contract that they money gem has with existing customers.