Search in sources :

Example 1 with FeeFormula

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;
}
Also used : FeeFormula(org.mifos.accounts.fees.util.helpers.FeeFormula)

Example 2 with FeeFormula

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);
    }
}
Also used : FeeFormula(org.mifos.accounts.fees.util.helpers.FeeFormula) PropertyNotFoundException(org.mifos.framework.exceptions.PropertyNotFoundException) VariableInstallmentWithFeeValidationResult(org.mifos.clientportfolio.newloan.applicationservice.VariableInstallmentWithFeeValidationResult) FeeDto(org.mifos.dto.domain.FeeDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with FeeFormula

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);
    }
}
Also used : FeePayment(org.mifos.accounts.fees.util.helpers.FeePayment) BusinessRuleException(org.mifos.service.BusinessRuleException) FeeFormula(org.mifos.accounts.fees.util.helpers.FeeFormula) ApplicationException(org.mifos.framework.exceptions.ApplicationException) FeeFrequencyType(org.mifos.accounts.fees.util.helpers.FeeFrequencyType) UserContext(org.mifos.security.util.UserContext) RecurrenceType(org.mifos.application.meeting.util.helpers.RecurrenceType) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) FeeBO(org.mifos.accounts.fees.business.FeeBO) FeeCategory(org.mifos.accounts.fees.util.helpers.FeeCategory)

Aggregations

FeeFormula (org.mifos.accounts.fees.util.helpers.FeeFormula)3 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 FeeCategory (org.mifos.accounts.fees.util.helpers.FeeCategory)1 FeeFrequencyType (org.mifos.accounts.fees.util.helpers.FeeFrequencyType)1 FeePayment (org.mifos.accounts.fees.util.helpers.FeePayment)1 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)1 RecurrenceType (org.mifos.application.meeting.util.helpers.RecurrenceType)1 VariableInstallmentWithFeeValidationResult (org.mifos.clientportfolio.newloan.applicationservice.VariableInstallmentWithFeeValidationResult)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 FeeDto (org.mifos.dto.domain.FeeDto)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1 PropertyNotFoundException (org.mifos.framework.exceptions.PropertyNotFoundException)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1