use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class HolidayServiceIntegrationTest method createOfficeHierarchy.
public void createOfficeHierarchy() {
headOffice = new OfficeBuilder().withGlobalOfficeNum("001").withName("headOffice").headOffice().withParentOffice(null).build();
IntegrationTestObjectMother.createOffice(headOffice);
regionalOffice = new OfficeBuilder().withGlobalOfficeNum("002").withName("region1").regionalOffice().withParentOffice(headOffice).build();
IntegrationTestObjectMother.createOffice(regionalOffice);
OfficeBO subRegionalOffice = new OfficeBuilder().withGlobalOfficeNum("003").withName("sub1-of-region1").subRegionalOffice().withParentOffice(regionalOffice).build();
IntegrationTestObjectMother.createOffice(subRegionalOffice);
areaOffice = new OfficeBuilder().withGlobalOfficeNum("004").withName("area-of-sub1-regional").areaOffice().withParentOffice(subRegionalOffice).build();
IntegrationTestObjectMother.createOffice(areaOffice);
branch1 = new OfficeBuilder().withGlobalOfficeNum("005").withName("branch1-of-area").branchOffice().withParentOffice(areaOffice).build();
IntegrationTestObjectMother.createOffice(branch1);
branch2 = new OfficeBuilder().withGlobalOfficeNum("006").withName("branch2-of-area").branchOffice().withParentOffice(areaOffice).build();
IntegrationTestObjectMother.createOffice(branch2);
branch3 = new OfficeBuilder().withGlobalOfficeNum("007").withName("branch1-of-regional").branchOffice().withParentOffice(regionalOffice).build();
IntegrationTestObjectMother.createOffice(branch3);
StaticHibernateUtil.flushAndClearSession();
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class ClientServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithExpectedSearchId.
@Test
public void shouldCreateGroupWithExpectedSearchId() {
// setup
boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
MeetingDto meetingDto = meeting.toDto();
String externalId = null;
AddressDto addressDto = new AddressDto("here", "", "", "", "", "", "", "");
PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
Short loanOfficerId = user.getPersonnelId();
List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
CustomerStatus.CLIENT_ACTIVE.getValue();
boolean trained = false;
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
Short officeId = branch1.getOfficeId();
DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
DateTime activationDate = new DateTime().minusWeeks(1);
List<Short> selectedSavingProducts = new ArrayList<Short>();
String clientName = "client";
Short formedBy = loanOfficerId;
Date dateOfBirth = new LocalDate(1990, 1, 1).toDateMidnight().toDate();
String governmentId = "";
Date trainedDate = new LocalDate(2000, 1, 1).toDateMidnight().toDate();
;
// not in a group
Short groupFlag = YesNoFlag.NO.getValue();
Integer salutation = 1;
String firstName = "first";
String middleName = null;
String lastName = "last";
String secondLastName = null;
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), salutation, firstName, middleName, lastName, secondLastName);
// magic numbers from default data
Integer ethnicity = 218;
Integer citizenship = 130;
Integer handicapped = 138;
Integer businessActivities = 225;
Integer educationLevel = 226;
Short numChildren = 0;
Short gender = 49;
Short povertyStatus = 41;
Integer maritalStatus = ClientPersonalDetailDto.MARRIED;
// active
Short clientStatus = 3;
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(ethnicity, citizenship, handicapped, businessActivities, maritalStatus, educationLevel, numChildren, gender, povertyStatus);
ClientNameDetailDto spouseFatherName = new ClientNameDetailDto(NameType.SPOUSE.getValue(), salutation, firstName, middleName, lastName, secondLastName);
InputStream picture = null;
String parentGroupId = null;
List<ClientNameDetailDto> familyNames = null;
List<ClientFamilyDetailDto> familyDetails = null;
ClientCreationDetail clientCreationDetail = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate.toDate(), externalId, addressDto, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, feesToApply, parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDate.toLocalDate());
// exercise test
ClientRules.setCenterHierarchyExists(false);
List<SavingsDetailDto> allowedSavingProducts = new ArrayList<SavingsDetailDto>();
CustomerDetailsDto newlyCreatedCustomerDetails = clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
// verification
ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
ClientBO client = customerDao.findClientBySystemId(newlyCreatedCustomerDetails.getGlobalCustNum());
Assert.assertThat(client.getSearchId(), is("1." + client.getCustomerId()));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldfindCurrentAndFutureOfficeHolidaysEarliestFirst.
@Test
public void shouldfindCurrentAndFutureOfficeHolidaysEarliestFirst() throws Exception {
DateTime yesterday = new DateTime().minusDays(1);
Set<HolidayBO> holidays;
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
holidays = new HashSet<HolidayBO>();
holidays.add((HolidayBO) new HolidayBuilder().withName("Fourth").from(yesterday.plusWeeks(4)).to(yesterday.plusWeeks(5)).build());
holidays.add((HolidayBO) new HolidayBuilder().withName("Second").from(yesterday.plusDays(1)).to(yesterday.plusWeeks(7)).build());
headOffice.setHolidays(holidays);
IntegrationTestObjectMother.createOffice(headOffice);
// builder not setting searchId correctly due to not going thru office.save (which uses HierarchyManager)
String headOfficeSearchId = headOffice.getSearchId();
OfficeBO areaOffice = new OfficeBuilder().withName("Area Office").withSearchId(headOfficeSearchId + "25.").withParentOffice(headOffice).withGlobalOfficeNum("area56").build();
holidays = new HashSet<HolidayBO>();
holidays.add((HolidayBO) new HolidayBuilder().withName("Fifth").from(yesterday.plusWeeks(8)).to(yesterday.plusWeeks(9)).build());
areaOffice.setHolidays(holidays);
IntegrationTestObjectMother.createOffice(areaOffice);
OfficeBO myOffice = new OfficeBuilder().withName("My Office").withSearchId(headOfficeSearchId + "25.1.").withParentOffice(areaOffice).withGlobalOfficeNum("my001").build();
holidays = new HashSet<HolidayBO>();
holidays.add((HolidayBO) new HolidayBuilder().withName("Third").from(yesterday.plusWeeks(3)).to(yesterday.plusWeeks(4)).build());
holidays.add((HolidayBO) new HolidayBuilder().withName("First").from(yesterday).to(yesterday.plusWeeks(2)).build());
myOffice.setHolidays(holidays);
IntegrationTestObjectMother.createOffice(myOffice);
OfficeBO anotherOffice = new OfficeBuilder().withName("Another Unconnected Office").withSearchId(headOfficeSearchId + "26.").withParentOffice(headOffice).withGlobalOfficeNum("n/a001").build();
holidays = new HashSet<HolidayBO>();
holidays.add((HolidayBO) new HolidayBuilder().withName("N/A").from(yesterday.minusWeeks(3)).to(yesterday.plusWeeks(4)).build());
anotherOffice.setHolidays(holidays);
IntegrationTestObjectMother.createOffice(anotherOffice);
List<Holiday> myHolidays = holidayDao.findCurrentAndFutureOfficeHolidaysEarliestFirst(myOffice.getOfficeId());
assertThat(myHolidays.size(), is(5));
assertThat(myHolidays.get(0).getName(), is("First"));
assertThat(myHolidays.get(1).getName(), is("Second"));
assertThat(myHolidays.get(2).getName(), is("Third"));
assertThat(myHolidays.get(3).getName(), is("Fourth"));
assertThat(myHolidays.get(4).getName(), is("Fifth"));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldRetrieveOfficeNames.
@Test
public void shouldRetrieveOfficeNames() throws Exception {
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
List<Short> officeIds = Arrays.asList(branch1.getOfficeId());
// exercise test
List<String> officeNames = holidayDao.retrieveApplicableOfficeNames(officeIds);
// verification
assertThat(officeNames, hasItem(branch1.getOfficeName()));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method insertHoliday.
private void insertHoliday(final Holiday holiday) {
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
HolidayDetails holidayDetails = new HolidayDetails("HolidayDaoTest", holiday.getFromDate().toDate(), holiday.getThruDate().toDate(), holiday.getRepaymentRuleType().getValue());
List<Short> officeIds = Arrays.asList(headOffice.getOfficeId());
IntegrationTestObjectMother.createHoliday(holidayDetails, officeIds);
}
Aggregations