use of org.mifos.accounts.fees.business.FeeStatusEntity in project head by mifos.
the class FeeServiceImpl method update.
@Override
public void update(FeeUpdateRequest feeUpdateRequest, UserContext userContext) throws ApplicationException {
FeeBO feeBo = this.feeDao.findById(feeUpdateRequest.getFeeId());
feeBo.updateDetails(userContext);
FeeChangeType feeChangeType;
FeeStatus feeStatus = null;
if (feeUpdateRequest.getFeeStatusValue() != null) {
feeStatus = FeeStatus.getFeeStatus(feeUpdateRequest.getFeeStatusValue());
}
FeeStatusEntity feeStatusEntity = new FeeStatusEntity(feeStatus);
if (feeBo.getFeeType().equals(RateAmountFlag.AMOUNT)) {
AmountFeeBO amountFee = ((AmountFeeBO) feeBo);
feeChangeType = amountFee.calculateNewFeeChangeType(new Money(getCurrency(feeUpdateRequest.getCurrencyId()), feeUpdateRequest.getAmount()), feeStatusEntity);
amountFee.setFeeAmount(new Money(getCurrency(feeUpdateRequest.getCurrencyId()), feeUpdateRequest.getAmount()));
} else {
RateFeeBO rateFee = ((RateFeeBO) feeBo);
feeChangeType = rateFee.calculateNewFeeChangeType(feeUpdateRequest.getRateValue(), feeStatusEntity);
rateFee.setRate(feeUpdateRequest.getRateValue());
}
try {
hibernateTransactionHelper.startTransaction();
feeBo.updateStatus(feeStatus);
feeBo.updateFeeChangeType(feeChangeType);
this.feeDao.save(feeBo);
hibernateTransactionHelper.commitTransaction();
} catch (ApplicationException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (Exception e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.accounts.fees.business.FeeStatusEntity in project head by mifos.
the class FeeAction method manage.
@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
form.reset(mapping, request);
FeeActionForm feeActionForm = (FeeActionForm) form;
Short feeId = Short.valueOf(feeActionForm.getFeeId());
FeeDto fee = this.feeDao.findDtoById(feeId);
List<FeeStatusEntity> feeStatuses = this.feeDao.retrieveFeeStatuses();
SessionUtils.setCollectionAttribute(FeeConstants.STATUSLIST, feeStatuses, request);
feeActionForm.updateWithFee(fee);
request.getSession().setAttribute("feeModel", fee);
return mapping.findForward(ActionForwards.manage_success.toString());
}
Aggregations