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;
}
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;
}
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);
}
}
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);
}
Aggregations