reluxa commented on code in PR #3584:
URL: https://github.com/apache/fineract/pull/3584#discussion_r1392084112
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanInstallmentMultiplesOfTest.java:
##########
@@ -0,0 +1,138 @@
+package org.apache.fineract.integrationtests;
+
+import java.math.BigDecimal;
+import java.util.stream.Stream;
+import org.apache.fineract.client.models.PostLoanProductsRequest;
+import org.apache.fineract.client.models.PostLoanProductsResponse;
+import org.apache.fineract.client.models.PostLoansLoanIdResponse;
+import org.apache.fineract.client.models.PostLoansRequest;
+import org.apache.fineract.client.models.PostLoansResponse;
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.junit.jupiter.api.Named;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+public class LoanInstallmentMultiplesOfTest extends BaseLoanIntegrationTest {
+
+ private final ClientHelper clientHelper = new
ClientHelper(this.requestSpec, this.responseSpec);
+
+ private static Stream<Arguments> interestTypes() {
+ return Stream.of(Arguments.of(Named.of("DECLINING_BALANCE",
InterestType.DECLINING_BALANCE)), //
+ Arguments.of(Named.of("FLAT", InterestType.FLAT)));
+ }
+
+ @ParameterizedTest
+ @MethodSource("interestTypes")
+ public void
test_LoanRepaymentScheduleIsEquallyDistributed_WhenInterestTypeIs(int
interestType) {
+ runAt("01 January 2023", () -> {
+ int amortizationType = AmortizationType.EQUAL_INSTALLMENTS;
+
+ // Create Client
+ Long clientId =
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+
+ // Create Loan Product
+ PostLoanProductsRequest product =
create1InstallmentAmountInMultiplesOf4Period1MonthLongWithInterestAndAmortizationProduct(
+ interestType, amortizationType);
+
+ PostLoanProductsResponse loanProductResponse =
loanProductHelper.createLoanProduct(product);
+ Long loanProductId = loanProductResponse.getResourceId();
+
+ // Apply and Approve Loan
+ double amount = 1250.0;
+
+ PostLoansRequest applicationRequest = applyLoanRequest(clientId,
loanProductId, "01 January 2023", amount, 4).repaymentEvery(1)//
+ .loanTermFrequency(4)//
+ .repaymentFrequencyType(RepaymentFrequencyType.MONTHS)//
+ .loanTermFrequencyType(RepaymentFrequencyType.MONTHS)//
+ .interestType(interestType)//
+ .amortizationType(amortizationType);
+
+ PostLoansResponse postLoansResponse =
loanTransactionHelper.applyLoan(applicationRequest);
+
+ PostLoansLoanIdResponse approvedLoanResult =
loanTransactionHelper.approveLoan(postLoansResponse.getResourceId(),
+ approveLoanRequest(amount));
+
+ Long loanId = approvedLoanResult.getLoanId();
+
+ // Verify Repayment Schedule
+ verifyRepaymentSchedule(loanId, //
+ installment(0, null, "01 January 2023"), //
+ installment(313.0, false, "01 February 2023"), //
+ installment(313.0, false, "01 March 2023"), //
+ installment(313.0, false, "01 April 2023"), //
+ installment(311.0, false, "01 May 2023") //
+ );
+
+ // disburse Loan
+ disburseLoan(loanId, BigDecimal.valueOf(1250.0), "01 January
2023");
+
+ // Verify Repayment Schedule
+ verifyRepaymentSchedule(loanId, //
+ installment(0, null, "01 January 2023"), //
+ installment(313.0, false, "01 February 2023"), //
+ installment(313.0, false, "01 March 2023"), //
+ installment(313.0, false, "01 April 2023"), //
+ installment(311.0, false, "01 May 2023") //
+ );
+ });
+ }
+ //
Review Comment:
IMO this comment section should be deleted.
--
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]