Search in sources :

Example 26 with OfficeBO

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

the class CustSearchActionStrutsTest method testLoadMainSearchNonLoBoUser.

@Test
public void testLoadMainSearchNonLoBoUser() throws Exception {
    OfficeBO officeBO = TestObjectFactory.getOffice(TestObjectFactory.SAMPLE_BRANCH_OFFICE);
    PersonnelBO personnelBO = TestObjectFactory.createPersonnel(PersonnelLevel.NON_LOAN_OFFICER, officeBO, Integer.valueOf("1"), Short.valueOf("1"), "1234", "raj", null, null, null, new Name("abe", null, null, null), null, new Date(), null, Integer.valueOf("1"), null, null, null, new Date(), new HashSet());
    userContext.setId(personnelBO.getPersonnelId());
    addActionAndMethod(Methods.loadMainSearch.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(CustomerSearchConstants.LOADFORWARDNONLOANOFFICER_SUCCESS);
    List<PersonnelBO> personnelList = (List<PersonnelBO>) SessionUtils.getAttribute(CustomerSearchConstants.LOANOFFICERSLIST, request);
    Assert.assertNotNull(personnelList);
    Assert.assertEquals(1, personnelList.size());
    Assert.assertEquals(officeBO.getOfficeName(), SessionUtils.getAttribute(CustomerSearchConstants.OFFICE, request));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) List(java.util.List) Date(java.util.Date) Name(org.mifos.framework.business.util.Name) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with OfficeBO

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

the class ApplyHolidayChangesHelperIntegrationTest method createOfficeHolidayTestData.

private void createOfficeHolidayTestData(DateTime startDate) throws Exception {
    /*
         * When startDate is 'yesterday' Head Office Holiday: from 2010-02-22 thru 2010-03-01 ... repayment rule is next
         * meeting date Branch Holiday:
         *
         * from 2010-03-08 thru 2010-03-22 ... moratorium
         *
         * One more holiday that should not affect any schedules
         */
    // Creating Office Holidays
    Set<HolidayBO> holidays;
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    holidays = new HashSet<HolidayBO>();
    holidays.add((HolidayBO) new HolidayBuilder().withName("HO Holiday").from(startDate).to(startDate.plusWeeks(1)).withRepaymentRule(RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT).build());
    headOffice.setHolidays(holidays);
    IntegrationTestObjectMother.createOffice(headOffice);
    OfficeBO centerOffice = testSaveCollectionSheetUtils.getCenter().getOffice();
    holidays = new HashSet<HolidayBO>();
    holidays.add((HolidayBO) new HolidayBuilder().withName("Center Hierarchy Holiday").from(startDate.plusWeeks(2)).to(startDate.plusWeeks(4)).withRepaymentMoratoriumRule().build());
    centerOffice.setHolidays(holidays);
    IntegrationTestObjectMother.createOffice(centerOffice);
    // builder not setting searchId correctly due to not going thru office.save (which uses HierarchyManager)
    String headOfficeSearchId = headOffice.getSearchId();
    OfficeBO anotherOffice = new OfficeBuilder().withParentOffice(headOffice).withName("Another Office").withSearchId(headOfficeSearchId + "26.").withGlobalOfficeNum("n/a001").build();
    holidays = new HashSet<HolidayBO>();
    holidays.add((HolidayBO) new HolidayBuilder().withName("N/A").from(startDate.minusWeeks(3)).to(startDate.plusWeeks(8)).withRepaymentMoratoriumRule().build());
    anotherOffice.setHolidays(holidays);
    IntegrationTestObjectMother.createOffice(anotherOffice);
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) HolidayBO(org.mifos.application.holiday.business.HolidayBO) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder)

Example 28 with OfficeBO

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

the class IntegrationTestObjectMotherBuilderDsl method anExistingBranchOffice.

public static OfficeBO anExistingBranchOffice(OfficeBuilder aBranchOffice) {
    OfficeBO headOffice = new OfficeBuilder().withGlobalOfficeNum("xxxx-001").withName("builder-head-office").withShortName("hf1").withSearchId("1.1.").headOffice().build();
    IntegrationTestObjectMother.createOffice(headOffice);
    OfficeBO areaOffice = new OfficeBuilder().withParentOffice(headOffice).withGlobalOfficeNum("xxxx-002").withName("builder-area-office").withShortName("af1").withSearchId("1.1.1.").areaOffice().build();
    IntegrationTestObjectMother.createOffice(areaOffice);
    OfficeBO branchOffice = aBranchOffice.withParentOffice(areaOffice).branchOffice().build();
    IntegrationTestObjectMother.createOffice(branchOffice);
    return branchOffice;
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO)

Example 29 with OfficeBO

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

the class CustomerSearchIdGenerationTest method transferClientFromOfficeToOfficeTest.

@Test
public void transferClientFromOfficeToOfficeTest() throws Exception {
    final short office1_id = 2;
    // setup
    OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
    PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
    ClientBO existingClient = new ClientBuilder().pendingApproval().withNoParent().withLoanOfficer(loanOfficer).buildForUnitTests();
    existingClient.setCustomerDao(customerDao);
    existingClient = spy(existingClient);
    int customer_id = 22;
    when(existingClient.getCustomerId()).thenReturn(customer_id);
    existingClient.generateSearchId();
    UserContext userContext = TestUtils.makeUser();
    existingClient.setUserContext(userContext);
    // stubbing
    when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
    // exercise test
    assertThat(existingClient.getSearchId(), is("1." + customer_id));
    customerService.transferClientTo(existingClient, office1);
    // verification
    assertThat(existingClient.getSearchId(), is("1." + customer_id));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 30 with OfficeBO

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

the class CustomerSearchIdGenerationTest method transferGroupFromOfficeToOfficeTest.

@Test
public void transferGroupFromOfficeToOfficeTest() throws Exception {
    final short office1_id = 2;
    // setup
    OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
    PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
    GroupBO existingGroup = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).buildAsTopOfHierarchy();
    existingGroup = spy(existingGroup);
    int customer_id = 22;
    when(existingGroup.getCustomerId()).thenReturn(customer_id);
    existingGroup.generateSearchId();
    ClientBO existingClient = new ClientBuilder().pendingApproval().withParentCustomer(existingGroup).buildForUnitTests();
    existingGroup.addChild(existingClient);
    existingGroup.setCustomerDao(customerDao);
    UserContext userContext = TestUtils.makeUser();
    existingGroup.setUserContext(userContext);
    // stubbing
    when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
    // exercise test
    assertThat(existingGroup.getSearchId(), is("1." + customer_id));
    assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
    customerService.transferGroupTo(existingGroup, office1);
    // verification
    assertThat(existingGroup.getSearchId(), is("1." + customer_id));
    assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) 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