Search in sources :

Example 26 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithFeeThatHasDifferentPeriod.

@Test
public void cannotCreateCenterWithFeeThatHasDifferentPeriod() {
    // setup
    DateTime today = new DateTime();
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly();
    CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(aWeeklyMeeting).withMfiJoiningDate(today).build();
    MeetingBuilder aMonthlyMeeting = new MeetingBuilder().periodicFeeMeeting().monthly();
    AmountFeeBO montlyPeriodicFee = new FeeBuilder().appliesToCenterOnly().with(aMonthlyMeeting).build();
    AccountFeesEntity accountFee = new AccountFeesEntity(null, montlyPeriodicFee, montlyPeriodicFee.getFeeAmount().getAmountDoubleValue());
    List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
    centerAccountFees.add(accountFee);
    // exercise test
    try {
        center.validateMeetingAndFees(centerAccountFees);
        fail("cannotCreateCenterWithFeeThatHasDifferentPeriod");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH));
    }
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 27 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithoutABranch.

@Test
public void cannotCreateCenterWithoutABranch() {
    // setup
    DateTime today = new DateTime();
    MeetingBuilder customerMeeting = new MeetingBuilder().customerMeeting();
    OfficeBO noBranch = null;
    CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(customerMeeting).withMfiJoiningDate(today).with(noBranch).build();
    // exercise test
    try {
        center.validate();
        fail("cannotCreateCenterWithoutABranch");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.INVALID_OFFICE));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) OfficeBO(org.mifos.customers.office.business.OfficeBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 28 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CenterUpdateTest method cannotUpdateCenterWithDifferentVersion.

@Test
public void cannotUpdateCenterWithDifferentVersion() {
    // setup
    int differentVersionNum = -1;
    CenterBO existingCenter = new CenterBuilder().withLoanOfficer(PersonnelBuilder.anyLoanOfficer()).withVersion(differentVersionNum).build();
    UserContext userContext = TestUtils.makeUser();
    CenterUpdate centerUpdate = new CenterUpdateBuilder().build();
    // stub
    when(customerDao.findCustomerById(centerUpdate.getCustomerId())).thenReturn(existingCenter);
    // exercise test
    try {
        customerService.updateCenter(userContext, centerUpdate);
        fail("cannotUpdateCenterWithDifferentVersion");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(Constants.ERROR_VERSION_MISMATCH));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterUpdateBuilder(org.mifos.domain.builders.CenterUpdateBuilder) CenterUpdate(org.mifos.dto.domain.CenterUpdate) UserContext(org.mifos.security.util.UserContext) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 29 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class TestCollectionSheetRetrieveSavingsAccountsUtils method createSampleCenterHierarchy.

/**
     * By default generates 1 center with a mandatory savings account (center savings accounts are always
     * PER_INDIVIDUAL)
     *
     * 1 group with a voluntary COMPLETE_GROUP savings account
     *
     * 1 client with a mandatory savings account
     *
     * 1 group with a mandatory PER_INDIVIDUAL savings account
     *
     * 1 client with a voluntary savings account
     */
public void createSampleCenterHierarchy() throws Exception {
    // TODO - correct clientBuilder so that when there are "PER_INDIVIDUAL" savings accounts relevant to it... a
    // saving schedule is created.
    //
    // As a work-around for this problem... the two "PER_INDIVIDUAL" savings accounts (centerSavingsAccount and
    // groupPerIndividualSavingsAccount) are created last... this kicks of a process that creates schedules for all
    // the relevant clients.
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().withNumberOfExistingCustomersInOffice(3).with(weeklyMeeting).withName("Savings Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
    if (!onlyCreateCenterAndItsSavingsAccount) {
        groupCompleteGroup = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
        IntegrationTestObjectMother.createGroup(groupCompleteGroup, weeklyMeeting);
        groupCompleteGroupSavingsAccount = createSavingsAccount(groupCompleteGroup, "gvcg", "2.0", true, false);
        MeetingBO weeklyClientMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
        groupCompleteGroup.setMeeting(weeklyClientMeeting);
        clientOfGroupCompleteGroup = new ClientBuilder().withSearchId(center.getSearchId() + ".1.1").withMeeting(weeklyClientMeeting).withName("Savings Client Of Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupCompleteGroup).buildForIntegrationTests();
        IntegrationTestObjectMother.createClient(clientOfGroupCompleteGroup, weeklyClientMeeting);
        clientOfGroupCompleteGroupSavingsAccount = createSavingsAccount(clientOfGroupCompleteGroup, "clm", "3.0", false, false);
        groupPerIndividual = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
        IntegrationTestObjectMother.createGroup(groupPerIndividual, weeklyMeeting);
        clientOfGroupPerIndividual = new ClientBuilder().withSearchId(center.getSearchId() + ".2.1").withMeeting(weeklyMeeting).withName("Savings Client Of Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupPerIndividual).buildForIntegrationTests();
        IntegrationTestObjectMother.createClient(clientOfGroupPerIndividual, weeklyMeeting);
        clientOfGroupPerIndividualSavingsAccount = createSavingsAccount(clientOfGroupPerIndividual, "clv", "5.0", true, false);
        groupPerIndividualSavingsAccount = createSavingsAccount(groupPerIndividual, "gmi", "4.0", false, true);
    }
    centerSavingsAccount = createSavingsAccount(center, "cemi", "1.0", false, false);
}
Also used : 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)

Example 30 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CustomerDaoHibernateIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    databaseCleaner.clean();
    weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
    center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
    weeklyPeriodicFeeForGroupOnly = new FeeBuilder().appliesToGroupsOnly().withFeeAmount("50.0").withName("Group Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForGroupOnly);
    group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withFee(weeklyPeriodicFeeForGroupOnly).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
    weeklyPeriodicFeeForClientsOnly = new FeeBuilder().appliesToClientsOnly().withFeeAmount("10.0").withName("Client Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForClientsOnly);
    activeClient = new ClientBuilder().active().withMeeting(weeklyMeeting).withName("Active Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    Address address = new Address("a", "b", "c", "gdynia", "pomorskie", "PL", "81-661", "0-89 222 33");
    activeClient.setCustomerAddressDetail(new CustomerAddressDetailEntity(activeClient, address));
    IntegrationTestObjectMother.createClient(activeClient, weeklyMeeting);
    weeklyPeriodicFeeForSecondClient = new FeeBuilder().appliesToClientsOnly().withFeeAmount("10.0").withName("Inactive Client Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForSecondClient);
    pendingClient = new ClientBuilder().pendingApproval().withMeeting(weeklyMeeting).withName("Pending Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(pendingClient, weeklyMeeting);
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) Address(org.mifos.framework.business.util.Address) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Before(org.junit.Before)

Aggregations

CenterBuilder (org.mifos.domain.builders.CenterBuilder)123 Test (org.junit.Test)98 CenterBO (org.mifos.customers.center.business.CenterBO)82 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)73 MeetingBO (org.mifos.application.meeting.business.MeetingBO)54 GroupBuilder (org.mifos.domain.builders.GroupBuilder)53 DateTime (org.joda.time.DateTime)52 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)46 ArrayList (java.util.ArrayList)42 GroupBO (org.mifos.customers.group.business.GroupBO)36 ClientBuilder (org.mifos.domain.builders.ClientBuilder)30 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 CustomerException (org.mifos.customers.exceptions.CustomerException)18 FeeBuilder (org.mifos.domain.builders.FeeBuilder)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)17 LocalDate (org.joda.time.LocalDate)14 Before (org.junit.Before)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 ClientBO (org.mifos.customers.client.business.ClientBO)13