Search in sources :

Example 51 with AccountActionDateEntity

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

the class LoanBO method getTotalPrincipalAmountInArrearsAndOutsideLateness.

public Money getTotalPrincipalAmountInArrearsAndOutsideLateness() throws PersistenceException {
    Money amount = new Money(getCurrency());
    loanPrdPersistence = new LoanPrdPersistence();
    Date currentDate = DateUtils.getCurrentDateWithoutTimeStamp();
    List<AccountActionDateEntity> actionDateList = getDetailsOfInstallmentsInArrears();
    for (AccountActionDateEntity accountActionDateEntity : actionDateList) {
        if (accountActionDateEntity.isNotPaid() && currentDate.getTime() - accountActionDateEntity.getActionDate().getTime() > loanPrdPersistence.retrieveLatenessForPrd().intValue() * 24 * 60 * 60 * 1000) {
            amount = amount.add(((LoanScheduleEntity) accountActionDateEntity).getPrincipalDue());
        }
    }
    return amount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanPrdPersistence(org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 52 with AccountActionDateEntity

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

the class LoanBO method applyChargeMifos5722.

public void applyChargeMifos5722(final Short feeId, final Double charge) throws AccountException {
    List<AccountActionDateEntity> dueInstallments = getAllInstallments();
    FeeBO fee = getFeeDao().findById(feeId);
    if (fee.getFeeFrequency().getFeePayment() != null) {
        applyOneTimeFee(fee, charge, dueInstallments.get(0));
    } else {
        applyPeriodicFee(fee, charge, dueInstallments);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO)

Example 53 with AccountActionDateEntity

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

the class LoanBO method payInterestAtDisbursement.

private AccountPaymentEntity payInterestAtDisbursement(final String receiptNum, final Date transactionDate, final Short paymentTypeId, final PersonnelBO loggedInUser, final Date receiptDate) throws AccountException {
    AccountActionDateEntity firstInstallment = null;
    for (AccountActionDateEntity accountActionDate : this.getAccountActionDates()) {
        if (accountActionDate.getInstallmentId().shortValue() == 1) {
            firstInstallment = accountActionDate;
            break;
        }
    }
    PaymentData paymentData = PaymentData.createPaymentData(((LoanScheduleEntity) firstInstallment).getTotalDueWithFees(), loggedInUser, paymentTypeId, transactionDate);
    paymentData.setReceiptDate(receiptDate);
    paymentData.setReceiptNum(receiptNum);
    // Pay 1st installment and return accountPayableEntity to disbursal process
    return makePayment(paymentData);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData)

Example 54 with AccountActionDateEntity

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

the class LoanBO method updateAccountActionDateEntity.

/**
     * Remove unpaid or partially paid fee from each installment whose id is in installmentIdList, and return the total
     * of all unpaid fees that were removed.
     */
@Override
public Money updateAccountActionDateEntity(final List<Short> intallmentIdList, final Short feeId) {
    Money totalFeeAmount = new Money(getCurrency());
    Set<AccountActionDateEntity> accountActionDateEntitySet = this.getAccountActionDates();
    for (AccountActionDateEntity accountActionDateEntity : accountActionDateEntitySet) {
        if (intallmentIdList.contains(accountActionDateEntity.getInstallmentId())) {
            totalFeeAmount = totalFeeAmount.add(((LoanScheduleEntity) accountActionDateEntity).removeFees(feeId));
        }
    }
    return totalFeeAmount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity)

Example 55 with AccountActionDateEntity

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

the class LoanBO method getOverDueAmntsUptoInstallment.

/**
     * It calculates over due amounts till installment 1 less than the one passed,because whatever amount is associated
     * with the current installment it is the due amount and not the over due amount. It calculates that by iterating
     * over the accountActionDates associated and summing up all the principal and principalPaid till installment-1 and
     * then returning the difference of the two.It also takes into consideration any miscellaneous fee or miscellaneous
     * penalty.
     *
     * @param installmentId
     *            - Installment id till which we want over due amounts.
     *
     */
public OverDueAmounts getOverDueAmntsUptoInstallment(final Short installmentId) {
    Set<AccountActionDateEntity> accountActionDateEntities = getAccountActionDates();
    OverDueAmounts totalOverDueAmounts = new OverDueAmounts();
    if (null != accountActionDateEntities && accountActionDateEntities.size() > 0) {
        for (AccountActionDateEntity accountActionDateEntity : accountActionDateEntities) {
            LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity;
            if (loanScheduleEntity.getInstallmentId() < installmentId) {
                totalOverDueAmounts.add(loanScheduleEntity.getDueAmnts());
            }
        }
    }
    return totalOverDueAmounts;
}
Also used : OverDueAmounts(org.mifos.accounts.util.helpers.OverDueAmounts) 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