use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class LegacyAccountDaoIntegrationTest method testGetCustomerSchedulesForAccountThatAreWithinDates.
@Test
public void testGetCustomerSchedulesForAccountThatAreWithinDates() throws Exception {
DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
DateTime thruDate = new DateMidnight().toDateTime().plusDays(23);
List<CustomerScheduleEntity> affectedDates = legacyAccountDao.getCustomerSchedulesForAccountThatAreWithinDates(center.getCustomerAccount().getAccountId(), fromDate, thruDate);
Assert.assertNotNull(affectedDates);
Assert.assertEquals(3, affectedDates.size());
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class AccountActionDateEntityIntegrationTest method testApplyPeriodicFees.
@Test
public void testApplyPeriodicFees() {
FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, Short.valueOf("1"));
AccountFeesEntity accountFeesEntity = new AccountFeesEntity(group.getCustomerAccount(), periodicFee, ((AmountFeeBO) periodicFee).getFeeAmount().getAmountDoubleValue(), null, null, new Date(System.currentTimeMillis()));
group.getCustomerAccount().addAccountFees(accountFeesEntity);
TestObjectFactory.updateObject(group);
StaticHibernateUtil.flushSession();
group = TestObjectFactory.getGroup(group.getCustomerId());
CustomerScheduleEntity accountActionDateEntity = (CustomerScheduleEntity) group.getCustomerAccount().getAccountActionDates().toArray()[0];
Set<AccountFeesActionDetailEntity> feeDetailsSet = accountActionDateEntity.getAccountFeesActionDetails();
List<Integer> feeList = new ArrayList<Integer>();
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : feeDetailsSet) {
feeList.add(accountFeesActionDetailEntity.getAccountFeesActionDetailId());
}
Set<AccountFeesEntity> accountFeeSet = group.getCustomerAccount().getAccountFees();
for (AccountFeesEntity accFeesEntity : accountFeeSet) {
if (accFeesEntity.getFees().getFeeName().equalsIgnoreCase("Periodic Fee")) {
CustomerAccountBOTestUtils.applyPeriodicFees(accountActionDateEntity, accFeesEntity.getFees().getFeeId(), new Money(getCurrency(), "100"));
break;
}
}
TestObjectFactory.updateObject(group);
StaticHibernateUtil.flushSession();
group = TestObjectFactory.getGroup(group.getCustomerId());
CustomerScheduleEntity firstInstallment = (CustomerScheduleEntity) group.getCustomerAccount().getAccountActionDates().toArray()[0];
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : firstInstallment.getAccountFeesActionDetails()) {
if (!feeList.contains(accountFeesActionDetailEntity.getAccountFeesActionDetailId())) {
Assert.assertEquals("Periodic Fee", accountFeesActionDetailEntity.getFee().getFeeName());
break;
}
}
StaticHibernateUtil.flushSession();
groupLoan = TestObjectFactory.getObject(LoanBO.class, groupLoan.getAccountId());
group = TestObjectFactory.getGroup(group.getCustomerId());
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class AccountActionDateEntityIntegrationTest method testWaiveCharges.
@Test
public void testWaiveCharges() {
StaticHibernateUtil.flushSession();
group = TestObjectFactory.getGroup(group.getCustomerId());
CustomerScheduleEntity accountActionDate = (CustomerScheduleEntity) group.getCustomerAccount().getAccountActionDates().toArray()[0];
CustomerAccountBOTestUtils.setMiscFee(accountActionDate, new Money(getCurrency(), "20"));
Money chargeWaived = CustomerAccountBOTestUtils.waiveCharges(accountActionDate);
Assert.assertEquals(new Money(getCurrency()), accountActionDate.getMiscFee());
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountActionDate.getAccountFeesActionDetails()) {
Assert.assertEquals(new Money(getCurrency()), accountFeesActionDetailEntity.getFeeAmount());
}
Assert.assertEquals(new Money(getCurrency(), "120.0"), chargeWaived);
StaticHibernateUtil.flushSession();
group = TestObjectFactory.getGroup(group.getCustomerId());
center = TestObjectFactory.getCenter(center.getCustomerId());
groupLoan = TestObjectFactory.getObject(LoanBO.class, groupLoan.getAccountId());
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class ApplyCustomerFeeChangesBatchJobIntegrationTest method assertThatFutureScheduleHasFeesDueOf.
private void assertThatFutureScheduleHasFeesDueOf(Set<AccountActionDateEntity> customerSchedules, double feesDue) {
for (AccountActionDateEntity accountActionDateEntity : customerSchedules) {
CustomerScheduleEntity customerSchedule = (CustomerScheduleEntity) center.getCustomerAccount().getAccountActionDate(accountActionDateEntity.getInstallmentId());
DateTime scheduledDate = new DateTime(customerSchedule.getActionDate());
if (scheduledDate.isAfter(new DateTime().minusDays(1))) {
assertThat(customerSchedule.getTotalFees().getAmountDoubleValue(), is(feesDue));
}
}
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class TestUtils method assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged.
public static void assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(CustomerBO customer, WeekDay expectedDayOfWeek) {
Set<AccountActionDateEntity> customerSchedules = customer.getCustomerAccount().getAccountActionDates();
for (AccountActionDateEntity accountActionDateEntity : customerSchedules) {
CustomerScheduleEntity customerSchedule = (CustomerScheduleEntity) accountActionDateEntity;
LocalDate scheduledDate = new LocalDate(customerSchedule.getActionDate());
DateTime endOfCurrentInstallmentPeriod = TestUtils.nearestDateMatchingPeriodStartingOn(new DateMidnight().toDateTime(), customer.getCustomerMeetingValue());
LocalDate endOfCurrentInstallmentPeriodLocalDate = new LocalDate(endOfCurrentInstallmentPeriod);
if (scheduledDate.isBefore(endOfCurrentInstallmentPeriodLocalDate)) {
assertThat(scheduledDate.dayOfWeek().get(), is(WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(expectedDayOfWeek.getValue())));
}
}
}
Aggregations