Skip to content

Fix: Allow fund transfers of exact account balance#9

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1759431345-fix-exact-balance-transfer
Open

Fix: Allow fund transfers of exact account balance#9
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1759431345-fix-exact-balance-transfer

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Fix: Allow fund transfers of exact account balance

Summary

Fixes a critical bug where fund transfers were incorrectly rejected when the transfer amount exactly equals the account balance.

Bug scenario: Account with R$ 5,000.00 balance cannot transfer exactly R$ 5,000.00 - throws "insufficient balance" error.

Root cause: Commit d673b8d (earlier today) changed the balance validation from < 0 to <= 0, which incorrectly rejects valid transfers where balance == amount.

Fix: Reverts the comparison back to < 0, which aligns with the correct logic used in Transaction Service and allows transfers when balance equals the requested amount.

Review & Testing Checklist for Human

This change affects critical financial logic and requires thorough testing:

  • Test the exact reported scenario: Create account with R$ 5,000.00, attempt transfer of exactly R$ 5,000.00 - should succeed
  • Verify no regressions: Test normal transfers (amount < balance) still work correctly
  • Confirm edge case protection: Transfers where amount > balance should still be rejected with insufficient funds error
  • End-to-end testing: Since this wasn't tested locally due to database/auth setup requirements, run full microservices stack and test actual fund transfers

Notes

  • The <= 0 logic was introduced in commit d673b8d earlier today - consider if there was a specific reason for that change
  • No unit tests exist for this service, so manual testing is critical
  • The corrected logic matches the pattern used in Transaction Service (TransactionServiceImpl.java line 68)
  • Link to Devin run: https://app.devin.ai/sessions/40a9a48560524b4993d4d75da256ae44
  • Requested by: @samfert-codeium

Reverts incorrect change from commit d673b8d that changed comparison
from '< 0' to '<= 0'. The correct logic should allow transfers when
balance equals the transfer amount.

Fixes bug where transfers of exactly R$ 5,000.00 with balance of
R$ 5,000.00 were incorrectly rejected with insufficient balance error.

Original correct implementation was in commit 757adbc (2023-09-13).
This aligns with the pattern used in Transaction Service.

Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants