use of org.mifos.accounts.savings.interest.EndOfDayDetail in project head by mifos.
the class SavingsServiceFacadeWebTier method withdrawalMakesBalanceNegative.
private boolean withdrawalMakesBalanceNegative(SavingsBO savings, Money withdrawalAmount, LocalDate trxnDate) {
boolean negativeBalance = false;
List<EndOfDayDetail> allEndOfDayDetailsForAccount = this.savingsDao.retrieveAllEndOfDayDetailsFor(savings.getCurrency(), savings.getAccountId().longValue());
Money balance = Money.zero(savings.getCurrency());
for (EndOfDayDetail endOfDayDetail : allEndOfDayDetailsForAccount) {
balance = balance.add(endOfDayDetail.getResultantAmountForDay());
if (endOfDayDetail.getDate().isEqual(trxnDate)) {
balance = balance.subtract(withdrawalAmount);
}
if (balance.isLessThanZero()) {
negativeBalance = true;
break;
}
}
return negativeBalance;
}
use of org.mifos.accounts.savings.interest.EndOfDayDetail in project head by mifos.
the class SavingsServiceFacadeWebTier method hasAccountNegativeBalance.
private boolean hasAccountNegativeBalance(SavingsBO savingsAccount) {
boolean negativeBalance = false;
List<EndOfDayDetail> allEndOfDayDetailsForAccount = savingsDao.retrieveAllEndOfDayDetailsFor(savingsAccount.getCurrency(), savingsAccount.getAccountId().longValue());
Money balance = Money.zero(savingsAccount.getCurrency());
for (EndOfDayDetail endOfDayDetail : allEndOfDayDetailsForAccount) {
balance = balance.add(endOfDayDetail.getResultantAmountForDay());
if (balance.isLessThanZero()) {
negativeBalance = true;
break;
}
}
return negativeBalance;
}
Aggregations