Search in sources :

Example 1 with BusinessActivityEntity

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

the class Localization method getLocaleForUI.

public List<ValueListElement> getLocaleForUI() {
    List<ValueListElement> localeForUI = new ArrayList<ValueListElement>();
    for (Short key : LOCALE_MAP.keySet()) {
        String displayName = getDisplayName(key);
        ValueListElement localeValue = new BusinessActivityEntity(key.intValue(), displayName, displayName);
        localeForUI.add(localeValue);
        Collections.sort(localeForUI, new ValueListElementSortByName());
    }
    return localeForUI;
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) ArrayList(java.util.ArrayList) ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 2 with BusinessActivityEntity

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

the class PersonnelServiceFacadeWebTier method retrieveUserSettings.

@Override
public UserSettingsDto retrieveUserSettings() {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    PersonnelBO personnel = this.personnelDao.findPersonnelById(userContext.getId());
    String gender = getNameForBusinessActivityEntity(personnel.getPersonnelDetails().getGender());
    String martialStatus = getNameForBusinessActivityEntity(personnel.getPersonnelDetails().getMaritalStatus());
    String language = Localization.getInstance().getDisplayName(personnel.getPreferredLocale());
    String sitePreference = SitePreferenceType.getSitePreference(personnel.getSitePreference()).name();
    List<ValueListElement> genders = this.customerDao.retrieveGenders();
    List<ValueListElement> martialStatuses = this.customerDao.retrieveMaritalStatuses();
    List<ValueListElement> languages = Localization.getInstance().getLocaleForUI();
    List<ValueListElement> sitePreferenceTypes = new ArrayList<ValueListElement>();
    for (short i = 0; i < SitePreferenceType.values().length; i++) {
        SitePreferenceType sitePreferenceType = SitePreferenceType.values()[i];
        ValueListElement valueListElement = new BusinessActivityEntity(sitePreferenceType.getValue().intValue(), sitePreferenceType.name(), sitePreferenceType.name());
        sitePreferenceTypes.add(valueListElement);
    }
    int age = DateUtils.DateDiffInYears(((Date) personnel.getPersonnelDetails().getDob()));
    if (age < 0) {
        age = 0;
    }
    return new UserSettingsDto(gender, martialStatus, language, age, sitePreference, genders, martialStatuses, languages, sitePreferenceTypes);
}
Also used : SitePreferenceType(org.mifos.config.SitePreferenceType) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) UserContext(org.mifos.security.util.UserContext) UserSettingsDto(org.mifos.dto.screen.UserSettingsDto) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) Date(java.sql.Date) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 3 with BusinessActivityEntity

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

the class ClientCustActionStrutsTest method testCreateSuccessWithAssociatedSavingsOfferings.

@Test
public void testCreateSuccessWithAssociatedSavingsOfferings() throws Exception {
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
    savingsOffering1 = TestObjectFactory.createSavingsProduct("savingsPrd1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    List<FeeDto> feesToRemove = getFees(RecurrenceType.WEEKLY);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    List<BusinessActivityEntity> povertyStatus = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("clientDetailView.gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter("customerDetail.povertyStatus", povertyStatus.get(0).getId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<SavingsDetailDto> savingsOfferingList = getSavingsOfferingsFromSession();
    SavingsDetailDto savingsOffering = savingsOfferingList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("savingsOffering[0]", savingsOffering.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.preview_success.toString());
    MeetingBO weeklyMeeting = new MeetingBuilder().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, weeklyMeeting, request);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "create");
    addRequestParameter("input", "create");
    addRequestParameter("status", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.create_success.toString());
    ClientCustActionForm actionForm = (ClientCustActionForm) request.getSession().getAttribute("clientCustActionForm");
    client = TestObjectFactory.getClient(actionForm.getCustomerIdAsInt());
    Assert.assertNotNull(client);
    Assert.assertNotNull(client.getOfferingsAssociatedInCreate());
    Assert.assertEquals(1, client.getOfferingsAssociatedInCreate().size());
    for (ClientInitialSavingsOfferingEntity offering : client.getOfferingsAssociatedInCreate()) {
        Assert.assertEquals(savingsOffering1.getPrdOfferingId(), offering.getSavingsOffering().getPrdOfferingId());
        Assert.assertTrue(true);
    }
    removeFees(feesToRemove);
    savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering.getPrdOfferingId());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) ClientInitialSavingsOfferingEntity(org.mifos.customers.client.business.ClientInitialSavingsOfferingEntity) Date(java.util.Date) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) List(java.util.List) ArrayList(java.util.ArrayList) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 4 with BusinessActivityEntity

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

the class ClientCustActionStrutsTest method testPreviewSuccess.

@Test
public void testPreviewSuccess() throws Exception {
    List<FeeDto> feesToRemove = getFees(RecurrenceType.MONTHLY);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    List<BusinessActivityEntity> povertyStatus = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("clientDetailView.gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter("customerDetail.povertyStatus", povertyStatus.get(0).getId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<ApplicableAccountFeeDto> feeList = (List<ApplicableAccountFeeDto>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request);
    ApplicableAccountFeeDto fee = feeList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("selectedFee[0].feeId", fee.getFeeId().toString());
    addRequestParameter("selectedFee[0].amount", fee.getAmount());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, new MeetingBO(RecurrenceType.MONTHLY, Short.valueOf("2"), new Date(), MeetingType.CUSTOMER_MEETING), request);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.preview_success.toString());
    removeFees(feesToRemove);
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) List(java.util.List) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) Date(java.util.Date) Test(org.junit.Test)

Example 5 with BusinessActivityEntity

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

the class ClientCustActionStrutsTest method testLoadWithGroupHavingNoLoanOfficer.

@Test
public void testLoadWithGroupHavingNoLoanOfficer() throws Exception {
    createParentGroup(CustomerStatus.GROUP_PARTIAL, null);
    savingsOffering1 = TestObjectFactory.createSavingsProduct("savingsoffering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("parentGroupId", group.getCustomerId().toString());
    addRequestParameter("groupFlag", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.SALUTATION_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.MARITAL_STATUS_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.CITIZENSHIP_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.BUSINESS_ACTIVITIES_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.EDUCATION_LEVEL_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.GENDER_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.SPOUSE_FATHER_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.HANDICAPPED_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(ClientConstants.ETHNICITY_ENTITY, request));
    Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.FORMEDBY_LOAN_OFFICER_LIST, request));
    List<BusinessActivityEntity> povertyStatusList = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    Assert.assertNotNull(povertyStatusList);
    List<SavingsDetailDto> savingsOfferingList = getSavingsOfferingsFromSession();
    Assert.assertNotNull(savingsOfferingList);
    Assert.assertEquals(1, savingsOfferingList.size());
    ClientCustActionForm actionForm = (ClientCustActionForm) request.getSession().getAttribute("clientCustActionForm");
    Assert.assertNull(actionForm.getFormedByPersonnelValue());
    group = (GroupBO) StaticHibernateUtil.getSessionTL().get(GroupBO.class, group.getCustomerId());
    StaticHibernateUtil.flushAndClearSession();
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)12 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)12 List (java.util.List)10 Test (org.junit.Test)10 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)9 Date (java.util.Date)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)5 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)4 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)3 MifosUser (org.mifos.security.MifosUser)3 MifosUserBuilder (org.mifos.builders.MifosUserBuilder)2 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)2 Authentication (org.springframework.security.core.Authentication)2 SecurityContext (org.springframework.security.core.context.SecurityContext)2 SecurityContextImpl (org.springframework.security.core.context.SecurityContextImpl)2 IOException (java.io.IOException)1