FINERACT-2385: Zero amount reage transaction should not be allowed
This commit is contained in:
committed by
Adam Saghy
parent
54e85c748d
commit
4ae6fd5694
+17
@@ -56,6 +56,7 @@ public class LoanReAgingValidator {
|
||||
public void validateReAge(Loan loan, JsonCommand command) {
|
||||
validateReAgeRequest(loan, command);
|
||||
validateReAgeBusinessRules(loan);
|
||||
validateReAgeOutstandingBalance(loan, command);
|
||||
}
|
||||
|
||||
private void validateReAgeRequest(Loan loan, JsonCommand command) {
|
||||
@@ -180,4 +181,20 @@ public class LoanReAgingValidator {
|
||||
private boolean transactionHappenedAfterOther(LoanTransaction transaction, LoanTransaction otherTransaction) {
|
||||
return new ChangeOperation(transaction).compareTo(new ChangeOperation(otherTransaction)) > 0;
|
||||
}
|
||||
|
||||
private void validateReAgeOutstandingBalance(final Loan loan, final JsonCommand command) {
|
||||
final LocalDate businessDate = getBusinessLocalDate();
|
||||
final LocalDate startDate = command.dateValueOfParameterNamed(LoanReAgingApiConstants.startDate);
|
||||
|
||||
final boolean isBackdated = businessDate.isAfter(startDate);
|
||||
if (isBackdated) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (loan.getSummary().getTotalPrincipalOutstanding().compareTo(java.math.BigDecimal.ZERO) == 0) {
|
||||
throw new GeneralPlatformDomainRuleException("error.msg.loan.reage.no.outstanding.balance.to.reage",
|
||||
"Loan cannot be re-aged as there are no outstanding balances to be re-aged", loan.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -44,6 +44,7 @@ import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanSummary;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepository;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
@@ -516,6 +517,9 @@ class LoanReAgingValidatorTest {
|
||||
given(loanProductRelatedDetail.getLoanScheduleType()).willReturn(LoanScheduleType.PROGRESSIVE);
|
||||
given(loan.isInterestBearing()).willReturn(false);
|
||||
given(loan.getLoanTransactions()).willReturn(List.of());
|
||||
LoanSummary loanSummary = mock(LoanSummary.class);
|
||||
given(loan.getSummary()).willReturn(loanSummary);
|
||||
given(loanSummary.getTotalPrincipalOutstanding()).willReturn(java.math.BigDecimal.valueOf(1000));
|
||||
return loan;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user