Search in sources :

Example 81 with LoanBO

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

the class LoanArrearsAgingHelperIntegrationTest method testLoanWithTwoOverduePayments.

@Test
public void testLoanWithTwoOverduePayments() throws Exception {
    LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    int daysOverdue = 10;
    LoanArrearsAgingEntity loanArrearsAgingEntity = ageLoanAndGetLoanArrearsAgingEntity(loan, repaymentInterval + daysOverdue);
    Assert.assertEquals(new Money(getCurrency(), "" + loanAmount), loanArrearsAgingEntity.getUnpaidPrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + totalInterest), loanArrearsAgingEntity.getUnpaidInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + 2 * principalForOneInstallment), loanArrearsAgingEntity.getOverduePrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + 2 * interestForOneInstallment), loanArrearsAgingEntity.getOverdueInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + (2 * (principalForOneInstallment + interestForOneInstallment))), loanArrearsAgingEntity.getOverdueBalance());
    Assert.assertEquals(daysOverdue, loanArrearsAgingEntity.getDaysInArrears().intValue());
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanArrearsAgingEntity(org.mifos.accounts.loan.business.LoanArrearsAgingEntity) Test(org.junit.Test)

Example 82 with LoanBO

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

the class LoanAccountBuilder method build.

public LoanBO build() {
    BigDecimal amount = BigDecimal.valueOf(orgininalLoanAmount);
    Money loanAmount = new Money(Money.getDefaultCurrency(), amount);
    BigDecimal balance = BigDecimal.valueOf(remainingLoanBalance);
    Money loanBalance = new Money(Money.getDefaultCurrency(), balance);
    final LoanBO loanAccount = new LoanBO(loanProduct, numOfInstallments, gracePeriodType, accountType, accountState, customer, offsettingAllowable, loanAmount, loanBalance);
    loanAccount.setUserContext(TestUtils.makeUser());
    loanAccount.setCreateDetails();
    return loanAccount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) BigDecimal(java.math.BigDecimal)

Example 83 with LoanBO

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

the class LoanArrearsAgingHelperIntegrationTest method setUpLoan.

private LoanBO setUpLoan(DateTime dateTime, AccountState accountState) {
    Date startDate = dateTime.toDate();
    meeting = getNewMeeting(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING, WeekDay.MONDAY, startDate);
    center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO product = TestObjectFactory.createLoanOffering("LoanProduct", "LP", startDate, meeting);
    LoanBO loan = createBasicLoanAccount(group, accountState, product, "" + loanAmount, numInstallments, interestRate);
    return loan;
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 84 with LoanBO

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

the class LoanArrearsAgingHelperIntegrationTest method testThatLoanInActiveInBadStandingStateDoesGenerateArrearsData.

@Test
public void testThatLoanInActiveInBadStandingStateDoesGenerateArrearsData() throws Exception {
    LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_BAD_STANDING);
    Assert.assertNotNull(ageLoanTenDaysAndGetLoanArrearsAgingEntity(loan));
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) Test(org.junit.Test)

Example 85 with LoanBO

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

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