You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, this is not a bug but by design. Quoting the README:
When the allocation yields a remainder, both split() and allocate() spread it on the first monies in the list, until the total adds up to the original Money. This is the algorithm suggested by Martin Fowler in his book Patterns of Enterprise Application Architecture. You can see that in the first example, where the first money gets 33.34 dollars while the others get 33.33 dollars.
In your example, the 545455 one gets < 120, so the allocator will never give it 120, even if it would make sense if we rounded everything.
If you think we can add an API for this use case, feel free to open a PR!
Activity
BenMorel commentedon Jan 31, 2026
Hi, this is not a bug but by design. Quoting the README:
In your example, the
545455one gets < 120, so the allocator will never give it 120, even if it would make sense if we rounded everything.If you think we can add an API for this use case, feel free to open a PR!
BenMorel commentedon Mar 29, 2026
New allocation modes are now available through AllocationMode in version 0.13.0, which might fit your use case:
zenas1210 commentedon Mar 29, 2026
Awesome!