use of org.mifos.accounts.loan.business.OriginalLoanScheduleEntity in project head by mifos.
the class LoanServiceFacadeWebTier method retrieveOriginalLoanSchedule.
@Override
public OriginalScheduleInfoDto retrieveOriginalLoanSchedule(Integer accountId) {
try {
List<OriginalLoanScheduleEntity> loanScheduleEntities = loanBusinessService.retrieveOriginalLoanSchedule(accountId);
ArrayList<RepaymentScheduleInstallment> repaymentScheduleInstallments = new ArrayList<RepaymentScheduleInstallment>();
for (OriginalLoanScheduleEntity loanScheduleEntity : loanScheduleEntities) {
repaymentScheduleInstallments.add(loanScheduleEntity.toDto());
}
LoanBO loan = this.loanDao.findById(accountId);
return new OriginalScheduleInfoDto(loan.getLoanAmount().toString(), loan.getDisbursementDate(), repaymentScheduleInstallments);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.loan.business.OriginalLoanScheduleEntity in project head by mifos.
the class LegacyLoanDaoIntegrationTest method testSaveAndGetOriginalLoanScheduleEntityWithFees.
@Test
public void testSaveAndGetOriginalLoanScheduleEntityWithFees() throws PersistenceException {
ArrayList<OriginalLoanScheduleEntity> originalLoanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
Date date = new Date(new java.util.Date().getTime());
Short installmentId = new Short("1");
FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
AccountFeesEntity accountUpfrontFee = new AccountFeesEntity(goodAccount, upfrontFee, new Double("20.0"), FeeStatus.ACTIVE.getValue(), null, date);
AccountTestUtils.addAccountFees(accountUpfrontFee, goodAccount);
TestObjectFactory.updateObject(goodAccount);
goodAccount = (LoanBO) TestObjectFactory.getObject(AccountBO.class, goodAccount.getAccountId());
LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(goodAccount, group, installmentId, date, PaymentStatus.UNPAID, Money.zero(), Money.zero());
LoanFeeScheduleEntity feesEntity = new LoanFeeScheduleEntity(loanScheduleEntity, upfrontFee, accountUpfrontFee, Money.zero());
loanScheduleEntity.addAccountFeesAction(feesEntity);
OriginalLoanScheduleEntity originalLoanScheduleEntity = new OriginalLoanScheduleEntity(loanScheduleEntity);
OriginalLoanFeeScheduleEntity scheduleEntityFee = new OriginalLoanFeeScheduleEntity(feesEntity, originalLoanScheduleEntity);
originalLoanScheduleEntities.add(originalLoanScheduleEntity);
legacyLoanDao.saveOriginalSchedule(originalLoanScheduleEntities);
List<OriginalLoanScheduleEntity> actual = legacyLoanDao.getOriginalLoanScheduleEntity(goodAccount.getAccountId());
List<OriginalLoanFeeScheduleEntity> fees = new ArrayList<OriginalLoanFeeScheduleEntity>(actual.get(0).getAccountFeesActionDetails());
Assert.assertEquals(1, actual.size());
Assert.assertEquals(1, fees.size());
assertThat(actual, is(new OriginalLoanScheduleEntitiesMatcher(originalLoanScheduleEntities)));
assertThat(fees.get(0), is(new OriginalLoanFeeScheduleEntityMatcher(scheduleEntityFee)));
}
use of org.mifos.accounts.loan.business.OriginalLoanScheduleEntity in project head by mifos.
the class LoanServiceFacadeWebTierTest method retrieveOriginalLoanSchedule.
@Test
public void retrieveOriginalLoanSchedule() throws PersistenceException {
Integer accountId = new Integer(1);
List<OriginalLoanScheduleEntity> loanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
OriginalLoanScheduleEntity originalLoanScheduleEntity1 = mock(OriginalLoanScheduleEntity.class);
OriginalLoanScheduleEntity originalLoanScheduleEntity2 = mock(OriginalLoanScheduleEntity.class);
loanScheduleEntities.add(originalLoanScheduleEntity1);
loanScheduleEntities.add(originalLoanScheduleEntity2);
RepaymentScheduleInstallment installment1 = new RepaymentScheduleInstallment();
RepaymentScheduleInstallment installment2 = new RepaymentScheduleInstallment();
when(originalLoanScheduleEntity1.toDto()).thenReturn(installment1);
when(originalLoanScheduleEntity2.toDto()).thenReturn(installment2);
List<RepaymentScheduleInstallment> expected = new ArrayList<RepaymentScheduleInstallment>();
expected.add(installment1);
expected.add(installment2);
Date date = new Date();
when(loanBO.getDisbursementDate()).thenReturn(date);
Money money = new Money(rupee, "4.9");
when(loanBO.getLoanAmount()).thenReturn(money);
when(loanBusinessService.retrieveOriginalLoanSchedule(accountId)).thenReturn(loanScheduleEntities);
when(loanDao.findById(accountId)).thenReturn(loanBO);
OriginalScheduleInfoDto expectedOriginalScheduleInfoDto = new OriginalScheduleInfoDto(money.toString(), date, expected);
OriginalScheduleInfoDto originalScheduleInfoDto = loanServiceFacade.retrieveOriginalLoanSchedule(accountId);
assertThat(originalScheduleInfoDto, is(new OriginalScheduleInfoDtoMatcher(expectedOriginalScheduleInfoDto)));
}
use of org.mifos.accounts.loan.business.OriginalLoanScheduleEntity in project head by mifos.
the class LoanBusinessService method clearAndPersistOriginalSchedule.
public void clearAndPersistOriginalSchedule(LoanBO loan) throws PersistenceException {
List<OriginalLoanScheduleEntity> originalLoanScheduleEntities = this.getlegacyLoanDao().getOriginalLoanScheduleEntity(loan.getAccountId());
Collection<LoanScheduleEntity> loanScheduleEntities = loan.getLoanScheduleEntities();
Iterator<LoanScheduleEntity> loanScheduleEntitiesIterator = loanScheduleEntities.iterator();
for (OriginalLoanScheduleEntity originalLoanScheduleEntity : originalLoanScheduleEntities) {
Iterator<AccountFeesActionDetailEntity> accountFeesIterator = loanScheduleEntitiesIterator.next().getAccountFeesActionDetails().iterator();
for (OriginalLoanFeeScheduleEntity originalLoanFeeScheduleEntity : originalLoanScheduleEntity.getAccountFeesActionDetails()) {
originalLoanFeeScheduleEntity.updateFeeAmount(accountFeesIterator.next().getFeeAmount().getAmount());
}
}
this.getlegacyLoanDao().saveOriginalSchedule(originalLoanScheduleEntities);
}
use of org.mifos.accounts.loan.business.OriginalLoanScheduleEntity in project head by mifos.
the class LoanBusinessServiceTest method originalLoanScheduleShouldPersistMiscFee.
@Test
public void originalLoanScheduleShouldPersistMiscFee() 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);
loanScheduleEntity.setMiscFee(money);
installments.add(loanScheduleEntity);
when(loanBO.getLoanScheduleEntities()).thenReturn(installments);
loanBusinessService.persistOriginalSchedule(loanBO);
ArrayList<OriginalLoanScheduleEntity> expected = new ArrayList<OriginalLoanScheduleEntity>();
OriginalLoanScheduleEntity originalLoanScheduleEntity = new OriginalLoanScheduleEntity(loanScheduleEntity);
assertEquals(originalLoanScheduleEntity.getMiscFee(), loanScheduleEntity.getMiscFee());
expected.add(originalLoanScheduleEntity);
verify(legacyLoanDao).saveOriginalSchedule(Mockito.argThat(new OriginalLoanScheduleEntitiesMatcher(expected)));
}
Aggregations