Search in sources :

Example 6 with EndOfDayDetail

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;
}
Also used : Money(org.mifos.framework.util.helpers.Money) EndOfDayDetail(org.mifos.accounts.savings.interest.EndOfDayDetail)

Example 7 with EndOfDayDetail

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;
}
Also used : Money(org.mifos.framework.util.helpers.Money) EndOfDayDetail(org.mifos.accounts.savings.interest.EndOfDayDetail)

Aggregations

EndOfDayDetail (org.mifos.accounts.savings.interest.EndOfDayDetail)7 Money (org.mifos.framework.util.helpers.Money)6 LocalDate (org.joda.time.LocalDate)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 CalendarPeriod (org.mifos.accounts.savings.interest.CalendarPeriod)3 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)3 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)3 Date (java.util.Date)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AccountNotesEntity (org.mifos.accounts.business.AccountNotesEntity)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 AccountException (org.mifos.accounts.exceptions.AccountException)1