feat(transactions): complete module with CRUD operations and budget calculations & fix auth validation#8
Merged
Joseph-Sameh-0 merged 39 commits intodevelopfrom Apr 21, 2026
Merged
Conversation
…ojects in build.gradle.kts
…te range, and all transactions
…expenses, and balance
…mount calculations
…fy deleteTransaction method
… domain objects directly
…w request models and improved endpoint structure
…d Transaction entities
…proved query structure and new request models
…ns and refactor repository methods
… category services with test configurations
…nullable spentAmount and improved query logic
…ices with spending calculations and token validation
…ction summary with coroutine support
…ests with mandatory budget
There was a problem hiding this comment.
Pull request overview
This PR finalizes the new transactions module by adding persisted Transaction/Category/Budget domain models, CRUD APIs, and budget/spending summary queries, while also tightening identity authentication validation and adding integration test coverage across modules.
Changes:
- Added
transactionsmodule domain model, repositories, services, controllers, and summary/budget calculation logic (plus module refactor fromcategories). - Fixed auth login credential validation to use
passwordEncoder.matches()and throwInvalidCredentialsException. - Added H2-backed integration tests and test applications/profiles for
transactions,identity,app, plus storage unit-style tests.
Reviewed changes
Copilot reviewed 61 out of 62 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| transactions/src/test/resources/application-test.properties | Adds H2 test DB config for transactions module. |
| transactions/src/test/kotlin/org/spendoo/transactions/integration/TransactionServiceIntegrationTest.kt | Integration tests for transaction CRUD + summaries. |
| transactions/src/test/kotlin/org/spendoo/transactions/integration/CategoryServiceIntegrationTest.kt | Integration tests for category CRUD + spending/budget summary. |
| transactions/src/test/kotlin/org/spendoo/transactions/integration/BudgetServiceIntegrationTest.kt | Integration tests for budget lifecycle and spent-amount calc. |
| transactions/src/test/kotlin/org/spendoo/transactions/TransactionsTestApplication.kt | Test boot config wiring services + repos for transactions tests. |
| transactions/src/main/kotlin/org/spendoo/transactions/service/model/CategoryParams.kt | Moves model package + adds spentAmount projection field. |
| transactions/src/main/kotlin/org/spendoo/transactions/service/model/CategoriesSummary.kt | Adds categories summary DTO for aggregated totals. |
| transactions/src/main/kotlin/org/spendoo/transactions/service/TransactionService.kt | Implements transaction CRUD + balance summary + top-spending query. |
| transactions/src/main/kotlin/org/spendoo/transactions/service/CategoryService.kt | Implements category CRUD + default category bootstrap + summary. |
| transactions/src/main/kotlin/org/spendoo/transactions/service/BudgetService.kt | Adds spent calculation via transactions + rollover helpers. |
| transactions/src/main/kotlin/org/spendoo/transactions/scheduler/BudgetExpirationScheduler.kt | Moves scheduler to transactions package and keeps rollover job. |
| transactions/src/main/kotlin/org/spendoo/transactions/repository/TransactionRepository.kt | Adds transaction queries (income/expenses sums, top spending, spent by category). |
| transactions/src/main/kotlin/org/spendoo/transactions/repository/CategoryRepository.kt | Adds category + budget + spending projection queries and summaries. |
| transactions/src/main/kotlin/org/spendoo/transactions/repository/BudgetRepository.kt | Moves repository to transactions package. |
| transactions/src/main/kotlin/org/spendoo/transactions/eventListener/UserCreatedListener.kt | Switches default category creation to CategoryService call. |
| transactions/src/main/kotlin/org/spendoo/transactions/entity/TransactionType.kt | Introduces transaction type enum. |
| transactions/src/main/kotlin/org/spendoo/transactions/entity/Transaction.kt | Adds Transaction entity. |
| transactions/src/main/kotlin/org/spendoo/transactions/entity/LeftOverOptions.kt | Moves enum to transactions package. |
| transactions/src/main/kotlin/org/spendoo/transactions/entity/CategoryIcon.kt | Moves enum to transactions package. |
| transactions/src/main/kotlin/org/spendoo/transactions/entity/Category.kt | Moves entity to transactions package + adds relationship to transactions. |
| transactions/src/main/kotlin/org/spendoo/transactions/entity/Budget.kt | Moves entity to transactions package + schema rename. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/response/TransactionResponse.kt | Adds Transaction response DTO and mapper. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/response/CategorySpendingDto.kt | Adds DTO projection for top spending. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/response/CategoryResponse.kt | Refactors category response and budget mapping from projections. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/response/BudgetResponse.kt | Adds spent/percentage fields computed from spending. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/response/BalanceSummary.kt | Adds balance summary response DTO. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/request/TransactionUpdateRequest.kt | Adds transaction update request + mapping to entity. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/request/CreateIncomeTransactionRequest.kt | Adds income transaction create DTO + mapping. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/request/CreateExpenseTransactionRequest.kt | Adds expense transaction create DTO + mapping. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/request/CategoryUpdateRequest.kt | Adds strict category update DTO + mapping. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/request/CategoryCreateRequest.kt | Makes budget required and adds validation on create. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/dto/request/BudgetCreateRequest.kt | Adjusts budget amount validation to allow zero. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/controller/TransactionController.kt | Adds REST endpoints for transaction CRUD + summaries. |
| transactions/src/main/kotlin/org/spendoo/transactions/api/controller/CategoryController.kt | Moves controller to transactions package + adds summary endpoint. |
| transactions/build.gradle.kts | Adds coroutines, Truth, H2 test runtime deps. |
| storage/src/test/kotlin/org/spendoo/storage/service/ImageStorageServiceIntegrationTest.kt | Adds S3 client mock-based tests for storage service. |
| storage/build.gradle.kts | Adds test dependencies/configuration for storage module. |
| settings.gradle.kts | Replaces categories module include with transactions. |
| identity/src/test/resources/application-test.properties | Adds H2 test DB config + test properties for identity module. |
| identity/src/test/kotlin/org/spendoo/identity/integration/UserServiceIntegrationTest.kt | Adds integration tests for user service image operations. |
| identity/src/test/kotlin/org/spendoo/identity/integration/EmailServiceIntegrationTest.kt | Adds tests for email event publishing and OTP format. |
| identity/src/test/kotlin/org/spendoo/identity/integration/AuthServiceIntegrationTest.kt | Adds extensive auth flow integration test coverage. |
| identity/src/test/kotlin/org/spendoo/identity/IdentityTestApplication.kt | Adds identity test boot configuration with mocked cross-module services. |
| identity/src/main/kotlin/org/spendoo/identity/service/AuthService.kt | Fixes password validation with passwordEncoder.matches + throws InvalidCredentialsException. |
| identity/src/main/kotlin/org/spendoo/identity/security/SecurityConfig.kt | Permits / in security config (for docs redirect). |
| identity/src/main/kotlin/org/spendoo/identity/security/JwtFilter.kt | Excludes / from JWT filtering (for docs redirect). |
| identity/src/main/kotlin/org/spendoo/identity/repository/RefreshTokenRepository.kt | Removes redundant @Repository annotation. |
| identity/src/main/kotlin/org/spendoo/identity/api/dto/request/RegisterRequest.kt | Removes redundant @NotNull constraints. |
| identity/build.gradle.kts | Adds MockK/Truth/H2 and crypto deps for identity tests. |
| categories/src/main/resources/db/categories.sql | Removes legacy categories SQL seed script. |
| categories/src/main/kotlin/org/spendoo/categories/service/CategoryService.kt | Removes legacy categories service. |
| categories/src/main/kotlin/org/spendoo/categories/repository/CategoryRepository.kt | Removes legacy categories repository and native insert method. |
| categories/src/main/kotlin/org/spendoo/categories/mapper/CategoryDashboardMapper.kt | Removes legacy dashboard mapper. |
| categories/src/main/kotlin/org/spendoo/categories/api/dto/response/CategoriesOverViewResponse.kt | Removes legacy overview response DTO. |
| categories/src/main/kotlin/org/spendoo/categories/api/dto/request/CategoryUpdateRequest.kt | Removes legacy update request DTO. |
| build.gradle.kts | Minor formatting change. |
| app/src/test/resources/application-test.properties | Adds unified app-level H2 test configuration. |
| app/src/test/kotlin/org/spendoo/app/SpendooApplicationTests.kt | Ensures app tests run under test profile. |
| app/src/main/kotlin/org/spendoo/api/DocsController.kt | Adds root / redirect to Swagger UI. |
| app/build.gradle.kts | Swaps dependency to transactions module + updates springdoc version + adds H2 test runtime. |
| AGENTS.md | Adds repo architecture/conventions documentation for contributors/agents. |
| .run/Run Tests.run.xml | Adds IDE run configuration to run module test suites. |
Comments suppressed due to low confidence (2)
transactions/src/main/kotlin/org/spendoo/transactions/service/BudgetService.kt:67
spentAmountis summed from expense transactions wheret.amount < 0, so it will be a negative number. Usingleftover = expiredBudget.amount - spentAmountwill increase leftover when there are expenses (e.g., 500 - (-150) = 650). Compute remaining budget using the absolute spend or add the negative sum (e.g.,leftover = expiredBudget.amount + spentAmountifspentAmountstays negative).
transactions/src/main/kotlin/org/spendoo/transactions/api/dto/response/BudgetResponse.kt:27spentAmountis represented as a negative number for expenses, butspendingPercentageis computed directly from it. This can produce a negative percentage (e.g., -120 / 1000 * 100 = -12), which is generally not meaningful for a “spent” ratio. Consider computing the percentage fromspentAmount.abs()(while keepingspentAmountnegative if that’s the chosen convention).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Joseph-Sameh-0
approved these changes
Apr 21, 2026
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
This PR establishes the core foundation of the transactions module by introducing full CRUD capabilities, essential database entities, and architectural refactoring. Additionally, it resolves a critical validation issue in the authentication flow to ensure secure access.
Key Changes:
Auth Security Fix: Updated AuthService to validate passwords using passwordEncoder.matches() and throw InvalidCredentialsException for incorrect credentials.
Module Refactoring: Renamed the categories package to transactions to align with the new system architecture.
Database Setup: Created Transaction entity, TransactionType enum, and TransactionRepository with required custom queries.
Transactions & Categories CRUD APIs: - Implemented full CRUD operations (POST, GET, PATCH, DELETE) matching the project's @AuthenticationPrincipal security standard.
Added Request/Response DTOs with strict validation for creating and updating records.
Created clean data Mappers using Kotlin extension functions.
Implemented @Transactional- service logic for secure batch saving, updating, and soft-deleting of entries.
Integrated budget calculation logic seamlessly with the retrieval APIs.