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 14:06:01 UTC

[fineract] 01/01: Revert "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 revert-2869-FINERACT-1818-Credit-Refund-Payout-Not-Getting-Created
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit 2eb8e3c10981def23273293af0df17886ab9c8bc
Author: taskain7 <ta...@gmail.com>
AuthorDate: Tue Jan 10 06:05:53 2023 -0800

    Revert "FINERACT-1818-Credit-Refund-Payout-Not-Getting-Created"
    
    This reverts commit 145adaa9fe8ba070b9aa87a4f341dc278b41d67d.
---
 .../portfolio/loanaccount/domain/Loan.java         | 27 ++++++++++------------
 1 file changed, 12 insertions(+), 15 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 2902c0222..8f13a73e2 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,11 +3253,10 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
 
         if (this.loanProduct.isMultiDisburseLoan() && adjustedTransaction == null) {
             BigDecimal totalDisbursed = getDisbursedAmount();
-            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);
+            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);
             }
         }
 
@@ -3319,12 +3318,11 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
 
         if (this.loanProduct.isMultiDisburseLoan()) {
             BigDecimal totalDisbursed = getDisbursedAmount();
-            BigDecimal totalPrincipalAdjusted = this.summary.getTotalPrincipalAdjustments();
-            BigDecimal totalPrincipalCredited = totalDisbursed.add(totalPrincipalAdjusted);
-            if (totalPrincipalCredited.compareTo(this.summary.getTotalPrincipalRepaid()) < 0
+            if (totalDisbursed.compareTo(this.summary.getTotalPrincipalRepaid()) < 0
                     && this.repaymentScheduleDetail().getPrincipal().minus(totalDisbursed).isGreaterThanZero()) {
-                final String errorMessage = "The transaction amount cannot exceed threshold.";
-                throw new InvalidLoanStateTransitionException("transaction", "amount.exceeds.threshold", errorMessage);
+                final String errorMessage = "The transaction cannot be done before the loan disbursement: "
+                        + getApprovedOnDate().toString();
+                throw new InvalidLoanStateTransitionException("transaction", "cannot.be.done.before.disbursement", errorMessage);
             }
         }
 
@@ -6199,11 +6197,10 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
 
         if (this.loanProduct.isMultiDisburseLoan() && adjustedTransaction == null) {
             BigDecimal totalDisbursed = getDisbursedAmount();
-            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);
+            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);
             }
         }