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