FINERACT-2065: Fixed length loan configuration
This commit is contained in:
committed by
Peter Bagrij
parent
76ad2a2bc9
commit
b2685ce9cf
+12
-4
@@ -1962,7 +1962,8 @@ public class AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan
|
||||
Integer localLoanProductId = createLoanProduct("500", "15", "4", true, "25", false, LoanScheduleType.PROGRESSIVE,
|
||||
LoanScheduleProcessingType.VERTICAL, assetAccount, incomeAccount, expenseAccount, overpaymentAccount);
|
||||
final PostLoansResponse loanResponse = applyForLoanApplication(client.getClientId(), localLoanProductId,
|
||||
BigDecimal.valueOf(500.0), 45, 15, 3, BigDecimal.ZERO, "01 January 2023", "01 January 2023");
|
||||
BigDecimal.valueOf(500.0), 45, 15, 3, BigDecimal.ZERO, "01 January 2023", "01 January 2023",
|
||||
LoanScheduleProcessingType.VERTICAL);
|
||||
|
||||
loanTransactionHelper.approveLoan(loanResponse.getLoanId(),
|
||||
new PostLoansLoanIdRequest().approvedLoanAmount(BigDecimal.valueOf(500)).dateFormat(DATETIME_PATTERN)
|
||||
@@ -2489,7 +2490,8 @@ public class AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan
|
||||
Integer localLoanProductId = createLoanProduct("1000", "15", "3", true, "25", false, LoanScheduleType.PROGRESSIVE,
|
||||
LoanScheduleProcessingType.VERTICAL, assetAccount, incomeAccount, expenseAccount, overpaymentAccount);
|
||||
final PostLoansResponse loanResponse = applyForLoanApplication(client.getClientId(), localLoanProductId,
|
||||
BigDecimal.valueOf(1000.0), 45, 15, 3, BigDecimal.ZERO, "01 September 2023", "01 September 2023");
|
||||
BigDecimal.valueOf(1000.0), 45, 15, 3, BigDecimal.ZERO, "01 September 2023", "01 September 2023",
|
||||
LoanScheduleProcessingType.VERTICAL);
|
||||
|
||||
loanTransactionHelper.approveLoan(loanResponse.getLoanId(),
|
||||
new PostLoansLoanIdRequest().approvedLoanAmount(BigDecimal.valueOf(1000)).dateFormat(DATETIME_PATTERN)
|
||||
@@ -3621,11 +3623,17 @@ public class AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan
|
||||
private static PostLoansResponse applyForLoanApplication(final Long clientId, final Integer loanProductId, final BigDecimal principal,
|
||||
final int loanTermFrequency, final int repaymentAfterEvery, final int numberOfRepayments, final BigDecimal interestRate,
|
||||
final String expectedDisbursementDate, final String submittedOnDate) {
|
||||
return applyForLoanApplication(clientId, loanProductId, principal, loanTermFrequency, repaymentAfterEvery, numberOfRepayments,
|
||||
interestRate, expectedDisbursementDate, submittedOnDate, LoanScheduleProcessingType.HORIZONTAL);
|
||||
}
|
||||
|
||||
private static PostLoansResponse applyForLoanApplication(final Long clientId, final Integer loanProductId, final BigDecimal principal,
|
||||
final int loanTermFrequency, final int repaymentAfterEvery, final int numberOfRepayments, final BigDecimal interestRate,
|
||||
final String expectedDisbursementDate, final String submittedOnDate, LoanScheduleProcessingType loanScheduleProcessingType) {
|
||||
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
return applyForLoanApplication(clientId, loanProductId, principal, loanTermFrequency, repaymentAfterEvery, numberOfRepayments,
|
||||
interestRate, expectedDisbursementDate, submittedOnDate,
|
||||
AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY,
|
||||
LoanScheduleProcessingType.HORIZONTAL.name());
|
||||
AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY, loanScheduleProcessingType.name());
|
||||
}
|
||||
|
||||
private static void validateLoanTransaction(GetLoansLoanIdResponse loanDetails, int index, double transactionAmount,
|
||||
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.integrationtests;
|
||||
|
||||
import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.models.PostLoanProductsRequest;
|
||||
import org.apache.fineract.client.models.PostLoanProductsResponse;
|
||||
import org.apache.fineract.client.models.PutLoanProductsProductIdRequest;
|
||||
import org.apache.fineract.client.models.PutLoanProductsProductIdResponse;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@ExtendWith(LoanTestLifecycleExtension.class)
|
||||
public class FixedLengthLoanProductIntegrationTest extends BaseLoanIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testCreateReadUpdateReadLoanProductWithFixedLength() {
|
||||
// create with 5
|
||||
PostLoanProductsRequest loanProductsRequest = fixedLengthLoanProduct(5);
|
||||
PostLoanProductsResponse loanProduct = loanProductHelper.createLoanProduct(loanProductsRequest);
|
||||
Assertions.assertNotNull(loanProduct.getResourceId());
|
||||
|
||||
// read
|
||||
GetLoanProductsProductIdResponse getLoanProductsProductIdResponse = loanProductHelper
|
||||
.retrieveLoanProductById(loanProduct.getResourceId());
|
||||
Assertions.assertEquals(5, getLoanProductsProductIdResponse.getFixedLength());
|
||||
|
||||
// update to 6
|
||||
PutLoanProductsProductIdRequest updateRequest = new PutLoanProductsProductIdRequest().fixedLength(6).locale("en");
|
||||
PutLoanProductsProductIdResponse putLoanProductsProductIdResponse = loanProductHelper
|
||||
.updateLoanProductById(loanProduct.getResourceId(), updateRequest);
|
||||
Assertions.assertNotNull(putLoanProductsProductIdResponse.getResourceId());
|
||||
|
||||
// read again
|
||||
getLoanProductsProductIdResponse = loanProductHelper.retrieveLoanProductById(loanProduct.getResourceId());
|
||||
Assertions.assertEquals(6, getLoanProductsProductIdResponse.getFixedLength());
|
||||
|
||||
// update to null
|
||||
loanTransactionHelper.updateLoanProduct(putLoanProductsProductIdResponse.getResourceId(), """
|
||||
{
|
||||
"fixedLength": null,
|
||||
"locale": "en"
|
||||
}
|
||||
""");
|
||||
|
||||
// read again
|
||||
getLoanProductsProductIdResponse = loanProductHelper.retrieveLoanProductById(loanProduct.getResourceId());
|
||||
Assertions.assertNull(getLoanProductsProductIdResponse.getFixedLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoanApplicationWithFixedLengthInheritedFromLoanProduct() {
|
||||
runAt("01 January 2023", () -> {
|
||||
Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
|
||||
|
||||
PostLoanProductsResponse loanProduct = loanProductHelper.createLoanProduct(fixedLengthLoanProduct(6));
|
||||
Assertions.assertNotNull(loanProduct.getResourceId());
|
||||
|
||||
Long loanId = applyAndApproveLoan(clientId, loanProduct.getResourceId(), "01 January 2023", 1000.0);
|
||||
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||
Assertions.assertEquals(6, loanDetails.getFixedLength());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoanApplicationWithFixedLengthOverriddenByLoanApplication() {
|
||||
runAt("01 January 2023", () -> {
|
||||
Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
|
||||
|
||||
PostLoanProductsResponse loanProduct = loanProductHelper.createLoanProduct(fixedLengthLoanProduct(6));
|
||||
Assertions.assertNotNull(loanProduct.getResourceId());
|
||||
|
||||
Long loanId = applyAndApproveLoan(clientId, loanProduct.getResourceId(), "01 January 2023", 1000.0, 1, //
|
||||
loanApplication -> loanApplication.fixedLength(5) //
|
||||
);
|
||||
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||
Assertions.assertEquals(5, loanDetails.getFixedLength());
|
||||
});
|
||||
}
|
||||
|
||||
private PostLoanProductsRequest fixedLengthLoanProduct(Integer fixedLength) {
|
||||
return createOnePeriod30DaysLongNoInterestPeriodicAccrualProduct().numberOfRepayments(4)//
|
||||
.repaymentEvery(1)//
|
||||
.repaymentFrequencyType(RepaymentFrequencyType.MONTHS.longValue())//
|
||||
.transactionProcessingStrategyCode("mifos-standard-strategy").fixedLength(fixedLength);
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -46,6 +46,10 @@ public class LoanProductHelper extends IntegrationTest {
|
||||
return ok(fineract().loanProducts.updateLoanProduct1(externalId, request));
|
||||
}
|
||||
|
||||
public PutLoanProductsProductIdResponse updateLoanProductById(Long loanProductId, PutLoanProductsProductIdRequest request) {
|
||||
return ok(fineract().loanProducts.updateLoanProduct(loanProductId, request));
|
||||
}
|
||||
|
||||
public GetLoanProductsTemplateResponse getLoanProductTemplate(boolean isProductMixTemplate) {
|
||||
return ok(fineract().loanProducts.retrieveTemplate11(isProductMixTemplate));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user