Search in sources :

Example 86 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method shouldNotThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDoNotDifferFromPreviousParentOffice.

@Test
public void shouldNotThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDoNotDifferFromPreviousParentOffice() throws Exception {
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    // setup
    createOfficeHierarchyUnderHeadOffice(headOffice);
    DateTime tomorrow = new DateTime().plusDays(1);
    HolidayDetails holidayDetails = new HolidayBuilder().withName("areaOffice2Holiday").from(tomorrow).to(tomorrow).buildDto();
    IntegrationTestObjectMother.createHoliday(holidayDetails, Arrays.asList(areaOffice2.getOfficeId(), areaOffice1.getOfficeId()));
    HolidayDetails branchOnlyHolidayDetails = new HolidayBuilder().withName("branchOnlyHoliday").from(tomorrow).to(tomorrow).buildDto();
    IntegrationTestObjectMother.createHoliday(branchOnlyHolidayDetails, Arrays.asList(branch1.getOfficeId()));
    // refetch
    branch1 = IntegrationTestObjectMother.findOfficeById(branch1.getOfficeId());
    // exercise test
    holidayDao.validateNoExtraFutureHolidaysApplicableOnParentOffice(branch1.getParentOffice().getOfficeId(), areaOffice2.getOfficeId());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) HolidayDetails(org.mifos.dto.domain.HolidayDetails) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 87 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class ClientCustActionStrutsTest method createAndSetClientInSession.

private void createAndSetClientInSession() throws Exception {
    OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER);
    meeting = getMeeting();
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), 1, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), 1, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    Calendar dob = new GregorianCalendar();
    dob.set(Calendar.YEAR, 1970);
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, new Address(), getCustomFields(), null, null, personnel, office, meeting, personnel, dob.getTime(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushAndClearSession();
    client = TestObjectFactory.getClient(Integer.valueOf(client.getCustomerId()).intValue());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
Also used : Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) ClientBO(org.mifos.customers.client.business.ClientBO) GregorianCalendar(java.util.GregorianCalendar) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence)

Example 88 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testSearchWithGovernmentId.

@Test
public void testSearchWithGovernmentId() throws Exception {
    OfficeBO office = IntegrationTestObjectMother.sampleBranchOffice();
    PersonnelBO testUser = IntegrationTestObjectMother.testUser();
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().monthly().every(1).onDayOfMonth(1).build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().with(weeklyMeeting).withName(this.getClass().getSimpleName() + " Center").with(office).withLoanOfficer(testUser).build();
    IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
    group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(office).withLoanOfficer(testUser).withParentCustomer(center).withStatus(CustomerStatus.GROUP_ACTIVE).build();
    IntegrationTestObjectMother.createGroup((GroupBO) group, weeklyMeeting);
    String clientGovernmentId = "76346793216";
    client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client 1").withOffice(office).withLoanOfficer(testUser).withParentCustomer(group).withStatus(CustomerStatus.CLIENT_ACTIVE).withGovernmentId(clientGovernmentId).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, weeklyMeeting);
    QueryResult queryResult = new CustomerPersistence().search(clientGovernmentId, office.getOfficeId(), testUser.getPersonnelId(), testUser.getOffice().getOfficeId(), filters);
    Assert.assertNotNull(queryResult);
    Assert.assertEquals(1, queryResult.getSize());
    Assert.assertEquals(1, queryResult.get(0, 10).size());
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 89 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class OfficePersistenceIntegrationTest method testGetBranchesUnderUser.

@Test
public void testGetBranchesUnderUser() throws Exception {
    OfficeBO parent = TestObjectFactory.getOffice(TestObjectFactory.HEAD_OFFICE);
    OfficeBO branchOffice = TestObjectFactory.createOffice(OfficeLevel.BRANCHOFFICE, parent, "abcd", "abcd");
    List<OfficeBO> officeList = getOfficePersistence().getActiveBranchesUnderUser("1.1");
    Assert.assertNotNull(officeList);
    Assert.assertEquals(2, officeList.size());
    Assert.assertEquals(branchOffice.getOfficeName(), officeList.get(0).getOfficeName());
    Assert.assertEquals("TestBranchOffice", officeList.get(1).getOfficeName());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) Test(org.junit.Test)

Example 90 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class OfficeActionStrutsTest method testEditPreviewHO.

@Test
public void testEditPreviewHO() throws Exception {
    addActionMethod(Methods.editpreview.toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    OfficeBO headoffice = TestObjectFactory.getOffice(TestObjectFactory.HEAD_OFFICE);
    addRequestParameter("officeName", "RAJOFFICE");
    addRequestParameter("shortName", headoffice.getShortName());
    addRequestParameter("officeLevel", headoffice.getOfficeLevel().getValue().toString());
    addRequestParameter("parentOfficeId", "");
    addRequestParameter("officeStatus", headoffice.getOfficeStatus().getValue().toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.editpreview_success.toString());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) Test(org.junit.Test)

Aggregations

OfficeBO (org.mifos.customers.office.business.OfficeBO)115 Test (org.junit.Test)62 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)45 DateTime (org.joda.time.DateTime)33 ArrayList (java.util.ArrayList)31 MeetingBO (org.mifos.application.meeting.business.MeetingBO)28 UserContext (org.mifos.security.util.UserContext)25 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)23 CenterBO (org.mifos.customers.center.business.CenterBO)21 CenterBuilder (org.mifos.domain.builders.CenterBuilder)21 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)19 MifosUser (org.mifos.security.MifosUser)18 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)17 Address (org.mifos.framework.business.util.Address)17 GroupBO (org.mifos.customers.group.business.GroupBO)16 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 GroupBuilder (org.mifos.domain.builders.GroupBuilder)14 AddressDto (org.mifos.dto.domain.AddressDto)13