diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java index be7bbac26..063b1bc99 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java @@ -184,7 +184,7 @@ public class DepositAccountData { this.interestPaid=account.getInterestPaid(); this.isInterestWithdrawable=account.isInterestWithdrawable(); this.interestCompoundingAllowed = account.isInterestCompoundingAllowed(); - this.availableInterestForWithdrawal=getAvailableInterestForWithdrawal(account);; + this.availableInterestForWithdrawal=determineAvailableInterestForWithdrawal(account);; } public DepositAccountData( @@ -444,15 +444,26 @@ public class DepositAccountData { public BigDecimal getAvailableInterestForWithdrawal() { return availableInterestForWithdrawal; } - public BigDecimal getAvailableInterestForWithdrawal(DepositAccountData account) { - if(account.getStatus().getId()==300){ - BigDecimal interstGettingForPeriod = BigDecimal.valueOf(account.getActualInterestAccrued().doubleValue()/new Double(account.getTenureInMonths())); - Integer noOfMonthsforInterestCal = Months.monthsBetween(account.getActualCommencementDate(), new LocalDate()).getMonths(); - Integer noOfPeriods = noOfMonthsforInterestCal / account.getInterestCompoundedEvery(); - return BigDecimal.valueOf(interstGettingForPeriod.multiply(new BigDecimal(noOfPeriods)).doubleValue()-account.getInterestPaid().doubleValue()); - } - else{ - return new BigDecimal(0); + + private BigDecimal determineAvailableInterestForWithdrawal(final DepositAccountData account) { + BigDecimal availableInterestForWithdrawal = BigDecimal.ZERO; + + if (account.getStatus().getId() == 300) { + BigDecimal interestGettingForPeriod = BigDecimal.valueOf(account + .getActualInterestAccrued().doubleValue() + / new Double(account.getTenureInMonths())); + Integer noOfMonthsforInterestCal = Months.monthsBetween( + account.getActualCommencementDate(), new LocalDate()) + .getMonths(); + Integer noOfPeriods = noOfMonthsforInterestCal + / account.getInterestCompoundedEvery(); + + availableInterestForWithdrawal = BigDecimal + .valueOf(interestGettingForPeriod.multiply( + new BigDecimal(noOfPeriods)).doubleValue() + - account.getInterestPaid().doubleValue()); } + + return availableInterestForWithdrawal; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccountTransaction.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccountTransaction.java index 270e79ca9..c59378955 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccountTransaction.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccountTransaction.java @@ -45,9 +45,11 @@ public class DepositAccountTransaction extends AbstractPersistable { @Column(name = "amount", scale = 6, precision = 19, nullable = false) private final BigDecimal amount; + @SuppressWarnings("unused") @Column(name = "interest", scale = 6, precision = 19, nullable = false) private final BigDecimal interest; + @SuppressWarnings("unused") @Column(name = "total", scale = 6, precision = 19, nullable = false) private final BigDecimal total;