FINERACT-1971: Disable delinquency calculation for non active loans
This commit is contained in:
committed by
Adam Saghy
parent
be655756a5
commit
5d0152c262
+5
-2
@@ -126,8 +126,8 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
|
||||
if (optLoan.isPresent()) {
|
||||
final Loan loan = optLoan.get();
|
||||
|
||||
// If the Loan is not Active yet, return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved()) {
|
||||
// If the Loan is not Active yet or is cancelled (rejected or withdrawn), return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved() || loan.isCancelled()) {
|
||||
return CollectionData.template();
|
||||
}
|
||||
|
||||
@@ -137,6 +137,9 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
|
||||
|
||||
final String nextPaymentDueDateConfig = configurationDomainService.getNextPaymentDateConfigForLoan();
|
||||
|
||||
// Below method calculates delinquency for active loans only and returns template data for Closed or
|
||||
// Overpaid
|
||||
// loans
|
||||
collectionData = loanDelinquencyDomainService.getOverdueCollectionData(loan, effectiveDelinquencyList);
|
||||
collectionData.setAvailableDisbursementAmount(loan.getApprovedPrincipal().subtract(loan.getDisbursedAmount()));
|
||||
collectionData.setNextPaymentDueDate(loan.possibleNextRepaymentDate(nextPaymentDueDateConfig));
|
||||
|
||||
+3
-1
@@ -162,7 +162,9 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
|
||||
}
|
||||
CollectionData collectionData = null;
|
||||
// If the Loan is not Active yet, return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved()) {
|
||||
// If the Loan is Rejected, Closed written-off, Withdrawn by Client, Closed with outstanding marked for
|
||||
// reschedule, Closed obligation met, Overpaid, return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved() || loan.isClosed() || loan.getStatus().isOverpaid()) {
|
||||
collectionData = CollectionData.template();
|
||||
} else {
|
||||
collectionData = loanDelinquencyDomainService.getOverdueCollectionData(loan, effectiveDelinquencyList);
|
||||
|
||||
+16
@@ -56,6 +56,14 @@ public class LoanDelinquencyDomainServiceImpl implements LoanDelinquencyDomainSe
|
||||
boolean overdueSinceDateWasSet = false;
|
||||
boolean firstNotYetDueInstallment = false;
|
||||
log.debug("Loan id {} with {} installments", loan.getId(), loan.getRepaymentScheduleInstallments().size());
|
||||
|
||||
// If the Loan is not Active yet, return template data
|
||||
// If the Loan is Rejected, Closed written-off, Withdrawn by Client, Closed with outstanding marked for
|
||||
// reschedule, Closed obligation met, Overpaid return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved() || loan.isClosed() || loan.getStatus().isOverpaid()) {
|
||||
return CollectionData.template();
|
||||
}
|
||||
|
||||
// Get the oldest overdue installment if exists one
|
||||
for (LoanRepaymentScheduleInstallment installment : loan.getRepaymentScheduleInstallments()) {
|
||||
if (!installment.isObligationsMet()) {
|
||||
@@ -124,6 +132,14 @@ public class LoanDelinquencyDomainServiceImpl implements LoanDelinquencyDomainSe
|
||||
boolean overdueSinceDateWasSet = false;
|
||||
boolean firstNotYetDueInstallment = false;
|
||||
log.debug("Loan id {} with {} installments", loan.getId(), loan.getRepaymentScheduleInstallments().size());
|
||||
|
||||
// If the Loan is not Active yet, return template data
|
||||
// If the Loan is Rejected, Closed written-off, Withdrawn by Client, Closed with outstanding marked for
|
||||
// reschedule, Closed obligation met, Overpaid, return template data
|
||||
if (loan.isSubmittedAndPendingApproval() || loan.isApproved() || loan.isClosed() || loan.getStatus().isOverpaid()) {
|
||||
return new LoanDelinquencyData(collectionData, loanInstallmentsCollectionData);
|
||||
}
|
||||
|
||||
for (LoanRepaymentScheduleInstallment installment : loan.getRepaymentScheduleInstallments()) {
|
||||
CollectionData installmentCollectionData = CollectionData.template();
|
||||
if (!installment.isObligationsMet()) {
|
||||
|
||||
+6
@@ -49,6 +49,7 @@ import org.apache.fineract.portfolio.loanaccount.data.CollectionData;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanDelinquencyData;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionToRepaymentScheduleMapping;
|
||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
|
||||
@@ -123,6 +124,7 @@ public class LoanDelinquencyDomainServiceTest {
|
||||
when(loan.getLoanProductRelatedDetail()).thenReturn(loanProductRelatedDetail);
|
||||
when(loan.getRepaymentScheduleInstallments()).thenReturn(repaymentScheduleInstallments);
|
||||
when(loan.getCurrency()).thenReturn(currency);
|
||||
when(loan.getStatus()).thenReturn(LoanStatus.ACTIVE);
|
||||
|
||||
CollectionData collectionData = underTest.getOverdueCollectionData(loan, effectiveDelinquencyList);
|
||||
|
||||
@@ -150,6 +152,7 @@ public class LoanDelinquencyDomainServiceTest {
|
||||
when(loan.getLoanTransactions(Mockito.any(Predicate.class))).thenReturn(Collections.emptyList());
|
||||
when(loan.getLastLoanRepaymentScheduleInstallment()).thenReturn(repaymentScheduleInstallments.get(0));
|
||||
when(loan.getCurrency()).thenReturn(currency);
|
||||
when(loan.getStatus()).thenReturn(LoanStatus.ACTIVE);
|
||||
when(delinquencyEffectivePauseHelper.getPausedDaysBeforeDate(effectiveDelinquencyList, businessDate)).thenReturn(0L);
|
||||
|
||||
CollectionData collectionData = underTest.getOverdueCollectionData(loan, effectiveDelinquencyList);
|
||||
@@ -186,6 +189,7 @@ public class LoanDelinquencyDomainServiceTest {
|
||||
when(loan.getLoanProductRelatedDetail()).thenReturn(loanProductRelatedDetail);
|
||||
when(loan.getRepaymentScheduleInstallments()).thenReturn(repaymentScheduleInstallments);
|
||||
when(loan.getCurrency()).thenReturn(currency);
|
||||
when(loan.getStatus()).thenReturn(LoanStatus.ACTIVE);
|
||||
|
||||
CollectionData collectionData = underTest.getOverdueCollectionData(loan, effectiveDelinquencyList);
|
||||
|
||||
@@ -217,6 +221,7 @@ public class LoanDelinquencyDomainServiceTest {
|
||||
when(loan.getLastLoanRepaymentScheduleInstallment()).thenReturn(repaymentScheduleInstallments.get(0));
|
||||
when(loan.getCurrency()).thenReturn(currency);
|
||||
when(loan.isEnableInstallmentLevelDelinquency()).thenReturn(true);
|
||||
when(loan.getStatus()).thenReturn(LoanStatus.ACTIVE);
|
||||
when(delinquencyEffectivePauseHelper.getPausedDaysBeforeDate(effectiveDelinquencyList, businessDate)).thenReturn(0L);
|
||||
|
||||
LoanDelinquencyData collectionData = underTest.getLoanDelinquencyData(loan, effectiveDelinquencyList);
|
||||
@@ -266,6 +271,7 @@ public class LoanDelinquencyDomainServiceTest {
|
||||
when(loan.getRepaymentScheduleInstallments()).thenReturn(repaymentScheduleInstallments);
|
||||
when(loan.isEnableInstallmentLevelDelinquency()).thenReturn(true);
|
||||
when(loan.getCurrency()).thenReturn(currency);
|
||||
when(loan.getStatus()).thenReturn(LoanStatus.ACTIVE);
|
||||
when(loan.getLoanTransactions(Mockito.any(Predicate.class))).thenReturn(Arrays.asList(loanTransaction));
|
||||
when(delinquencyEffectivePauseHelper.getPausedDaysBeforeDate(effectiveDelinquencyList, businessDate)).thenReturn(0L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user