Feat: Complete Expense Management CRUD Functionality#25
Merged
SymonMuchemi merged 6 commits intomasterfrom Oct 12, 2025
Merged
Conversation
…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.
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.
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:
ExpenseControllerandExpenseServiceto handle the full CRUD lifecycle for expenses, including mapping expenses to existing categories and applying business validation.ExpenseRequestDTO,ExpenseResponseDTO) and mappers to ensure clean separation between the API layer and theExpenseentity.Expenseentity now includes a requireddatefield, and auditing fields have been standardized using@CreationTimestampand@UpdateTimestamp.dto.categorypackage for a cleaner, more scalable directory structure.existsByDescriptionIgnoreCasemethod to the repository to enforce the uniqueness of expense descriptions.IllegalArgumentExceptionand return user-friendly error messages for invalid expense requests.Requests.httpwith complete examples for all new expense endpoints and updated the projectREADME.mdto reflect the completion of the category management feature.These changes complete the foundation for tracking expenses within the application.