Skip to content

Feat: Complete Expense Management CRUD Functionality#25

Merged
SymonMuchemi merged 6 commits intomasterfrom
feat/expense
Oct 12, 2025
Merged

Feat: Complete Expense Management CRUD Functionality#25
SymonMuchemi merged 6 commits intomasterfrom
feat/expense

Conversation

@SymonMuchemi
Copy link
Copy Markdown
Owner

This pull request introduces the core Expense Management feature set to the API, allowing users to Create, Read, Update, and Delete (CRUD) expense records. It includes new API endpoints, business logic, necessary data structures, and significant improvements to code organization and error handling.


Key Features and Changes:

  • Full Expense API: Implemented ExpenseController and ExpenseService to handle the full CRUD lifecycle for expenses, including mapping expenses to existing categories and applying business validation.
  • New Data Structures: Introduced dedicated Data Transfer Objects (ExpenseRequestDTO, ExpenseResponseDTO) and mappers to ensure clean separation between the API layer and the Expense entity.
  • Entity and Auditing Updates: The Expense entity now includes a required date field, and auditing fields have been standardized using @CreationTimestamp and @UpdateTimestamp.
  • Code Organization & Refactoring:
    • Package Cleanup: All Category DTOs have been moved to a dedicated dto.category package for a cleaner, more scalable directory structure.
    • Repository Enhancement: Added a existsByDescriptionIgnoreCase method to the repository to enforce the uniqueness of expense descriptions.
  • Improved Error Handling: A global exception handler was introduced to catch IllegalArgumentException and return user-friendly error messages for invalid expense requests.
  • Documentation: Updated Requests.http with complete examples for all new expense endpoints and updated the project README.md to reflect the completion of the category management feature.

These changes complete the foundation for tracking expenses within the application.

…feature

- Marked the Category Management (CRUD) feature as completed in the README.
- Adjusted the description for recording expenses to maintain clarity and consistency.
- Removed the CategoryService.java file as it is no longer needed.
- Updated import statements in CategoryController and CategoryService to use the correct package for CategoryRequestDTO and CategoryResponseDTO.
- Added ExpenseController with RESTful annotations and integrated ExpenseService for handling expense-related operations.
- Introduced ExpenseRequestDTO and ExpenseResponseDTO with necessary fields for expense management.
- Implemented ExpenseService with methods for creating new expenses and checking for existing descriptions.
- Added exception handling for illegal arguments in ExpenseService.
- Updated CategoryServiceTest to reflect changes in DTO imports.
- Added methods in ExpenseController for creating, retrieving, updating, and deleting expenses.
- Implemented createExpense, getAllExpenses, getExpenseById, updateExpense, and deleteExpenseById methods in ExpenseService.
- Enhanced validation for expense description in createNewExpense and updateExpense methods.
- Introduced static method getAllExpenses to retrieve all expenses from the repository.
- Updated ExpenseResponseDTO to include necessary fields for response.
- Introduced a new endpoint for creating expenses in Requests.http.
- Updated ExpenseRequestDTO to include a date field for expenses.
- Modified the Expense entity to add a date field and ensure it is not nullable.
- Refactored ExpenseService to reduce code duplication by creating a prepareExpense method for expense creation and updating.
… DTO mapping

- Added new HTTP requests for creating, retrieving, updating, and deleting expenses in the Requests.http file.
- Introduced ExpenseResponseDTOMapper to convert Expense entities to ExpenseResponseDTOs, improving code organization and readability.
- Updated ExpenseResponseDTO to include a date field, allowing for better tracking of expenses.
- Refactored ExpenseService to utilize the new mapper for creating and retrieving expenses, ensuring consistent data handling and reducing code duplication.
- Updated ExpenseService to use instance variables instead of static references for repositories, improving encapsulation and testability.
- Changed method signatures in ExpenseService to remove static modifiers, allowing for instance-based method calls.
- Implemented comprehensive unit tests for ExpenseService, covering scenarios such as creating, retrieving, updating, and deleting expenses, as well as validation checks for expense descriptions.
- Added tests to ensure proper handling of exceptions and edge cases, enhancing the reliability of the expense management functionality.
@SymonMuchemi SymonMuchemi merged commit 77d097f into master Oct 12, 2025
1 check passed
@SymonMuchemi SymonMuchemi deleted the feat/expense branch October 13, 2025 08:47
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.

1 participant