Feature/implement recurring expenses#9
Conversation
A basic spring project with the springboot dependencies added to the maven POM file. JDK 21 and Springboot 3 Database is PostgresSQL
Included postgres specifications to allow application to start
Migrated configuration from application.properties to application.yaml
…' of https://github.com/SkillsForge-Community/Expense-Tracker-Backend-Java into add-liquibase-dependency-and-implement-application.yaml
…ency-and-implement-application.yaml replaced application.properties with application.yaml and added the liquibase dependency from maven central repository
…ons and get transactions by id
…nd ditch the previous id implementation in the TransactionServiceImpl
…e revised TransactionDto
…e revised TransactionDto
…e appropriate service class
…troller.java to the appropriate service class
…eateTransaction-Endpoint-&-getTransactionById-Endpoint Feature/implement create transaction endpoint & get transaction by id endpoint
…y before raising PRs
…etch-transactions add update transaction and paginated fetch endpoints
…ion and getTransactionById endpoints (#6) * removed ResponseEntity in TransactionController for consistent dto returns * added spotless maven plugin in pom.xml * applied spotless formatting to all files... * removed redundant dependency
* added jjwt dependencies in pom.xml file * chore: ignore secrets directory * added user entity and role-based permissions * added relationship between user and transactions * implemented userRepository * added database migration xml files * created SignupRequest * created LoginRequest DTO * corrected LoginRequest DTO design * added AuthResponse DTO * reformatted UserDto as a record and corrected error in User entity * fixed inconsitencies in DTOs * fixed inconsistencies in DTOs * Successfully implemented all security components with proper formatting: JwtUtil, UserDetailsServiceImpl, JwtAuthenticationFilter, SecurityConfig, and added getPermissions() method to Role enum. Code formatting applied via Spotless * added extra exception classes * updated the GlobalExceptionHandler class * added the EmailAlreadyExistsException class * added the UsernameAlreadyExistsException class * added the InvalidCredentialException class * modified the GlobalExceptionHandler * scaffolded UserService class * implemented the userService * removed unnecessary comments and implemented AuthController * implemented auth controller and removed redudant comments * fixed bug with app not starting * fixed issue where JPA wasn't adding timestamps to base entitiy added @EntityListener annotation and @createdat and @lastmodified date to baseEntity, this fixes the entity creation flow * modified Filter Chain to change endpoint access * added loggin to JwtAuthenticationFilter to detect the issue * refactored secrets file * fixed issue with system_admin credentials * removed unneeded config in application.yaml * added preAuthorize annotation to /me endpoint * added JWT_SECRET to IDEA environment variables
|
|
||
| @Getter | ||
| @Setter | ||
| public class RecurringUpdateBatchRequest { |
There was a problem hiding this comment.
I dont like this name. What is it batching?
|
|
||
| // Find all active recurring transactions that are due for execution | ||
| // (nextExecutionDate <= today) | ||
| List<RecurringTransaction> findByIsActiveTrueAndNextExecutionDateLessThanEqual(LocalDate date); |
There was a problem hiding this comment.
why are you trying to fetch for transactions that are less than or equal to a date. I would expect you to break this query down into two.
- A query that fetches for current day. so that it can trigger the insertion of transaction.
- A query that takes a date range. so that it can send reminders for upcoming subscriptions.
| RecurringTransaction existing = | ||
| recurringTransactionRepository | ||
| .findById(id) | ||
| .filter(rt -> rt.getUser().getId().equals(user.getId())) |
There was a problem hiding this comment.
Find by user and Id instead so you dont have to filter
| RecurringTransaction existing = | ||
| recurringTransactionRepository | ||
| .findById(id) | ||
| .filter(rt -> rt.getUser().getId().equals(user.getId())) |
| public void runExecutionCycle() { | ||
| LocalDate today = LocalDate.now(); | ||
| List<RecurringTransaction> dueTransactions = | ||
| recurringTransactionRepository.findByIsActiveTrueAndNextExecutionDateLessThanEqual(today); |
There was a problem hiding this comment.
what happens here is that if todays date is 24, this query will search from beginning of time till todays date. expensive query. just search for todays date since this is a job that runs daily.
| } | ||
| } | ||
|
|
||
| private User getCurrentUser() { |
There was a problem hiding this comment.
on the controlller, you can add the annotation @AuthenticationPrincipal User user then you can pass that user as arguments to the methods. again, look at my sample codebase.
15ba464 to
e13150a
Compare
Implements the end-to-end infrastructure for recurring transactions including automated generation, scheduling, and secure RESTful endpoints.