use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanArrearsAgingHelperIntegrationTest method testLoanWithOnePaymentMadeAndNoOverduePayments.
@Ignore
@Test
public void testLoanWithOnePaymentMadeAndNoOverduePayments() throws Exception {
LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_BAD_STANDING);
Assert.assertNull(loan.getLoanArrearsAgingEntity());
short daysPastPaymentDate = 3;
// advance time daysOverdue past the second repayment interval
dateTime = dateTime.plusDays(repaymentInterval + daysPastPaymentDate);
new DateTimeService().setCurrentDateTimeFixed(dateTime);
runLoanArrearsThenLoanArrearsAging();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNotNull(loan.getLoanArrearsAgingEntity());
// 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);
//jpwrunLoanArrearsThenLoanArrearsAging();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNull(loan.getLoanArrearsAgingEntity());
Assert.assertTrue(loan.getState().equals(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING));
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanArrearsAgingHelperIntegrationTest method testLoanWithEarlyRepaymentWithInterestWaiver.
@Ignore
@Test
public void testLoanWithEarlyRepaymentWithInterestWaiver() throws Exception {
LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
Assert.assertNull(loan.getLoanArrearsAgingEntity());
short daysPastPaymentDate = 3;
// advance time daysOverdue past the second repayment interval
dateTime = dateTime.plusDays(repaymentInterval + daysPastPaymentDate);
new DateTimeService().setCurrentDateTimeFixed(dateTime);
runLoanArrearsThenLoanArrearsAging();
StaticHibernateUtil.flushAndClearSession();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNotNull(loan.getLoanArrearsAgingEntity());
Money totalAmount = new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "" + loanAmount + 0);
String receiptNumber = "1";
loan.makeEarlyRepayment(null, loan.getPersonnel().getPersonnelId(), true, new Money(loan.getCurrency(), "0"));
//jpw runLoanArrearsThenLoanArrearsAging();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNull(loan.getLoanArrearsAgingEntity());
Assert.assertTrue(loan.getState().equals(AccountState.LOAN_CLOSED_OBLIGATIONS_MET));
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanArrearsAgingHelperIntegrationTest method initializeToFixedDateTime.
private DateTime initializeToFixedDateTime() {
DateTime dateTime = new DateTime(2009, 12, 7, 0, 0, 0, 0);
DateTimeService dateTimeService = new DateTimeService();
dateTimeService.setCurrentDateTimeFixed(dateTime);
return dateTime;
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanArrearsAgingHelperIntegrationTest method testLoanWithEarlyRepayment.
@Ignore
@Test
public void testLoanWithEarlyRepayment() throws Exception {
LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_BAD_STANDING);
Assert.assertNull(loan.getLoanArrearsAgingEntity());
short daysPastPaymentDate = 3;
// advance time daysOverdue past the second repayment interval
dateTime = dateTime.plusDays(repaymentInterval + daysPastPaymentDate);
new DateTimeService().setCurrentDateTimeFixed(dateTime);
runLoanArrearsThenLoanArrearsAging();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNotNull(loan.getLoanArrearsAgingEntity());
Money totalAmount = new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "" + loanAmount + totalInterest);
String receiptNumber = "1";
loan.makeEarlyRepayment(null, loan.getPersonnel().getPersonnelId(), false, new Money(loan.getCurrency(), "0"));
//jpw runLoanArrearsThenLoanArrearsAging();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNull(loan.getLoanArrearsAgingEntity());
Assert.assertTrue(loan.getState().equals(AccountState.LOAN_CLOSED_OBLIGATIONS_MET));
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanArrearsAgingHelperIntegrationTest method testLoanWithOnePartialPayment.
/**
* unsure why its failing.
*/
@Ignore
@Test
public void testLoanWithOnePartialPayment() throws Exception {
LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
Assert.assertNull(loan.getLoanArrearsAgingEntity());
short daysOverdue = 3;
dateTime = dateTime.plusDays(repaymentInterval + daysOverdue);
new DateTimeService().setCurrentDateTimeFixed(dateTime);
// make one payment of 8. Interest is paid off first, so 2 goes to interest and 6 to principal
int principalPayment = 6;
int interestPayment = 2;
// paymentAmount == 8
int paymentAmount = interestPayment + principalPayment;
PaymentData paymentData = PaymentData.createPaymentData(new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "" + paymentAmount), 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 - principalPayment)), loanArrearsAgingEntity.getUnpaidPrincipal());
Assert.assertEquals(new Money(getCurrency(), "" + (totalInterest - interestPayment)), loanArrearsAgingEntity.getUnpaidInterest());
Assert.assertEquals(new Money(getCurrency(), "" + (principalForOneInstallment - principalPayment)), loanArrearsAgingEntity.getOverduePrincipal());
Assert.assertEquals(new Money(getCurrency(), "0"), loanArrearsAgingEntity.getOverdueInterest());
Assert.assertEquals(new Money(getCurrency(), "" + (principalForOneInstallment - principalPayment)), loanArrearsAgingEntity.getOverdueBalance());
Assert.assertEquals(Short.valueOf(daysOverdue), loanArrearsAgingEntity.getDaysInArrears());
}
Aggregations