use of org.mifos.accounts.loan.business.OriginalLoanFeeScheduleEntity 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.OriginalLoanFeeScheduleEntity 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)));
}
Aggregations