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)));
}
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)));
}
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);
}
}
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);
}
Aggregations