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;
}
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);
}
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());
}
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);
}
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();
}
Aggregations