Search in sources :

Example 26 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class ClientBoTest method testGetClientAttendanceForMeeting.

@Test
public void testGetClientAttendanceForMeeting() {
    DateTime meetingDate = new DateTimeService().getCurrentDateTime();
    client.addClientAttendance(buildClientAttendance(meetingDate.toDate()));
    Assert.assertEquals("The value of customer attendance for the meeting : ", AttendanceType.PRESENT, client.getClientAttendanceForMeeting(meetingDate.toDate()).getAttendanceAsEnum());
}
Also used : DateTimeService(org.mifos.framework.util.DateTimeService) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 27 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class ClientBoTest method testHandleAttendance.

@Test
public void testHandleAttendance() throws Exception {
    DateTime meetingDate = new DateTimeService().getCurrentDateTime();
    client.handleAttendance(meetingDate.toDate(), AttendanceType.PRESENT.getValue(), false);
    Assert.assertEquals("The size of customer attendance is : ", client.getClientAttendances().size(), 1);
    Assert.assertEquals("The value of customer attendance for the meeting : ", AttendanceType.PRESENT, client.getClientAttendanceForMeeting(meetingDate.toDate()).getAttendanceAsEnum());
    client.handleAttendance(meetingDate.toDate(), AttendanceType.ABSENT.getValue(), false);
    Assert.assertEquals("The size of customer attendance is : ", 1, client.getClientAttendances().size());
    Assert.assertEquals("The value of customer attendance for the meeting : ", AttendanceType.ABSENT, client.getClientAttendanceForMeeting(meetingDate.toDate()).getAttendanceAsEnum());
}
Also used : DateTimeService(org.mifos.framework.util.DateTimeService) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 28 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class ClientBoTest method testHandleAttendanceForDifferentDates.

@Test
public void testHandleAttendanceForDifferentDates() throws Exception {
    DateTime meetingDate = new DateTimeService().getCurrentDateTime();
    client.handleAttendance(meetingDate.toDate(), AttendanceType.PRESENT.getValue(), false);
    Assert.assertEquals("The size of customer attendance is : ", client.getClientAttendances().size(), 1);
    Assert.assertEquals("The value of customer attendance for the meeting : ", AttendanceType.PRESENT, client.getClientAttendanceForMeeting(meetingDate.toDate()).getAttendanceAsEnum());
    DateMidnight offSetDate = getDateOffset(1);
    client.handleAttendance(new java.sql.Date(offSetDate.getMillis()), AttendanceType.ABSENT.getValue(), false);
    Assert.assertEquals("The size of customer attendance is : ", client.getClientAttendances().size(), 2);
    Assert.assertEquals("The value of customer attendance for the meeting : ", AttendanceType.PRESENT, client.getClientAttendanceForMeeting(meetingDate.toDate()).getAttendanceAsEnum());
    Assert.assertEquals("The value of customer attendance for the meeting : ", AttendanceType.ABSENT, client.getClientAttendanceForMeeting(offSetDate.toDate()).getAttendanceAsEnum());
}
Also used : DateMidnight(org.joda.time.DateMidnight) DateTimeService(org.mifos.framework.util.DateTimeService) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 29 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class LoanArrearsAgingHelperIntegrationTest method ageLoanAndGetLoanArrearsAgingEntity.

private LoanArrearsAgingEntity ageLoanAndGetLoanArrearsAgingEntity(LoanBO loan, int daysToAgeLoan) throws BatchJobException, PersistenceException {
    Assert.assertNull(loan.getLoanArrearsAgingEntity());
    new DateTimeService().setCurrentDateTimeFixed(dateTime.plusDays(daysToAgeLoan));
    runLoanArrearsThenLoanArrearsAging();
    StaticHibernateUtil.flushAndClearSession();
    LoanBO reloadedLoan = legacyLoanDao.getAccount(loan.getAccountId());
    return reloadedLoan.getLoanArrearsAgingEntity();
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) DateTimeService(org.mifos.framework.util.DateTimeService)

Example 30 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class LoanArrearsAgingHelperIntegrationTest method testLoanWithOnePaymentMadeAndOneOverduePayments.

/**
     * unsure why its failing.
     */
@Ignore
@Test
public void testLoanWithOnePaymentMadeAndOneOverduePayments() throws Exception {
    LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    Assert.assertNull(loan.getLoanArrearsAgingEntity());
    short daysOverdue = 3;
    // advance time daysOverdue past the second repayment interval
    dateTime = dateTime.plusDays(2 * repaymentInterval + daysOverdue);
    new DateTimeService().setCurrentDateTimeFixed(dateTime);
    // make one payment, so we should still be one payment behind after that
    PaymentData paymentData = PaymentData.createPaymentData(new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "" + onePayment), loan.getPersonnel(), Short.valueOf("1"), dateTime.toDate());
    IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
    runLoanArrearsThenLoanArrearsAging();
    StaticHibernateUtil.flushAndClearSession();
    loan = legacyLoanDao.getAccount(loan.getAccountId());
    Assert.assertNotNull(loan.getLoanArrearsAgingEntity());
    LoanArrearsAgingEntity loanArrearsAgingEntity = loan.getLoanArrearsAgingEntity();
    Assert.assertEquals(new Money(getCurrency(), "" + (loanAmount - principalForOneInstallment)), loanArrearsAgingEntity.getUnpaidPrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + (totalInterest - interestForOneInstallment)), loanArrearsAgingEntity.getUnpaidInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + principalForOneInstallment), loanArrearsAgingEntity.getOverduePrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + interestForOneInstallment), loanArrearsAgingEntity.getOverdueInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + (principalForOneInstallment + interestForOneInstallment)), loanArrearsAgingEntity.getOverdueBalance());
    Assert.assertEquals(Short.valueOf(daysOverdue), loanArrearsAgingEntity.getDaysInArrears());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanArrearsAgingEntity(org.mifos.accounts.loan.business.LoanArrearsAgingEntity) DateTimeService(org.mifos.framework.util.DateTimeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

DateTimeService (org.mifos.framework.util.DateTimeService)99 Test (org.junit.Test)24 Date (java.util.Date)21 Money (org.mifos.framework.util.helpers.Money)20 DateTime (org.joda.time.DateTime)19 PersistenceException (org.mifos.framework.exceptions.PersistenceException)19 MeetingBO (org.mifos.application.meeting.business.MeetingBO)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)16 LocalDate (org.joda.time.LocalDate)15 AccountException (org.mifos.accounts.exceptions.AccountException)14 LoanBO (org.mifos.accounts.loan.business.LoanBO)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)14 ArrayList (java.util.ArrayList)13 CustomerBO (org.mifos.customers.business.CustomerBO)10 CustomerException (org.mifos.customers.exceptions.CustomerException)10 UserContext (org.mifos.security.util.UserContext)10 BusinessRuleException (org.mifos.service.BusinessRuleException)9 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)8 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)8 ApplicationException (org.mifos.framework.exceptions.ApplicationException)8