Search in sources :

Example 6 with FeeFormulaEntity

use of org.mifos.accounts.fees.business.FeeFormulaEntity in project head by mifos.

the class FeeServiceImpl method createOneTimeFee.

private FeeBO createOneTimeFee(FeeCreateRequest feeCreateRequest, FeeFrequencyTypeEntity feeFrequencyType, CategoryTypeEntity feeCategoryType, GLCodeEntity glCodeEntity, UserContext userContext) throws FeeException {
    FeePaymentEntity feePaymentEntity = this.feeDao.findFeePaymentEntityByType(feeCreateRequest.getFeePaymentType());
    FeeBO feeBO = null;
    if (feeCreateRequest.isRateFee()) {
        FeeFormulaEntity feeFormulaEntity = this.feeDao.findFeeFormulaEntityByType(feeCreateRequest.getFeeFormula());
        feeBO = new RateFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeCreateRequest.getRate(), feeFormulaEntity, feeCreateRequest.isCustomerDefaultFee(), feePaymentEntity);
    } else {
        Money feeMoney = new Money(getCurrency(feeCreateRequest.getCurrencyId()), feeCreateRequest.getAmount());
        feeBO = new AmountFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeMoney, feeCreateRequest.isCustomerDefaultFee(), feePaymentEntity);
    }
    return feeBO;
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) FeePaymentEntity(org.mifos.accounts.fees.business.FeePaymentEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 7 with FeeFormulaEntity

use of org.mifos.accounts.fees.business.FeeFormulaEntity in project head by mifos.

the class FeeServiceImpl method createPeriodicFee.

private FeeBO createPeriodicFee(FeeCreateRequest feeCreateRequest, FeeFrequencyTypeEntity feeFrequencyType, CategoryTypeEntity feeCategoryType, GLCodeEntity glCodeEntity, UserContext userContext) throws FeeException, MeetingException {
    MeetingBO feeMeeting = feeCreateRequest.getFeeRecurrenceType().equals(RecurrenceType.MONTHLY) ? new MeetingBO(feeCreateRequest.getFeeRecurrenceType(), feeCreateRequest.getMonthRecurAfter(), new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE) : new MeetingBO(feeCreateRequest.getFeeRecurrenceType(), feeCreateRequest.getWeekRecurAfter(), new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE);
    FeeBO feeBO = null;
    if (feeCreateRequest.isRateFee()) {
        FeeFormulaEntity feeFormulaEntity = this.feeDao.findFeeFormulaEntityByType(feeCreateRequest.getFeeFormula());
        feeBO = new RateFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeCreateRequest.getRate(), feeFormulaEntity, feeCreateRequest.isCustomerDefaultFee(), feeMeeting);
    } else {
        Money feeMoney = new Money(getCurrency(feeCreateRequest.getCurrencyId()), feeCreateRequest.getAmount());
        feeBO = new AmountFeeBO(userContext, feeCreateRequest.getFeeName(), feeCategoryType, feeFrequencyType, glCodeEntity, feeMoney, feeCreateRequest.isCustomerDefaultFee(), feeMeeting);
    }
    return feeBO;
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) DateTimeService(org.mifos.framework.util.DateTimeService) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 8 with FeeFormulaEntity

use of org.mifos.accounts.fees.business.FeeFormulaEntity in project head by mifos.

the class LoanBO method populateAccountFeeAmount.

/**
     * @deprecated - see {@link InstallmentFeeCalculator}.
     */
@Deprecated
private void populateAccountFeeAmount(final Set<AccountFeesEntity> accountFees, final Money loanInterest) {
    for (AccountFeesEntity accountFeesEntity : accountFees) {
        Money accountFeeAmount1 = new Money(getCurrency());
        Double feeAmount = accountFeesEntity.getFeeAmount();
        if (accountFeesEntity.getFees().getFeeType() == RateAmountFlag.AMOUNT) {
            accountFeeAmount1 = new Money(getCurrency(), feeAmount.toString());
        } else if (accountFeesEntity.getFees().getFeeType() == RateAmountFlag.RATE) {
            RateFeeBO rateFeeBO = (RateFeeBO) getFeeDao().findById(accountFeesEntity.getFees().getFeeId());
            FeeFormulaEntity formula = rateFeeBO.getFeeFormula();
            Money amountToCalculateOn = new Money(getCurrency(), "1.0");
            if (formula.getId().equals(FeeFormula.AMOUNT.getValue())) {
                amountToCalculateOn = loanAmount;
            } else if (formula.getId().equals(FeeFormula.AMOUNT_AND_INTEREST.getValue())) {
                amountToCalculateOn = loanAmount.add(loanInterest);
            } else if (formula.getId().equals(FeeFormula.INTEREST.getValue())) {
                amountToCalculateOn = loanInterest;
            }
            Double rateAmount = amountToCalculateOn.multiply(feeAmount).divide(100).getAmountDoubleValue();
            String rateBasedOnFormula = rateAmount.toString();
            accountFeeAmount1 = new Money(getCurrency(), rateBasedOnFormula);
        }
        Money accountFeeAmount = accountFeeAmount1;
        accountFeesEntity.setAccountFeeAmount(accountFeeAmount);
    }
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity)

Example 9 with FeeFormulaEntity

use of org.mifos.accounts.fees.business.FeeFormulaEntity in project head by mifos.

the class RateInstalmentFeeCalculator method calculate.

@Override
public Money calculate(Double feeRate, Money loanAmount, Money loanInterest, FeeBO fee) {
    // make sure that we are not using a proxied object when we cast
    RateFeeBO rateFeeBO = (RateFeeBO) feeDao.initializeAndUnproxy(fee);
    FeeFormulaEntity formula = rateFeeBO.getFeeFormula();
    Money amountToCalculateOn = new Money(loanAmount.getCurrency(), "1.0");
    if (formula.getId().equals(FeeFormula.AMOUNT.getValue())) {
        amountToCalculateOn = loanAmount;
    } else if (formula.getId().equals(FeeFormula.AMOUNT_AND_INTEREST.getValue())) {
        amountToCalculateOn = loanAmount.add(loanInterest);
    } else if (formula.getId().equals(FeeFormula.INTEREST.getValue())) {
        amountToCalculateOn = loanInterest;
    }
    return amountToCalculateOn.multiply(feeRate).divide(100);
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity)

Aggregations

FeeFormulaEntity (org.mifos.accounts.fees.business.FeeFormulaEntity)9 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)6 Money (org.mifos.framework.util.helpers.Money)4 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)3 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)3 FeeBO (org.mifos.accounts.fees.business.FeeBO)3 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)3 FeePaymentEntity (org.mifos.accounts.fees.business.FeePaymentEntity)3 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)3 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerException (org.mifos.customers.exceptions.CustomerException)2 OfficeException (org.mifos.customers.office.exceptions.OfficeException)2 ApplicationException (org.mifos.framework.exceptions.ApplicationException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 SystemException (org.mifos.framework.exceptions.SystemException)2 DateTimeService (org.mifos.framework.util.DateTimeService)2 ArrayList (java.util.ArrayList)1