Search in sources :

Example 86 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class CustomerAccountCreationTest method firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency.

@Test
public void firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
    LocalDate mon18thOfMay = new DateTime().withDate(2011, 5, 18).toLocalDate();
    assertThat(firstCenterDate, is(mon18thOfMay));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) DateTime(org.joda.time.DateTime) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 87 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class CustomerAccountCreationTest method customerAccountCanBeCreatedWithNoAccountFees.

@Test
public void customerAccountCanBeCreatedWithNoAccountFees() throws Exception {
    // setup
    accountFees = new ArrayList<AccountFeesEntity>();
    customer = new CenterBuilder().inActive().build();
    // exercise test
    customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
    // verification
    assertThat(customerAccount.getAccountFees().isEmpty(), is(true));
}
Also used : CenterBuilder(org.mifos.domain.builders.CenterBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 88 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class CustomerAccountCreationTest method customerAccountIsNotCreatedWithCustomerSchedulesWhenAssociatedCustomerIsNotActive.

@Test
public void customerAccountIsNotCreatedWithCustomerSchedulesWhenAssociatedCustomerIsNotActive() throws Exception {
    // setup
    accountFees = new ArrayList<AccountFeesEntity>();
    customer = new CenterBuilder().inActive().build();
    // exercise test
    customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
    // verification
    assertThat(customerAccount.getAccountActionDates().isEmpty(), is(true));
}
Also used : CenterBuilder(org.mifos.domain.builders.CenterBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 89 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class FeeInstallmentTest method createMergedFeeInstallmentsForOneFeeBothAccountAndFeeAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEvent.

@Test
public void createMergedFeeInstallmentsForOneFeeBothAccountAndFeeAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEvent() {
    ScheduledEvent masterEvent = new ScheduledEventBuilder().every(1).weeks().build();
    FeeBO feeBO = createWeeklyFeeBO(1);
    AccountFeesEntity accountFeesEntity = createAccountFeesEntity(feeBO, 10.0);
    List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallmentsForOneFee(masterEvent, accountFeesEntity, 3);
    assertThat(feeInstallments.size(), is(3));
    assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO);
    assertFeeInstallment(feeInstallments.get(1), 2, 10.0, feeBO);
    assertFeeInstallment(feeInstallments.get(2), 3, 10.0, feeBO);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 90 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class FeeInstallmentTest method createMergedFeeInstallmentsForOneFeeAccountScheduledEveryWeekFeeScheduledEveryOtherWeekShouldGetOneFeeInstallmentPerEveryOtherAccountEvent.

@Test
public void createMergedFeeInstallmentsForOneFeeAccountScheduledEveryWeekFeeScheduledEveryOtherWeekShouldGetOneFeeInstallmentPerEveryOtherAccountEvent() {
    ScheduledEvent accountEvent = new ScheduledEventBuilder().every(1).weeks().build();
    FeeBO feeBO = createWeeklyFeeBO(2);
    AccountFeesEntity accountFeesEntity = createAccountFeesEntity(feeBO, 10.0);
    List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallmentsForOneFee(accountEvent, accountFeesEntity, 4);
    assertThat(feeInstallments.size(), is(2));
    assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO);
    assertFeeInstallment(feeInstallments.get(1), 3, 10.0, feeBO);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Aggregations

AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)118 ArrayList (java.util.ArrayList)78 Test (org.junit.Test)65 CenterBuilder (org.mifos.domain.builders.CenterBuilder)46 DateTime (org.joda.time.DateTime)42 MeetingBO (org.mifos.application.meeting.business.MeetingBO)42 CenterBO (org.mifos.customers.center.business.CenterBO)39 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)38 FeeBO (org.mifos.accounts.fees.business.FeeBO)25 Money (org.mifos.framework.util.helpers.Money)25 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)24 UserContext (org.mifos.security.util.UserContext)22 LocalDate (org.joda.time.LocalDate)21 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)21 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)18 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)17 OfficeBO (org.mifos.customers.office.business.OfficeBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 MifosUser (org.mifos.security.MifosUser)16 AccountException (org.mifos.accounts.exceptions.AccountException)14