You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ad...@apache.org on 2024/02/29 16:36:26 UTC
(fineract) branch develop updated: FINERACT-1971: Delinquency evaluation should be happen only for Active loans in COB
This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new fc0fee1e6 FINERACT-1971: Delinquency evaluation should be happen only for Active loans in COB
fc0fee1e6 is described below
commit fc0fee1e6aa9a6c35e0f3690c17f0df44c142176
Author: Jose Alberto Hernandez <al...@black-box.local>
AuthorDate: Wed Feb 28 19:19:26 2024 -0600
FINERACT-1971: Delinquency evaluation should be happen only for Active loans in COB
---
.../DelinquencyWritePlatformServiceImpl.java | 8 ++-
.../DelinquencyBucketsIntegrationTest.java | 60 +++++++++++++++++++++-
2 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java
index 29451c169..185ef2875 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java
@@ -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);
}
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java
index 9b3953a6d..6743b0007 100644
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java
@@ -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,