use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountCreationTest method givenMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.
@Test
public void givenMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
// setup
applicableCalendarEvents = new CalendarEventBuilder().build();
DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
accountFees = new ArrayList<AccountFeesEntity>();
MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(1).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().monthly().every(1).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
// exercise test
CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
// verification
List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
assertThat(firstGroupDate, is(firstCenterDate));
assertThat(secondGroupDate, is(secondCenterDate));
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountCreationTest method customerSchedulesAreCreatedFromCustomersActivationDate.
@Test
public void customerSchedulesAreCreatedFromCustomersActivationDate() throws Exception {
// setup
applicableCalendarEvents = new CalendarEventBuilder().build();
DateTime twoWeeksAgo = new DateTime().minusWeeks(2);
customerMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingFrom(twoWeeksAgo.toDate()).build();
accountFees = new ArrayList<AccountFeesEntity>();
customer = new CenterBuilder().active().withActivationDate(new DateMidnight().toDateTime()).build();
// exercise test
customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
// verification
assertThat(customerAccount.getAccountActionDates().isEmpty(), is(false));
List<AccountActionDateEntity> customerSchedules = new ArrayList<AccountActionDateEntity>(customerAccount.getAccountActionDates());
LocalDate activationDate = new LocalDate(CalendarUtils.nearestWorkingDay(new DateTime()));
assertThat(new LocalDate(customerSchedules.get(0).getActionDate()), is(activationDate));
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountCreationTest method givenBiMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.
@Test
public void givenBiMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
// setup
applicableCalendarEvents = new CalendarEventBuilder().build();
DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
accountFees = new ArrayList<AccountFeesEntity>();
MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
// exercise test
CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
// verification
List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
assertThat(firstGroupDate, is(firstCenterDate));
assertThat(secondGroupDate, is(secondCenterDate));
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountCreationTest method givenTriMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.
@Test
public void givenTriMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
// setup
applicableCalendarEvents = new CalendarEventBuilder().build();
DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
accountFees = new ArrayList<AccountFeesEntity>();
MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().monthly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
// exercise test
CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
// verification
List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
assertThat(firstGroupDate, is(firstCenterDate));
assertThat(secondGroupDate, is(secondCenterDate));
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testGenerateMeetingScheduleWhenFirstTwoMeeingDatesOfCenterIsPassed.
@Ignore
@Test
public void testGenerateMeetingScheduleWhenFirstTwoMeeingDatesOfCenterIsPassed() throws ApplicationException, SystemException {
MeetingBO meetingBO = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center_Active_test", meetingBO);
changeAllInstallmentDateToPreviousDate(center.getCustomerAccount(), 14);
center.update();
StaticHibernateUtil.flushAndClearSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
StaticHibernateUtil.flushAndClearSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
java.util.Date nextMeetingDate = center.getCustomerAccount().getNextMeetingDate();
group = TestObjectFactory.getGroup(group.getCustomerId());
for (AccountActionDateEntity actionDateEntity : group.getCustomerAccount().getAccountActionDates()) {
if (actionDateEntity.getInstallmentId().equals(Short.valueOf("1"))) {
Assert.assertEquals(DateUtils.getDateWithoutTimeStamp(actionDateEntity.getActionDate().getTime()), DateUtils.getDateWithoutTimeStamp(nextMeetingDate.getTime()));
}
}
}
Aggregations