Skip to content

fix(money): keep negative allocation parts summing to the amount - #645

Merged
DigiBanks99 merged 1 commit into
mainfrom
fix/616-money-allocate-negative-remainder
Nov 15, 2026
Merged

DigiBanks99 merged 1 commit into
mainfrom
fix/616-money-allocate-negative-remainder

Conversation

@DigiBanks99

Copy link
Copy Markdown
Owner

Summary

  • Money.Allocate(int parts) dropped the remainder cents for negative amounts, so -R100.00 in 3 parts summed to -R99.99.
  • Remainder cents now move each part away from zero, so -R100.00 gives -R33.34, -R33.33, -R33.33.
  • Positive allocation is unchanged. Money API reference documents the negative case.

Acceptance criteria

  • Allocating a negative amount gives parts that add up to the original. Verified by GivenNegativeMoney_WhenAllocatingWithRemainder and GivenNegativeMoneyWithOddCents_WhenAllocatingWithRemainder. Both fail on the old code and pass with the fix.
  • A test covers it alongside the existing positive allocation tests (MoneyAllocationTests).
  • docs/reference/money-api.md says how negative amounts are allocated.

Verification: dotnet test on Menlo.Lib.Tests passes (272/272). dotnet format --verify-no-changes is clean on the changed files.

Closes #616

🤖 Generated with Claude Code

Allocate(int parts) added the remainder cents only when the remainder
was positive. A negative amount has a negative remainder, so the cents
were dropped: -R100.00 in 3 parts summed to -R99.99.

Remainder cents now move each part away from zero in the amount's
direction, so -R100.00 gives -R33.34, -R33.33, -R33.33. Document this
in the Money API reference.

Implements #616

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@DigiBanks99
DigiBanks99 enabled auto-merge (rebase) November 15, 2026 05:58
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@DigiBanks99
DigiBanks99 merged commit f9605bb into main Nov 15, 2026
13 checks passed
@DigiBanks99
DigiBanks99 deleted the fix/616-money-allocate-negative-remainder branch November 15, 2026 06:03
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.

Money.Allocate loses a cent when splitting a negative amount

1 participant