4949import org .apache .fineract .integrationtests .common .ClientHelper ;
5050import org .apache .fineract .integrationtests .common .loans .LoanTestLifecycleExtension ;
5151import org .apache .fineract .integrationtests .common .products .DelinquencyBucketsHelper ;
52+ import org .apache .fineract .integrationtests .inlinecob .InlineLoanCOBHelper ;
5253import org .junit .jupiter .api .Assertions ;
5354import org .junit .jupiter .api .Test ;
5455import org .junit .jupiter .api .extension .ExtendWith ;
@@ -266,7 +267,7 @@ public void testVerifyLoanDelinquencyRecalculationForBackdatedPauseDelinquencyAc
266267 Long clientId = clientHelper .createClient (ClientHelper .defaultClientCreationRequest ()).getClientId ();
267268
268269 // Create Loan Product
269- Long loanProductId = createLoanProductWith25PctDownPaymentAndDelinquencyBucket (true , true , true );
270+ Long loanProductId = createLoanProductWith25PctDownPaymentAndDelinquencyBucket (true , true , true , 3 );
270271
271272 // Apply and Approve Loan
272273 Long loanId = applyAndApproveLoan (clientId , loanProductId , "25 December 2022" , 1500.0 , 3 ,
@@ -322,6 +323,48 @@ public void testValidationErrorIsThrownWhenCreatingActionThatOverlaps() {
322323 });
323324 }
324325
326+ @ Test
327+ public void testLoanAndInstallmentDelinquencyCalculationForCOBAfterPausePeriodEndTest () {
328+ runAt ("01 November 2023" , () -> {
329+ // Create Client
330+ Long clientId = clientHelper .createClient (ClientHelper .defaultClientCreationRequest ()).getClientId ();
331+
332+ // Create Loan Product
333+ Long loanProductId = createLoanProductWith25PctDownPaymentAndDelinquencyBucket (true , true , true , 0 );
334+
335+ // Apply and Approve Loan
336+ Long loanId = applyAndApproveLoan (clientId , loanProductId , "01 November 2023" , 1000.0 , 3 , req -> {
337+ req .submittedOnDate ("01 November 2023" );
338+ req .setLoanTermFrequency (45 );
339+ req .setRepaymentEvery (15 );
340+ req .setGraceOnArrearsAgeing (0 );
341+ });
342+
343+ // Partial Loan amount Disbursement
344+ disburseLoan (loanId , BigDecimal .valueOf (100.00 ), "01 November 2023" );
345+
346+ // Update business date
347+ businessDateHelper .updateBusinessDate (new BusinessDateRequest ().type (BUSINESS_DATE .getName ()).date ("05 November 2023" )
348+ .dateFormat (DATETIME_PATTERN ).locale ("en" ));
349+
350+ // Create Delinquency Pause for the Loan
351+ PostLoansDelinquencyActionResponse response = loanTransactionHelper .createLoanDelinquencyAction (loanId , PAUSE ,
352+ "16 November 2023" , "25 November 2023" );
353+
354+ // run cob for business date 26 November
355+ final InlineLoanCOBHelper inlineLoanCOBHelper = new InlineLoanCOBHelper (requestSpec , responseSpec );
356+ businessDateHelper .updateBusinessDate (new BusinessDateRequest ().type (BUSINESS_DATE .getName ()).date ("26 November 2023" )
357+ .dateFormat (DATETIME_PATTERN ).locale ("en" ));
358+ inlineLoanCOBHelper .executeInlineCOB (List .of (loanId .longValue ()));
359+
360+ // Loan delinquency data
361+ verifyLoanDelinquencyData (loanId , 1 , new InstallmentDelinquencyData (1 , 3 , BigDecimal .valueOf (25.0 )));
362+
363+ // Validate Delinquency Pause Period on Loan
364+ validateLoanDelinquencyPausePeriods (loanId , pausePeriods ("16 November 2023" , "25 November 2023" , false ));
365+ });
366+ }
367+
325368 private void validateLoanDelinquencyPausePeriods (Long loanId , GetLoansLoanIdDelinquencyPausePeriod ... pausePeriods ) {
326369 GetLoansLoanIdResponse loan = loanTransactionHelper .getLoan (requestSpec , responseSpec , loanId .intValue ());
327370 Assertions .assertNotNull (loan .getDelinquent ());
@@ -388,7 +431,7 @@ private Long createLoanProductWith25PctDownPayment(boolean autoDownPaymentEnable
388431 }
389432
390433 private Long createLoanProductWith25PctDownPaymentAndDelinquencyBucket (boolean autoDownPaymentEnabled , boolean multiDisburseEnabled ,
391- boolean installmentLevelDelinquencyEnabled ) {
434+ boolean installmentLevelDelinquencyEnabled , Integer graceOnArrearsAging ) {
392435 // Create DelinquencyBuckets
393436 Integer delinquencyBucketId = DelinquencyBucketsHelper .createDelinquencyBucket (requestSpec , responseSpec , List .of (//
394437 Pair .of (1 , 3 ), //
@@ -400,6 +443,7 @@ private Long createLoanProductWith25PctDownPaymentAndDelinquencyBucket(boolean a
400443 product .setDelinquencyBucketId (delinquencyBucketId .longValue ());
401444 product .setMultiDisburseLoan (multiDisburseEnabled );
402445 product .setEnableDownPayment (true );
446+ product .setGraceOnArrearsAgeing (graceOnArrearsAging );
403447
404448 product .setDisbursedAmountPercentageForDownPayment (DOWN_PAYMENT_PERCENTAGE );
405449 product .setEnableAutoRepaymentForDownPayment (autoDownPaymentEnabled );
0 commit comments