FINERACT-1971: Delinquency evaluation should be happen only for Active Loans
This commit is contained in:
committed by
Adam Saghy
parent
189b94bd19
commit
e169b5cd61
+5
@@ -126,6 +126,11 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
|
|||||||
if (optLoan.isPresent()) {
|
if (optLoan.isPresent()) {
|
||||||
final Loan loan = optLoan.get();
|
final Loan loan = optLoan.get();
|
||||||
|
|
||||||
|
// If the Loan is not Active yet, return template data
|
||||||
|
if (loan.isSubmittedAndPendingApproval() || loan.isApproved()) {
|
||||||
|
return CollectionData.template();
|
||||||
|
}
|
||||||
|
|
||||||
final List<LoanDelinquencyAction> savedDelinquencyList = retrieveLoanDelinquencyActions(loanId);
|
final List<LoanDelinquencyAction> savedDelinquencyList = retrieveLoanDelinquencyActions(loanId);
|
||||||
List<LoanDelinquencyActionData> effectiveDelinquencyList = delinquencyEffectivePauseHelper
|
List<LoanDelinquencyActionData> effectiveDelinquencyList = delinquencyEffectivePauseHelper
|
||||||
.calculateEffectiveDelinquencyList(savedDelinquencyList);
|
.calculateEffectiveDelinquencyList(savedDelinquencyList);
|
||||||
|
|||||||
+64
-2
@@ -1571,6 +1571,58 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoanClassificationOnyForActiveLoan() {
|
||||||
|
|
||||||
|
// Given
|
||||||
|
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
|
|
||||||
|
ArrayList<Integer> rangeIds = new ArrayList<>();
|
||||||
|
// First Range
|
||||||
|
String jsonRange = DelinquencyRangesHelper.getAsJSON(4, 30);
|
||||||
|
PostDelinquencyRangeResponse delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec, responseSpec,
|
||||||
|
jsonRange);
|
||||||
|
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||||
|
|
||||||
|
String jsonBucket = DelinquencyBucketsHelper.getAsJSON(rangeIds);
|
||||||
|
PostDelinquencyBucketResponse delinquencyBucketResponse = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec,
|
||||||
|
responseSpec, jsonBucket);
|
||||||
|
assertNotNull(delinquencyBucketResponse);
|
||||||
|
final GetDelinquencyBucketsResponse delinquencyBucket = DelinquencyBucketsHelper.getDelinquencyBucket(requestSpec, responseSpec,
|
||||||
|
delinquencyBucketResponse.getResourceId());
|
||||||
|
|
||||||
|
// Client and Loan account creation
|
||||||
|
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||||
|
final GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProduct(loanTransactionHelper,
|
||||||
|
Math.toIntExact(delinquencyBucket.getId()), null);
|
||||||
|
assertNotNull(getLoanProductsProductResponse);
|
||||||
|
|
||||||
|
final LocalDate todaysDate = Utils.getLocalDateOfTenant();
|
||||||
|
// Older date to have more than one overdue installment
|
||||||
|
LocalDate transactionDate = todaysDate.minusDays(37);
|
||||||
|
String operationDate = Utils.dateFormatter.format(transactionDate);
|
||||||
|
|
||||||
|
// Create Loan Application
|
||||||
|
final Integer loanId = createLoanApplication(loanTransactionHelper, clientId.toString(),
|
||||||
|
getLoanProductsProductResponse.getId().toString(), operationDate, null);
|
||||||
|
|
||||||
|
// Evaluate default delinquent values in No Active Loan
|
||||||
|
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
|
assertNotNull(getLoansLoanIdResponse);
|
||||||
|
assertNotNull(getLoansLoanIdResponse.getDelinquent());
|
||||||
|
assertEquals(0, getLoansLoanIdResponse.getDelinquent().getDelinquentDays());
|
||||||
|
assertEquals(0, getLoansLoanIdResponse.getDelinquent().getDelinquentAmount());
|
||||||
|
|
||||||
|
// Loan Disbursement
|
||||||
|
disburseLoanAccount(loanTransactionHelper, loanId, operationDate);
|
||||||
|
// Evaluate default delinquent values in No Active Loan
|
||||||
|
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
|
assertNotNull(getLoansLoanIdResponse);
|
||||||
|
assertNotNull(getLoansLoanIdResponse.getDelinquent());
|
||||||
|
assertNotEquals(0, getLoansLoanIdResponse.getDelinquent().getDelinquentDays());
|
||||||
|
assertNotEquals(0, getLoansLoanIdResponse.getDelinquent().getDelinquentAmount());
|
||||||
|
}
|
||||||
|
|
||||||
private GetLoanProductsProductIdResponse createLoanProduct(final LoanTransactionHelper loanTransactionHelper,
|
private GetLoanProductsProductIdResponse createLoanProduct(final LoanTransactionHelper loanTransactionHelper,
|
||||||
final Integer delinquencyBucketId, final String inArrearsTolerance) {
|
final Integer delinquencyBucketId, final String inArrearsTolerance) {
|
||||||
final HashMap<String, Object> loanProductMap = new LoanProductTestBuilder().withInArrearsTolerance(inArrearsTolerance).build(null,
|
final HashMap<String, Object> loanProductMap = new LoanProductTestBuilder().withInArrearsTolerance(inArrearsTolerance).build(null,
|
||||||
@@ -1595,8 +1647,8 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
return loanTransactionHelper.updateLoanProduct(id, requestModifyLoan);
|
return loanTransactionHelper.updateLoanProduct(id, requestModifyLoan);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer createLoanAccount(final LoanTransactionHelper loanTransactionHelper, final String clientId, final String loanProductId,
|
private Integer createLoanApplication(final LoanTransactionHelper loanTransactionHelper, final String clientId,
|
||||||
final String operationDate, final String inArrearsTolerance) {
|
final String loanProductId, final String operationDate, final String inArrearsTolerance) {
|
||||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(principalAmount).withLoanTermFrequency("12")
|
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(principalAmount).withLoanTermFrequency("12")
|
||||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("12").withRepaymentEveryAfter("1")
|
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("12").withRepaymentEveryAfter("1")
|
||||||
.withRepaymentFrequencyTypeAsMonths() //
|
.withRepaymentFrequencyTypeAsMonths() //
|
||||||
@@ -1608,7 +1660,17 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
.build(clientId, loanProductId, null);
|
.build(clientId, loanProductId, null);
|
||||||
final Integer loanId = loanTransactionHelper.getLoanId(loanApplicationJSON);
|
final Integer loanId = loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||||
loanTransactionHelper.approveLoan(operationDate, principalAmount, loanId, null);
|
loanTransactionHelper.approveLoan(operationDate, principalAmount, loanId, null);
|
||||||
|
return loanId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disburseLoanAccount(final LoanTransactionHelper loanTransactionHelper, final Integer loanId, final String operationDate) {
|
||||||
loanTransactionHelper.disburseLoanWithNetDisbursalAmount(operationDate, loanId, principalAmount);
|
loanTransactionHelper.disburseLoanWithNetDisbursalAmount(operationDate, loanId, principalAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer createLoanAccount(final LoanTransactionHelper loanTransactionHelper, final String clientId, final String loanProductId,
|
||||||
|
final String operationDate, final String inArrearsTolerance) {
|
||||||
|
final Integer loanId = createLoanApplication(loanTransactionHelper, clientId, loanProductId, operationDate, inArrearsTolerance);
|
||||||
|
disburseLoanAccount(loanTransactionHelper, loanId, operationDate);
|
||||||
return loanId;
|
return loanId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user