You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "alberto-art3ch (via GitHub)" <gi...@apache.org> on 2026/01/21 03:54:19 UTC

[PR] FINERACT-2421: Allow multiple interest rate schedule adjustments same date [fineract]

alberto-art3ch opened a new pull request, #5358:
URL: https://github.com/apache/fineract/pull/5358

   ## Description
   
   We need the ability to be able to adjust interest rates on a loan on the same day. Currently fineract allows only one interest rate change for a given day. If another interest rate needs to happen using the adjust-schedule api, we need to wait 1 more day before submitting the change. 
   
   It would be great to have a way to submit multiple adjust schedules on the same day and then have a way to determine which adjust schedule is currently active.
   
   [FINERACT-2421](https://issues.apache.org/jira/browse/FINERACT-2421)
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [ ] Write the commit message as per [our guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [ ] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
   - [ ] Create/update [unit or integration tests](https://fineract.apache.org/docs/current/#_testing) for verifying the changes made.
   - [ ] Follow our [coding conventions](https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions).
   - [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
   - [ ] [This PR must not be a "code dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit). Large changes can be made in a branch, with assistance. Ask for help on the [developer mailing list](https://fineract.apache.org/#contribute).
   
   Your assigned reviewer(s) will follow our [guidelines for code reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2421: Allow multiple interest rate schedule adjustments same date [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #5358:
URL: https://github.com/apache/fineract/pull/5358


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2421: Allow multiple interest rate schedule adjustments same date [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5358:
URL: https://github.com/apache/fineract/pull/5358#discussion_r2721090292


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java:
##########
@@ -223,17 +222,14 @@ public void validateForRejectAction(JsonCommand jsonCommand, LoanRescheduleReque
         throw new UnsupportedOperationException("Nothing to override here");
     }
 
-    private void validateInterestRateChangeRescheduleFromDate(Loan loan, LocalDate rescheduleFromDate) {
-        boolean alreadyExistInterestRateChange = loanRescheduleRequestRepository.exists((root, query, criteriaBuilder) -> {
-            Predicate loanPredicate = criteriaBuilder.equal(root.get("loan"), loan);
-            Predicate statusPredicate = root.get("statusEnum")
-                    .in(List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
-            Predicate datePredicate = criteriaBuilder.equal(root.get("rescheduleFromDate"), rescheduleFromDate);
-            return criteriaBuilder.and(loanPredicate, statusPredicate, datePredicate);
-        });
-        if (alreadyExistInterestRateChange) {
-            throw new GeneralPlatformDomainRuleException("loan.reschedule.interest.rate.change.already.exists",
-                    "Interest rate change for the provided date is already exists.", rescheduleFromDate);
+    private void validateInterestRateChangeRescheduleFromDate(final Loan loan, final LocalDate rescheduleFromDate) {
+        Optional<LoanRescheduleRequest> optLoanRescheduleRequest = loanRescheduleRequestRepository.fetchByLoanAndFromDateAndStatus(loan, //
+                rescheduleFromDate, List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
+
+        if (optLoanRescheduleRequest.isPresent()) {
+            LoanRescheduleRequest loanRescheduleRequest = optLoanRescheduleRequest.get();
+            loanRescheduleRequest.reject(loanRescheduleRequest.getSubmittedByUser(), rescheduleFromDate);
+            loanRescheduleRequestRepository.save(loanRescheduleRequest);

Review Comment:
   I think we need to do the following instead:
   - We are not changing on the `LoanRescheduleRequest`. It should reflect the original values!
   
   If there is 2 **same** loan term variations, mark the existing one as `isActive=false`! Only the latter one will be active and in effect:
   
   1. Change interest rate from 2 February 2025 to 4%
   - LoanRescheduleRequest is created with PENDING status, No Loan term variations created yet.
   - Once its approved, loan term variation is created
   
   2. Change interest rate from 2 February 2025 to 5%
   - LoanRescheduleRequest is created with PENDING status, No **new** Loan term variations created yet.
   - Once its approved, we should check whether there is ACTIVE loan term variation with the same type and date and if so mark this as INACTIVE and create a new loan term variations with the new details.
    



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2421: Allow multiple interest rate schedule adjustments same date [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5358:
URL: https://github.com/apache/fineract/pull/5358#discussion_r2720967444


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java:
##########
@@ -223,17 +222,14 @@ public void validateForRejectAction(JsonCommand jsonCommand, LoanRescheduleReque
         throw new UnsupportedOperationException("Nothing to override here");
     }
 
-    private void validateInterestRateChangeRescheduleFromDate(Loan loan, LocalDate rescheduleFromDate) {
-        boolean alreadyExistInterestRateChange = loanRescheduleRequestRepository.exists((root, query, criteriaBuilder) -> {
-            Predicate loanPredicate = criteriaBuilder.equal(root.get("loan"), loan);
-            Predicate statusPredicate = root.get("statusEnum")
-                    .in(List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
-            Predicate datePredicate = criteriaBuilder.equal(root.get("rescheduleFromDate"), rescheduleFromDate);
-            return criteriaBuilder.and(loanPredicate, statusPredicate, datePredicate);
-        });
-        if (alreadyExistInterestRateChange) {
-            throw new GeneralPlatformDomainRuleException("loan.reschedule.interest.rate.change.already.exists",
-                    "Interest rate change for the provided date is already exists.", rescheduleFromDate);
+    private void validateInterestRateChangeRescheduleFromDate(final Loan loan, final LocalDate rescheduleFromDate) {
+        Optional<LoanRescheduleRequest> optLoanRescheduleRequest = loanRescheduleRequestRepository.fetchByLoanAndFromDateAndStatus(loan, //
+                rescheduleFromDate, List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
+
+        if (optLoanRescheduleRequest.isPresent()) {
+            LoanRescheduleRequest loanRescheduleRequest = optLoanRescheduleRequest.get();
+            loanRescheduleRequest.reject(loanRescheduleRequest.getSubmittedByUser(), rescheduleFromDate);
+            loanRescheduleRequestRepository.save(loanRescheduleRequest);

Review Comment:
   I dont like this. This class is a validator, rejecting prior reschedules should not happen here!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2421: Allow multiple interest rate schedule adjustments same date [fineract]

Posted by "alberto-art3ch (via GitHub)" <gi...@apache.org>.
alberto-art3ch commented on code in PR #5358:
URL: https://github.com/apache/fineract/pull/5358#discussion_r2723101021


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java:
##########
@@ -223,17 +222,14 @@ public void validateForRejectAction(JsonCommand jsonCommand, LoanRescheduleReque
         throw new UnsupportedOperationException("Nothing to override here");
     }
 
-    private void validateInterestRateChangeRescheduleFromDate(Loan loan, LocalDate rescheduleFromDate) {
-        boolean alreadyExistInterestRateChange = loanRescheduleRequestRepository.exists((root, query, criteriaBuilder) -> {
-            Predicate loanPredicate = criteriaBuilder.equal(root.get("loan"), loan);
-            Predicate statusPredicate = root.get("statusEnum")
-                    .in(List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
-            Predicate datePredicate = criteriaBuilder.equal(root.get("rescheduleFromDate"), rescheduleFromDate);
-            return criteriaBuilder.and(loanPredicate, statusPredicate, datePredicate);
-        });
-        if (alreadyExistInterestRateChange) {
-            throw new GeneralPlatformDomainRuleException("loan.reschedule.interest.rate.change.already.exists",
-                    "Interest rate change for the provided date is already exists.", rescheduleFromDate);
+    private void validateInterestRateChangeRescheduleFromDate(final Loan loan, final LocalDate rescheduleFromDate) {
+        Optional<LoanRescheduleRequest> optLoanRescheduleRequest = loanRescheduleRequestRepository.fetchByLoanAndFromDateAndStatus(loan, //
+                rescheduleFromDate, List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
+
+        if (optLoanRescheduleRequest.isPresent()) {
+            LoanRescheduleRequest loanRescheduleRequest = optLoanRescheduleRequest.get();
+            loanRescheduleRequest.reject(loanRescheduleRequest.getSubmittedByUser(), rescheduleFromDate);
+            loanRescheduleRequestRepository.save(loanRescheduleRequest);

Review Comment:
   Code updated according to the details mentioned above. Thanks!
   
   The ITC enriched to validate:
   - Loan Reschedule Request status
   - Loan Term Variants status
   - Loan interest charged on each Loan Reschedule approve action
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2421: Allow multiple interest rate schedule adjustments same date [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5358:
URL: https://github.com/apache/fineract/pull/5358#discussion_r2721069775


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java:
##########
@@ -223,17 +222,14 @@ public void validateForRejectAction(JsonCommand jsonCommand, LoanRescheduleReque
         throw new UnsupportedOperationException("Nothing to override here");
     }
 
-    private void validateInterestRateChangeRescheduleFromDate(Loan loan, LocalDate rescheduleFromDate) {
-        boolean alreadyExistInterestRateChange = loanRescheduleRequestRepository.exists((root, query, criteriaBuilder) -> {
-            Predicate loanPredicate = criteriaBuilder.equal(root.get("loan"), loan);
-            Predicate statusPredicate = root.get("statusEnum")
-                    .in(List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
-            Predicate datePredicate = criteriaBuilder.equal(root.get("rescheduleFromDate"), rescheduleFromDate);
-            return criteriaBuilder.and(loanPredicate, statusPredicate, datePredicate);
-        });
-        if (alreadyExistInterestRateChange) {
-            throw new GeneralPlatformDomainRuleException("loan.reschedule.interest.rate.change.already.exists",
-                    "Interest rate change for the provided date is already exists.", rescheduleFromDate);
+    private void validateInterestRateChangeRescheduleFromDate(final Loan loan, final LocalDate rescheduleFromDate) {
+        Optional<LoanRescheduleRequest> optLoanRescheduleRequest = loanRescheduleRequestRepository.fetchByLoanAndFromDateAndStatus(loan, //
+                rescheduleFromDate, List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(), LoanStatus.APPROVED.getValue()));
+
+        if (optLoanRescheduleRequest.isPresent()) {
+            LoanRescheduleRequest loanRescheduleRequest = optLoanRescheduleRequest.get();
+            loanRescheduleRequest.reject(loanRescheduleRequest.getSubmittedByUser(), rescheduleFromDate);
+            loanRescheduleRequestRepository.save(loanRescheduleRequest);

Review Comment:
   Also i dont think we should automatically reject is... it is misleading. Leave it APPROVED, but when we fetch these term variations, if the same applies to the same date, take the latter only. 
   
   Can it work?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org