use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.
the class AccountServiceIntegrationTest method getLoanAccountWithAllTypesOfFees.
private AccountBO getLoanAccountWithAllTypesOfFees() {
accountBO = getLoanAccount();
LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountBO.getAccountActionDate(Short.valueOf("1"));
FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
AccountFeesEntity accountUpfrontFee = new AccountFeesEntity(accountBO, upfrontFee, new Double("20.0"), FeeStatus.ACTIVE.getValue(), null, loanScheduleEntity.getActionDate());
AccountTestUtils.addAccountFees(accountUpfrontFee, accountBO);
AccountFeesActionDetailEntity accountUpfrontFeesaction = new LoanFeeScheduleEntity(loanScheduleEntity, upfrontFee, accountUpfrontFee, new Money(getCurrency(), "20.0"));
loanScheduleEntity.addAccountFeesAction(accountUpfrontFeesaction);
TestObjectFactory.updateObject(accountBO);
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
loanScheduleEntity = (LoanScheduleEntity) accountBO.getAccountActionDate(Short.valueOf("1"));
FeeBO timeOfDisbursementFees = TestObjectFactory.createOneTimeAmountFee("Disbursement Fee", FeeCategory.LOAN, "30", FeePayment.TIME_OF_DISBURSEMENT);
AccountFeesEntity accountDisbursementFee = new AccountFeesEntity(accountBO, timeOfDisbursementFees, new Double("30.0"), FeeStatus.ACTIVE.getValue(), null, loanScheduleEntity.getActionDate());
AccountTestUtils.addAccountFees(accountDisbursementFee, accountBO);
AccountFeesActionDetailEntity accountDisbursementFeesaction = new LoanFeeScheduleEntity(loanScheduleEntity, timeOfDisbursementFees, accountDisbursementFee, new Money(getCurrency(), "30.0"));
loanScheduleEntity.addAccountFeesAction(accountDisbursementFeesaction);
TestObjectFactory.updateObject(accountBO);
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
loanScheduleEntity = (LoanScheduleEntity) accountBO.getAccountActionDate(Short.valueOf("1"));
FeeBO firstLoanRepaymentFee = TestObjectFactory.createOneTimeAmountFee("First Loan Repayment Fee", FeeCategory.LOAN, "40", FeePayment.TIME_OF_FIRSTLOANREPAYMENT);
AccountFeesEntity accountFirstLoanRepaymentFee = new AccountFeesEntity(accountBO, firstLoanRepaymentFee, new Double("40.0"), FeeStatus.ACTIVE.getValue(), null, loanScheduleEntity.getActionDate());
AccountTestUtils.addAccountFees(accountFirstLoanRepaymentFee, accountBO);
AccountFeesActionDetailEntity accountTimeOfFirstLoanRepaymentFeesaction = new LoanFeeScheduleEntity(loanScheduleEntity, firstLoanRepaymentFee, accountFirstLoanRepaymentFee, new Money(getCurrency(), "40.0"));
loanScheduleEntity.addAccountFeesAction(accountTimeOfFirstLoanRepaymentFeesaction);
TestObjectFactory.updateObject(accountBO);
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "200", RecurrenceType.WEEKLY, Short.valueOf("1"));
AccountFeesEntity accountPeriodicFee = new AccountFeesEntity(accountBO, periodicFee, new Double("200.0"), FeeStatus.INACTIVE.getValue(), null, null);
AccountTestUtils.addAccountFees(accountPeriodicFee, accountBO);
TestObjectFactory.updateObject(accountBO);
return accountBO;
}
use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.
the class LegacyAccountDaoIntegrationTest method testGetLoanSchedulesForAccountThatAreWithinDates.
@Test
public void testGetLoanSchedulesForAccountThatAreWithinDates() throws Exception {
DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
List<LoanScheduleEntity> affectedDates = legacyAccountDao.getLoanSchedulesForAccountThatAreWithinDates(groupLoan.getAccountId(), fromDate, thruDate);
Assert.assertNotNull(affectedDates);
Assert.assertEquals(4, affectedDates.size());
}
use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.
the class LoanAccountServiceFacadeWebTierTest method shouldReturnInterestDueForNextInstallmentForDIPBLoanWithWaiveInterest.
@Test
public void shouldReturnInterestDueForNextInstallmentForDIPBLoanWithWaiveInterest() {
LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity() {
};
Money interest = TestUtils.createMoney("1234");
Money interestPaid = TestUtils.createMoney("1200");
loanScheduleEntity.setInterest(interest);
loanScheduleEntity.setInterestPaid(interestPaid);
when(loanBO.getDetailsOfNextInstallment()).thenReturn(loanScheduleEntity);
when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
BigDecimal interestDue = ((LoanAccountServiceFacadeWebTier) loanAccountServiceFacade).interestDueForNextInstallment(BigDecimal.TEN, BigDecimal.ZERO, loanBO, true);
assertThat(interestDue.doubleValue(), is(0d));
}
use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.
the class LoanAccountServiceFacadeWebTierTest method interestDueForNextInstallmentShouldReturnZeroIfNextInstallmentIsNull.
@Test
public void interestDueForNextInstallmentShouldReturnZeroIfNextInstallmentIsNull() {
LoanScheduleEntity loanScheduleEntity = null;
when(loanBO.getDetailsOfNextInstallment()).thenReturn(loanScheduleEntity);
when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(false);
BigDecimal interestDue = ((LoanAccountServiceFacadeWebTier) loanAccountServiceFacade).interestDueForNextInstallment(BigDecimal.TEN, BigDecimal.ZERO, loanBO, false);
assertThat(interestDue.doubleValue(), is(0d));
}
use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.
the class PortfolioAtRiskCalculationIntegrationTest method createPayment.
private void createPayment(LoanBO loan, Money amountPaid) throws Exception {
Set<AccountActionDateEntity> actionDateEntities = loan.getAccountActionDates();
LoanScheduleEntity[] paymentsArray = LoanBOTestUtils.getSortedAccountActionDateEntity(actionDateEntities, 6);
PersonnelBO personnelBO = legacyPersonnelDao.getPersonnel(TestObjectFactory.getContext().getId());
LoanScheduleEntity loanSchedule = paymentsArray[0];
Short paymentTypeId = PaymentTypes.CASH.getValue();
PaymentData paymentData = PaymentData.createPaymentData(amountPaid, personnelBO, paymentTypeId, loanSchedule.getActionDate());
IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
paymentData = PaymentData.createPaymentData(amountPaid, personnelBO, paymentTypeId, loanSchedule.getActionDate());
IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
}
Aggregations