Skip to content

Fork 202604#826

Open
kdocki wants to merge 5 commits into
moneyphp:masterfrom
dsq-technology:fork-202604
Open

Fork 202604#826
kdocki wants to merge 5 commits into
moneyphp:masterfrom
dsq-technology:fork-202604

Conversation

@kdocki

@kdocki kdocki commented Apr 30, 2026

Copy link
Copy Markdown

Usually when we allocate it is all positive, example break apart $100 ... 50/50 (which is $50 / $50). This fork was made to handle an real world edge case we ran into where need to allocate across "debt & credits owed."

So imagine you have $100 and you want to allocate it [2, -1]? This may seem strange but effectively this is saying, I'll give you $200 and you owe me $100 (mathematically $100 = $200 - $100). It is still a valid allocation although a bit of a brain twister until you release that it's dealing with credit/debt so not all the money has been paid between 2 different parties that are settling an account balance.

tabennett and others added 5 commits January 12, 2021 12:13
…gative (this is an unnecessary check and prevents valid use cases).
Restores the zero-total guard that was removed in 990f29e while still
allowing negative ratios as long as the total is non-zero. Without this,
allocate([0, 0]) hit a DivisionByZeroError in BcMathCalculator::share
instead of the documented InvalidArgumentException.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@frederikbosch

Copy link
Copy Markdown
Member

Please include some tests and rebase.

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

Successfully merging this pull request may close these issues.

4 participants