Repository: incubator-fineract
Updated Branches:
  refs/heads/develop 416a6e528 -> d22ef5dec


#1319:Foreclosure charge issue


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

Branch: refs/heads/develop
Commit: d22ef5decb7b76fe282bcf432845e6690e475033
Parents: 416a6e5
Author: jinjurajan <jinju.ra...@confluxtechnologies.com>
Authored: Thu Aug 18 22:05:19 2016 +0530
Committer: jinjurajan <jinju.ra...@confluxtechnologies.com>
Committed: Thu Aug 18 22:05:19 2016 +0530

----------------------------------------------------------------------
 .../portfolio/loanaccount/domain/Loan.java      | 44 +++++++++++++-------
 1 file changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/d22ef5de/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 0ab4b2d..d401a6f 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
@@ -2969,7 +2969,7 @@ public class Loan extends AbstractPersistable<Long> {
                 .getTransactionDate());
         boolean reprocess = true;
 
-        if (isTransactionChronologicallyLatest && adjustedTransaction == null
+        if (!isForeclosure() && isTransactionChronologicallyLatest && 
adjustedTransaction == null
                 && 
loanTransaction.getTransactionDate().isEqual(DateUtils.getLocalDateOfTenant()) 
&& currentInstallment != null
                 && 
currentInstallment.getTotalOutstanding(getCurrency()).isEqualTo(loanTransaction.getAmount(getCurrency())))
 {
             reprocess = false;
@@ -6067,8 +6067,7 @@ public class Loan extends AbstractPersistable<Long> {
                 }
             } else if (installment.getDueDate().isAfter(paymentDate)) {
                 paidFromFutureInstallments = 
paidFromFutureInstallments.plus(installment.getInterestPaid(currency))
-                        
.plus(installment.getPenaltyChargesPaid(currency)).plus(installment.getFeeChargesPaid(currency))
-                        
.minus(installment.getFeeChargesWaived(currency)).minus(installment.getPenaltyChargesWaived(currency));
+                        
.plus(installment.getPenaltyChargesPaid(currency)).plus(installment.getFeeChargesPaid(currency));
             }
 
         }
@@ -6091,18 +6090,33 @@ public class Loan extends AbstractPersistable<Long> {
         interestForCurrentPeriod = 
Money.of(getCurrency(),BigDecimal.valueOf(calculateInterestForDays(totalPeriodDays,
 installment.getInterestCharged(getCurrency())
                 .getAmount(), tillDays)));
         interestAccountedForCurrentPeriod = 
installment.getInterestWaived(getCurrency()).plus(installment.getInterestPaid(getCurrency()));
-        for (LoanCharge loanCharge : this.charges) {
-            if (loanCharge.isActive()
-                    && 
loanCharge.isDueForCollectionFromAndUpToAndIncluding(installment.getFromDate(), 
paymentDate)) {
-                if (loanCharge.isPenaltyCharge()) {
-                    penaltyForCurrentPeriod = 
loanCharge.getAmount(getCurrency());
-                    penaltyAccoutedForCurrentPeriod = 
loanCharge.getAmountWaived(getCurrency()).plus(loanCharge.getAmountPaid(getCurrency()));
-                } else {
-                    feeForCurrentPeriod = loanCharge.getAmount(currency);
-                    feeAccountedForCurrentPeriod = 
loanCharge.getAmountWaived(getCurrency()).plus(loanCharge.getAmountPaid(getCurrency()));
-                }
-            }
-        }
+               for (LoanCharge loanCharge : this.charges) {
+                       if (loanCharge.isActive() && 
!loanCharge.isDueAtDisbursement()) {
+                               if 
(loanCharge.isDueForCollectionFromAndUpToAndIncluding(installment.getFromDate(),
 paymentDate)) {
+                                       if (loanCharge.isPenaltyCharge()) {
+                                               penaltyForCurrentPeriod = 
penaltyForCurrentPeriod.plus(loanCharge.getAmount(getCurrency()));
+                                               penaltyAccoutedForCurrentPeriod 
= penaltyAccoutedForCurrentPeriod.plus(loanCharge
+                                                               
.getAmountWaived(getCurrency()).plus(loanCharge.getAmountPaid(getCurrency())));
+                                       } else {
+                                               feeForCurrentPeriod = 
feeForCurrentPeriod.plus(loanCharge.getAmount(currency));
+                                               feeAccountedForCurrentPeriod = 
feeAccountedForCurrentPeriod
+                                                               
.plus(loanCharge.getAmountWaived(getCurrency()).plus(
+
+                                                                               
loanCharge.getAmountPaid(getCurrency())));
+                                       }
+                               } else if (loanCharge.isInstalmentFee()) {
+                                       LoanInstallmentCharge 
loanInstallmentCharge = loanCharge
+                                                       
.getInstallmentLoanCharge(installment.getInstallmentNumber());
+                                       if (loanCharge.isPenaltyCharge()) {
+                                               penaltyAccoutedForCurrentPeriod 
= penaltyAccoutedForCurrentPeriod
+                                                               
.plus(loanInstallmentCharge.getAmountPaid(currency));
+                                       } else {
+                                               feeAccountedForCurrentPeriod = 
feeAccountedForCurrentPeriod
+                                                               
.plus(loanInstallmentCharge.getAmountPaid(currency));
+                                       }
+                               }
+                       }
+               }
         
         Money[] balances = new Money[6];
         balances[0] = interestForCurrentPeriod;

Reply via email to