Search in sources :

Example 11 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity 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)

Example 12 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class FeeActionStrutsTest method testSuccessfulUpdate_AmountFee.

@Test
public void testSuccessfulUpdate_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("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();
    request.removeAttribute("feeModel");
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "editPreview");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("amount", "200.0");
    addRequestParameter("feeStatus", FeeStatus.INACTIVE.getValue().toString());
    actionPerform();
    request.removeAttribute("feeModel");
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "update");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.update_success.toString());
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, fee.getFeeId());
    Assert.assertFalse(fee.isActive());
    Assert.assertEquals(new Money(getCurrency(), "200.0"), ((AmountFeeBO) fee).getFeeAmount());
}
Also used : Money(org.mifos.framework.util.helpers.Money) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) Test(org.junit.Test)

Example 13 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class FeeActionStrutsTest method testSuccessfulUpdate_RateFee.

@Test
public void testSuccessfulUpdate_RateFee() throws Exception {
    fee = TestObjectFactory.createOneTimeRateFee("One Time Fee", FeeCategory.ALLCUSTOMERS, 24.0, 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, "1", 24d, "1"));
    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("rate", "30");
    actionPerform();
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "update");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.update_success.toString());
    fee = (FeeBO) TestObjectFactory.getObject(FeeBO.class, fee.getFeeId());
    Assert.assertTrue(fee.isActive());
    Assert.assertEquals(30.0, ((RateFeeBO) fee).getRate(), DELTA);
}
Also used : LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) Test(org.junit.Test)

Example 14 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class TestObjectFactory method createPeriodicAmountFee.

private static FeeBO createPeriodicAmountFee(final String feeName, final FeeCategory feeCategory, final String feeAmnt, final RecurrenceType meetingFrequency, final Short recurAfter, final UserContext userContext, String categoryLookupValue) {
    try {
        GLCodeEntity glCode = ChartOfAccountsCache.get("31301").getAssociatedGlcode();
        MeetingBO meeting = new MeetingBO(meetingFrequency, recurAfter, new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE);
        LookUpValueEntity lookUpValue = new LookUpValueEntity();
        lookUpValue.setLookUpName(categoryLookupValue);
        CategoryTypeEntity categoryType = new CategoryTypeEntity(feeCategory);
        categoryType.setLookUpValue(lookUpValue);
        FeeBO fee = new AmountFeeBO(userContext, feeName, categoryType, new FeeFrequencyTypeEntity(FeeFrequencyType.PERIODIC), glCode, TestUtils.createMoney(feeAmnt), false, meeting);
        return testObjectPersistence.createFee(fee);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) DateTimeService(org.mifos.framework.util.DateTimeService) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 15 with LookUpValueEntity

use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.

the class TestObjectFactory method createOneTimeRateFee.

/**
     * createOneTimeRateFee.
     * <p/>
     * Changing TestObjectFactory#getUserContext() to {@link TestUtils#makeUserWithLocales()} caused a failure in
     * {@link LoanBOIntegrationTest#testApplyUpfrontFee} (and other tests).
     *
     * @param categoryTypeName TODO
     */
public static FeeBO createOneTimeRateFee(final String feeName, final FeeCategory feeCategory, final Double rate, final FeeFormula feeFormula, final FeePayment feePayment, String categoryTypeName) {
    GLCodeEntity glCode = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.FEES);
    FeeBO fee;
    try {
        LookUpValueEntity lookUpValue = new LookUpValueEntity();
        lookUpValue.setLookUpName(categoryTypeName);
        CategoryTypeEntity categoryType = new CategoryTypeEntity(feeCategory);
        categoryType.setLookUpValue(lookUpValue);
        fee = new RateFeeBO(getUserContext(), feeName, categoryType, new FeeFrequencyTypeEntity(FeeFrequencyType.ONETIME), glCode, rate, new FeeFormulaEntity(feeFormula), false, new FeePaymentEntity(feePayment));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return testObjectPersistence.createFee(fee);
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) FeePaymentEntity(org.mifos.accounts.fees.business.FeePaymentEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Aggregations

LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)38 Test (org.junit.Test)11 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)9 LookUpEntity (org.mifos.application.master.business.LookUpEntity)8 MessageLookup (org.mifos.application.master.MessageLookup)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 SystemException (org.mifos.framework.exceptions.SystemException)5 LookUpValueLocaleEntity (org.mifos.application.master.business.LookUpValueLocaleEntity)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)3 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)3 FeeBO (org.mifos.accounts.fees.business.FeeBO)3 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)3 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)3 FeeActionForm (org.mifos.accounts.fees.struts.actionforms.FeeActionForm)3 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)3 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)3