use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanAdjustmentsIntegrationTest method testWhenARepaymentIsAdjustedItGoesBackToBadStandingIfNecessary.
@Test
public void testWhenARepaymentIsAdjustedItGoesBackToBadStandingIfNecessary() throws Exception {
// relates to mifos-3479
new DateTimeService().setCurrentDateTimeFixed(date(2010, 10, 13));
loan = createLoan();
loan.updateDetails(TestUtils.makeUserWithLocales());
// pay 2 installments
makePayment(loan, "222.0");
loan.updateDetails(TestUtils.makeUserWithLocales());
// pay 1 more installment
makePayment(loan, "111.0");
loan.updateDetails(TestUtils.makeUserWithLocales());
// Ensure that after the adjustment the loan is calculated to be in bad standing.
new DateTimeService().setCurrentDateTimeFixed(date(2010, 11, 13));
adjustLastLoanPayment(loan);
loan.updateDetails(TestUtils.makeUserWithLocales());
assertNotNull("Account Status Change History Should Not Be Null", loan.getAccountStatusChangeHistory());
Integer listSize = loan.getAccountStatusChangeHistory().size();
assertFalse(listSize == 0);
// check if the last entry has an oldstatus LOAN_ACTIVE_IN_GOOD_STANDING and a new status of
// LOAN_ACTIVE_IN_BAD_STANDING
AccountStateEntity oldStatus = loan.getAccountStatusChangeHistory().get(listSize - 1).getOldStatus();
AccountStateEntity newStatus = loan.getAccountStatusChangeHistory().get(listSize - 1).getNewStatus();
assertTrue("Old Status Should Have Been LOAN_ACTIVE_IN_GOOD_STANDING", oldStatus.isInState(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING));
assertTrue("New Status Should Have Been LOAN_ACTIVE_IN_BAD_STANDING", newStatus.isInState(AccountState.LOAN_ACTIVE_IN_BAD_STANDING));
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanAdjustmentsIntegrationTest method makeEarlyPayment.
private void makeEarlyPayment(LoanBO loan) throws AccountException {
loan.makeEarlyRepayment(new AccountPaymentDto(loan.getEarlyRepayAmount().getAmount().doubleValue(), new DateTimeService().getCurrentJavaDateTime(), "", null, (short) 1), testUser().getPersonnelId(), false, new Money(loan.getCurrency(), "0"));
StaticHibernateUtil.flushSession();
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanAdjustmentsIntegrationTest method testWhenALoanIsRepaidEarlyAndThenAdjustedThatTheLoanSummaryAndSchedulesDetailsAreTheSameBeforeAndAfter.
/**
* not sure why this is failing now.
*/
@Ignore
@Test
public void testWhenALoanIsRepaidEarlyAndThenAdjustedThatTheLoanSummaryAndSchedulesDetailsAreTheSameBeforeAndAfter() throws Exception {
// relates to mifos-1986
new DateTimeService().setCurrentDateTimeFixed(date(2010, 10, 13));
loan = createLoan();
Money initialOriginalPrincipal = loan.getLoanSummary().getOriginalPrincipal();
Money initialOriginalInterest = loan.getLoanSummary().getOriginalInterest();
Money initialOriginalFees = loan.getLoanSummary().getOriginalFees();
Money initialPrincipalPaid = loan.getLoanSummary().getPrincipalPaid();
Money initialInterestPaid = loan.getLoanSummary().getInterestPaid();
Money initialFeesPaid = loan.getLoanSummary().getFeesPaid();
// pay 3 installments
makePayment(loan, "333.0");
StaticHibernateUtil.flushAndClearSession();
loan = (LoanBO) legacyAccountDao.getAccount(loan.getAccountId());
loan.updateDetails(TestUtils.makeUserWithLocales());
assertThat(loan.getLoanSummary().getOriginalPrincipal(), is(initialOriginalPrincipal));
assertThat(loan.getLoanSummary().getOriginalInterest(), is(initialOriginalInterest));
assertThat(loan.getLoanSummary().getOriginalFees(), is(initialOriginalFees));
assertFalse(loan.getLoanSummary().getPrincipalPaid().equals(initialPrincipalPaid));
assertFalse(loan.getLoanSummary().getInterestPaid().equals(initialInterestPaid));
assertFalse(loan.getLoanSummary().getFeesPaid().equals(initialFeesPaid));
List<LoanInstallment> copySchedule = copyLoanSchedule(loan);
makeEarlyPayment(loan);
StaticHibernateUtil.flushAndClearSession();
loan = (LoanBO) legacyAccountDao.getAccount(loan.getAccountId());
loan.updateDetails(TestUtils.makeUserWithLocales());
// The early repayment should have caused the original interest and fees to be changed to equal the amounts
// paid.
assertThat(loan.getLoanSummary().getOriginalPrincipal(), is(initialOriginalPrincipal));
assertFalse(loan.getLoanSummary().getOriginalInterest().equals(initialOriginalInterest));
assertFalse(loan.getLoanSummary().getOriginalFees().equals(initialOriginalFees));
assertThat(loan.getLoanSummary().getPrincipalPaid(), is(loan.getLoanSummary().getOriginalPrincipal()));
assertThat(loan.getLoanSummary().getInterestPaid(), is(loan.getLoanSummary().getOriginalInterest()));
assertThat(loan.getLoanSummary().getFeesPaid(), is(loan.getLoanSummary().getOriginalFees()));
assertFalse(sameSchedule(copySchedule, loan.getAccountActionDates()));
adjustLastLoanPayment(loan);
StaticHibernateUtil.flushAndClearSession();
loan = (LoanBO) legacyAccountDao.getAccount(loan.getAccountId());
loan.updateDetails(TestUtils.makeUserWithLocales());
// The adjustment of a completed loan should have caused the original amounts to be reset
assertThat(loan.getLoanSummary().getOriginalPrincipal(), is(initialOriginalPrincipal));
assertThat(loan.getLoanSummary().getOriginalInterest(), is(initialOriginalInterest));
assertThat(loan.getLoanSummary().getOriginalFees(), is(initialOriginalFees));
assertTrue(sameSchedule(copySchedule, loan.getAccountActionDates()));
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class ClientLoanDisbursalTest method logOut.
@AfterMethod(alwaysRun = true)
public void logOut() {
new DateTimeService().resetToCurrentSystemDateTime();
(new MifosPage(selenium)).logout();
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CollectionSheetServiceImplIntegrationTest method initializeToFixedDateTime.
private DateTime initializeToFixedDateTime(Date date) {
LocalDate localDate = DateUtils.getLocalDateFromDate(date).plusDays(3);
DateTime dateTime = new DateTime(localDate.getYear(), localDate.getMonthOfYear(), localDate.getDayOfMonth(), 0, 0, 0, 0);
DateTimeService dateTimeService = new DateTimeService();
dateTimeService.setCurrentDateTimeFixed(dateTime);
return dateTime;
}
Aggregations