Skip to content

Fix positive repayments for negative balances - #19

Merged
twisti-dev merged 2 commits into
version/26.1from
fix/allow-positive-debt-repayments
May 14, 2026
Merged

twisti-dev merged 2 commits into
version/26.1from
fix/allow-positive-debt-repayments

Conversation

@Keviro

@Keviro Keviro commented May 14, 2026

Copy link
Copy Markdown
Contributor

Closes #18

Summary

  • only enforce the minimum-balance validation when a transaction reduces the receiver account balance
  • allow positive transactions to accounts that are still below the currency minimum after the transaction
  • keep negative balance-reducing transactions blocked so players cannot go further into debt

Validation

  • Reviewed the existing transaction persistence flow: failed persistence rolls back, and transfer sender failures are still mapped from ReceiverInsufficientFunds to SenderInsufficientFunds.
  • Manually checked use cases:
    • player with a negative balance receives money but remains negative: allowed
    • player with a negative balance receives enough money to become non-negative: allowed
    • player tries to send/pay money while that would put or keep their own account below the minimum: blocked as sender insufficient funds
    • direct negative transaction that would further reduce an account below minimum: blocked
    • receiver side of a normal transfer is positive: allowed, including when repaying debt

Notes

  • I could not run the Gradle test suite locally in this environment because the container has no network access to clone/resolve the repository, so the validation above is based on code inspection and branch diff review.

Copilot AI review requested due to automatic review settings May 14, 2026 18:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the microservice-side minimum-balance enforcement so that accounts with negative balances can receive positive transactions (repay debt) without being blocked, while still preventing transactions that would further reduce an account below the currency minimum.

Changes:

  • Gate the minimum-balance validation behind a “balance-decreasing transaction” condition (amount < 0).
  • Preserve existing rollback behavior by keeping the validation inside the same DB transaction flow.

@Keviro
Keviro requested a review from twisti-dev May 14, 2026 18:14
@twisti-dev
twisti-dev added this pull request to the merge queue May 14, 2026
Merged via the queue into version/26.1 with commit cd8f08a May 14, 2026
1 check passed
@twisti-dev
twisti-dev deleted the fix/allow-positive-debt-repayments branch May 14, 2026 18:44
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.

Transactions to players with a negative total balance: positive allowed, further negative blocked

3 participants