fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [1/2] incubator-fineract git commit: FINERACT-64 issues resolved
Date Tue, 22 Mar 2016 09:37:53 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop dd736852f -> c1af84dd4


FINERACT-64 issues resolved


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

Branch: refs/heads/develop
Commit: db367216a9f5fa54938362d5e2edfbf40ea59660
Parents: 04fe104
Author: venkatconflux <venkata.conflux@confluxtechnologies.com>
Authored: Mon Mar 21 18:19:05 2016 +0530
Committer: venkatconflux <venkata.conflux@confluxtechnologies.com>
Committed: Mon Mar 21 18:19:05 2016 +0530

----------------------------------------------------------------------
 .../portfolio/loanaccount/domain/Loan.java      | 22 +++++++++++++++-----
 .../service/LoanChargeAssembler.java            | 15 ++++++++-----
 2 files changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/db367216/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 5697c9e..ebc2b6c 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
@@ -856,7 +856,7 @@ public class Loan extends AbstractPersistable<Long> {
         if (loanCharge.isOverdueInstallmentCharge()) { return loanCharge.getAmountPercentageAppliedTo();
}
         switch (loanCharge.getChargeCalculation()) {
             case PERCENT_OF_AMOUNT:
-                amount = getPrincpal().getAmount();
+                    amount = getDerivedAmountForCharge(loanCharge);
             break;
             case PERCENT_OF_AMOUNT_AND_INTEREST:
                 final BigDecimal totalInterestCharged = getTotalInterest();
@@ -1074,7 +1074,7 @@ public class Loan extends AbstractPersistable<Long> {
             if (loanCharge.getId() == null) {
                 LoanTrancheDisbursementCharge loanTrancheDisbursementCharge = null;
                 loanCharge.update(this);
-                if (this.loanProduct.isMultiDisburseLoan()) {
+                if (this.loanProduct.isMultiDisburseLoan() && loanCharge.isTrancheDisbursementCharge())
{
                     loanCharge.getTrancheDisbursementCharge().getloanDisbursementDetails().updateLoan(this);
                     for (final LoanDisbursementDetails loanDisbursementDetails : this.disbursementDetails)
{
                         if (loanCharge.getTrancheDisbursementCharge().getloanDisbursementDetails().getId()
== null) {
@@ -2576,7 +2576,7 @@ public class Loan extends AbstractPersistable<Long> {
         updateLoanSchedule(loanSchedule, currentUser);
         Set<LoanCharge> charges = this.charges();
         for (LoanCharge loanCharge : charges) {
-            recalculateLoanCharge(loanCharge, scheduleGeneratorDTO.getPenaltyWaitPeriod());
+                recalculateLoanCharge(loanCharge, scheduleGeneratorDTO.getPenaltyWaitPeriod());
         }
     }
 
@@ -2640,7 +2640,9 @@ public class Loan extends AbstractPersistable<Long> {
         final Integer installmentNumber = null;
         for (final LoanCharge charge : charges()) {
             Date actualDisbursementDate = getActualDisbursementDate(charge);
-            if (charge.getCharge().getChargeTimeType() == ChargeTimeType.DISBURSEMENT.getValue()
+            if ((charge.getCharge().getChargeTimeType() == ChargeTimeType.DISBURSEMENT.getValue()

+            		&& disbursedOn.equals(new LocalDate(actualDisbursementDate)) &&
actualDisbursementDate != null
+                    && !charge.isWaived() && !charge.isFullyPaid())
                     || (charge.getCharge().getChargeTimeType() == ChargeTimeType.TRANCHE_DISBURSEMENT.getValue()
                             && disbursedOn.equals(new LocalDate(actualDisbursementDate))
&& actualDisbursementDate != null
                             && !charge.isWaived() && !charge.isFullyPaid()))
{
@@ -5530,7 +5532,7 @@ public class Loan extends AbstractPersistable<Long> {
     }
 
     private Date getActualDisbursementDate(final LoanCharge loanCharge) {
-        Date actualDisbursementDate = null;
+        Date actualDisbursementDate = this.actualDisbursementDate;
         if (loanCharge.isDueAtDisbursement() && loanCharge.isActive()) {
             LoanTrancheDisbursementCharge trancheDisbursementCharge = loanCharge.getTrancheDisbursementCharge();
             if (trancheDisbursementCharge != null) {
@@ -5698,5 +5700,15 @@ public class Loan extends AbstractPersistable<Long> {
         }
         return nextRepaymentDate;
     }
+    
+    public BigDecimal getDerivedAmountForCharge(LoanCharge loanCharge) {
+        BigDecimal amount = BigDecimal.ZERO;
+        if (isMultiDisburmentLoan() && (loanCharge.getCharge().getChargeTimeType()
== ChargeTimeType.DISBURSEMENT.getValue())) {
+            amount = getApprovedPrincipal();
+        } else {
+            amount = getPrincpal().getAmount();
+        }
+        return amount;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/db367216/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeAssembler.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeAssembler.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeAssembler.java
index 8095142..13b3839 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeAssembler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeAssembler.java
@@ -162,8 +162,11 @@ public class LoanChargeAssembler {
                                         final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition,
principal, amount,
                                                 chargeTime, chargeCalculation, dueDate, chargePaymentModeEnum,
numberOfRepayments);
                                         loanCharges.add(loanCharge);
-                                        loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge,
disbursementDetail);
-                                        loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
+                                        if (loanCharge.isTrancheDisbursementCharge()) {
+                                            loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge,
+                                                    disbursementDetail);
+                                            loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
+                                        }
                                     } else {
                                         if (disbursementDetail.expectedDisbursementDateAsLocalDate().equals(expectedDisbursementDate))
{
                                             final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition,
@@ -171,9 +174,11 @@ public class LoanChargeAssembler {
                                                     disbursementDetail.expectedDisbursementDateAsLocalDate(),
chargePaymentModeEnum,
                                                     numberOfRepayments);
                                             loanCharges.add(loanCharge);
-                                            loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge,
-                                                    disbursementDetail);
-                                            loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
+                                            if (loanCharge.isTrancheDisbursementCharge())
{
+                                                loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge,
+                                                        disbursementDetail);
+                                                loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
+                                            }
                                         }
                                     }
                                 }


Mime
View raw message