Search in sources :

Example 36 with LoanScheduleEntity

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;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) LoanFeeScheduleEntity(org.mifos.accounts.loan.business.LoanFeeScheduleEntity) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity)

Example 37 with LoanScheduleEntity

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());
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) DateMidnight(org.joda.time.DateMidnight) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 38 with LoanScheduleEntity

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));
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 39 with LoanScheduleEntity

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));
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 40 with LoanScheduleEntity

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);
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO)

Aggregations

LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)54 Money (org.mifos.framework.util.helpers.Money)32 ArrayList (java.util.ArrayList)19 OriginalLoanScheduleEntity (org.mifos.accounts.loan.business.OriginalLoanScheduleEntity)18 Test (org.junit.Test)16 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)14 BigDecimal (java.math.BigDecimal)11 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)8 LoanBO (org.mifos.accounts.loan.business.LoanBO)8 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)7 Date (java.util.Date)5 CustomerBO (org.mifos.customers.business.CustomerBO)5 UserContext (org.mifos.security.util.UserContext)5 LocalDate (org.joda.time.LocalDate)4 AccountPenaltiesEntity (org.mifos.accounts.business.AccountPenaltiesEntity)4 OriginalLoanScheduleEntitiesMatcher (org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher)4 InstallmentDetailsDto (org.mifos.dto.domain.InstallmentDetailsDto)4 LoanInstallmentDetailsDto (org.mifos.dto.domain.LoanInstallmentDetailsDto)4 MifosUser (org.mifos.security.MifosUser)4 Date (java.sql.Date)3