fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [2/5] incubator-fineract git commit: FINERACT-108 : disbursement change with tranche loan
Date Tue, 10 May 2016 12:27:32 GMT
FINERACT-108 : disbursement change with tranche loan


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/e58e591c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/e58e591c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/e58e591c

Branch: refs/heads/develop
Commit: e58e591c8912b748aaae3154b3d43f476b5eec83
Parents: f3f6f4b
Author: pramod <pramod@confluxtechnologies.com>
Authored: Tue May 10 16:58:09 2016 +0530
Committer: pramod <pramod@confluxtechnologies.com>
Committed: Tue May 10 16:58:46 2016 +0530

----------------------------------------------------------------------
 .../fineract/portfolio/loanaccount/domain/Loan.java       |  8 +++++---
 .../loanaccount/service/LoanReadPlatformServiceImpl.java  | 10 ++++++++--
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/e58e591c/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
----------------------------------------------------------------------
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 85725d2..dae03dd 100755
--- 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
@@ -1683,7 +1683,7 @@ public class Loan extends AbstractPersistable<Long> {
     public void updateDisbursementDetails(final JsonCommand jsonCommand, final Map<String,
Object> actualChanges) {
 
         List<Long> disbursementList = fetchDisbursementIds();
-        List<Long> loanChargeIds = fetchLoanChargeIds();
+        List<Long> loanChargeIds = fetchLoanTrancheChargeIds();
         int chargeIdLength = loanChargeIds.size();
         String chargeIds = null;
         // From modify application page, if user removes all charges, we should
@@ -1807,10 +1807,12 @@ public class Loan extends AbstractPersistable<Long> {
         }
     }
 
-    private List<Long> fetchLoanChargeIds() {
+    private List<Long> fetchLoanTrancheChargeIds() {
         List<Long> list = new ArrayList<>();
         for (LoanCharge charge : this.charges) {
-            list.add(charge.getId());
+            if (charge.isTrancheDisbursementCharge() && charge.isActive()) {
+                list.add(charge.getId());
+            }
         }
         return list;
     }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/e58e591c/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
index ba0ee0a..d0712ce 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
@@ -1027,6 +1027,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
             final MonetaryCurrency monCurrency = new MonetaryCurrency(this.currency.code(),
this.currency.decimalPlaces(),
                     this.currency.currencyInMultiplesOf());
             BigDecimal totalPrincipalDisbursed = BigDecimal.ZERO;
+            BigDecimal disbursementChargeAmount = this.totalFeeChargesDueAtDisbursement;
             if (disbursementData == null || disbursementData.isEmpty()) {
                 periods.add(disbursementPeriod);
                 totalPrincipalDisbursed = Money.of(monCurrency, this.disbursement.amount()).getAmount();
@@ -1034,6 +1035,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
                 if (!this.disbursement.isDisbursed()) {
                     excludePastUndisbursed = false;
                 }
+                for(DisbursementData disbursementData : disbursementData){
+                    if(disbursementData.getChargeAmount() != null){
+                        disbursementChargeAmount = disbursementChargeAmount.subtract(disbursementData.getChargeAmount());
+                    }
+                }
                 this.outstandingLoanPrincipalBalance = BigDecimal.ZERO;
             }
 
@@ -1072,11 +1078,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
                             principal = principal.add(data.amount());
                             if (data.getChargeAmount() == null) {
                                 final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
-                                        data.disbursementDate(), data.amount(), BigDecimal.ZERO,
data.isDisbursed());
+                                        data.disbursementDate(), data.amount(), disbursementChargeAmount,
data.isDisbursed());
                                 periods.add(periodData);
                             } else {
                                 final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
-                                        data.disbursementDate(), data.amount(), data.getChargeAmount(),
data.isDisbursed());
+                                        data.disbursementDate(), data.amount(), disbursementChargeAmount.add(data.getChargeAmount()),
data.isDisbursed());
                                 periods.add(periodData);
                             }
                             this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());


Mime
View raw message