alberto-art3ch commented on code in PR #4025:
URL: https://github.com/apache/fineract/pull/4025#discussion_r1720052686


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java:
##########
@@ -5095,6 +5095,41 @@ public void uc147b() {
         });
     }
 
+    // uc148a: Advanced payment allocation, with Interest Recalculation in 
Loan Product and Adjust last, unpaid period
+    // ADVANCED_PAYMENT_ALLOCATION_STRATEGY
+    // 1. Create a Loan product with Adv. Pment. Alloc. with Interest 
Recalculation enabled and Adjust last, unpaid
+    // period
+    @Test
+    public void uc148a() {
+        runAt("23 March 2024", () -> {
+            final Integer rescheduleStrategyMethod = 4; // Adjust last, unpaid 
period
+            PostLoanProductsRequest loanProduct = 
createOnePeriod30DaysPeriodicAccrualProductWithAdvancedPaymentAllocationAndInterestRecalculation(
+                    (double) 80.0, rescheduleStrategyMethod);
+
+            PostLoanProductsResponse loanProductResponse = 
loanProductHelper.createLoanProduct(loanProduct);
+            assertNotNull(loanProductResponse);
+        });
+    }
+
+    // uc148b: Negative Test: Advanced payment allocation, with Interest 
Recalculation in Loan Product but try to use
+    // Reduce EMI amount
+    // ADVANCED_PAYMENT_ALLOCATION_STRATEGY
+    // 1. Try to Create a Loan product with Adv. Pment. Alloc. with Interest 
Recalculation enabled and use Reduce EMI
+    // amount
+    @Test
+    public void uc148b() {
+        runAt("23 March 2024", () -> {
+            final Integer rescheduleStrategyMethod = 3; // Reduce EMI amount
+            PostLoanProductsRequest loanProduct = 
createOnePeriod30DaysPeriodicAccrualProductWithAdvancedPaymentAllocationAndInterestRecalculation(
+                    (double) 80.0, rescheduleStrategyMethod);
+
+            CallFailedRuntimeException callFailedRuntimeException = 
Assertions.assertThrows(CallFailedRuntimeException.class,
+                    () -> loanProductHelper.createLoanProduct(loanProduct));
+
+            
Assertions.assertTrue(callFailedRuntimeException.getMessage().contains("is not 
supported for Progressive loan schedule type"));
+        });
+    }
+

Review Comment:
   Done! TC added



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java:
##########
@@ -1042,7 +1043,27 @@ private void validateInterestRecalculationParams(final 
JsonElement element, fina
             final Integer rescheduleStrategyMethod = this.fromApiJsonHelper
                     
.extractIntegerNamed(LoanProductConstants.rescheduleStrategyMethodParameterName,
 element, Locale.getDefault());
             
baseDataValidator.reset().parameter(LoanProductConstants.rescheduleStrategyMethodParameterName).value(rescheduleStrategyMethod)
-                    .notNull().inMinMaxRange(1, 3);
+                    .notNull().inMinMaxRange(1, 4);
+            final LoanRescheduleStrategyMethod loanRescheduleStrategyMethod = 
LoanRescheduleStrategyMethod
+                    .fromInt(rescheduleStrategyMethod);
+
+            String loanScheduleType = LoanScheduleType.CUMULATIVE.toString();
+            if 
(fromApiJsonHelper.parameterExists(LoanProductConstants.LOAN_SCHEDULE_TYPE, 
element)) {
+                loanScheduleType = 
fromApiJsonHelper.extractStringNamed(LoanProductConstants.LOAN_SCHEDULE_TYPE, 
element);
+            }
+            if 
(LoanScheduleType.CUMULATIVE.equals(LoanScheduleType.valueOf(loanScheduleType))
+                    && 
LoanRescheduleStrategyMethod.ADJUST_LAST_UNPAID_PERIOD.equals(loanRescheduleStrategyMethod))
 {
+                
baseDataValidator.reset().parameter(LoanProductConstants.rescheduleStrategyMethodParameterName).failWithCode(
+                        
"reschedule.strategy.method.not.supported.for.loan.schedule.type.cumulative",
+                        "Adjust last, unpaid period is only supported for 
Progressive loan schedule type");
+            }
+
+            if 
(LoanScheduleType.PROGRESSIVE.equals(LoanScheduleType.valueOf(loanScheduleType))
+                    && 
!LoanRescheduleStrategyMethod.ADJUST_LAST_UNPAID_PERIOD.equals(loanRescheduleStrategyMethod))
 {
+                
baseDataValidator.reset().parameter(LoanProductConstants.rescheduleStrategyMethodParameterName).failWithCode(
+                        
"reschedule.strategy.method.not.supported.for.loan.schedule.type.progressive",
+                        "Reschedule strategy type is not supported for 
Progressive loan schedule type");

Review Comment:
   Done! updated



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java:
##########
@@ -5095,6 +5095,41 @@ public void uc147b() {
         });
     }
 
+    // uc148a: Advanced payment allocation, with Interest Recalculation in 
Loan Product and Adjust last, unpaid period
+    // ADVANCED_PAYMENT_ALLOCATION_STRATEGY
+    // 1. Create a Loan product with Adv. Pment. Alloc. with Interest 
Recalculation enabled and Adjust last, unpaid
+    // period
+    @Test
+    public void uc148a() {
+        runAt("23 March 2024", () -> {
+            final Integer rescheduleStrategyMethod = 4; // Adjust last, unpaid 
period
+            PostLoanProductsRequest loanProduct = 
createOnePeriod30DaysPeriodicAccrualProductWithAdvancedPaymentAllocationAndInterestRecalculation(
+                    (double) 80.0, rescheduleStrategyMethod);
+
+            PostLoanProductsResponse loanProductResponse = 
loanProductHelper.createLoanProduct(loanProduct);
+            assertNotNull(loanProductResponse);

Review Comment:
   Done! TC extended



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionAccrualActivityPostingTest.java:
##########
@@ -1016,6 +1016,7 @@ private PostLoanProductsRequest 
loanProductsRequestPin30InterestDecliningBalance
                 .isEqualAmortization(false)//
                 .interestCalculationPeriodType(0)//
                 .transactionProcessingStrategyCode("mifos-standard-strategy")//
+                .loanScheduleType(LoanScheduleType.CUMULATIVE.toString())//

Review Comment:
   Done! removed



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to