Search in sources :

Example 1 with LegacyLoanDao

use of org.mifos.accounts.loan.persistance.LegacyLoanDao in project head by mifos.

the class LoanScheduleEntity method updateSummaryAndPerformanceHistory.

public LoanTrxnDetailEntity updateSummaryAndPerformanceHistory(AccountPaymentEntity accountPayment, PersonnelBO personnel, Date transactionDate) {
    LoanBO loanBO = (LoanBO) account;
    LegacyLoanDao legacyLoanDao = loanBO.getlegacyLoanDao();
    LoanTrxnDetailEntity loanTrxnDetailEntity = recordTransaction(accountPayment, personnel, transactionDate, legacyLoanDao);
    loanBO.recordSummaryAndPerfHistory(isPaid(), paymentAllocation);
    return loanTrxnDetailEntity;
}
Also used : LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao)

Example 2 with LegacyLoanDao

use of org.mifos.accounts.loan.persistance.LegacyLoanDao in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testFindIndividualLoans.

@Test
public void testFindIndividualLoans() throws Exception {
    LegacyLoanDao loanPersistance = legacyLoanDao;
    List<LoanBO> listLoanBO = loanPersistance.findIndividualLoans(loanAccount.getAccountId().toString());
    Assert.assertEquals(0, listLoanBO.size());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) Test(org.junit.Test)

Example 3 with LegacyLoanDao

use of org.mifos.accounts.loan.persistance.LegacyLoanDao in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testFindBySystemId.

@Test
public void testFindBySystemId() throws Exception {
    LegacyLoanDao loanPersistance = legacyLoanDao;
    LoanBO loanBO = loanPersistance.findBySystemId(loanAccount.getGlobalAccountNum());
    Assert.assertEquals(loanAccount.getGlobalAccountNum(), loanBO.getGlobalAccountNum());
    Assert.assertEquals(loanAccount.getAccountId(), loanBO.getAccountId());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) Test(org.junit.Test)

Example 4 with LegacyLoanDao

use of org.mifos.accounts.loan.persistance.LegacyLoanDao in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testFindByExternalId.

@Test
public void testFindByExternalId() throws Exception {
    String externalId = "ABC";
    StaticHibernateUtil.startTransaction();
    loanAccount.setExternalId(externalId);
    StaticHibernateUtil.flushSession();
    LegacyLoanDao loanPersistance = legacyLoanDao;
    LoanBO loanBO = loanPersistance.findByExternalId(loanAccount.getExternalId());
    Assert.assertEquals(externalId, loanBO.getExternalId());
    Assert.assertEquals(loanAccount.getAccountId(), loanBO.getAccountId());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) Test(org.junit.Test)

Example 5 with LegacyLoanDao

use of org.mifos.accounts.loan.persistance.LegacyLoanDao in project head by mifos.

the class LoanBOTest method repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoans.

@Test
public void repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoans() throws PersistenceException {
    final LegacyLoanDao legacyLoanDao = mock(LegacyLoanDao.class);
    final CustomerBO customerBO = mock(CustomerBO.class);
    final LoanSummaryEntity loanSummaryEntity = mock(LoanSummaryEntity.class);
    LoanBO loanBO = new LoanBO() {

        @Override
        public boolean isDecliningBalanceInterestRecalculation() {
            return true;
        }

        @Override
        public LegacyLoanDao getlegacyLoanDao() {
            return legacyLoanDao;
        }

        @Override
        public CustomerBO getCustomer() {
            return customerBO;
        }

        @Override
        public LoanSummaryEntity getLoanSummary() {
            return loanSummaryEntity;
        }
    };
    AccountActionTypes accountActionTypes = AccountActionTypes.LOAN_REPAYMENT;
    AccountActionEntity accountActionEntity = mock(AccountActionEntity.class);
    AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntityBuilder().with(loanBO).build();
    PersonnelBO user = new PersonnelBO();
    Money extraInterestDue = new Money(rupee, "0.98");
    Money interest = new Money(rupee, "10");
    Money interestDue = new Money(rupee, "2.07");
    when(legacyLoanDao.getPersistentObject(AccountActionEntity.class, accountActionTypes.getValue())).thenReturn(accountActionEntity);
    when(loanScheduleEntity.getPrincipalDue()).thenReturn(new Money(rupee, "1000"));
    when(loanScheduleEntity.getTotalFeeDueWithMiscFeeDue()).thenReturn(new Money(rupee, "10"));
    when(loanScheduleEntity.getPenaltyDue()).thenReturn(new Money(rupee, "10"));
    when(loanScheduleEntity.getPenalty()).thenReturn(new Money(rupee, "100"));
    when(loanScheduleEntity.getExtraInterestDue()).thenReturn(extraInterestDue);
    when(loanScheduleEntity.getExtraInterestPaid()).thenReturn(extraInterestDue);
    when(loanScheduleEntity.getInterest()).thenReturn(interest);
    when(loanScheduleEntity.getInterestDue()).thenReturn(interestDue);
    loanBO.repayInstallment(loanScheduleEntity, accountPaymentEntity, accountActionTypes, user, "", interestDue);
    Set<AccountTrxnEntity> accountTrxns = accountPaymentEntity.getAccountTrxns();
    AccountTrxnEntity accountTrxnEntity = accountTrxns.toArray(new AccountTrxnEntity[accountTrxns.size()])[0];
    LoanTrxnDetailEntity loanTrxnDetailEntity = (LoanTrxnDetailEntity) accountTrxnEntity;
    assertThat(loanTrxnDetailEntity.getInterestAmount().getAmount().doubleValue(), is(3.05));
    CalculatedInterestOnPayment calculatedInterestOnPayment = loanTrxnDetailEntity.getCalculatedInterestOnPayment();
    assertNotNull(calculatedInterestOnPayment);
    assertThat(calculatedInterestOnPayment.getExtraInterestPaid(), is(extraInterestDue));
    assertThat(calculatedInterestOnPayment.getInterestDueTillPaid(), is(interestDue));
    assertThat(calculatedInterestOnPayment.getOriginalInterest(), is(interest));
    Mockito.verify(loanScheduleEntity).makeEarlyRepaymentEntries(LoanConstants.PAY_FEES_PENALTY_INTEREST, interestDue, accountPaymentEntity.getPaymentDate());
}
Also used : AccountPaymentEntityBuilder(org.mifos.accounts.business.AccountPaymentEntityBuilder) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) AccountActionTypes(org.mifos.accounts.util.helpers.AccountActionTypes) Money(org.mifos.framework.util.helpers.Money) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerBO(org.mifos.customers.business.CustomerBO) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) Test(org.junit.Test)

Aggregations

LegacyLoanDao (org.mifos.accounts.loan.persistance.LegacyLoanDao)6 Test (org.junit.Test)5 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 AccountActionEntity (org.mifos.accounts.business.AccountActionEntity)2 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)2 AccountPaymentEntityBuilder (org.mifos.accounts.business.AccountPaymentEntityBuilder)2 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)2 AccountActionTypes (org.mifos.accounts.util.helpers.AccountActionTypes)2 CustomerBO (org.mifos.customers.business.CustomerBO)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 Money (org.mifos.framework.util.helpers.Money)2