Search in sources :

Example 11 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class ClientCustActionStrutsTest method createClientForAuditLog.

private void createClientForAuditLog() throws Exception {
    OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER);
    meeting = getMeeting();
    Integer salutation = 47;
    Integer ethnicity = 218;
    Integer citizenship = 130;
    Integer handicapped = 138;
    Integer businessActivities = 225;
    Integer educationLevel = 226;
    Short numChildren = Short.valueOf("1");
    Short gender = Short.valueOf("49");
    Short povertyStatus = Short.valueOf("41");
    StaticHibernateUtil.startTransaction();
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), salutation, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(ethnicity, citizenship, handicapped, businessActivities, ClientPersonalDetailDto.MARRIED, educationLevel, numChildren, gender, povertyStatus);
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, new Address(), getCustomFields(), null, null, personnel, office, meeting, personnel, new java.util.Date(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushAndClearSession();
    client = TestObjectFactory.getClient(new Integer(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) ClientBO(org.mifos.customers.client.business.ClientBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Date(java.util.Date)

Example 12 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class ClientCustActionStrutsTest method createGroupWithoutFee.

private void createGroupWithoutFee() throws Exception {
    meeting = new MeetingBO(WeekDay.MONDAY, TestObjectFactory.EVERY_WEEK, new Date(), MeetingType.CUSTOMER_MEETING, "Delhi");
    group = new GroupBO(userContext, "groupName", CustomerStatus.GROUP_PENDING, "1234", false, null, null, null, null, legacyPersonnelDao.getPersonnel(Short.valueOf("3")), new OfficePersistence().getOffice(Short.valueOf("3")), meeting, legacyPersonnelDao.getPersonnel(Short.valueOf("3")));
    new GroupPersistence().saveGroup(group);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBO(org.mifos.customers.group.business.GroupBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Date(java.util.Date) GroupPersistence(org.mifos.customers.group.persistence.GroupPersistence)

Example 13 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class ClientIntegrationTest method testSuccessfulCreateClientInBranch.

@Test
public void testSuccessfulCreateClientInBranch() throws Exception {
    OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
    String firstName = "Client";
    String lastName = "Last";
    String displayName = "Client Last";
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, firstName, "", lastName, "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "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"));
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, null, getCustomFields(), null, null, personnel, office, meeting, personnel, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    Assert.assertEquals(displayName, client.getDisplayName());
    Assert.assertEquals(firstName, client.getFirstName());
    Assert.assertEquals(lastName, client.getLastName());
    Assert.assertEquals(officeId, client.getOffice().getOfficeId());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 14 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class ClientIntegrationTest method testUpdateBranchSecondTime.

@Test
public void testUpdateBranchSecondTime() throws Exception {
    StaticHibernateUtil.closeSession();
    createObjectsForClientTransfer();
    Assert.assertNull(client.getActiveCustomerMovement());
    OfficeBO oldOffice = client.getOffice();
    client.transferToBranch(office);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    client.setUserContext(TestUtils.makeUser());
    CustomerMovementEntity currentMovement = client.getActiveCustomerMovement();
    Assert.assertNotNull(currentMovement);
    Assert.assertEquals(office.getOfficeId(), currentMovement.getOffice().getOfficeId());
    Assert.assertEquals(office.getOfficeId(), client.getOffice().getOfficeId());
    client.transferToBranch(oldOffice);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    currentMovement = client.getActiveCustomerMovement();
    Assert.assertNotNull(currentMovement);
    Assert.assertEquals(oldOffice.getOfficeId(), currentMovement.getOffice().getOfficeId());
    Assert.assertEquals(oldOffice.getOfficeId(), client.getOffice().getOfficeId());
    office = new OfficePersistence().getOffice(office.getOfficeId());
}
Also used : CustomerMovementEntity(org.mifos.customers.business.CustomerMovementEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 15 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class ClientIntegrationTest method testSuccessfulCreateInActiveState_WithAssociatedSavingsOffering.

@Test
public void testSuccessfulCreateInActiveState_WithAssociatedSavingsOffering() throws Exception {
    savingsOffering1 = TestObjectFactory.createSavingsProduct("offering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    StaticHibernateUtil.flushSession();
    List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>();
    selectedOfferings.add(savingsOffering1);
    String name = "Client 1";
    Short povertyStatus = Short.valueOf("41");
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), povertyStatus);
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.CLIENT_ACTIVE, null, null, null, null, null, selectedOfferings, personnel, new OfficePersistence().getOffice(TestObjectFactory.SAMPLE_BRANCH_OFFICE), getMeeting(), personnel, null, null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    Assert.assertEquals(name, client.getDisplayName());
    Assert.assertEquals(1, client.getOfferingsAssociatedInCreate().size());
    Assert.assertEquals(2, client.getAccounts().size());
    for (AccountBO account : client.getAccounts()) {
        if (account instanceof SavingsBO) {
            Assert.assertEquals(savingsOffering1.getPrdOfferingId(), ((SavingsBO) account).getSavingsOffering().getPrdOfferingId());
            Assert.assertNotNull(account.getGlobalAccountNum());
            Assert.assertTrue(true);
        }
    }
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(client.getCustomerId());
    savingsOffering1 = null;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)37 PersistenceException (org.mifos.framework.exceptions.PersistenceException)17 OfficeBO (org.mifos.customers.office.business.OfficeBO)16 Test (org.junit.Test)11 MifosRuntimeException (org.mifos.core.MifosRuntimeException)11 OfficeException (org.mifos.customers.office.exceptions.OfficeException)11 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)8 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)8 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)8 ArrayList (java.util.ArrayList)7 CustomerException (org.mifos.customers.exceptions.CustomerException)7 ClientBO (org.mifos.customers.client.business.ClientBO)6 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)5 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)5 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)5 Date (java.util.Date)4 MessageLookup (org.mifos.application.master.MessageLookup)4 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)4 Address (org.mifos.framework.business.util.Address)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4