use of org.mifos.accounts.fees.util.helpers.FeeFormula in project head by mifos.
the class LoanPrdActionForm method validateFeeIsNotDependentOnPercentOfInterest.
private boolean validateFeeIsNotDependentOnPercentOfInterest(FeeBO fee, ActionErrors errors) {
boolean result = true;
if (fee.getFeeType().equals(RateAmountFlag.RATE)) {
FeeFormula feeFormula = ((RateFeeBO) fee).getFeeFormula().getFeeFormula();
if (feeFormula != null) {
if (feeFormula.equals(FeeFormula.AMOUNT_AND_INTEREST)) {
addError(errors, "AdditionalFee", ProductDefinitionConstants.FEE_WITH_PERCENT_INTEREST_NOT_APPLICABLE, fee.getFeeName());
result = false;
} else if (feeFormula.equals(FeeFormula.INTEREST)) {
addError(errors, "AdditionalFee", ProductDefinitionConstants.FEE_WITH_PERCENT_INTEREST_NOT_APPLICABLE, fee.getFeeName());
result = false;
}
}
}
return result;
}
use of org.mifos.accounts.fees.util.helpers.FeeFormula in project head by mifos.
the class LoanAccountServiceFacadeWebTier method validateFeeCanBeAppliedToVariableInstallmentLoan.
@Override
public VariableInstallmentWithFeeValidationResult validateFeeCanBeAppliedToVariableInstallmentLoan(Long feeId) {
try {
org.mifos.dto.domain.FeeDto fee = this.feeDao.findDtoById(feeId.shortValue());
boolean feeCanBeAppliedToVariableInstallmentLoan = true;
String feeName = fee.getName();
if (fee.isPeriodic()) {
feeCanBeAppliedToVariableInstallmentLoan = false;
} else if (fee.isRateBasedFee()) {
FeeFormula formula = FeeFormula.getFeeFormula(fee.getFeeFormula().getId());
switch(formula) {
case AMOUNT_AND_INTEREST:
feeCanBeAppliedToVariableInstallmentLoan = false;
break;
case INTEREST:
feeCanBeAppliedToVariableInstallmentLoan = false;
break;
default:
break;
}
}
return new VariableInstallmentWithFeeValidationResult(feeCanBeAppliedToVariableInstallmentLoan, feeName);
} catch (PropertyNotFoundException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.fees.util.helpers.FeeFormula in project head by mifos.
the class FeeServiceFacadeWebTier method createFee.
@Override
public String createFee(FeeCreateDto feeCreateDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
try {
FeeCategory feeCategory = (feeCreateDto.getCategoryType() != null) ? FeeCategory.getFeeCategory(feeCreateDto.getCategoryType()) : null;
FeeFrequencyType feeFrequencyType = (feeCreateDto.getFeeFrequencyType() != null) ? FeeFrequencyType.getFeeFrequencyType(feeCreateDto.getFeeFrequencyType()) : null;
FeePayment feePayment = (feeCreateDto.getFeePaymentType() != null) ? FeePayment.getFeePayment(feeCreateDto.getFeePaymentType()) : null;
FeeFormula feeFormula = (feeCreateDto.getFeeFormula() != null) ? FeeFormula.getFeeFormula(feeCreateDto.getFeeFormula()) : null;
RecurrenceType feeRecurrenceType = (feeCreateDto.getFeeRecurrenceType() != null) ? RecurrenceType.fromInt(feeCreateDto.getFeeRecurrenceType()) : null;
FeeCreateRequest feeCreateRequest = new FeeCreateRequest(feeCategory, feeFrequencyType, feeCreateDto.getGlCode(), feePayment, feeFormula, feeCreateDto.getFeeName(), feeCreateDto.isRateFee(), feeCreateDto.isCustomerDefaultFee(), feeCreateDto.getRate(), feeCreateDto.getCurrencyId(), feeCreateDto.getAmount(), feeRecurrenceType, feeCreateDto.getMonthRecurAfter(), feeCreateDto.getWeekRecurAfter());
FeeBO fee = this.feeService.create(feeCreateRequest, userContext);
return fee.getFeeId().toString();
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations