-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
allocateWithRemainder() performs no allocation #68
Comments
Hi, I did not think that the previous behaviour could be useful, sorry for "fixing" it! One solution I can see is to provide both behaviours, either under different method names, or behind a flag. I'm open to suggestions regarding naming! Maybe even both implementations could be merged into In the meantime, I guess you could just copy the old implementation in your own codebase? |
Thanks Ben, I'll stay on v0.5.3 for now, but will look into replicating the old implementation in my own codebase as you suggested. 👍 |
I'd like to re-introduce the old behaviour in some form though, do you know how we could name the old and the new behaviour? |
Sorry for the late reply, I ended up adding the needed functionality in an external helper named |
Prior to this change,
Money::of('1', 'USD')->allocateWithRemainder(400, 0, 40, 20, 2)
returned86, 0, 8, 4, 0, 2
(as cents wrapped in Money instances of course), and I distributed the 2 cents remainder by adding one to the 86 figure, one to the 8 figure.After the change,
Money::of('1', 'USD')->allocateWithRemainder(400, 0, 40, 20, 2)
returns0, 0, 0, 0, 0, 100
.I understand the reason behind this, however
allocateWithRemainder()
is no longer helpful in cases like the above, as it does no allocation at all.Is there anything within the library that can help me with that? Or should I resort to allocating the 100 cents myself (probably by weight)?
Thanks!
The text was updated successfully, but these errors were encountered: