Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support an allocate method that is symmetrical with positive/negative amounts #190

Open
rvanmelle opened this issue Oct 3, 2019 · 0 comments

Comments

@rvanmelle
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant