Search in sources :

Example 1 with FeeActionForm

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

the class FeeAction method editPreview.

@TransactionDemarcate(joinToken = true)
public ActionForward editPreview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    Short feeId = ((FeeActionForm) form).getFeeIdValue();
    FeeDto feeDto = this.feeDao.findDtoById(feeId);
    Short appliedFeeId = this.feeDao.findFeeAppliedToLoan(feeId);
    boolean isInProducts = appliedFeeId == null ? true : false;
    List<Short> feesAppliedLoanAccountList = this.feeDao.getAllUsedLoansWithAttachedFee();
    boolean isFeeAppliedToLoan = feesAppliedLoanAccountList.contains(feeId);
    Short feeInSchedule = this.feeDao.findFeeInSchedule(feeId);
    boolean isFeeInSchedule = feeInSchedule == null ? false : true;
    ActionMessages messages = new ActionMessages();
    if (!(((FeeActionForm) form).isToRemove() && feeDto.getFeeStatus().getId().equalsIgnoreCase("2"))) {
        form.reset(mapping, request);
    }
    if (((FeeActionForm) form).isToRemove()) {
        if (!isInProducts && !isFeeAppliedToLoan) {
            messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemoved"));
        } else if (isFeeAppliedToLoan) {
            if (!isFeeInSchedule) {
                messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrd"));
                ((FeeActionForm) form).setCantBeRemoved(true);
            } else {
                messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrdButNotDeleted"));
            }
        } else {
            messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeNotUsedRemove"));
        }
    } else {
        if (((FeeActionForm) form).getFeeStatusValue().getValue() == 2) {
            messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrdWhenInActive"));
        }
    }
    saveErrors(request, messages);
    request.getSession().setAttribute("feeModel", feeDto);
    return mapping.findForward(ActionForwards.editPreview_success.toString());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) ActionMessages(org.apache.struts.action.ActionMessages) FeeDto(org.mifos.dto.domain.FeeDto) ActionMessage(org.apache.struts.action.ActionMessage) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with FeeActionForm

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

the class FeeAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    Short feeId = ((FeeActionForm) form).getFeeIdValue();
    FeeDto feeDto = this.feeDao.findDtoById(feeId);
    request.setAttribute("feeModel", feeDto);
    request.setAttribute("GlNamesMode", AccountingRules.getGlNamesMode());
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) FeeDto(org.mifos.dto.domain.FeeDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with FeeActionForm

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

the class FeeAction method editPrevious.

@TransactionDemarcate(joinToken = true)
public ActionForward editPrevious(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    Short feeId = ((FeeActionForm) form).getFeeIdValue();
    FeeDto feeDto = this.feeDao.findDtoById(feeId);
    request.setAttribute("feeModel", feeDto);
    return mapping.findForward(ActionForwards.editprevious_success.toString());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) FeeDto(org.mifos.dto.domain.FeeDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with FeeActionForm

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

the class FeeActionStrutsTest method testSuccessfulEditPreview.

@Ignore
@Test
public void testSuccessfulEditPreview() throws Exception {
    fee = TestObjectFactory.createOneTimeAmountFee("One Time Fee", FeeCategory.ALLCUSTOMERS, "12.34", FeePayment.UPFRONT);
    LookUpValueEntity lookUpValue = new LookUpValueEntity();
    fee.getFeeFrequency().getFeeFrequencyType().setLookUpValue(lookUpValue);
    fee.getFeeFrequency().getFeePayment().setLookUpValue(lookUpValue);
    String feeId = fee.getFeeId().toString();
    request.setAttribute("feeModel", TestObjectFactory.getAmountBasedFee(feeId, "1", "12.34"));
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("feeId", feeId);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "editPreview");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("amount", "200.0");
    addRequestParameter("feeStatus", FeeStatus.INACTIVE.getValue().toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.editPreview_success.toString());
    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    Assert.assertEquals("200.0", actionForm.getAmount());
    Assert.assertEquals(FeeStatus.INACTIVE, actionForm.getFeeStatusValue());
    Assert.assertNull(actionForm.getRate());
    Assert.assertNull(actionForm.getFeeFormula());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with FeeActionForm

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

the class FeeActionStrutsTest method testSuccessfulManage_AmountFee.

@Test
public void testSuccessfulManage_AmountFee() throws Exception {
    fee = TestObjectFactory.createOneTimeAmountFee("One Time Fee", FeeCategory.ALLCUSTOMERS, "12.34", FeePayment.UPFRONT);
    LookUpValueEntity lookUpValue = new LookUpValueEntity();
    fee.getFeeFrequency().getFeeFrequencyType().setLookUpValue(lookUpValue);
    fee.getFeeFrequency().getFeePayment().setLookUpValue(lookUpValue);
    String feeId = fee.getFeeId().toString();
    request.setAttribute("feefeeModel", TestObjectFactory.getAmountBasedFee(feeId, "StatusID", "12.34"));
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("feeId", feeId);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.manage_success.toString());
    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    Assert.assertEquals("12.3", actionForm.getAmount());
    Assert.assertNull(actionForm.getRate());
    Assert.assertNull(actionForm.getFeeFormula());
    Assert.assertEquals("The size of master data for status", 2, ((List<MasterDataEntity>) SessionUtils.getAttribute(FeeConstants.STATUSLIST, request)).size());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) Test(org.junit.Test)

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