alberto-art3ch commented on code in PR #3808:
URL: https://github.com/apache/fineract/pull/3808#discussion_r1535109409
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java:
##########
@@ -3467,6 +3467,147 @@ public void uc124() {
});
}
+ // UC125: Advanced payment allocation with Fixed Length for 40 days and
Loan Term for 45 days (3 repayments every 15
+ // days)
+ // ADVANCED_PAYMENT_ALLOCATION_STRATEGY
+ // 1. Create a Loan product with Adv. Pment. Alloc. and No Interest
+ // 2. Submit Loan and approve
+ // 3. Disburse
+ // 4. Validate Repayment Schedule
+ @Test
+ public void uc125() {
+ runAt("22 November 2023", () -> {
+ final Integer fixedLength = 40; // 40 days
+ Long clientId =
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+ PostLoanProductsRequest product =
createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
+
.numberOfRepayments(3).repaymentEvery(15).fixedLength(fixedLength);
+ PostLoanProductsResponse loanProductResponse =
loanProductHelper.createLoanProduct(product);
+ PostLoansRequest applicationRequest = applyLoanRequest(clientId,
loanProductResponse.getResourceId(), "22 November 2023",
+ 1000.0, 4);
+
+ applicationRequest =
applicationRequest.numberOfRepayments(3).loanTermFrequency(45)
+
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY).repaymentEvery(15);
+
+ PostLoansResponse loanResponse =
loanTransactionHelper.applyLoan(applicationRequest);
+
+ loanTransactionHelper.approveLoan(loanResponse.getLoanId(),
+ new
PostLoansLoanIdRequest().approvedLoanAmount(BigDecimal.valueOf(1000)).dateFormat(DATETIME_PATTERN)
+ .approvedOnDate("22 November 2023").locale("en"));
+
+ loanTransactionHelper.disburseLoan(loanResponse.getLoanId(),
+ new PostLoansLoanIdRequest().actualDisbursementDate("22
November 2023").dateFormat(DATETIME_PATTERN)
+
.transactionAmount(BigDecimal.valueOf(100.0)).locale("en"));
+
+ GetLoansLoanIdResponse loanDetails =
loanTransactionHelper.getLoanDetails(loanResponse.getLoanId());
+ validateLoanSummaryBalances(loanDetails, 100.0, 0.0, 100.0, 0.0,
null);
+ validateRepaymentPeriod(loanDetails, 1, LocalDate.of(2023, 12, 7),
33.0, 0.0, 33.0, 0.0, 0.0);
+ validateRepaymentPeriod(loanDetails, 2, LocalDate.of(2023, 12,
22), 33.0, 0.0, 33.0, 0.0, 0.0);
+ validateRepaymentPeriod(loanDetails, 3, LocalDate.of(2024, 1, 01),
34.0, 0.0, 34.0, 0.0, 0.0);
+ assertEquals(loanDetails.getNumberOfRepayments(), 3);
+
assertEquals(Utils.getDifferenceInDays(loanDetails.getTimeline().getActualDisbursementDate(),
LocalDate.of(2024, 1, 01)),
+ fixedLength.longValue());
+ assertTrue(loanDetails.getStatus().getActive());
+ });
+ }
+
+ // UC126: Advanced payment allocation with Fixed Length for 5 weeks and
Loan Term for 6 weeks (3 repayments every 2
+ // weeks)
+ // ADVANCED_PAYMENT_ALLOCATION_STRATEGY
+ // 1. Create a Loan product with Adv. Pment. Alloc. and No Interest
+ // 2. Submit Loan and approve
+ // 3. Disburse
+ // 4. Validate Repayment Schedule
+ @Test
+ public void uc126() {
+ runAt("22 November 2023", () -> {
+ final Integer fixedLength = 5; // 5 weeks
+ final Integer repaymentFrequencyType = 1; // week
+
+ Long clientId =
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+ PostLoanProductsRequest product =
createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
+
.numberOfRepayments(3).repaymentEvery(2).repaymentFrequencyType(repaymentFrequencyType.longValue())
+ .fixedLength(fixedLength);
+ PostLoanProductsResponse loanProductResponse =
loanProductHelper.createLoanProduct(product);
+ PostLoansRequest applicationRequest = applyLoanRequest(clientId,
loanProductResponse.getResourceId(), "22 November 2023",
+ 1000.0, 4);
+
+ applicationRequest =
applicationRequest.numberOfRepayments(3).loanTermFrequency(6).loanTermFrequencyType(repaymentFrequencyType)
+
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY).repaymentEvery(2)
+ .repaymentFrequencyType(repaymentFrequencyType);
+
+ PostLoansResponse loanResponse =
loanTransactionHelper.applyLoan(applicationRequest);
+
+ loanTransactionHelper.approveLoan(loanResponse.getLoanId(),
+ new
PostLoansLoanIdRequest().approvedLoanAmount(BigDecimal.valueOf(1000)).dateFormat(DATETIME_PATTERN)
+ .approvedOnDate("22 November 2023").locale("en"));
+
+ loanTransactionHelper.disburseLoan(loanResponse.getLoanId(),
+ new PostLoansLoanIdRequest().actualDisbursementDate("22
November 2023").dateFormat(DATETIME_PATTERN)
+
.transactionAmount(BigDecimal.valueOf(100.0)).locale("en"));
+
+ GetLoansLoanIdResponse loanDetails =
loanTransactionHelper.getLoanDetails(loanResponse.getLoanId());
+ validateLoanSummaryBalances(loanDetails, 100.0, 0.0, 100.0, 0.0,
null);
+ validateRepaymentPeriod(loanDetails, 1, LocalDate.of(2023, 12, 6),
33.0, 0.0, 33.0, 0.0, 0.0);
+ validateRepaymentPeriod(loanDetails, 2, LocalDate.of(2023, 12,
20), 33.0, 0.0, 33.0, 0.0, 0.0);
+ validateRepaymentPeriod(loanDetails, 3, LocalDate.of(2023, 12,
27), 34.0, 0.0, 34.0, 0.0, 0.0);
+ assertEquals(loanDetails.getNumberOfRepayments(), 3);
+
assertEquals(Utils.getDifferenceInWeeks(loanDetails.getTimeline().getActualDisbursementDate(),
LocalDate.of(2023, 12, 27)),
Review Comment:
Done, validations updated with the due date of the last period
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java:
##########
@@ -3467,6 +3467,147 @@ public void uc124() {
});
}
+ // UC125: Advanced payment allocation with Fixed Length for 40 days and
Loan Term for 45 days (3 repayments every 15
+ // days)
+ // ADVANCED_PAYMENT_ALLOCATION_STRATEGY
+ // 1. Create a Loan product with Adv. Pment. Alloc. and No Interest
+ // 2. Submit Loan and approve
+ // 3. Disburse
+ // 4. Validate Repayment Schedule
+ @Test
+ public void uc125() {
+ runAt("22 November 2023", () -> {
+ final Integer fixedLength = 40; // 40 days
+ Long clientId =
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+ PostLoanProductsRequest product =
createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
+
.numberOfRepayments(3).repaymentEvery(15).fixedLength(fixedLength);
+ PostLoanProductsResponse loanProductResponse =
loanProductHelper.createLoanProduct(product);
+ PostLoansRequest applicationRequest = applyLoanRequest(clientId,
loanProductResponse.getResourceId(), "22 November 2023",
+ 1000.0, 4);
+
+ applicationRequest =
applicationRequest.numberOfRepayments(3).loanTermFrequency(45)
+
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY).repaymentEvery(15);
+
+ PostLoansResponse loanResponse =
loanTransactionHelper.applyLoan(applicationRequest);
+
+ loanTransactionHelper.approveLoan(loanResponse.getLoanId(),
+ new
PostLoansLoanIdRequest().approvedLoanAmount(BigDecimal.valueOf(1000)).dateFormat(DATETIME_PATTERN)
+ .approvedOnDate("22 November 2023").locale("en"));
+
+ loanTransactionHelper.disburseLoan(loanResponse.getLoanId(),
+ new PostLoansLoanIdRequest().actualDisbursementDate("22
November 2023").dateFormat(DATETIME_PATTERN)
+
.transactionAmount(BigDecimal.valueOf(100.0)).locale("en"));
+
+ GetLoansLoanIdResponse loanDetails =
loanTransactionHelper.getLoanDetails(loanResponse.getLoanId());
+ validateLoanSummaryBalances(loanDetails, 100.0, 0.0, 100.0, 0.0,
null);
+ validateRepaymentPeriod(loanDetails, 1, LocalDate.of(2023, 12, 7),
33.0, 0.0, 33.0, 0.0, 0.0);
+ validateRepaymentPeriod(loanDetails, 2, LocalDate.of(2023, 12,
22), 33.0, 0.0, 33.0, 0.0, 0.0);
+ validateRepaymentPeriod(loanDetails, 3, LocalDate.of(2024, 1, 01),
34.0, 0.0, 34.0, 0.0, 0.0);
+ assertEquals(loanDetails.getNumberOfRepayments(), 3);
+
assertEquals(Utils.getDifferenceInDays(loanDetails.getTimeline().getActualDisbursementDate(),
LocalDate.of(2024, 1, 01)),
Review Comment:
Done, validations updated with the due date of the last period
--
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]