Search in sources :

Example 11 with FeeActionForm

use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.

the class FeeAction method load.

@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    form.reset(mapping, request);
    ((FeeActionForm) form).clear();
    FeeDetailsForLoadDto feeDetailsForLoad = this.feeServiceFacade.retrieveDetailsForFeeLoad();
    request.getSession().setAttribute("isMultiCurrencyEnabled", feeDetailsForLoad.isMultiCurrencyEnabled());
    request.getSession().setAttribute(FeeParameters.class.getSimpleName(), feeDetailsForLoad.getFeeParameters());
    request.getSession().setAttribute("currencies", AccountingRules.getCurrencies());
    request.getSession().setAttribute("GlNamesMode", AccountingRules.getGlNamesMode());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) FeeDetailsForLoadDto(org.mifos.dto.screen.FeeDetailsForLoadDto) FeeParameters(org.mifos.dto.screen.FeeParameters) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 12 with FeeActionForm

use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.

the class FeeAction method preview.

@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    FeeActionForm feeActionForm = (FeeActionForm) form;
    Short currencyId = feeActionForm.getCurrencyId();
    FeeDetailsForPreviewDto feeDetailsForPreview = this.feeServiceFacade.retrieveDetailsforFeePreview(currencyId);
    SessionUtils.setAttribute("isMultiCurrencyEnabled", feeDetailsForPreview.isMultiCurrencyEnabled(), request);
    if (feeDetailsForPreview.isMultiCurrencyEnabled()) {
        request.getSession().setAttribute("currencyCode", feeDetailsForPreview.getCurrencyCode());
    }
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) FeeDetailsForPreviewDto(org.mifos.dto.screen.FeeDetailsForPreviewDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 13 with FeeActionForm

use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.

the class FeeAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    FeeActionForm actionForm = (FeeActionForm) form;
    Short feeCategory = null;
    if (actionForm.getCategoryTypeValue() != null) {
        feeCategory = actionForm.getCategoryTypeValue().getValue();
    }
    Short feeFrequency = null;
    if (actionForm.getFeeFrequencyTypeValue() != null) {
        feeFrequency = actionForm.getFeeFrequencyTypeValue().getValue();
    }
    Short feePayment = null;
    if (actionForm.getFeePaymentTypeValue() != null) {
        feePayment = actionForm.getFeePaymentTypeValue().getValue();
    }
    Short feeFormula = null;
    if (actionForm.getFeeFormulaValue() != null) {
        feeFormula = actionForm.getFeeFormulaValue().getValue();
    }
    Short feeRecurrence = null;
    if (actionForm.getFeeRecurrenceTypeValue() != null) {
        feeRecurrence = actionForm.getFeeRecurrenceTypeValue().getValue();
    }
    FeeCreateDto feeCreateRequest = new FeeCreateDto(feeCategory, feeFrequency, actionForm.getGlCodeValue(), feePayment, feeFormula, actionForm.getFeeName(), actionForm.isRateFee(), actionForm.isCustomerDefaultFee(), actionForm.getRateValue(), actionForm.getCurrencyId(), actionForm.getAmount(), feeRecurrence, actionForm.getMonthRecurAfterValue(), actionForm.getWeekRecurAfterValue());
    String feeId = this.feeServiceFacade.createFee(feeCreateRequest);
    actionForm.setFeeId(feeId);
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) FeeCreateDto(org.mifos.dto.domain.FeeCreateDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 14 with FeeActionForm

use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.

the class FeeAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    FeeActionForm feeActionForm = (FeeActionForm) form;
    FeeStatus feeStatus = feeActionForm.getFeeStatusValue();
    String forward = "";
    Short feeStatusValue = null;
    String whereToForward = "";
    if (feeStatus != null) {
        feeStatusValue = feeStatus.getValue();
    }
    FeeUpdateRequest feeUpdateRequest = new FeeUpdateRequest(Short.valueOf(feeActionForm.getFeeId()), feeActionForm.getCurrencyId(), feeActionForm.getAmount(), feeStatusValue, feeActionForm.getRateValue());
    if (feeUpdateRequest.getFeeStatusValue() == 2) {
        this.feeServiceFacade.updateFee(feeUpdateRequest);
        try {
            boolean remove = feeActionForm.isToRemove();
            this.feeServiceFacade.removeFee(feeUpdateRequest, remove);
            whereToForward = REMOVE_SUCCESS;
        } catch (MifosRuntimeException e) {
            ActionMessages messages = new ActionMessages();
            messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeCannotBeRemoved"));
            saveMessages(request, messages);
            whereToForward = UPDATE_SUCCESS;
        }
    } else if (feeActionForm.isToRemove() && feeUpdateRequest.getFeeStatusValue() == 1) {
        ActionMessages errors = new ActionMessages();
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeCantBeRemove"));
        saveErrors(request, errors);
        whereToForward = UPDATE_FAILURE;
    } else {
        this.feeServiceFacade.updateFee(feeUpdateRequest);
        whereToForward = UPDATE_SUCCESS;
    }
    if (whereToForward.equals(UPDATE_SUCCESS)) {
        forward = ActionForwards.update_success.toString();
    } else if (whereToForward.equals(UPDATE_FAILURE)) {
        forward = ActionForwards.update_failure.toString();
    } else if (whereToForward.equals(REMOVE_SUCCESS)) {
        forward = ActionForwards.remove_fee_success.toString();
    }
    return mapping.findForward(forward);
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) ActionMessages(org.apache.struts.action.ActionMessages) FeeUpdateRequest(org.mifos.dto.domain.FeeUpdateRequest) ActionMessage(org.apache.struts.action.ActionMessage) FeeStatus(org.mifos.accounts.fees.util.helpers.FeeStatus) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 15 with FeeActionForm

use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm 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());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) FeeStatusEntity(org.mifos.accounts.fees.business.FeeStatusEntity) FeeDto(org.mifos.dto.domain.FeeDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

FeeActionForm (org.mifos.accounts.fees.struts.actionforms.FeeActionForm)15 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)8 Test (org.junit.Test)7 FeeDto (org.mifos.dto.domain.FeeDto)4 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)3 Money (org.mifos.framework.util.helpers.Money)3 ActionMessage (org.apache.struts.action.ActionMessage)2 ActionMessages (org.apache.struts.action.ActionMessages)2 MasterDataEntity (org.mifos.application.master.business.MasterDataEntity)2 Ignore (org.junit.Ignore)1 FeeStatusEntity (org.mifos.accounts.fees.business.FeeStatusEntity)1 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)1 FeeStatus (org.mifos.accounts.fees.util.helpers.FeeStatus)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 FeeCreateDto (org.mifos.dto.domain.FeeCreateDto)1 FeeUpdateRequest (org.mifos.dto.domain.FeeUpdateRequest)1 FeeDetailsForLoadDto (org.mifos.dto.screen.FeeDetailsForLoadDto)1 FeeDetailsForPreviewDto (org.mifos.dto.screen.FeeDetailsForPreviewDto)1 FeeParameters (org.mifos.dto.screen.FeeParameters)1