@@ -6000,6 +6000,114 @@ public void uc155() {
60006000 });
60016001 }
60026002
6003+ // uc156: Avoid Loan Reschedule to modify Interest Rate from X value to Zero
6004+ // 1. Create a Loan product
6005+ // 2. Submit, Approve and Disburse Loan with Nominal Interest equal to 4%
6006+ // 3. Apply a Loan repayment
6007+ // 4. Try to create Loan Reschedule with new Interest Rate equal to zero to get the exception
6008+ @ Test
6009+ public void uc156 () {
6010+ final String operationDate = "1 April 2025" ;
6011+ AtomicLong createdLoanId = new AtomicLong ();
6012+ runAt ("1 April 2025" , () -> {
6013+ Long clientId = clientHelper .createClient (ClientHelper .defaultClientCreationRequest ()).getClientId ();
6014+ PostLoanProductsRequest product = create4IProgressive ().interestRatePerPeriod (4.0 ).numberOfRepayments (4 )//
6015+ .installmentAmountInMultiplesOf (null )//
6016+ .multiDisburseLoan (false )//
6017+ .disallowExpectedDisbursements (null )//
6018+ .allowApprovedDisbursedAmountsOverApplied (false )//
6019+ .overAppliedCalculationType (null )//
6020+ .interestCalculationPeriodType (InterestCalculationPeriodType .DAILY )//
6021+ .overAppliedNumber (null )//
6022+ ;//
6023+ PostLoanProductsResponse loanProductResponse = loanProductHelper .createLoanProduct (product );
6024+ PostLoansRequest applicationRequest = applyLP2ProgressiveLoanRequest (clientId , loanProductResponse .getResourceId (),
6025+ operationDate , 1000.0 , 4.0 , 4 , null );
6026+
6027+ PostLoansResponse loanResponse = loanTransactionHelper .applyLoan (applicationRequest );
6028+ createdLoanId .set (loanResponse .getLoanId ());
6029+
6030+ loanTransactionHelper .approveLoan (loanResponse .getLoanId (), new PostLoansLoanIdRequest ()
6031+ .approvedLoanAmount (BigDecimal .valueOf (1000 )).dateFormat (DATETIME_PATTERN ).approvedOnDate (operationDate ).locale ("en" ));
6032+
6033+ loanTransactionHelper .disburseLoan (loanResponse .getLoanId (), new PostLoansLoanIdRequest ().actualDisbursementDate (operationDate )
6034+ .dateFormat (DATETIME_PATTERN ).locale ("en" ).transactionAmount (BigDecimal .valueOf (1000.0 )));
6035+ });
6036+
6037+ runAt ("1 May 2025" , () -> {
6038+ executeInlineCOB (createdLoanId .get ());
6039+
6040+ loanTransactionHelper .makeLoanRepayment (createdLoanId .get (), new PostLoansLoanIdTransactionsRequest ()
6041+ .transactionDate ("1 May 2025" ).dateFormat ("dd MMMM yyyy" ).locale ("en" ).transactionAmount (250.00 ));
6042+ });
6043+
6044+ runAt ("6 May 2025" , () -> {
6045+ executeInlineCOB (createdLoanId .get ());
6046+
6047+ CallFailedRuntimeException callFailedRuntimeException = Assertions .assertThrows (CallFailedRuntimeException .class ,
6048+ () -> loanRescheduleRequestHelper .createLoanRescheduleRequest (new PostCreateRescheduleLoansRequest ()
6049+ .loanId (createdLoanId .get ()).dateFormat (DATETIME_PATTERN ).locale ("en" ).submittedOnDate ("6 May 2025" )
6050+ .newInterestRate (BigDecimal .ZERO ).rescheduleReasonId (1L ).rescheduleFromDate ("1 June 2025" )));
6051+
6052+ Assertions .assertTrue (
6053+ callFailedRuntimeException .getMessage ().contains ("The parameter `newInterestRate` must be greater than 0." ));
6054+ });
6055+ }
6056+
6057+ // uc157: Avoid Loan Reschedule to modify Interest Rate from Zero to X value
6058+ // 1. Create a Loan product
6059+ // 2. Submit, Approve and Disburse Loan with Nominal Interest equal to 0 (zero)
6060+ // 3. Apply a Loan repayment
6061+ // 4. Try to create Loan Reschedule with new Interest Rate greater than zero to get the exception
6062+ @ Test
6063+ public void uc157 () {
6064+ final String operationDate = "1 April 2025" ;
6065+ AtomicLong createdLoanId = new AtomicLong ();
6066+ runAt ("1 April 2025" , () -> {
6067+ Long clientId = clientHelper .createClient (ClientHelper .defaultClientCreationRequest ()).getClientId ();
6068+ PostLoanProductsRequest product = create4IProgressive ().interestRatePerPeriod (0.0 ).numberOfRepayments (4 )//
6069+ .installmentAmountInMultiplesOf (null )//
6070+ .multiDisburseLoan (false )//
6071+ .disallowExpectedDisbursements (null )//
6072+ .allowApprovedDisbursedAmountsOverApplied (false )//
6073+ .overAppliedCalculationType (null )//
6074+ .interestCalculationPeriodType (InterestCalculationPeriodType .DAILY )//
6075+ .overAppliedNumber (null )//
6076+ ;//
6077+ PostLoanProductsResponse loanProductResponse = loanProductHelper .createLoanProduct (product );
6078+ PostLoansRequest applicationRequest = applyLP2ProgressiveLoanRequest (clientId , loanProductResponse .getResourceId (),
6079+ operationDate , 1000.0 , 0.0 , 4 , null );
6080+
6081+ PostLoansResponse loanResponse = loanTransactionHelper .applyLoan (applicationRequest );
6082+ createdLoanId .set (loanResponse .getLoanId ());
6083+
6084+ loanTransactionHelper .approveLoan (loanResponse .getLoanId (), new PostLoansLoanIdRequest ()
6085+ .approvedLoanAmount (BigDecimal .valueOf (1000 )).dateFormat (DATETIME_PATTERN ).approvedOnDate (operationDate ).locale ("en" ));
6086+
6087+ loanTransactionHelper .disburseLoan (loanResponse .getLoanId (), new PostLoansLoanIdRequest ().actualDisbursementDate (operationDate )
6088+ .dateFormat (DATETIME_PATTERN ).locale ("en" ).transactionAmount (BigDecimal .valueOf (1000.0 )));
6089+ });
6090+
6091+ runAt ("1 May 2025" , () -> {
6092+ executeInlineCOB (createdLoanId .get ());
6093+
6094+ loanTransactionHelper .makeLoanRepayment (createdLoanId .get (), new PostLoansLoanIdTransactionsRequest ()
6095+ .transactionDate ("1 May 2025" ).dateFormat ("dd MMMM yyyy" ).locale ("en" ).transactionAmount (250.00 ));
6096+ });
6097+
6098+ runAt ("6 May 2025" , () -> {
6099+ executeInlineCOB (createdLoanId .get ());
6100+
6101+ CallFailedRuntimeException callFailedRuntimeException = Assertions .assertThrows (CallFailedRuntimeException .class ,
6102+ () -> loanRescheduleRequestHelper .createLoanRescheduleRequest (new PostCreateRescheduleLoansRequest ()
6103+ .loanId (createdLoanId .get ()).dateFormat (DATETIME_PATTERN ).locale ("en" ).submittedOnDate ("6 May 2025" )
6104+ .newInterestRate (BigDecimal .valueOf (4.0 )).rescheduleReasonId (1L ).rescheduleFromDate ("1 June 2025" )));
6105+
6106+ Assertions .assertTrue (
6107+ callFailedRuntimeException .getMessage ().contains ("Loan rescheduling is not allowed from interest rate 0 (zero)" ));
6108+ });
6109+ }
6110+
60036111 private Long applyAndApproveLoanProgressiveAdvancedPaymentAllocationStrategyMonthlyRepayments (Long clientId , Long loanProductId ,
60046112 Integer numberOfRepayments , String loanDisbursementDate , double amount ) {
60056113 LOG .info ("------------------------------APPLY AND APPROVE LOAN ---------------------------------------" );
0 commit comments