Search in sources :

Example 1 with PropertyNotFoundException

use of org.mifos.framework.exceptions.PropertyNotFoundException 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 2 with PropertyNotFoundException

use of org.mifos.framework.exceptions.PropertyNotFoundException in project head by mifos.

the class CustomerAccountBO method updateFee.

public void updateFee(final AccountFeesEntity fee, final FeeBO feeBO) throws BatchJobException {
    boolean feeApplied = isFeeAlreadyApplied(fee, feeBO);
    if (!feeApplied) {
        // update this account fee
        try {
            if (feeBO.getFeeChangeType().equals(FeeChangeType.AMOUNT_AND_STATUS_UPDATED)) {
                if (!feeBO.isActive()) {
                    removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeBO.getFeeId(), Short.valueOf("1"));
                    fee.changeFeesStatus(FeeStatus.INACTIVE, new DateTimeService().getCurrentJavaDateTime());
                    updateAccountFee(fee, (AmountFeeBO) feeBO);
                } else {
                    // generate repayment schedule and enable fee
                    fee.changeFeesStatus(FeeStatus.ACTIVE, new DateTimeService().getCurrentJavaDateTime());
                    updateAccountFee(fee, (AmountFeeBO) feeBO);
                    associateFeeWithAllKnownFutureInstallments(fee);
                }
            } else if (feeBO.getFeeChangeType().equals(FeeChangeType.STATUS_UPDATED)) {
                if (!feeBO.isActive()) {
                    removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeBO.getFeeId(), Short.valueOf("1"));
                } else {
                    fee.changeFeesStatus(FeeStatus.ACTIVE, new DateTimeService().getCurrentJavaDateTime());
                    associateFeeWithAllKnownFutureInstallments(fee);
                }
            } else if (feeBO.getFeeChangeType().equals(FeeChangeType.AMOUNT_UPDATED)) {
                updateAccountFee(fee, (AmountFeeBO) feeBO);
                updateUpcomingAndFutureInstallments(fee);
            }
        } catch (PropertyNotFoundException e) {
            throw new BatchJobException(e);
        } catch (AccountException e) {
            throw new BatchJobException(e);
        }
    }
}
Also used : BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) PropertyNotFoundException(org.mifos.framework.exceptions.PropertyNotFoundException) AccountException(org.mifos.accounts.exceptions.AccountException) DateTimeService(org.mifos.framework.util.DateTimeService)

Aggregations

PropertyNotFoundException (org.mifos.framework.exceptions.PropertyNotFoundException)2 AccountException (org.mifos.accounts.exceptions.AccountException)1 FeeFormula (org.mifos.accounts.fees.util.helpers.FeeFormula)1 VariableInstallmentWithFeeValidationResult (org.mifos.clientportfolio.newloan.applicationservice.VariableInstallmentWithFeeValidationResult)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 FeeDto (org.mifos.dto.domain.FeeDto)1 BatchJobException (org.mifos.framework.components.batchjobs.exceptions.BatchJobException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1