Search in sources :

Example 16 with FeeBuilder

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

the class CenterScheduleCreationUsingCustomerServiceIntegrationTest method createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeAndOneTimeFeeNoHoliday.

@Test
public void createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeAndOneTimeFeeNoHoliday() throws Exception {
    DateTime startDate = date(2010, 4, 5);
    //Monday
    DateTimeUtils.setCurrentMillisFixed(startDate.getMillis());
    // setup
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    MeetingBuilder weeklyMeetingForFees = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).startingToday();
    AmountFeeBO weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").with(weeklyMeetingForFees).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
    AmountFeeBO oneTimeFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("25.0").withName("Center UpfrontFee").oneTime().build();
    IntegrationTestObjectMother.saveFee(oneTimeFeeForCenterOnly);
    CenterBO center = new CenterBuilder().with(weeklyMeeting).withName("Center-IntegrationTest").with(sampleBranchOffice()).withLoanOfficer(testUser()).withUserContext().build();
    // exercise test
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting, weeklyPeriodicFeeForCenterOnly, oneTimeFeeForCenterOnly);
    // verification
    StaticHibernateUtil.flushAndClearSession();
    validateDates(center.getGlobalCustNum(), startDate, startDate.plusWeeks(1), startDate.plusWeeks(2), startDate.plusWeeks(3), startDate.plusWeeks(4), startDate.plusWeeks(5), startDate.plusWeeks(6), startDate.plusWeeks(7), startDate.plusWeeks(8), startDate.plusWeeks(9));
    validateOnePeriodicFeeAndOneOneTimeFee(center.getGlobalCustNum(), "Center Weekly Periodic Fee", "Center UpfrontFee", 25.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0);
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 17 with FeeBuilder

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

the class CenterScheduleCreationUsingCustomerServiceIntegrationTest method createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeAndOneTimeFeeWithThirdAndFourthMeetingsInMoratorium.

@Ignore
@Test
public void createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeAndOneTimeFeeWithThirdAndFourthMeetingsInMoratorium() throws Exception {
    DateTime startDate = date(2010, 4, 5);
    //Monday
    DateTimeUtils.setCurrentMillisFixed(startDate.getMillis());
    // setup
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    MeetingBuilder weeklyMeetingForFees = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).startingToday();
    AmountFeeBO weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").with(weeklyMeetingForFees).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
    AmountFeeBO oneTimeFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("25.0").withName("Center UpfrontFee").oneTime().build();
    IntegrationTestObjectMother.saveFee(oneTimeFeeForCenterOnly);
    saveHoliday(startDate.plusWeeks(2), startDate.plusWeeks(3).plusDays(4), RepaymentRuleTypes.REPAYMENT_MORATORIUM);
    StaticHibernateUtil.flushSession();
    CenterBO center = new CenterBuilder().with(weeklyMeeting).withName("Center-IntegrationTest").with(sampleBranchOffice()).withLoanOfficer(testUser()).withUserContext().build();
    // exercise test
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting, weeklyPeriodicFeeForCenterOnly, oneTimeFeeForCenterOnly);
    // verification
    StaticHibernateUtil.flushAndClearSession();
    validateDates(center.getGlobalCustNum(), startDate, startDate.plusWeeks(1), startDate.plusWeeks(4), startDate.plusWeeks(5), startDate.plusWeeks(6), startDate.plusWeeks(7), startDate.plusWeeks(8), startDate.plusWeeks(9), startDate.plusWeeks(10), startDate.plusWeeks(11));
    validateOnePeriodicFeeAndOneOneTimeFee(center.getGlobalCustNum(), "Center Weekly Periodic Fee", "Center UpfrontFee", 25.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0);
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with FeeBuilder

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

the class CenterScheduleCreationUsingCustomerServiceIntegrationTest method createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeAndOneTimeFeeWithFirstMeetingInMoratorium.

@Test
public void createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeAndOneTimeFeeWithFirstMeetingInMoratorium() throws Exception {
    DateTime today = date(2010, 4, 5);
    //Today is a Monday
    DateTimeUtils.setCurrentMillisFixed(today.getMillis());
    // Start tomorrow, Tuesday
    DateTime tomorrow = today.plusDays(1);
    // setup
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingFrom(tomorrow.toDate()).build();
    MeetingBuilder weeklyMeetingForFees = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).startingToday();
    AmountFeeBO weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").with(weeklyMeetingForFees).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
    AmountFeeBO oneTimeFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("25.0").withName("Center UpfrontFee").oneTime().build();
    IntegrationTestObjectMother.saveFee(oneTimeFeeForCenterOnly);
    // Declare a one-day moratorium on the first meeting day
    saveHoliday(tomorrow, tomorrow, RepaymentRuleTypes.REPAYMENT_MORATORIUM);
    CenterBO center = new CenterBuilder().with(weeklyMeeting).withName("Center-IntegrationTest").with(sampleBranchOffice()).withLoanOfficer(testUser()).withUserContext().active().withActivationDate(tomorrow).build();
    // exercise test
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting, weeklyPeriodicFeeForCenterOnly, oneTimeFeeForCenterOnly);
    // verification
    StaticHibernateUtil.flushAndClearSession();
    validateDates(center.getGlobalCustNum(), today.plusWeeks(1), today.plusWeeks(2), today.plusWeeks(3), today.plusWeeks(4), today.plusWeeks(5), today.plusWeeks(6), today.plusWeeks(7), today.plusWeeks(8), today.plusWeeks(9), today.plusWeeks(10));
    validateOnePeriodicFeeAndOneOneTimeFee(center.getGlobalCustNum(), "Center Weekly Periodic Fee", "Center UpfrontFee", 25.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0);
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 19 with FeeBuilder

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithMultipleInstancesOfTheSameOneTimeFee.

@Test
public void canCreateCenterWithMultipleInstancesOfTheSameOneTimeFee() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    String centerName = "Center-IntegrationTest";
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    // setup
    AmountFeeBO existingWeeklyFee = new FeeBuilder().oneTime().with(aWeeklyMeeting).appliesToCenterOnly().with(anExistingBranch).build();
    IntegrationTestObjectMother.saveFee(existingWeeklyFee);
    AccountFeesEntity accountFee = new AccountFeesEntity(null, existingWeeklyFee, existingWeeklyFee.getFeeAmount().getAmountDoubleValue());
    List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
    centerAccountFees.add(accountFee);
    centerAccountFees.add(accountFee);
    // exercise test
    customerService.createCenter(center, center.getCustomerMeetingValue(), centerAccountFees);
    // verification
    assertThat(center.getCustomerId(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(notNullValue()));
    assertThat(center.getCustomerAccount().getAccountFees().isEmpty(), is(false));
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) 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 20 with FeeBuilder

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

the class CenterScheduleCreationUsingCustomerServiceIntegrationTest method createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeNoHoliday.

/***********************************************
     * Weekly meeting, with fees
     ***********************************************/
@Test
public void createCenterScheduleWithWeeklyMeetingWithOnePeriodicFeeNoHoliday() throws Exception {
    DateTime startDate = date(2010, 4, 5);
    //Monday
    DateTimeUtils.setCurrentMillisFixed(startDate.getMillis());
    // setup
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    MeetingBuilder weeklyMeetingForFees = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).startingToday();
    AmountFeeBO weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").with(weeklyMeetingForFees).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
    CenterBO center = new CenterBuilder().with(weeklyMeeting).withName("Center-IntegrationTest").with(sampleBranchOffice()).withLoanOfficer(testUser()).withUserContext().build();
    // exercise test
    IntegrationTestObjectMother.createCenter(center, weeklyMeeting, weeklyPeriodicFeeForCenterOnly);
    // verification
    StaticHibernateUtil.flushAndClearSession();
    validateDates(center.getGlobalCustNum(), startDate, startDate.plusWeeks(1), startDate.plusWeeks(2), startDate.plusWeeks(3), startDate.plusWeeks(4), startDate.plusWeeks(5), startDate.plusWeeks(6), startDate.plusWeeks(7), startDate.plusWeeks(8), startDate.plusWeeks(9));
    validateOnePeriodicFee(center.getGlobalCustNum(), "Center Weekly Periodic Fee", 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0);
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Aggregations

FeeBuilder (org.mifos.domain.builders.FeeBuilder)20 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)20 CenterBuilder (org.mifos.domain.builders.CenterBuilder)18 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)13 DateTime (org.joda.time.DateTime)12 Test (org.junit.Test)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 CenterBO (org.mifos.customers.center.business.CenterBO)8 ArrayList (java.util.ArrayList)7 Before (org.junit.Before)6 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)6 ClientBuilder (org.mifos.domain.builders.ClientBuilder)5 GroupBuilder (org.mifos.domain.builders.GroupBuilder)5 LocalDate (org.joda.time.LocalDate)3 BigDecimal (java.math.BigDecimal)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 RecurringSchedule (org.mifos.clientportfolio.loan.service.RecurringSchedule)2 CreateLoanAccount (org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount)2 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)2 OfficeBO (org.mifos.customers.office.business.OfficeBO)2