show Interest Earnings/Overdraft Interest not yet posted
This commit is contained in:
+7
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
+11
-3
@@ -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");
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE `m_savings_account`
|
||||
ADD COLUMN `last_interest_calculation_date` DATE NULL DEFAULT NULL AFTER `tax_group_id`;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user