Search in sources :

Example 6 with OriginalLoanScheduleEntity

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

the class LoanBusinessServiceTest method persistOriginalSchedule.

@Test
public void persistOriginalSchedule() throws PersistenceException {
    Set<LoanScheduleEntity> installments = new LinkedHashSet<LoanScheduleEntity>();
    MifosCurrency mifosCurrency = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
    Money money = new Money(mifosCurrency, "123");
    AccountBO accountBO = mock(AccountBO.class);
    CustomerBO customerBO = mock(CustomerBO.class);
    when(accountBO.getCurrency()).thenReturn(mifosCurrency);
    LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(accountBO, customerBO, new Short("1"), new java.sql.Date(new Date().getTime()), PaymentStatus.UNPAID, money, money);
    installments.add(loanScheduleEntity);
    when(loanBO.getLoanScheduleEntities()).thenReturn(installments);
    loanBusinessService.persistOriginalSchedule(loanBO);
    ArrayList<OriginalLoanScheduleEntity> expected = new ArrayList<OriginalLoanScheduleEntity>();
    expected.add(new OriginalLoanScheduleEntity(loanScheduleEntity));
    verify(legacyLoanDao).saveOriginalSchedule(Mockito.argThat(new OriginalLoanScheduleEntitiesMatcher(expected)));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) ArrayList(java.util.ArrayList) Date(java.util.Date) OriginalLoanScheduleEntitiesMatcher(org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher) Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) CustomerBO(org.mifos.customers.business.CustomerBO) MifosCurrency(org.mifos.application.master.business.MifosCurrency) Test(org.junit.Test)

Example 7 with OriginalLoanScheduleEntity

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

the class LegacyLoanDaoIntegrationTest method testSaveAndGetOriginalLoanScheduleEntity.

@Test
public void testSaveAndGetOriginalLoanScheduleEntity() throws PersistenceException, IOException {
    ArrayList<OriginalLoanScheduleEntity> originalLoanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
    Short installmentId = new Short("1");
    Date date = new Date(new java.util.Date().getTime());
    LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(goodAccount, group, installmentId, date, PaymentStatus.UNPAID, Money.zero(), Money.zero());
    originalLoanScheduleEntities.add(new OriginalLoanScheduleEntity(loanScheduleEntity));
    legacyLoanDao.saveOriginalSchedule(originalLoanScheduleEntities);
    List<OriginalLoanScheduleEntity> actual = legacyLoanDao.getOriginalLoanScheduleEntity(goodAccount.getAccountId());
    Assert.assertEquals(1, actual.size());
    Assert.assertNotNull(actual.get(0));
    assertThat(actual, is(new OriginalLoanScheduleEntitiesMatcher(originalLoanScheduleEntities)));
}
Also used : OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) ArrayList(java.util.ArrayList) Date(java.sql.Date) OriginalLoanScheduleEntitiesMatcher(org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher) Test(org.junit.Test)

Example 8 with OriginalLoanScheduleEntity

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

the class LoanAccountServiceFacadeWebTier method retrieveOriginalLoanSchedule.

@Override
public OriginalScheduleInfoDto retrieveOriginalLoanSchedule(String globalAccountNum) {
    LoanBO loanBO = this.loanDao.findByGlobalAccountNum(globalAccountNum);
    Integer accountId = loanBO.getAccountId();
    try {
        List<OriginalLoanScheduleEntity> loanScheduleEntities = loanBusinessService.retrieveOriginalLoanSchedule(accountId);
        ArrayList<RepaymentScheduleInstallmentDto> repaymentScheduleInstallments = new ArrayList<RepaymentScheduleInstallmentDto>();
        for (OriginalLoanScheduleEntity loanScheduleEntity : loanScheduleEntities) {
            RepaymentScheduleInstallment repaymentScheduleInstallment = loanScheduleEntity.toDto();
            RepaymentScheduleInstallmentDto installmentDto = new RepaymentScheduleInstallmentDto(repaymentScheduleInstallment.getInstallment(), repaymentScheduleInstallment.getPrincipal().toString(), repaymentScheduleInstallment.getInterest().toString(), repaymentScheduleInstallment.getFees().toString(), repaymentScheduleInstallment.getMiscFees().toString(), repaymentScheduleInstallment.getFeesWithMiscFee().toString(), repaymentScheduleInstallment.getMiscPenalty().toString(), repaymentScheduleInstallment.getTotal(), repaymentScheduleInstallment.getDueDate());
            repaymentScheduleInstallments.add(installmentDto);
        }
        return new OriginalScheduleInfoDto(loanBO.getLoanAmount().toString(), loanBO.getDisbursementDate(), repaymentScheduleInstallments);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) OriginalScheduleInfoDto(org.mifos.dto.domain.OriginalScheduleInfoDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) RepaymentScheduleInstallmentDto(org.mifos.dto.domain.RepaymentScheduleInstallmentDto) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 9 with OriginalLoanScheduleEntity

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

the class LoanBusinessService method persistOriginalSchedule.

public void persistOriginalSchedule(LoanBO loan) throws PersistenceException {
    Collection<LoanScheduleEntity> loanScheduleEntities = loan.getLoanScheduleEntities();
    Collection<OriginalLoanScheduleEntity> originalLoanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
    for (LoanScheduleEntity loanScheduleEntity : loanScheduleEntities) {
        originalLoanScheduleEntities.add(new OriginalLoanScheduleEntity(loanScheduleEntity));
    }
    this.getlegacyLoanDao().saveOriginalSchedule(originalLoanScheduleEntities);
}
Also used : OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) ArrayList(java.util.ArrayList)

Aggregations

OriginalLoanScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanScheduleEntity)9 ArrayList (java.util.ArrayList)8 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)6 Test (org.junit.Test)5 OriginalLoanScheduleEntitiesMatcher (org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher)4 Date (java.util.Date)3 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)3 Money (org.mifos.framework.util.helpers.Money)3 Date (java.sql.Date)2 LinkedHashSet (java.util.LinkedHashSet)2 AccountBO (org.mifos.accounts.business.AccountBO)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 OriginalLoanFeeScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanFeeScheduleEntity)2 OriginalScheduleInfoDto (org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto)2 MifosCurrency (org.mifos.application.master.business.MifosCurrency)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerBO (org.mifos.customers.business.CustomerBO)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)1 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)1