fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vorbur...@apache.org
Subject [fineract] branch develop updated: Add validation error for recovery repayments (FINERACT-1113)
Date Tue, 29 Sep 2020 16:11:21 GMT
This is an automated email from the ASF dual-hosted git repository.

vorburger 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 3479e44  Add validation error for recovery repayments (FINERACT-1113)
3479e44 is described below

commit 3479e44b4048ff5e4eacb65c2c4f4ed623a15caf
Author: Brian C Cooke <tonic889@users.noreply.github.com>
AuthorDate: Tue Sep 29 12:11:11 2020 -0400

    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>
---
 .../java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
index 9a419b1..6b1cf04 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
@@ -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);


Mime
View raw message