You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ta...@apache.org on 2023/01/10 13:12:03 UTC

[fineract] branch develop updated: FINERACT-1818-Credit-Refund-Payout-Not-Getting-Created

This is an automated email from the ASF dual-hosted git repository.

taskain 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 145adaa9f FINERACT-1818-Credit-Refund-Payout-Not-Getting-Created
145adaa9f is described below

commit 145adaa9fe8ba070b9aa87a4f341dc278b41d67d
Author: Ruchi Dhamankar <ru...@gmail.com>
AuthorDate: Mon Jan 9 20:39:55 2023 +0530

    FINERACT-1818-Credit-Refund-Payout-Not-Getting-Created
---
 .../portfolio/loanaccount/domain/Loan.java         | 27 ++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)

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 8f13a73e2..2902c0222 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
@@ -3253,10 +3253,11 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
 
         if (this.loanProduct.isMultiDisburseLoan() && adjustedTransaction == null) {
             BigDecimal totalDisbursed = getDisbursedAmount();
-            if (totalDisbursed.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
-                final String errorMessage = "The transaction cannot be done before the loan disbursement: "
-                        + getApprovedOnDate().toString();
-                throw new InvalidLoanStateTransitionException("transaction", "cannot.be.done.before.disbursement", errorMessage);
+            BigDecimal totalPrincipalAdjusted = this.summary.getTotalPrincipalAdjustments();
+            BigDecimal totalPrincipalCredited = totalDisbursed.add(totalPrincipalAdjusted);
+            if (totalPrincipalCredited.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
+                final String errorMessage = "The transaction amount cannot exceed threshold.";
+                throw new InvalidLoanStateTransitionException("transaction", "amount.exceeds.threshold", errorMessage);
             }
         }
 
@@ -3318,11 +3319,12 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
 
         if (this.loanProduct.isMultiDisburseLoan()) {
             BigDecimal totalDisbursed = getDisbursedAmount();
-            if (totalDisbursed.compareTo(this.summary.getTotalPrincipalRepaid()) < 0
+            BigDecimal totalPrincipalAdjusted = this.summary.getTotalPrincipalAdjustments();
+            BigDecimal totalPrincipalCredited = totalDisbursed.add(totalPrincipalAdjusted);
+            if (totalPrincipalCredited.compareTo(this.summary.getTotalPrincipalRepaid()) < 0
                     && this.repaymentScheduleDetail().getPrincipal().minus(totalDisbursed).isGreaterThanZero()) {
-                final String errorMessage = "The transaction cannot be done before the loan disbursement: "
-                        + getApprovedOnDate().toString();
-                throw new InvalidLoanStateTransitionException("transaction", "cannot.be.done.before.disbursement", errorMessage);
+                final String errorMessage = "The transaction amount cannot exceed threshold.";
+                throw new InvalidLoanStateTransitionException("transaction", "amount.exceeds.threshold", errorMessage);
             }
         }
 
@@ -6197,10 +6199,11 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
 
         if (this.loanProduct.isMultiDisburseLoan() && adjustedTransaction == null) {
             BigDecimal totalDisbursed = getDisbursedAmount();
-            if (totalDisbursed.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
-                final String errorMessage = "The transaction cannot be done before the loan disbursement: "
-                        + getApprovedOnDate().toString();
-                throw new InvalidLoanStateTransitionException("transaction", "cannot.be.done.before.disbursement", errorMessage);
+            BigDecimal totalPrincipalAdjusted = this.summary.getTotalPrincipalAdjustments();
+            BigDecimal totalPrincipalCredited = totalDisbursed.add(totalPrincipalAdjusted);
+            if (totalPrincipalCredited.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
+                final String errorMessage = "The transaction amount cannot exceed threshold.";
+                throw new InvalidLoanStateTransitionException("transaction", "amount.exceeds.threshold", errorMessage);
             }
         }