Search in sources :

Example 21 with FeeInstallment

use of org.mifos.accounts.util.helpers.FeeInstallment in project head by mifos.

the class CustomerAccountBO method applyFeeToInstallments.

private Money applyFeeToInstallments(final List<FeeInstallment> feeInstallmentList, final List<AccountActionDateEntity> accountActionDateList) {
    Date lastAppliedDate = null;
    Money totalFeeAmountApplied = new Money(getCurrency());
    AccountFeesEntity accountFeesEntity = null;
    for (AccountActionDateEntity accountActionDateEntity : accountActionDateList) {
        CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
        for (FeeInstallment feeInstallment : feeInstallmentList) {
            if (feeInstallment.getInstallmentId().equals(customerScheduleEntity.getInstallmentId())) {
                lastAppliedDate = customerScheduleEntity.getActionDate();
                totalFeeAmountApplied = totalFeeAmountApplied.add(feeInstallment.getAccountFee());
                AccountFeesActionDetailEntity accountFeesActionDetailEntity = new CustomerFeeScheduleEntity(customerScheduleEntity, feeInstallment.getAccountFeesEntity().getFees(), feeInstallment.getAccountFeesEntity(), feeInstallment.getAccountFee());
                customerScheduleEntity.addAccountFeesAction(accountFeesActionDetailEntity);
                accountFeesEntity = feeInstallment.getAccountFeesEntity();
            }
        }
    }
    if (accountFeesEntity != null) {
        accountFeesEntity.setLastAppliedDate(lastAppliedDate);
        addAccountFees(accountFeesEntity);
    }
    return totalFeeAmountApplied;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 22 with FeeInstallment

use of org.mifos.accounts.util.helpers.FeeInstallment in project head by mifos.

the class CustomerAccountBO method generateMeetingSchedule.

/**
     * @deprecated - use static factory methods for creating {@link CustomerAccountBO} and inject in installment dates.
     */
@Deprecated
private void generateMeetingSchedule() throws AccountException {
    // generate dates that adjust for holidays
    List<InstallmentDate> installmentDates = getInstallmentDates(getCustomer().getCustomerMeeting().getMeeting(), (short) 10, (short) 0);
    // generate dates without adjusting for holidays
    List<InstallmentDate> nonAdjustedInstallmentDates = getInstallmentDates(getCustomer().getCustomerMeeting().getMeeting(), (short) 10, (short) 0, false, true);
    logger.debug("RepamentSchedular:getRepaymentSchedule , installment dates obtained ");
    List<FeeInstallment> feeInstallmentList = mergeFeeInstallments(getFeeInstallments(installmentDates, nonAdjustedInstallmentDates));
    logger.debug("RepamentSchedular:getRepaymentSchedule , fee installment obtained ");
    for (InstallmentDate installmentDate : installmentDates) {
        CustomerScheduleEntity customerScheduleEntity = new CustomerScheduleEntity(this, getCustomer(), installmentDate.getInstallmentId(), new java.sql.Date(installmentDate.getInstallmentDueDate().getTime()), PaymentStatus.UNPAID);
        addAccountActionDate(customerScheduleEntity);
        for (FeeInstallment feeInstallment : feeInstallmentList) {
            if (feeInstallment.getInstallmentId().equals(installmentDate.getInstallmentId())) {
                CustomerFeeScheduleEntity customerFeeScheduleEntity = new CustomerFeeScheduleEntity(customerScheduleEntity, feeInstallment.getAccountFeesEntity().getFees(), feeInstallment.getAccountFeesEntity(), feeInstallment.getAccountFee());
                customerScheduleEntity.addAccountFeesAction(customerFeeScheduleEntity);
            }
        }
    }
    logger.debug("RepamentSchedular:getRepaymentSchedule , repayment schedule generated  ");
}
Also used : FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate)

Example 23 with FeeInstallment

use of org.mifos.accounts.util.helpers.FeeInstallment in project head by mifos.

the class CustomerAccountBO method applyOneTimeFee.

private void applyOneTimeFee(final FeeBO fee, final Money charge, final AccountActionDateEntity accountActionDateEntity) throws AccountException {
    CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
    AccountFeesEntity accountFee = new AccountFeesEntity(this, fee, charge.getAmountDoubleValue(), FeeStatus.ACTIVE.getValue(), new DateTimeService().getCurrentJavaDateTime(), null);
    List<AccountActionDateEntity> customerScheduleList = new ArrayList<AccountActionDateEntity>();
    customerScheduleList.add(customerScheduleEntity);
    List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
    installmentDates.add(new InstallmentDate(accountActionDateEntity.getInstallmentId(), accountActionDateEntity.getActionDate()));
    List<FeeInstallment> feeInstallmentList = new ArrayList<FeeInstallment>();
    feeInstallmentList.add(handleOneTime(accountFee, installmentDates));
    Money totalFeeAmountApplied = applyFeeToInstallments(feeInstallmentList, customerScheduleList);
    updateCustomerActivity(fee.getFeeId(), totalFeeAmountApplied, fee.getFeeName() + AccountConstants.APPLIED);
    accountFee.setFeeStatus(FeeStatus.ACTIVE);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) ArrayList(java.util.ArrayList) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTimeService(org.mifos.framework.util.DateTimeService) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate)

Example 24 with FeeInstallment

use of org.mifos.accounts.util.helpers.FeeInstallment in project head by mifos.

the class CustomerAccountBO method applyFeesToInitialSetOfInstallments.

private void applyFeesToInitialSetOfInstallments(List<AccountFeesEntity> accountFees, final ScheduledEvent scheduledEvent) {
    List<FeeInstallment> mergedFeeInstallments = FeeInstallment.createMergedFeeInstallments(scheduledEvent, accountFees, numberOfMeetingDatesToGenerate);
    for (AccountActionDateEntity accountAction : this.getAccountActionDates()) {
        this.applyFeesToScheduledEvent((CustomerScheduleEntity) accountAction, mergedFeeInstallments);
    }
    this.setLastAppliedDatesForFees(accountFees);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment)

Example 25 with FeeInstallment

use of org.mifos.accounts.util.helpers.FeeInstallment in project head by mifos.

the class CustomerAccountBO method applyFeesToScheduledEvent.

private void applyFeesToScheduledEvent(CustomerScheduleEntity customerScheduleEntity, List<FeeInstallment> mergedFeeInstallments) {
    for (FeeInstallment feeInstallment : mergedFeeInstallments) {
        if (feeInstallment.getInstallmentId().equals(customerScheduleEntity.getInstallmentId())) {
            CustomerFeeScheduleEntity customerFeeScheduleEntity = new CustomerFeeScheduleEntity(customerScheduleEntity, feeInstallment.getAccountFeesEntity().getFees(), feeInstallment.getAccountFeesEntity(), feeInstallment.getAccountFee());
            customerScheduleEntity.addAccountFeesAction(customerFeeScheduleEntity);
        }
    }
}
Also used : FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment)

Aggregations

FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)25 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)17 ScheduledEvent (org.mifos.schedule.ScheduledEvent)12 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)11 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)9 FeeBO (org.mifos.accounts.fees.business.FeeBO)9 ScheduledEventBuilder (org.mifos.domain.builders.ScheduledEventBuilder)9 Money (org.mifos.framework.util.helpers.Money)9 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)7 Date (java.util.Date)4 LocalDate (org.joda.time.LocalDate)4 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)2 RateAmountFlag (org.mifos.accounts.fees.util.helpers.RateAmountFlag)2 InstallmentPrincipalAndInterest (org.mifos.accounts.loan.util.helpers.InstallmentPrincipalAndInterest)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 DateTimeService (org.mifos.framework.util.DateTimeService)2