FINERACT-1971: Delinquency evaluation should be happen only for Active loans in COB
This commit is contained in:
committed by
Adam Saghy
parent
84afccc1f7
commit
fc0fee1e6a
+7
-1
@@ -160,7 +160,13 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
|
||||
if (loan == null) {
|
||||
loan = this.loanRepository.findOneWithNotFoundDetection(loanScheduleDelinquencyData.getLoanId());
|
||||
}
|
||||
final CollectionData collectionData = loanDelinquencyDomainService.getOverdueCollectionData(loan, effectiveDelinquencyList);
|
||||
CollectionData collectionData = null;
|
||||
// If the Loan is not Active yet, return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved()) {
|
||||
collectionData = CollectionData.template();
|
||||
} else {
|
||||
collectionData = loanDelinquencyDomainService.getOverdueCollectionData(loan, effectiveDelinquencyList);
|
||||
}
|
||||
log.debug("Delinquency {}", collectionData);
|
||||
return new LoanScheduleDelinquencyData(loan.getId(), collectionData.getDelinquentDate(), collectionData.getDelinquentDays(), loan);
|
||||
}
|
||||
|
||||
+59
-1
@@ -1580,7 +1580,7 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoanClassificationOnyForActiveLoan() {
|
||||
public void testLoanClassificationOnlyForActiveLoan() {
|
||||
|
||||
// Given
|
||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
@@ -1631,6 +1631,64 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
assertNotEquals(0, getLoansLoanIdResponse.getDelinquent().getDelinquentAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoanClassificationOnlyForActiveLoanWithCOB() {
|
||||
try {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||
final String operationDate = "01 January 2012";
|
||||
|
||||
LocalDate bussinesLocalDate = Utils.getDateAsLocalDate(operationDate);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
|
||||
// Given
|
||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
final SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
||||
|
||||
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 creation
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec, operationDate);
|
||||
final GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProduct(loanTransactionHelper,
|
||||
Math.toIntExact(delinquencyBucket.getId()), null);
|
||||
assertNotNull(getLoanProductsProductResponse);
|
||||
|
||||
// Create Loan Application
|
||||
final Integer loanId = createLoanApplication(loanTransactionHelper, clientId.toString(),
|
||||
getLoanProductsProductResponse.getId().toString(), operationDate, null);
|
||||
|
||||
// run cob for business date 01 January 2012
|
||||
final String jobName = "Loan COB";
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate(operationDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
// Loan delinquency data
|
||||
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
GetLoansLoanIdDelinquencySummary delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
assertNotNull(getLoansLoanIdResponse);
|
||||
assertNotNull(delinquent);
|
||||
assertEquals(0, delinquent.getDelinquentDays());
|
||||
assertEquals(0, delinquent.getDelinquentAmount());
|
||||
|
||||
} finally {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
private GetLoanProductsProductIdResponse createLoanProduct(final LoanTransactionHelper loanTransactionHelper,
|
||||
final Integer delinquencyBucketId, final String inArrearsTolerance) {
|
||||
final HashMap<String, Object> loanProductMap = new LoanProductTestBuilder().withInArrearsTolerance(inArrearsTolerance).build(null,
|
||||
|
||||
Reference in New Issue
Block a user