Search in sources :

Example 31 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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 32 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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 33 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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 34 with MeetingBuilder

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

the class CustomerCreationDaoHibernateIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    // jdbc
    // delete from customer_fee_schedule
    // delete form customer_schedule
    // delete from customer_account
    // delete from account
    // delete from customer_meeting
    // delete from customer
    weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    customerDao = new CustomerDaoHibernate(genericDao);
}
Also used : MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CustomerDaoHibernate(org.mifos.customers.persistence.CustomerDaoHibernate) Before(org.junit.Before)

Example 35 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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

MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)106 Test (org.junit.Test)74 MeetingBO (org.mifos.application.meeting.business.MeetingBO)74 CenterBuilder (org.mifos.domain.builders.CenterBuilder)73 DateTime (org.joda.time.DateTime)58 ArrayList (java.util.ArrayList)47 CenterBO (org.mifos.customers.center.business.CenterBO)43 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)38 LocalDate (org.joda.time.LocalDate)27 GroupBuilder (org.mifos.domain.builders.GroupBuilder)24 Before (org.junit.Before)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)20 FeeBuilder (org.mifos.domain.builders.FeeBuilder)20 OfficeBO (org.mifos.customers.office.business.OfficeBO)19 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)14 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 Ignore (org.junit.Ignore)10