FINERACT-1958-Configuration-extending-schedule-with-downpayment

This commit is contained in:
Ruchi Dhamankar
2023-09-11 10:48:29 +02:00
committed by Adam Saghy
parent 4b02527561
commit 233cb5af57
17 changed files with 275 additions and 26 deletions
@@ -459,6 +459,89 @@ public class LoanProductWithDownPaymentConfigurationTest {
}
@Test
public void loanProductAndLoanAccountCreationWithEnableDownPaymentAndDisableRepaymentScheduleExtensionConfigurationTest() {
// Loan ExternalId
String loanExternalIdStr = UUID.randomUUID().toString();
// down-payment configuration
Boolean enableDownPayment = true;
BigDecimal disbursedAmountPercentageForDownPayment = BigDecimal.valueOf(25);
Boolean enableAutoRepaymentForDownPayment = false;
Boolean disableScheduleExtensionForDownPayment = true;
final Integer clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId().intValue();
// Loan Product creation with down-payment configuration
GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProductWithEnableDownPaymentAndMultipleDisbursementsWithDisableRepaymentConfiguration(
loanTransactionHelper, enableDownPayment, "25", enableAutoRepaymentForDownPayment, disableScheduleExtensionForDownPayment);
assertNotNull(getLoanProductsProductResponse);
assertEquals(enableDownPayment, getLoanProductsProductResponse.getEnableDownPayment());
assertEquals(0, getLoanProductsProductResponse.getDisbursedAmountPercentageForDownPayment()
.compareTo(disbursedAmountPercentageForDownPayment));
assertEquals(enableAutoRepaymentForDownPayment, getLoanProductsProductResponse.getEnableAutoRepaymentForDownPayment());
assertEquals(disableScheduleExtensionForDownPayment, getLoanProductsProductResponse.getDisableScheduleExtensionForDownPayment());
final Integer loanId = createLoanAccountMultipleRepaymentsDisbursement(clientId, getLoanProductsProductResponse.getId(),
loanExternalIdStr);
// Retrieve Loan with loanId
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId.longValue());
// verify down-payment details for Loan
assertNotNull(loanDetails);
assertEquals(enableDownPayment, loanDetails.getEnableDownPayment());
assertEquals(0, loanDetails.getDisbursedAmountPercentageForDownPayment().compareTo(disbursedAmountPercentageForDownPayment));
assertEquals(enableAutoRepaymentForDownPayment, loanDetails.getEnableAutoRepaymentForDownPayment());
assertEquals(disableScheduleExtensionForDownPayment, loanDetails.getDisableScheduleExtensionForDownPayment());
}
@Test
public void loanProductCreationWithEnableDownPaymentAndDisableRepaymentScheduleExtensionConfigurationValidationTest() {
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
final LoanTransactionHelper validationErrorHelper = new LoanTransactionHelper(this.requestSpec, errorResponse);
// down-payment configuration
Boolean enableDownPayment = true;
Boolean enableAutoRepaymentForDownPayment = false;
Boolean disableScheduleExtensionForDownPayment = true;
// Loan Product with no multi disbursement settings and enable down payment and with disable Schedule Extension
// For DownPayment
String loanProductJSON = new LoanProductTestBuilder().withPrincipal("1000").withRepaymentTypeAsMonth().withRepaymentAfterEvery("1")
.withNumberOfRepayments("3").withRepaymentTypeAsMonth().withinterestRatePerPeriod("0")
.withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance()
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).withDaysInMonth("30").withDaysInYear("365")
.withMoratorium("0", "0").withEnableDownPayment(enableDownPayment, "25", enableAutoRepaymentForDownPayment)
.withDisableScheduleExtensionForDownPayment(disableScheduleExtensionForDownPayment).build(null);
ArrayList<HashMap<String, Object>> loanProductErrorData = validationErrorHelper.getLoanProductError(loanProductJSON,
CommonConstants.RESPONSE_ERROR);
assertNotNull(loanProductErrorData);
assertEquals(
"validation.msg.loanproduct.disableScheduleExtensionForDownPayment.supported.only.for.multi.disburse.loan.with.enable.down.payment.true",
loanProductErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
// Loan Product with multi disbursement settings and disable down payment and with disable Schedule Extension
// For DownPayment
enableDownPayment = false;
loanProductJSON = new LoanProductTestBuilder().withPrincipal("1000").withRepaymentTypeAsMonth().withRepaymentAfterEvery("1")
.withNumberOfRepayments("3").withRepaymentTypeAsMonth().withinterestRatePerPeriod("0")
.withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance()
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).withDaysInMonth("30").withDaysInYear("365")
.withMoratorium("0", "0").withMultiDisburse().withDisallowExpectedDisbursements(true)
.withEnableDownPayment(enableDownPayment, null, enableAutoRepaymentForDownPayment)
.withDisableScheduleExtensionForDownPayment(disableScheduleExtensionForDownPayment).build(null);
loanProductErrorData = validationErrorHelper.getLoanProductError(loanProductJSON, CommonConstants.RESPONSE_ERROR);
assertNotNull(loanProductErrorData);
assertEquals(
"validation.msg.loanproduct.disableScheduleExtensionForDownPayment.supported.only.for.multi.disburse.loan.with.enable.down.payment.true",
loanProductErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
}
private void checkNoDownPaymentTransaction(final Integer loanID) {
ArrayList<HashMap> transactions = (ArrayList<HashMap>) loanTransactionHelper.getLoanTransactions(this.requestSpec,
this.responseSpec, loanID);
@@ -576,4 +659,18 @@ public class LoanProductWithDownPaymentConfigurationTest {
return loanId;
}
private GetLoanProductsProductIdResponse createLoanProductWithEnableDownPaymentAndMultipleDisbursementsWithDisableRepaymentConfiguration(
LoanTransactionHelper loanTransactionHelper, Boolean enableDownPayment, String disbursedAmountPercentageForDownPayment,
boolean enableAutoRepaymentForDownPayment, boolean disableScheduleExtensionForDownPayment) {
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal("1000").withRepaymentTypeAsMonth()
.withRepaymentAfterEvery("1").withNumberOfRepayments("3").withRepaymentTypeAsMonth().withinterestRatePerPeriod("0")
.withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance()
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).withDaysInMonth("30").withDaysInYear("365")
.withMoratorium("0", "0").withMultiDisburse().withDisallowExpectedDisbursements(true)
.withEnableDownPayment(enableDownPayment, disbursedAmountPercentageForDownPayment, enableAutoRepaymentForDownPayment)
.withDisableScheduleExtensionForDownPayment(disableScheduleExtensionForDownPayment).build(null);
final Integer loanProductId = loanTransactionHelper.getLoanProductId(loanProductJSON);
return loanTransactionHelper.getLoanProduct(loanProductId);
}
}
@@ -150,6 +150,7 @@ public class LoanProductTestBuilder {
private String disbursedAmountPercentageForDownPayment = null;
private boolean enableAutoRepaymentForDownPayment = false;
private Integer repaymentStartDateType = null;
private boolean disableScheduleExtensionForDownPayment = false;
public String build() {
final HashMap<String, Object> map = build(null, null);
@@ -303,6 +304,9 @@ public class LoanProductTestBuilder {
if (this.repaymentStartDateType != null) {
map.put("repaymentStartDateType", repaymentStartDateType);
}
if (disableScheduleExtensionForDownPayment) {
map.put("disableScheduleExtensionForDownPayment", disableScheduleExtensionForDownPayment);
}
return map;
}
@@ -733,4 +737,9 @@ public class LoanProductTestBuilder {
return this;
}
public LoanProductTestBuilder withDisableScheduleExtensionForDownPayment(final Boolean disableScheduleExtensionForDownPayment) {
this.disableScheduleExtensionForDownPayment = disableScheduleExtensionForDownPayment;
return this;
}
}