Search in sources :

Example 16 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupTransferServiceIntegrationTest method transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroupsChildren.

@Ignore
@Test
public void transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroupsChildren() throws Exception {
    // setup
    OfficeBO branchOffice = anExistingBranchOffice(new OfficeBuilder().withGlobalOfficeNum("xxxx-003").withName("builder-branch-office1").withShortName("bf1").withSearchId("1.1.1.1."));
    OfficeBO branchOffice2 = new OfficeBuilder().withParentOffice(branchOffice.getParentOffice()).branchOffice().withGlobalOfficeNum("xxxx-004").withName("builder-branch-office2").withShortName("bf1").withSearchId("1.1.1.2.").build();
    IntegrationTestObjectMother.createOffice(branchOffice2);
    DateTime todaySixWeeksAgo = new DateMidnight().toDateTime().minusWeeks(6);
    MeetingBO weeklyMeeting = aWeeklyMeeting().withLocation("weeklyMeeting-sixWeeksAgo").startingFrom(todaySixWeeksAgo.toDate()).build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    CenterBuilder centerWithWeeklyMeeting = anActiveCenter().withName("center-with-no-children").with(weeklyMeeting).with(branchOffice).withActivationDate(todaySixWeeksAgo).withLoanOfficer(anExistingLoanOfficer());
    CenterBO centerWithNoChildren = anExistingActiveCenter(centerWithWeeklyMeeting);
    DateTime tomorrowTwoWeeksAgo = new DateMidnight().toDateTime().minusWeeks(2).plusDays(1);
    MeetingBO differentWeeklyMeeting = aWeeklyMeeting().withLocation("weeklyMeeting-tomorrow-twoWeeksAgo").withStartDate(tomorrowTwoWeeksAgo.minusWeeks(1)).build();
    IntegrationTestObjectMother.saveMeeting(differentWeeklyMeeting);
    CenterBuilder centerInDifferentBranchWithDifferentMeeting = centerWithWeeklyMeeting.withName("center-with-group").with(branchOffice2).with(differentWeeklyMeeting).withActivationDate(tomorrowTwoWeeksAgo);
    GroupBO groupForTransfer = anExistingGroupUnderCenterInDifferentBranchAs(centerInDifferentBranchWithDifferentMeeting);
    ClientBO child1 = new ClientBuilder().active().withName("client1").withParentCustomer(groupForTransfer).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(child1, child1.getCustomerMeetingValue());
    // pre-verification
    ClientBO client = customerDao.findClientBySystemId(child1.getGlobalCustNum());
    TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(client, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
    // exercise test
    groupForTransfer = customerDao.findGroupBySystemId(groupForTransfer.getGlobalCustNum());
    groupForTransfer.setUserContext(TestUtils.makeUser());
    customerService.transferGroupTo(groupForTransfer, centerWithNoChildren);
    // verification
    client = customerDao.findClientBySystemId(child1.getGlobalCustNum());
    TestUtils.assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(client, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
// TO-FIX TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(client, WeekDay.getJodaWeekDay(todaySixWeeksAgo.getDayOfWeek()));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) DateMidnight(org.joda.time.DateMidnight) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) DateTime(org.joda.time.DateTime) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with GroupBO

use of org.mifos.customers.group.business.GroupBO 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 18 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class TestObjectFactory method createGroupUnderCenter.

public static GroupBO createGroupUnderCenter(final String customerName, final CustomerStatus customerStatus, final String externalId, final boolean trained, final Date trainedDate, final Address address, final List<CustomFieldDto> customFields, final List<FeeDto> fees, final Short formedById, final CustomerBO parentCustomer) {
    GroupBO group;
    try {
        group = new GroupBO(TestUtils.makeUserWithLocales(), customerName, customerStatus, externalId, trained, trainedDate, address, customFields, fees, getPersonnel(formedById), parentCustomer);
        new GroupPersistence().saveGroup(group);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return group;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) GroupBO(org.mifos.customers.group.business.GroupBO) GroupPersistence(org.mifos.customers.group.persistence.GroupPersistence) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Example 19 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class TestObjectFactory method createInstanceForTest.

public static GroupBO createInstanceForTest(final UserContext userContext, final GroupTemplate template, final CenterBO center, final Date customerActivationDate) {
    PersonnelBO formedBy = null;
    DateTime mfiJoiningDate = new DateTime().toDateMidnight().toDateTime();
    DateTime activationDate = new DateTime().toDateMidnight().toDateTime();
    GroupBO group = GroupBO.createGroupWithCenterAsParent(userContext, template.getDisplayName(), formedBy, center, template.getAddress(), template.getExternalId(), template.isTrained(), new DateTime(template.getTrainedDate()), template.getCustomerStatus(), mfiJoiningDate, activationDate);
    group.setCustomerActivationDate(customerActivationDate);
    return group;
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) GroupBO(org.mifos.customers.group.business.GroupBO) DateTime(org.joda.time.DateTime)

Example 20 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class IntegrationTestObjectMotherBuilderDsl method anExistingGroupUnderCenterInSameBranchAs.

public static GroupBO anExistingGroupUnderCenterInSameBranchAs(CenterBuilder centerBuilder) {
    CenterBO centerAsParent = centerBuilder.build();
    IntegrationTestObjectMother.createCenter(centerAsParent, centerAsParent.getCustomerMeetingValue());
    GroupBO group = anActiveGroup().withParentCustomer(centerAsParent).formedBy(anExistingApplicationUser()).build();
    IntegrationTestObjectMother.createGroup(group, group.getCustomerMeetingValue());
    return group;
}
Also used : CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO)

Aggregations

GroupBO (org.mifos.customers.group.business.GroupBO)84 Test (org.junit.Test)56 CenterBO (org.mifos.customers.center.business.CenterBO)45 GroupBuilder (org.mifos.domain.builders.GroupBuilder)42 CenterBuilder (org.mifos.domain.builders.CenterBuilder)36 CustomerException (org.mifos.customers.exceptions.CustomerException)23 ClientBO (org.mifos.customers.client.business.ClientBO)22 ArrayList (java.util.ArrayList)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)16 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 DateTime (org.joda.time.DateTime)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)11 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 UserContext (org.mifos.security.util.UserContext)11 LocalDate (org.joda.time.LocalDate)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)10 ApplicationException (org.mifos.framework.exceptions.ApplicationException)10 Date (java.util.Date)9