Repository: incubator-fineract
Updated Branches:
  refs/heads/develop 851b22d16 -> f96d96a14


show Interest Earnings/Overdraft Interest not yet posted


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

Branch: refs/heads/develop
Commit: f96d96a1476f9e5c7512a3e308de370b2598bd96
Parents: 851b22d
Author: AvinashKumarG <avinash.ku...@confluxtechnologies.com>
Authored: Wed May 25 17:37:55 2016 +0530
Committer: AvinashKumarG <avinash.ku...@confluxtechnologies.com>
Committed: Fri May 27 12:17:09 2016 +0530

----------------------------------------------------------------------
 .../savings/data/SavingsAccountSummaryData.java       |  8 +++++++-
 .../savings/domain/SavingsAccountSummary.java         | 13 +++++++++++--
 .../DepositAccountReadPlatformServiceImpl.java        |  2 +-
 .../SavingsAccountReadPlatformServiceImpl.java        | 14 +++++++++++---
 ..._add_interest_recalculation_in_savings_account.sql |  5 +++++
 5 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/f96d96a1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java
index e2d3d0e..21d23b7 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountSummaryData.java
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.savings.data;
 import java.math.BigDecimal;
 
 import org.apache.fineract.organisation.monetary.data.CurrencyData;
+import org.joda.time.LocalDate;
 
 /**
  * Immutable data object representing Savings Account summary information.
@@ -40,11 +41,14 @@ public class SavingsAccountSummaryData {
     private final BigDecimal totalPenaltyCharge;
     private final BigDecimal totalOverdraftInterestDerived;
     private final BigDecimal totalWithholdTax;
+    private final BigDecimal interestNotPosted;
+    private final LocalDate lastInterestCalculationDate;
 
     public SavingsAccountSummaryData(final CurrencyData currency, final 
BigDecimal totalDeposits, final BigDecimal totalWithdrawals,
             final BigDecimal totalWithdrawalFees, final BigDecimal 
totalAnnualFees, final BigDecimal totalInterestEarned,
             final BigDecimal totalInterestPosted, final BigDecimal 
accountBalance, final BigDecimal totalFeeCharge,
-            final BigDecimal totalPenaltyCharge, final BigDecimal 
totalOverdraftInterestDerived,final BigDecimal totalWithholdTax) {
+            final BigDecimal totalPenaltyCharge, final BigDecimal 
totalOverdraftInterestDerived,final BigDecimal totalWithholdTax,
+            final BigDecimal interestNotPosted, final LocalDate 
lastInterestCalculationDate) {
         this.currency = currency;
         this.totalDeposits = totalDeposits;
         this.totalWithdrawals = totalWithdrawals;
@@ -57,5 +61,7 @@ public class SavingsAccountSummaryData {
         this.totalPenaltyCharge = totalPenaltyCharge;
         this.totalOverdraftInterestDerived = totalOverdraftInterestDerived;
         this.totalWithholdTax = totalWithholdTax;
+        this.interestNotPosted = interestNotPosted;
+        this.lastInterestCalculationDate = lastInterestCalculationDate;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/f96d96a1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountSummary.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountSummary.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountSummary.java
index 7a2b5f2..735016d 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountSummary.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccountSummary.java
@@ -19,15 +19,20 @@
 package org.apache.fineract.portfolio.savings.domain;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 import javax.persistence.Column;
 import javax.persistence.Embeddable;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.fineract.infrastructure.core.service.DateUtils;
 import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
 import org.apache.fineract.organisation.monetary.domain.Money;
 import org.apache.fineract.portfolio.savings.domain.interest.PostingPeriod;
+import org.joda.time.LocalDate;
 
 /**
  * {@link SavingsAccountSummary} encapsulates all the summary details of a
@@ -75,6 +80,10 @@ public final class SavingsAccountSummary {
 
     @Column(name = "total_withhold_tax_derived", scale = 6, precision = 19)
     private BigDecimal totalWithholdTax;
+    
+    @Temporal(TemporalType.DATE)
+    @Column(name = "last_interest_calculation_date")
+    private Date lastInterestCalculationDate;
 
     protected SavingsAccountSummary() {
         //
@@ -104,13 +113,13 @@ public final class SavingsAccountSummary {
     public void updateFromInterestPeriodSummaries(final MonetaryCurrency 
currency, final List<PostingPeriod> allPostingPeriods) {
 
         Money totalEarned = Money.zero(currency);
-
+        LocalDate interestCalculationDate = DateUtils.getLocalDateOfTenant();
         for (final PostingPeriod period : allPostingPeriods) {
             Money interestEarned = period.interest();
             interestEarned = interestEarned == null ? Money.zero(currency) : 
interestEarned;
             totalEarned = totalEarned.plus(interestEarned);
         }
-
+        this.lastInterestCalculationDate = interestCalculationDate.toDate();
         this.totalInterestEarned = totalEarned.getAmount();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/f96d96a1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java
index 5e0dab7..5853ddb 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java
@@ -741,7 +741,7 @@ public class DepositAccountReadPlatformServiceImpl 
implements DepositAccountRead
 
             final SavingsAccountSummaryData summary = new 
SavingsAccountSummaryData(currency, totalDeposits, totalWithdrawals,
                     totalWithdrawalFees, totalAnnualFees, totalInterestEarned, 
totalInterestPosted, accountBalance, totalFeeCharge,
-                    totalPenaltyCharge, totalOverdraftInterestDerived, 
totalWithholdTax);
+                    totalPenaltyCharge, totalOverdraftInterestDerived, 
totalWithholdTax, null, null);
 
             return DepositAccountData.instance(id, accountNo, externalId, 
groupId, groupName, clientId, clientName, productId, productName,
                     fieldOfficerId, fieldOfficerName, status, timeline, 
currency, nominalAnnualInterestRate, interestCompoundingPeriodType,

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/f96d96a1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java
index f9014a5..5cc784d 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java
@@ -289,8 +289,9 @@ public class SavingsAccountReadPlatformServiceImpl 
implements SavingsAccountRead
             sqlBuilder.append("sa.min_required_balance as minRequiredBalance, 
");
             sqlBuilder.append("sa.enforce_min_required_balance as 
enforceMinRequiredBalance, ");
             sqlBuilder.append("sa.on_hold_funds_derived as onHoldFunds, ");
-            sqlBuilder.append("sa.withhold_tax as withHoldTax,");
-            sqlBuilder.append("sa.total_withhold_tax_derived as 
totalWithholdTax,");
+            sqlBuilder.append("sa.withhold_tax as withHoldTax, ");
+            sqlBuilder.append("sa.total_withhold_tax_derived as 
totalWithholdTax, ");
+            sqlBuilder.append("sa.last_interest_calculation_date as 
lastInterestCalculationDate, ");
             sqlBuilder.append("tg.id as taxGroupId, tg.name as taxGroupName, 
");
             sqlBuilder.append("(select 
IFNULL(max(sat.transaction_date),sa.activatedon_date) ");
             sqlBuilder.append("from m_savings_account_transaction as sat ");
@@ -497,10 +498,17 @@ public class SavingsAccountReadPlatformServiceImpl 
implements SavingsAccountRead
             final BigDecimal minBalanceForInterestCalculation = 
JdbcSupport.getBigDecimalDefaultToNullIfZero(rs,
                     "minBalanceForInterestCalculation");
             final BigDecimal onHoldFunds = rs.getBigDecimal("onHoldFunds");
+            
+            BigDecimal interestNotPosted = BigDecimal.ZERO;
+            if (totalInterestEarned != null) {
+                 interestNotPosted = 
totalInterestEarned.subtract(totalInterestPosted).add(totalOverdraftInterestDerived);
+            }
+            
+            LocalDate lastInterestCalculationDate = 
JdbcSupport.getLocalDate(rs, "lastInterestCalculationDate");
 
             final SavingsAccountSummaryData summary = new 
SavingsAccountSummaryData(currency, totalDeposits, totalWithdrawals,
                     totalWithdrawalFees, totalAnnualFees, totalInterestEarned, 
totalInterestPosted, accountBalance, totalFeeCharge,
-                    totalPenaltyCharge, totalOverdraftInterestDerived, 
totalWithholdTax);
+                    totalPenaltyCharge, totalOverdraftInterestDerived, 
totalWithholdTax, interestNotPosted, lastInterestCalculationDate);
 
             final boolean withHoldTax = rs.getBoolean("withHoldTax");
             final Long taxGroupId = JdbcSupport.getLong(rs, "taxGroupId");

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/f96d96a1/fineract-provider/src/main/resources/sql/migrations/core_db/V308__add_interest_recalculation_in_savings_account.sql
----------------------------------------------------------------------
diff --git 
a/fineract-provider/src/main/resources/sql/migrations/core_db/V308__add_interest_recalculation_in_savings_account.sql
 
b/fineract-provider/src/main/resources/sql/migrations/core_db/V308__add_interest_recalculation_in_savings_account.sql
new file mode 100644
index 0000000..010766a
--- /dev/null
+++ 
b/fineract-provider/src/main/resources/sql/migrations/core_db/V308__add_interest_recalculation_in_savings_account.sql
@@ -0,0 +1,5 @@
+ALTER TABLE `m_savings_account`
+       ADD COLUMN `last_interest_calculation_date` DATE NULL DEFAULT NULL 
AFTER `tax_group_id`;
+
+
+

Reply via email to