Search in sources :

Example 1 with CustomerScheduleEntity

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());
}
Also used : DateMidnight(org.joda.time.DateMidnight) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 2 with CustomerScheduleEntity

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());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Date(java.util.Date) Money(org.mifos.framework.util.helpers.Money) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 3 with CustomerScheduleEntity

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());
}
Also used : Money(org.mifos.framework.util.helpers.Money) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Test(org.junit.Test)

Example 4 with CustomerScheduleEntity

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));
        }
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) DateTime(org.joda.time.DateTime)

Example 5 with CustomerScheduleEntity

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())));
        }
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) DateMidnight(org.joda.time.DateMidnight) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime)

Aggregations

CustomerScheduleEntity (org.mifos.customers.business.CustomerScheduleEntity)18 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)8 Test (org.junit.Test)5 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)5 DateTime (org.joda.time.DateTime)4 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)4 Money (org.mifos.framework.util.helpers.Money)4 ArrayList (java.util.ArrayList)3 DateMidnight (org.joda.time.DateMidnight)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)3 Date (java.sql.Date)2 LocalDate (org.joda.time.LocalDate)2 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 CustomerTrxnDetailEntity (org.mifos.customers.business.CustomerTrxnDetailEntity)2 CenterBO (org.mifos.customers.center.business.CenterBO)2 Date (java.util.Date)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1