Add validation error for recovery repayments (FINERACT-1113)
per FINERACT-1113 and community-app issue #2225, add a validation error when a user attempts a recovery repayment which is greater than the total written off for the loan. Return an error if the recovery repayment amount is greater than the written off amount. Co-authored-by: tonic889 <tonic889@github.com>
This commit is contained in:
co-authored by
tonic889
parent
e8344e23fa
commit
3479e44b40
+6
@@ -3026,6 +3026,12 @@ public class Loan extends AbstractPersistableCustom {
|
||||
statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_REPAYMENT_OR_WAIVER, LoanStatus.fromInt(this.loanStatus));
|
||||
}
|
||||
|
||||
if (loanTransaction.isRecoveryRepayment()
|
||||
&& loanTransaction.getAmount(loanCurrency()).getAmount().compareTo(getSummary().getTotalWrittenOff()) > 0) {
|
||||
final String errorMessage = "The transaction amount cannot greater than the remaining written off amount.";
|
||||
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.greater.than.total.written.off", errorMessage);
|
||||
}
|
||||
|
||||
this.loanStatus = statusEnum.getValue();
|
||||
|
||||
loanTransaction.updateLoan(this);
|
||||
|
||||
Reference in New Issue
Block a user