refactor: [devjaes] update transaction date validation and enhance tr…#4
Merged
Conversation
…ansaction repository methods - Changed date validation in transaction filters from datetime to date. - Updated transaction repository methods to include category names in category totals. - Improved date handling in transaction queries to ensure correct filtering by date range.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors transaction date validation and enhances transaction repository methods to improve date filtering accuracy and category aggregation functionality. The main purpose is to ensure date-based filtering includes all transactions for selected days and to provide category names alongside totals in aggregation results.
- Added utility functions for proper date boundary handling (
setStartOfDayandsetEndOfDay) - Updated transaction filtering to use date validation instead of datetime and enhanced category aggregation to include category names
- Improved code formatting and consistency across SQL joins in the repository
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/utils/date.utils.ts | New utility functions for setting start and end of day boundaries |
| src/features/transactions/infrastructure/adapters/transaction.repository.ts | Enhanced date filtering, category aggregation, and improved SQL join formatting |
| src/features/transactions/domain/ports/transaction-repository.port.ts | Updated interface to include categoryName in aggregation results |
| src/features/transactions/domain/entities/ITrends.ts | Added CategoryTotalData interface for type safety |
| src/features/transactions/application/services/transactions.service.ts | Updated service to handle new categoryName field and entity properties |
| src/features/transactions/application/dtos/transaction.dto.ts | Changed date validation from datetime to date format |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…repository.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 improvements to how transactions are filtered and aggregated by date and category, as well as refactors related repository logic for clarity and correctness. The main focus is to ensure date-based filtering includes all transactions for the selected days, and to enhance category-based aggregation with category names. Additionally, the codebase sees some cleanup and consistency improvements in joins and entity mapping.
Date handling and filtering improvements:
setStartOfDayandsetEndOfDayinsrc/shared/utils/date.utils.tsto ensure date filters include all transactions for the selected days. These are now used throughout the repository for date range queries.transactionFiltersSchemato use.date()instead of.datetime()forstartDateandendDate, reflecting that only the date part is relevant for filtering.setStartOfDayandsetEndOfDayfor all date range queries, ensuring correct inclusion of transactions at the boundaries. [1] [2] [3]Category aggregation enhancements:
categoryNamealong withcategoryIdandtotal, both in the repository interface and implementation, and reflected this in service and DTO layers. [1] [2] [3] [4]Repository consistency and code cleanup:
PgTransactionRepositoryfor better readability and consistent formatting. [1] [2] [3] [4] [5] [6]categoryandpaymentMethodobjects more cleanly.DTO and service updates:
categoryName) and ensure compatibility with the improved repository methods. [1] [2]These changes collectively make date filtering more robust, enhance reporting by including category names, and improve code maintainability and readability.…ansaction repository methods