FINERACT-1724-Loan-Product-Update
This commit is contained in:
committed by
Arnold Gálovics
parent
69c3d575b7
commit
231a178d1e
+3
-1
@@ -2285,7 +2285,9 @@ public final class LoanProductDataValidator {
|
||||
considerPartialPeriodUpdates = considerPartialPeriods;
|
||||
}
|
||||
} else if (loanProduct != null) {
|
||||
considerPartialPeriodUpdates = loanProduct.getLoanProductRelatedDetail().isAllowPartialPeriodInterestCalcualtion();
|
||||
if (!interestCalculationPeriodMethod.isDaily()) {
|
||||
considerPartialPeriodUpdates = loanProduct.getLoanProductRelatedDetail().isAllowPartialPeriodInterestCalcualtion();
|
||||
}
|
||||
}
|
||||
|
||||
if (!considerPartialPeriodUpdates) {
|
||||
|
||||
+47
@@ -91,6 +91,43 @@ public class LoanProductUpdateApiTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loanProductWithInterestCalculationTypeDailyModifyForAdvancedPaymentAllocationRuleTest() {
|
||||
// create loan product with Advanced Payment Allocation Strategy with default allocation with future installment
|
||||
// allocation as NEXT_INSTALLMENT
|
||||
String futureInstallmentAllocationRule = "NEXT_INSTALLMENT";
|
||||
AdvancedPaymentData defaultAllocation = createDefaultPaymentAllocation(futureInstallmentAllocationRule);
|
||||
|
||||
Integer loanProductId = createLoanProductWithInterestCalculationPeriodTypeDaily(defaultAllocation);
|
||||
Assertions.assertNotNull(loanProductId);
|
||||
|
||||
// verify allocation rule
|
||||
GetLoanProductsProductIdResponse loanProduct = LOAN_TRANSACTION_HELPER.getLoanProduct(loanProductId);
|
||||
Assertions.assertNotNull(loanProduct.getPaymentAllocation());
|
||||
|
||||
Optional<AdvancedPaymentData> defaultAllocationAfterCreate = loanProduct.getPaymentAllocation().stream()
|
||||
.filter(advancedPaymentData -> "DEFAULT".equals(advancedPaymentData.getTransactionType())).findFirst();
|
||||
Assertions.assertTrue(defaultAllocationAfterCreate.isPresent());
|
||||
Assertions.assertEquals(futureInstallmentAllocationRule, defaultAllocationAfterCreate.get().getFutureInstallmentAllocationRule());
|
||||
|
||||
// Change future installment allocation rule to "LAST_INSTALLMENT" and update loan product
|
||||
futureInstallmentAllocationRule = "LAST_INSTALLMENT";
|
||||
defaultAllocation = createDefaultPaymentAllocation(futureInstallmentAllocationRule);
|
||||
|
||||
loanProductId = updateLoanProduct(loanProductId, defaultAllocation);
|
||||
Assertions.assertNotNull(loanProductId);
|
||||
|
||||
loanProduct = LOAN_TRANSACTION_HELPER.getLoanProduct(loanProductId);
|
||||
Assertions.assertNotNull(loanProduct.getPaymentAllocation());
|
||||
|
||||
// verify allocation rule
|
||||
Optional<AdvancedPaymentData> defaultAllocationAfterUpdate = loanProduct.getPaymentAllocation().stream()
|
||||
.filter(advancedPaymentData -> "DEFAULT".equals(advancedPaymentData.getTransactionType())).findFirst();
|
||||
Assertions.assertTrue(defaultAllocationAfterUpdate.isPresent());
|
||||
Assertions.assertEquals(futureInstallmentAllocationRule, defaultAllocationAfterUpdate.get().getFutureInstallmentAllocationRule());
|
||||
|
||||
}
|
||||
|
||||
private Integer updateLoanProduct(Integer loanProductId, AdvancedPaymentData... advancedPaymentData) {
|
||||
final PutLoanProductsProductIdRequest requestModifyLoan = new PutLoanProductsProductIdRequest()
|
||||
.transactionProcessingStrategyCode("advanced-payment-allocation-strategy")
|
||||
@@ -107,6 +144,16 @@ public class LoanProductUpdateApiTest {
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProductWithInterestCalculationPeriodTypeDaily(AdvancedPaymentData... advancedPaymentData) {
|
||||
String loanProductCreateJSON = new LoanProductTestBuilder().withPrincipal("15,000.00").withNumberOfRepayments("4")
|
||||
.withRepaymentAfterEvery("1").withRepaymentTypeAsMonth().withinterestRatePerPeriod("1")
|
||||
.withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestTypeAsDecliningBalance()
|
||||
.withInterestCalculationPeriodTypeAsDays().withAllowPartialPeriodInterestCalculation(false)
|
||||
.addAdvancedPaymentAllocation(advancedPaymentData).build();
|
||||
return LOAN_TRANSACTION_HELPER.getLoanProductId(loanProductCreateJSON);
|
||||
|
||||
}
|
||||
|
||||
private AdvancedPaymentData createDefaultPaymentAllocation(String futureInstallmentAllocationRule) {
|
||||
AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData();
|
||||
advancedPaymentData.setTransactionType("DEFAULT");
|
||||
|
||||
+5
@@ -742,4 +742,9 @@ public class LoanProductTestBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withAllowPartialPeriodInterestCalculation(final Boolean allowPartialPeriodInterestCalcualtion) {
|
||||
this.allowPartialPeriodInterestCalcualtion = allowPartialPeriodInterestCalcualtion;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user