Search in sources :

Example 6 with FeeActionForm

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

the class FeeActionStrutsTest method testSuccessfulCreatePeriodicFee.

@Test
public void testSuccessfulCreatePeriodicFee() throws Exception {
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "load");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("categoryType", FeeCategory.ALLCUSTOMERS.getValue().toString());
    addRequestParameter("currencyId", TestUtils.RUPEE.getCurrencyId().toString());
    addRequestParameter("amount", "100");
    addRequestParameter("customerDefaultFee", "1");
    addRequestParameter("feeName", "Customer Periodic Fee");
    addRequestParameter("feeFrequencyType", FeeFrequencyType.PERIODIC.getValue().toString());
    addRequestParameter("feeRecurrenceType", RecurrenceType.WEEKLY.getValue().toString());
    addRequestParameter("weekRecurAfter", "2");
    addRequestParameter("glCode", GLOCDE_ID);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "create");
    addRequestParameter("org.apache.struts.taglib.html.TOKEN", (String) request.getSession().getAttribute("org.apache.struts.action.TOKEN"));
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());
    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, actionForm.getFeeIdValue());
    Assert.assertEquals("Customer Periodic Fee", fee.getFeeName());
    Assert.assertEquals(FeeCategory.ALLCUSTOMERS.getValue(), fee.getCategoryType().getId());
    Assert.assertEquals(RateAmountFlag.AMOUNT, fee.getFeeType());
    Assert.assertEquals(new Money(getCurrency(), "100.0"), ((AmountFeeBO) fee).getFeeAmount());
    Assert.assertTrue(fee.isPeriodic());
    Assert.assertTrue(fee.isCustomerDefaultFee());
    Assert.assertTrue(fee.isActive());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) Money(org.mifos.framework.util.helpers.Money) Test(org.junit.Test)

Example 7 with FeeActionForm

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

the class FeeActionStrutsTest method testSuccessfulManage_RateFee.

@Test
public void testSuccessfulManage_RateFee() throws Exception {
    fee = TestObjectFactory.createOneTimeRateFee("One Time Fee", FeeCategory.ALLCUSTOMERS, 12.34, FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
    LookUpValueEntity lookUpValue = new LookUpValueEntity();
    fee.getFeeFrequency().getFeeFrequencyType().setLookUpValue(lookUpValue);
    fee.getFeeFrequency().getFeePayment().setLookUpValue(lookUpValue);
    ((RateFeeBO) fee).getFeeFormula().setLookUpValue(lookUpValue);
    String feeId = fee.getFeeId().toString();
    request.setAttribute("feeModel", TestObjectFactory.getRateBasedFee(feeId, "StatusID", 12.34, "1"));
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, fee, request);
    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.34", actionForm.getRate());
    Assert.assertEquals("1", actionForm.getFeeFormula());
    Assert.assertNull(actionForm.getAmount());
    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)

Example 8 with FeeActionForm

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

the class FeeActionStrutsTest method testSuccessfulCreatePeriodicFeeWithFormula.

@Test
public void testSuccessfulCreatePeriodicFeeWithFormula() throws Exception {
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "load");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("categoryType", FeeCategory.LOAN.getValue().toString());
    addRequestParameter("currencyId", TestUtils.RUPEE.getCurrencyId().toString());
    addRequestParameter("rate", "23");
    addRequestParameter("amount", "");
    addRequestParameter("feeFormula", FeeFormula.AMOUNT.getValue().toString());
    addRequestParameter("feeName", "Loan_Periodic_Fee");
    addRequestParameter("customerDefaultFee", "0");
    addRequestParameter("feeFrequencyType", FeeFrequencyType.PERIODIC.getValue().toString());
    addRequestParameter("feeRecurrenceType", RecurrenceType.WEEKLY.getValue().toString());
    addRequestParameter("weekRecurAfter", "2");
    addRequestParameter("glCode", GLOCDE_ID);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "create");
    addRequestParameter("org.apache.struts.taglib.html.TOKEN", (String) request.getSession().getAttribute("org.apache.struts.action.TOKEN"));
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());
    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, actionForm.getFeeIdValue());
    Assert.assertEquals("Loan_Periodic_Fee", fee.getFeeName());
    Assert.assertEquals(FeeCategory.LOAN.getValue(), fee.getCategoryType().getId());
    Assert.assertEquals(RateAmountFlag.RATE, fee.getFeeType());
    Assert.assertEquals(23.0, ((RateFeeBO) fee).getRate(), DELTA);
    Assert.assertEquals(((RateFeeBO) fee).getFeeFormula().getId(), FeeFormula.AMOUNT.getValue(), DELTA);
    Assert.assertTrue(fee.isPeriodic());
    Assert.assertTrue(fee.isActive());
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) Test(org.junit.Test)

Example 9 with FeeActionForm

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

the class FeeActionStrutsTest method testSuccessfulCreateOneTimeFee.

@Test
public void testSuccessfulCreateOneTimeFee() throws Exception {
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "load");
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("categoryType", FeeCategory.ALLCUSTOMERS.getValue().toString());
    addRequestParameter("currencyId", TestUtils.RUPEE.getCurrencyId().toString());
    addRequestParameter("amount", "100");
    addRequestParameter("feeName", "Customer_One_time");
    addRequestParameter("feeFrequencyType", FeeFrequencyType.ONETIME.getValue().toString());
    addRequestParameter("customerCharge", FeePayment.UPFRONT.getValue().toString());
    addRequestParameter("glCode", GLOCDE_ID);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "create");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());
    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, actionForm.getFeeIdValue());
    Assert.assertEquals("Customer_One_time", fee.getFeeName());
    Assert.assertEquals(FeeCategory.ALLCUSTOMERS.getValue(), fee.getCategoryType().getId());
    Assert.assertEquals(RateAmountFlag.AMOUNT, fee.getFeeType());
    Assert.assertEquals(new Money(getCurrency(), "100.0"), ((AmountFeeBO) fee).getFeeAmount());
    Assert.assertTrue(fee.isOneTime());
    Assert.assertFalse(fee.isCustomerDefaultFee());
    Assert.assertTrue(fee.isActive());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) Money(org.mifos.framework.util.helpers.Money) Test(org.junit.Test)

Example 10 with FeeActionForm

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

the class FeeActionStrutsTest method testSuccessfulCreateOneTimeAdminFee.

@Test
public void testSuccessfulCreateOneTimeAdminFee() throws Exception {
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "load");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("categoryType", FeeCategory.ALLCUSTOMERS.getValue().toString());
    addRequestParameter("currencyId", TestUtils.RUPEE.getCurrencyId().toString());
    addRequestParameter("amount", "100");
    addRequestParameter("customerDefaultFee", "1");
    addRequestParameter("feeName", "Customer_One_time_Default_Fee");
    addRequestParameter("feeFrequencyType", FeeFrequencyType.ONETIME.getValue().toString());
    addRequestParameter("customerCharge", FeePayment.UPFRONT.getValue().toString());
    addRequestParameter("glCode", GLOCDE_ID);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "create");
    addRequestParameter("org.apache.struts.taglib.html.TOKEN", (String) request.getSession().getAttribute("org.apache.struts.action.TOKEN"));
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());
    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, actionForm.getFeeIdValue());
    Assert.assertEquals("Customer_One_time_Default_Fee", fee.getFeeName());
    Assert.assertEquals(FeeCategory.ALLCUSTOMERS.getValue(), fee.getCategoryType().getId());
    Assert.assertEquals(RateAmountFlag.AMOUNT, fee.getFeeType());
    Assert.assertEquals(new Money(getCurrency(), "100.0"), ((AmountFeeBO) fee).getFeeAmount());
    Assert.assertTrue(fee.isOneTime());
    Assert.assertTrue(fee.isCustomerDefaultFee());
    Assert.assertTrue(fee.isActive());
}
Also used : FeeActionForm(org.mifos.accounts.fees.struts.actionforms.FeeActionForm) Money(org.mifos.framework.util.helpers.Money) 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