Phase 3: Functional fixes — amount validation, BigDecimal money, checkUserExists - #49
Open
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…er labels (Phase 3) - checkUserExists now checks checkEmailExists(email) instead of the username - Transaction amounts stored/handled as BigDecimal (PrimaryTransaction, SavingsTransaction) to avoid floating-point currency drift - AccountService deposit/withdraw take BigDecimal; add AmountUtil helper that parses/validates positive amounts and checks sufficient funds - Guard deposit/withdraw/transfer against non-positive, non-numeric, and insufficient-funds inputs (no unhandled NumberFormatException) - Make between-accounts transfer category label consistent (Account) for both Primary->Savings and Savings->Primary - Add tests for invalid/negative/zero amounts, insufficient funds, and the checkUserExists email fix Co-Authored-By: Gael Kekatos <gael.kekatos@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 3 of the modernization plan: version-independent functional bug fixes. Stacked on the Phase 2 PR (#48) (which is itself on Phase 1). Backend suite grows 21 → 35 tests, all green.
1.
checkUserExistsemail bugPreviously a signup with a new username but an already-registered email slipped through (it checked the username against the email index twice).
2. Money handling →
BigDecimalPrimaryTransaction.amount/SavingsTransaction.amountchanged fromdoubletoBigDecimal, andAccountService.deposit/withdrawnow takeBigDecimalinstead ofdouble. This removes binary floating-point drift on currency and theDouble.parseDouble(...)calls in the service/controller layers.3. Amount validation + sufficient funds (no unhandled
NumberFormatException)New
AmountUtilcentralizes parsing/validation, plus anInsufficientFundsException:AccountControllerdeposit/withdraw parse viaAmountUtiland, on bad input, redirect to…?errorinstead of throwing a rawNumberFormatException(500).AccountServiceImpl/TransactionServiceImplvalidate positivity and check funds before subtracting, for deposits, withdrawals, between-account transfers, and transfers to a recipient.4. Consistent transfer category labels
Between-accounts transfers were inconsistent: Primary→Savings recorded type
"Account"while Savings→Primary recorded"Transfer". Both now use"Account".Tests (+14)
AmountUtilTest: valid/negative/zero/non-numeric/null parsing, over-draw vs exact-balance funds check.AccountServiceIntegrationTest: non-positive deposit, zero withdraw, insufficient-funds withdraw.TransactionServiceIntegrationTest: negative / non-numeric / insufficient-funds between-accounts transfer.UserServiceIntegrationTest:checkUserExistsdetects duplicate email under a new username.Verified:
mvn clean test→ 35 tests, 0 failures.Link to Devin session: https://app.devin.ai/sessions/82be2e41fda54343a20a9b73e01c0631
Requested by: @gaelkekatos-jpg
Devin Review