[FINERACT-1971] LoanRepaymentDueBusinessEvent shouldn't be sent if the loan is not disbursed or the outstanding balance is greater than 0
This commit is contained in:
+16
-6
@@ -40,6 +40,8 @@ import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.repayment.LoanRepaymentDueBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanSummary;
|
||||
@@ -79,15 +81,19 @@ public class CheckLoanRepaymentDueBusinessStepTest {
|
||||
Loan loanForProcessing = Mockito.mock(Loan.class);
|
||||
LoanProduct loanProduct = Mockito.mock(LoanProduct.class);
|
||||
LoanSummary loanSummary = Mockito.mock(LoanSummary.class);
|
||||
LoanRepaymentScheduleInstallment repaymentInstallment = new LoanRepaymentScheduleInstallment(loanForProcessing, 1,
|
||||
LocalDate.now(ZoneId.systemDefault()), loanInstallmentRepaymentDueDate, BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
|
||||
BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), false, new HashSet<>(), BigDecimal.valueOf(0.0));
|
||||
MonetaryCurrency currency = Mockito.mock(MonetaryCurrency.class);
|
||||
Money money = Mockito.mock(Money.class);
|
||||
LoanRepaymentScheduleInstallment repaymentInstallment = Mockito.mock(LoanRepaymentScheduleInstallment.class);
|
||||
List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments = Arrays.asList(repaymentInstallment);
|
||||
when(repaymentInstallment.getDueDate()).thenReturn(loanInstallmentRepaymentDueDate);
|
||||
when(loanForProcessing.getLoanProduct()).thenReturn(loanProduct);
|
||||
when(loanProduct.getDueDaysForRepaymentEvent()).thenReturn(null);
|
||||
when(loanForProcessing.getRepaymentScheduleInstallments()).thenReturn(loanRepaymentScheduleInstallments);
|
||||
when(loanForProcessing.getLoanSummary()).thenReturn(loanSummary);
|
||||
when(loanForProcessing.getLoanSummary().getTotalOutstanding()).thenReturn(BigDecimal.ONE);
|
||||
when(loanForProcessing.getCurrency()).thenReturn(currency);
|
||||
when(repaymentInstallment.getDue(currency)).thenReturn(money);
|
||||
when(money.isGreaterThanZero()).thenReturn(true);
|
||||
|
||||
// when
|
||||
Loan processedLoan = underTest.execute(loanForProcessing);
|
||||
@@ -132,16 +138,20 @@ public class CheckLoanRepaymentDueBusinessStepTest {
|
||||
Loan loanForProcessing = Mockito.mock(Loan.class);
|
||||
LoanProduct loanProduct = Mockito.mock(LoanProduct.class);
|
||||
LoanSummary loanSummary = Mockito.mock(LoanSummary.class);
|
||||
LoanRepaymentScheduleInstallment repaymentInstallment = new LoanRepaymentScheduleInstallment(loanForProcessing, 1,
|
||||
LocalDate.now(ZoneId.systemDefault()), loanInstallmentRepaymentDueDate, BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
|
||||
BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), false, new HashSet<>(), BigDecimal.valueOf(0.0));
|
||||
MonetaryCurrency currency = Mockito.mock(MonetaryCurrency.class);
|
||||
Money money = Mockito.mock(Money.class);
|
||||
LoanRepaymentScheduleInstallment repaymentInstallment = Mockito.mock(LoanRepaymentScheduleInstallment.class);
|
||||
List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments = Arrays.asList(repaymentInstallment);
|
||||
when(repaymentInstallment.getDueDate()).thenReturn(loanInstallmentRepaymentDueDate);
|
||||
when(loanForProcessing.getLoanProduct()).thenReturn(loanProduct);
|
||||
// Loan Product setting overrides global settings
|
||||
when(loanProduct.getDueDaysForRepaymentEvent()).thenReturn(1);
|
||||
when(loanForProcessing.getRepaymentScheduleInstallments()).thenReturn(loanRepaymentScheduleInstallments);
|
||||
when(loanForProcessing.getLoanSummary()).thenReturn(loanSummary);
|
||||
when(loanForProcessing.getLoanSummary().getTotalOutstanding()).thenReturn(BigDecimal.ONE);
|
||||
when(loanForProcessing.getCurrency()).thenReturn(currency);
|
||||
when(repaymentInstallment.getDue(currency)).thenReturn(money);
|
||||
when(money.isGreaterThanZero()).thenReturn(true);
|
||||
|
||||
// when
|
||||
Loan processedLoan = underTest.execute(loanForProcessing);
|
||||
|
||||
Reference in New Issue
Block a user