Search in sources :

Example 86 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO 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)

Example 87 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LoanArrearsAgingHelperIntegrationTest method testLoanWithOneOverduePayment.

// create a weekly 10 week loan of 100 with flat 100% interest (total interest is 20 or 2 each week)
// advance the date by ten days, run the batch job
// one weeks payment should be in arrears
@Ignore
@Test
public void testLoanWithOneOverduePayment() throws Exception {
    LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    LoanArrearsAgingEntity loanArrearsAgingEntity = ageLoanTenDaysAndGetLoanArrearsAgingEntity(loan);
    Assert.assertEquals(new Money(getCurrency(), "" + loanAmount), loanArrearsAgingEntity.getUnpaidPrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + totalInterest), 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("3"), loanArrearsAgingEntity.getDaysInArrears());
    assertForLoanArrearsAgingEntity(loan);
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanArrearsAgingEntity(org.mifos.accounts.loan.business.LoanArrearsAgingEntity) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 88 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LoanArrearsHelperIntegrationTest method setDisbursementDateAsOldDate.

private void setDisbursementDateAsOldDate(AccountBO account) {
    Date startDate = offSetCurrentDate(15);
    LoanBO loan = (LoanBO) account;
    LoanBOTestUtils.modifyDisbursementDate(loan, startDate);
    for (AccountActionDateEntity actionDate : loan.getAccountActionDates()) {
        LoanBOTestUtils.setActionDate(actionDate, offSetGivenDate(actionDate.getActionDate(), 18));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.sql.Date)

Example 89 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LoanArrearsTaskIntegrationTest method setDisbursementDateAsOldDate.

private void setDisbursementDateAsOldDate(AccountBO account) {
    Date startDate = offSetCurrentDate(15);
    LoanBO loan = (LoanBO) account;
    LoanBOTestUtils.modifyDisbursementDate(loan, startDate);
    for (AccountActionDateEntity actionDate : loan.getAccountActionDates()) {
        LoanBOTestUtils.setActionDate(actionDate, offSetGivenDate(actionDate.getActionDate(), 18));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.sql.Date)

Example 90 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class TestObjectFactory method deleteSpecificAccount.

private static void deleteSpecificAccount(final AccountBO account, final Session session) {
    if (account instanceof LoanBO) {
        LoanBO loan = (LoanBO) account;
        if (null != loan.getLoanSummary()) {
            session.delete(loan.getLoanSummary());
        }
        session.delete(account);
        loan.getLoanOffering().getLoanOfferingMeeting().setMeeting(null);
        session.delete(loan.getLoanOffering().getLoanOfferingMeeting());
        session.delete(loan.getLoanOffering());
    }
    if (account instanceof SavingsBO) {
        SavingsBO savings = (SavingsBO) account;
        session.delete(account);
        // FIXME - no longer create a meeting to track intereswt calculation for each savings account, instead we always use value from savigns product.
        //            session.delete(savings.getTimePerForInstcalc());
        PrdOfferingMeetingEntity prdOfferingMeeting1 = savings.getSavingsOffering().getTimePerForInstcalc();
        prdOfferingMeeting1.setMeeting(null);
        session.delete(prdOfferingMeeting1);
        PrdOfferingMeetingEntity prdOfferingMeeting2 = savings.getSavingsOffering().getFreqOfPostIntcalc();
        prdOfferingMeeting2.setMeeting(null);
        session.delete(prdOfferingMeeting2);
        session.delete(savings.getSavingsOffering());
    } else {
        session.delete(account);
    }
}
Also used : PrdOfferingMeetingEntity(org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Aggregations

LoanBO (org.mifos.accounts.loan.business.LoanBO)215 ArrayList (java.util.ArrayList)76 Test (org.junit.Test)62 Money (org.mifos.framework.util.helpers.Money)60 UserContext (org.mifos.security.util.UserContext)45 MifosRuntimeException (org.mifos.core.MifosRuntimeException)42 Date (java.util.Date)37 AccountException (org.mifos.accounts.exceptions.AccountException)35 AccountBO (org.mifos.accounts.business.AccountBO)34 MifosUser (org.mifos.security.MifosUser)33 BigDecimal (java.math.BigDecimal)30 HashMap (java.util.HashMap)28 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)26 LocalDate (org.joda.time.LocalDate)23 PaymentData (org.mifos.accounts.util.helpers.PaymentData)22 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)22 PersistenceException (org.mifos.framework.exceptions.PersistenceException)21 ServiceException (org.mifos.framework.exceptions.ServiceException)19 BusinessRuleException (org.mifos.service.BusinessRuleException)19 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)18