Search in sources :

Example 16 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class CustomerAccountBO method getTotalAmountDue.

@Override
public Money getTotalAmountDue() {
    Money totalAmt = getTotalAmountInArrears();
    List<AccountActionDateEntity> dueActionDateList = getTotalDueInstallments();
    if (dueActionDateList.size() > 0) {
        AccountActionDateEntity nextInstallment = dueActionDateList.get(0);
        totalAmt = totalAmt.add(getDueAmount(nextInstallment));
    }
    return totalAmt;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity)

Example 17 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class CustomerAccountBO method applyCharge.

@Override
public void applyCharge(final Short feeId, final Double charge) throws AccountException {
    if (!isCustomerValid()) {
        if (feeId.equals(Short.valueOf(AccountConstants.MISC_FEES)) || feeId.equals(Short.valueOf(AccountConstants.MISC_PENALTY))) {
            throw new AccountException(AccountConstants.MISC_CHARGE_NOT_APPLICABLE);
        }
        addFeeToAccountFee(feeId, charge);
        FeeBO fee = getFeeDao().findById(feeId);
        updateCustomerActivity(feeId, new Money(((AmountFeeBO) fee).getFeeAmount().getCurrency(), charge.toString()), fee.getFeeName() + AccountConstants.APPLIED);
    } else {
        Money chargeAmount = new Money(getCurrency(), String.valueOf(charge));
        List<AccountActionDateEntity> dueInstallments = null;
        if (feeId.equals(Short.valueOf(AccountConstants.MISC_FEES)) || feeId.equals(Short.valueOf(AccountConstants.MISC_PENALTY))) {
            dueInstallments = getTotalDueInstallments();
            if (dueInstallments.isEmpty()) {
                throw new AccountException(AccountConstants.NOMOREINSTALLMENTS);
            }
            applyMiscCharge(feeId, chargeAmount, dueInstallments.get(0));
        } else {
            dueInstallments = getTotalDueInstallments();
            if (dueInstallments.isEmpty()) {
                throw new AccountException(AccountConstants.NOMOREINSTALLMENTS);
            }
            FeeBO fee = getFeeDao().findById(feeId);
            if (fee.getFeeFrequency().getFeePayment() != null) {
                applyOneTimeFee(fee, chargeAmount);
            } else {
                applyPeriodicFee(fee, chargeAmount);
            }
        }
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountException(org.mifos.accounts.exceptions.AccountException) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 18 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class CustomerAccountBO method findAllUnpaidInstallmentsUpToDatePlusNextMeeting.

private List<CustomerScheduleEntity> findAllUnpaidInstallmentsUpToDatePlusNextMeeting(final Date transactionDate) {
    List<AccountActionDateEntity> unpaidDates = new ArrayList<AccountActionDateEntity>();
    for (AccountActionDateEntity accountActionDateEntity : getAccountActionDates()) {
        if (accountActionDateEntity != null && !accountActionDateEntity.isPaid()) {
            unpaidDates.add(accountActionDateEntity);
        }
    }
    final List<CustomerScheduleEntity> customerSchedulePayments = new ArrayList<CustomerScheduleEntity>();
    for (AccountActionDateEntity accountActionDateEntity : unpaidDates) {
        if (!accountActionDateEntity.getActionDate().after(transactionDate)) {
            customerSchedulePayments.add((CustomerScheduleEntity) accountActionDateEntity);
        }
    }
    AccountActionDateEntity nextMeeting = null;
    for (AccountActionDateEntity accountActionDateEntity : getAccountActionDates()) {
        if (accountActionDateEntity != null && accountActionDateEntity.getActionDate().after(transactionDate)) {
            if (nextMeeting == null || nextMeeting.getActionDate().after(accountActionDateEntity.getActionDate())) {
                nextMeeting = accountActionDateEntity;
            }
        }
    }
    if (nextMeeting != null && !nextMeeting.isPaid()) {
        customerSchedulePayments.add((CustomerScheduleEntity) nextMeeting);
    }
    Collections.sort(customerSchedulePayments, new Comparator<CustomerScheduleEntity>() {

        @Override
        public int compare(CustomerScheduleEntity o1, CustomerScheduleEntity o2) {
            return o1.getActionDate().compareTo(o2.getActionDate());
        }
    });
    return customerSchedulePayments;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) ArrayList(java.util.ArrayList)

Example 19 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class CustomerAccountBO method waiveAmountDue.

public void waiveAmountDue() throws AccountException {
    AccountActionDateEntity accountActionDateEntity = getUpcomingInstallment();
    Money chargeWaived = ((CustomerScheduleEntity) accountActionDateEntity).waiveCharges();
    if (chargeWaived != null && chargeWaived.isGreaterThanZero()) {
        addCustomerActivity(buildCustomerActivity(chargeWaived, AccountConstants.AMNT_WAIVED, userContext.getId()));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money)

Example 20 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class CustomerAccountBO method associateFeeWithAllKnownFutureInstallments.

private void associateFeeWithAllKnownFutureInstallments(final AccountFeesEntity fee) throws AccountException {
    CustomerScheduleEntity nextInstallment = (CustomerScheduleEntity) getDetailsOfNextInstallment();
    createCustomerFeeScheduleForInstallment(fee, nextInstallment);
    List<AccountActionDateEntity> futureInstallments = getFutureInstallments();
    for (AccountActionDateEntity accountActionDateEntity : futureInstallments) {
        CustomerScheduleEntity installment = (CustomerScheduleEntity) accountActionDateEntity;
        createCustomerFeeScheduleForInstallment(fee, installment);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity)

Aggregations

AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)211 Money (org.mifos.framework.util.helpers.Money)80 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)58 LocalDate (org.joda.time.LocalDate)42 Date (java.util.Date)39 DateTime (org.joda.time.DateTime)33 MeetingBO (org.mifos.application.meeting.business.MeetingBO)33 AccountException (org.mifos.accounts.exceptions.AccountException)24 PaymentData (org.mifos.accounts.util.helpers.PaymentData)24 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)21 Date (java.sql.Date)19 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)15 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)14 UserContext (org.mifos.security.util.UserContext)14 Calendar (java.util.Calendar)13 GregorianCalendar (java.util.GregorianCalendar)13 CenterBuilder (org.mifos.domain.builders.CenterBuilder)13