Skip to content

feat(transactions): complete module with CRUD operations and budget calculations & fix auth validation#8

Merged
Joseph-Sameh-0 merged 39 commits intodevelopfrom
feature/transaction
Apr 21, 2026
Merged

feat(transactions): complete module with CRUD operations and budget calculations & fix auth validation#8
Joseph-Sameh-0 merged 39 commits intodevelopfrom
feature/transaction

Conversation

@IsraaXx
Copy link
Copy Markdown
Member

@IsraaXx IsraaXx commented Mar 18, 2026

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.

@IsraaXx IsraaXx changed the title feat(transaction): initialize module base & fix auth validation feat(transaction): implement create transaction API & fix auth validation Mar 23, 2026
@IsraaXx IsraaXx changed the title feat(transaction): implement create transaction API & fix auth validation feat(transactions): complete module with CRUD operations and budget calculations & fix auth validation Mar 31, 2026
@IsraaXx IsraaXx requested a review from Joseph-Sameh-0 March 31, 2026 13:23
@IsraaXx IsraaXx marked this pull request as ready for review March 31, 2026 14:01
Copy link
Copy Markdown

Copilot AI left a comment

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 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 transactions module domain model, repositories, services, controllers, and summary/budget calculation logic (plus module refactor from categories).
  • Fixed auth login credential validation to use passwordEncoder.matches() and throw InvalidCredentialsException.
  • 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

  • spentAmount is summed from expense transactions where t.amount < 0, so it will be a negative number. Using leftover = expiredBudget.amount - spentAmount will 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 + spentAmount if spentAmount stays negative).
    transactions/src/main/kotlin/org/spendoo/transactions/api/dto/response/BudgetResponse.kt:27
  • spentAmount is represented as a negative number for expenses, but spendingPercentage is 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 from spentAmount.abs() (while keeping spentAmount negative if that’s the chosen convention).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread transactions/src/main/kotlin/org/spendoo/transactions/entity/TransactionType.kt Outdated
@Joseph-Sameh-0 Joseph-Sameh-0 merged commit 45f1a0e into develop Apr 21, 2026
3 checks passed
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.

4 participants