This is an automated email from the ASF dual-hosted git repository.

adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 6ca02686d FINERACT-2114: Reschedule validations enhancement
6ca02686d is described below

commit 6ca02686d2e2c14739bd65137f579b0dd9cfd57b
Author: Adam Saghy <[email protected]>
AuthorDate: Fri Aug 23 16:11:36 2024 +0200

    FINERACT-2114: Reschedule validations enhancement
---
 .../data/ProgressiveLoanRescheduleRequestDataValidator.java    | 10 +++++++---
 .../fineract/integrationtests/LoanRescheduleRequestTest.java   |  8 ++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java
 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java
index 8736ab5c5..4f767f5fc 100644
--- 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java
+++ 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java
@@ -94,9 +94,11 @@ public class ProgressiveLoanRescheduleRequestDataValidator 
implements LoanResche
         final LocalDate businessDate = DateUtils.getBusinessLocalDate();
         if (rescheduleFromDate != null) {
             if (hasInterestRateChange && 
!rescheduleFromDate.isAfter(businessDate)) {
-                
dataValidatorBuilder.reset().parameter(RescheduleLoansApiConstants.rescheduleFromDateParamName).failWithCode(
+                throw new GeneralPlatformDomainRuleException(
                         
"loan.reschedule.interest.rate.change.reschedule.from.date.should.be.in.future",
-                        "Loan Reschedule From date should be in the future.");
+                        String.format("Loan Reschedule From date (%s) for 
Loan: %s should be in the future.", rescheduleFromDate,
+                                loan.getId()),
+                        loan.getId(), rescheduleFromDate);
             }
             if (hasInterestRateChange) {
                 validateInterestRateChangeRescheduleFromDate(loan, 
rescheduleFromDate);
@@ -154,7 +156,9 @@ public class ProgressiveLoanRescheduleRequestDataValidator 
implements LoanResche
             if (!rescheduleFromDate.isAfter(DateUtils.getBusinessLocalDate())) 
{
                 throw new GeneralPlatformDomainRuleException(
                         
"loan.reschedule.interest.rate.change.reschedule.from.date.should.be.in.future",
-                        "Loan Reschedule From date should be in the future.", 
rescheduleFromDate);
+                        String.format("Loan Reschedule From date (%s) for 
Loan: %s should be in the future.", rescheduleFromDate,
+                                loan.getId()),
+                        loan.getId(), rescheduleFromDate);
             }
         } else {
             installment = 
loan.getRepaymentScheduleInstallment(rescheduleFromDate);
diff --git 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
index 0f3b14c58..2090b7ba7 100644
--- 
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
+++ 
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
@@ -282,6 +282,14 @@ public class LoanRescheduleRequestTest extends 
BaseLoanIntegrationTest {
                     new PostLoansLoanIdRequest().actualDisbursementDate("15 
February 2023").dateFormat(DATETIME_PATTERN)
                             
.transactionAmount(BigDecimal.valueOf(500.00)).locale("en"));
 
+            exception = assertThrows(CallFailedRuntimeException.class,
+                    () -> loanRescheduleRequestHelper
+                            .createLoanRescheduleRequest(new 
PostCreateRescheduleLoansRequest().loanId(loanResponse.get().getLoanId())
+                                    
.dateFormat(DATETIME_PATTERN).locale("en").submittedOnDate("15 February 2023")
+                                    
.newInterestRate(BigDecimal.ONE).rescheduleReasonId(1L).rescheduleFromDate("15 
February 2023")));
+            assertEquals(403, exception.getResponse().code());
+            
assertTrue(exception.getMessage().contains("loan.reschedule.interest.rate.change.reschedule.from.date.should.be.in.future"));
+
             
rescheduleResponse.set(loanRescheduleRequestHelper.createLoanRescheduleRequest(new
 PostCreateRescheduleLoansRequest()
                     
.loanId(loanResponse.get().getLoanId()).dateFormat(DATETIME_PATTERN).locale("en").submittedOnDate("15
 February 2023")
                     
.newInterestRate(BigDecimal.ONE).rescheduleReasonId(1L).rescheduleFromDate("16 
February 2023")));

Reply via email to