fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [1/2] fineract git commit: 475 tranche waive charge
Date Thu, 13 Jul 2017 10:36:01 GMT
Repository: fineract
Updated Branches:
  refs/heads/develop 1ef276be5 -> 5b808fecc


475 tranche waive charge


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

Branch: refs/heads/develop
Commit: 77b0625a5d378c73a556f90bf9ed84ed4810ed01
Parents: ee150b1
Author: nazeer shaik <nazeer.shaik@confluxtechnologies.com>
Authored: Wed Jul 5 16:21:44 2017 +0530
Committer: nazeer shaik <nazeer.shaik@confluxtechnologies.com>
Committed: Wed Jul 5 16:21:44 2017 +0530

----------------------------------------------------------------------
 .../loanaccount/data/DisbursementData.java        | 12 +++++++++++-
 .../data/RepaymentScheduleRelatedLoanData.java    |  3 ++-
 .../portfolio/loanaccount/domain/Loan.java        |  4 ++--
 .../domain/LoanDisbursementDetails.java           |  3 ++-
 .../service/LoanScheduleAssembler.java            |  3 ++-
 .../service/LoanReadPlatformServiceImpl.java      | 18 +++++++++---------
 6 files changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/fineract/blob/77b0625a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
index 97ab973..939a0ac 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
@@ -35,15 +35,17 @@ public class DisbursementData implements Comparable<DisbursementData>
{
     @SuppressWarnings("unused")
     private final String loanChargeId;
     private final BigDecimal chargeAmount;
+    private final BigDecimal waivedChargeAmount;
 
     public DisbursementData(Long id, final LocalDate expectedDisbursementDate, final LocalDate
actualDisbursementDate,
-            final BigDecimal principalDisbursed, final String loanChargeId, BigDecimal chargeAmount)
{
+            final BigDecimal principalDisbursed, final String loanChargeId, BigDecimal chargeAmount,
BigDecimal waivedChargeAmount) {
         this.id = id;
         this.expectedDisbursementDate = expectedDisbursementDate;
         this.actualDisbursementDate = actualDisbursementDate;
         this.principal = principalDisbursed;
         this.loanChargeId = loanChargeId;
         this.chargeAmount = chargeAmount;
+        this.waivedChargeAmount = waivedChargeAmount;
     }
 
     public LocalDate disbursementDate() {
@@ -83,4 +85,12 @@ public class DisbursementData implements Comparable<DisbursementData>
{
         return target != null && target.isAfter(fromNotInclusive) && !target.isAfter(upToAndInclusive);
     }
 
+    
+    public BigDecimal getWaivedChargeAmount() {
+        if(this.waivedChargeAmount == null){
+            return BigDecimal.ZERO;
+        }
+        return this.waivedChargeAmount;
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/77b0625a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java
index 446ee3c..12bb038 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/RepaymentScheduleRelatedLoanData.java
@@ -75,6 +75,7 @@ public class RepaymentScheduleRelatedLoanData {
     }
 
     public DisbursementData disbursementData() {
-        return new DisbursementData(null, this.expectedDisbursementDate, this.actualDisbursementDate,
this.principal, null, null);
+        BigDecimal waivedChargeAmount = null;
+        return new DisbursementData(null, this.expectedDisbursementDate, this.actualDisbursementDate,
this.principal, null, null, waivedChargeAmount);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/77b0625a/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 b71205e..480b081 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
@@ -5576,9 +5576,9 @@ public class Loan extends AbstractPersistableCustom<Long> {
             if (loanDisbursementDetails.actualDisbursementDate() != null) {
                 actualDisbursementDate = new LocalDate(loanDisbursementDetails.actualDisbursementDate());
             }
-
+            BigDecimal waivedChargeAmount = null;
             disbursementData.add(new DisbursementData(loanDisbursementDetails.getId(), expectedDisbursementDate,
actualDisbursementDate,
-                    loanDisbursementDetails.principal(), null, null));
+                    loanDisbursementDetails.principal(), null, null, waivedChargeAmount));
         }
 
         return disbursementData;

http://git-wip-us.apache.org/repos/asf/fineract/blob/77b0625a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
index ef70a18..d19b60f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
@@ -119,7 +119,8 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom<Long>
{
         if (this.actualDisbursementDate != null) {
             actualDisburseDate = new LocalDate(this.actualDisbursementDate);
         }
-        return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal,
null, null);
+        BigDecimal waivedChargeAmount = null;
+        return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal,
null, null, waivedChargeAmount);
     }
 
     public void updateActualDisbursementDate(Date actualDisbursementDate) {

http://git-wip-us.apache.org/repos/asf/fineract/blob/77b0625a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
index a335e9c..1d62273 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
@@ -515,7 +515,8 @@ public class LoanScheduleAssembler {
                             && StringUtils.isNotBlank((jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).getAsString())))
{
                         principal = jsonObject.getAsJsonPrimitive(LoanApiConstants.disbursementPrincipalParameterName).getAsBigDecimal();
                     }
-                    disbursementDatas.add(new DisbursementData(null, expectedDisbursementDate,
null, principal, null, null));
+                    BigDecimal waivedChargeAmount = null;
+                    disbursementDatas.add(new DisbursementData(null, expectedDisbursementDate,
null, principal, null, null, waivedChargeAmount));
                     i++;
                 } while (i < disbursementDataArray.size());
             }

http://git-wip-us.apache.org/repos/asf/fineract/blob/77b0625a/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 19ea4ae..ab6c310 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
@@ -62,7 +62,6 @@ import org.apache.fineract.portfolio.calendar.data.CalendarData;
 import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
 import org.apache.fineract.portfolio.calendar.service.CalendarReadPlatformService;
 import org.apache.fineract.portfolio.charge.data.ChargeData;
-import org.apache.fineract.portfolio.charge.domain.ChargeCalculationType;
 import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
 import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService;
 import org.apache.fineract.portfolio.client.data.ClientData;
@@ -93,8 +92,6 @@ import org.apache.fineract.portfolio.loanaccount.data.PaidInAdvanceData;
 import org.apache.fineract.portfolio.loanaccount.data.RepaymentScheduleRelatedLoanData;
 import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
-import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
-import org.apache.fineract.portfolio.loanaccount.domain.LoanInstallmentCharge;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleTransactionProcessorFactory;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
@@ -1056,7 +1053,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
 
         @Override
         public LoanScheduleData extractData(final ResultSet rs) throws SQLException, DataAccessException
{
-
+            BigDecimal waivedChargeAmount = BigDecimal.ZERO;
+            for (DisbursementData disbursementDetail : disbursementData) {
+                waivedChargeAmount = waivedChargeAmount.add(disbursementDetail.getWaivedChargeAmount());
+            }
             final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(
                     this.disbursement.disbursementDate(), this.disbursement.amount(), this.totalFeeChargesDueAtDisbursement,
                     this.disbursement.isDisbursed());
@@ -1095,9 +1095,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
             Money totalOutstanding = Money.zero(monCurrency);
 
             // update totals with details of fees charged during disbursement
-            totalFeeChargesCharged = totalFeeChargesCharged.plus(disbursementPeriod.feeChargesDue());
-            totalRepaymentExpected = totalRepaymentExpected.plus(disbursementPeriod.feeChargesDue());
-            totalRepayment = totalRepayment.plus(disbursementPeriod.feeChargesPaid());
+            totalFeeChargesCharged = totalFeeChargesCharged.plus(disbursementPeriod.feeChargesDue().subtract(waivedChargeAmount));
+            totalRepaymentExpected = totalRepaymentExpected.plus(disbursementPeriod.feeChargesDue()).minus(waivedChargeAmount);
+            totalRepayment = totalRepayment.plus(disbursementPeriod.feeChargesPaid()).minus(waivedChargeAmount);
             totalOutstanding = totalOutstanding.plus(disbursementPeriod.feeChargesDue()).minus(disbursementPeriod.feeChargesPaid());
 
             Integer loanTermInDays = Integer.valueOf(0);
@@ -1121,7 +1121,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
                                             disbursementChargeAmount, data.isDisbursed());
                                 } else {
                                     periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(),
data.amount(),
-                                            disbursementChargeAmount.add(data.getChargeAmount()),
data.isDisbursed());
+                                            disbursementChargeAmount.add(data.getChargeAmount()).subtract(waivedChargeAmount),
data.isDisbursed());
                                 }
                                 if (periodData != null) {
                                     periods.add(periodData);
@@ -1543,7 +1543,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
             final BigDecimal waivedAmount = rs.getBigDecimal("waivedAmount");
             if (chargeAmount != null && waivedAmount != null) chargeAmount = chargeAmount.subtract(waivedAmount);
             final DisbursementData disbursementData = new DisbursementData(id, expectedDisbursementdate,
actualDisbursementdate, principal,
-                    loanChargeId, chargeAmount);
+                    loanChargeId, chargeAmount, waivedAmount);
             return disbursementData;
         }
 


Mime
View raw message