Search in sources :

Example 16 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class LoanAccountServiceFacadeWebTierTest method testMakeEarlyRepaymentForNotWaiverInterestLoanProduct.

@Test
public void testMakeEarlyRepaymentForNotWaiverInterestLoanProduct() throws AccountException, PersistenceException {
    setMifosUserFromContext();
    when(loanDao.findByGlobalAccountNum("1")).thenReturn(loanBO);
    when(loanDao.findById(0)).thenReturn(loanBO);
    boolean waiveInterest = false;
    when(loanBO.getCurrency()).thenReturn(rupee);
    when(loanBO.getOfficeId()).thenReturn((short) 1);
    when(loanBO.getCustomer()).thenReturn(customer);
    when(customer.getLoanOfficerId()).thenReturn((short) 1);
    when(customer.getCustomerId()).thenReturn(2);
    LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity() {
    };
    loanScheduleEntity.setInterest(new Money(rupee, 100d));
    when(loanBO.getDetailsOfNextInstallment()).thenReturn(loanScheduleEntity);
    java.sql.Date date = mock(java.sql.Date.class);
    when(loanBO.isTrxnDateValid(date, date, false)).thenReturn(true);
    when(customerDao.getFirstMeetingDateForCustomer(2)).thenReturn(date);
    when(configurationPersistence.isRepaymentIndepOfMeetingEnabled()).thenReturn(false);
    String paymentMethod = "1";
    String receiptNumber = "001";
    AccountPaymentDto paymentDto = new AccountPaymentDto(new Double(100), date, receiptNumber, date, Short.valueOf((short) 1));
    loanAccountServiceFacade.makeEarlyRepayment(new RepayLoanInfoDto("1", "100.0", receiptNumber, date, paymentMethod, (short) 1, waiveInterest, date, BigDecimal.ZERO, BigDecimal.ZERO));
    short userId = (short) 1;
    verify(loanBO).makeEarlyRepayment(paymentDto, userId, waiveInterest, new Money(rupee, 100d));
    verify(loanBusinessService).computeExtraInterest(loanBO, date);
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) RepayLoanInfoDto(org.mifos.dto.screen.RepayLoanInfoDto) AccountPaymentDto(org.mifos.dto.domain.AccountPaymentDto) Test(org.junit.Test)

Example 17 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class LoanAccountServiceFacadeWebTierTest method shouldReturnInterestDueForNextInstallmentWhenWaiveInterestFlagIsOnAndInterestIsNotWaived.

@Test
public void shouldReturnInterestDueForNextInstallmentWhenWaiveInterestFlagIsOnAndInterestIsNotWaived() {
    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);
    BigDecimal interestDue = ((LoanAccountServiceFacadeWebTier) loanAccountServiceFacade).interestDueForNextInstallment(BigDecimal.TEN, BigDecimal.ZERO, loanBO, false);
    Double expectedDue = interest.subtract(interestPaid).getAmount().doubleValue();
    assertThat(interestDue.doubleValue(), is(expectedDue));
}
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 18 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class LoanAccountServiceFacadeWebTierTest method shouldReturnInterestDueForNextInstallmentForDIPBLoanWithDoNotWaiveInterest.

@Test
public void shouldReturnInterestDueForNextInstallmentForDIPBLoanWithDoNotWaiveInterest() {
    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, false);
    assertThat(interestDue.doubleValue(), is(10d));
}
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 19 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class TestObjectFactory method getBulkEntryAccountFeeActionViews.

public static List<CollectionSheetEntryAccountFeeActionDto> getBulkEntryAccountFeeActionViews(final AccountActionDateEntity accountActionDateEntity) {
    List<CollectionSheetEntryAccountFeeActionDto> bulkEntryFeeViews = new ArrayList<CollectionSheetEntryAccountFeeActionDto>();
    Set<AccountFeesActionDetailEntity> feeActions = null;
    if (accountActionDateEntity instanceof LoanScheduleEntity) {
        feeActions = ((LoanScheduleEntity) accountActionDateEntity).getAccountFeesActionDetails();
    } else if (accountActionDateEntity instanceof CustomerScheduleEntity) {
        feeActions = ((CustomerScheduleEntity) accountActionDateEntity).getAccountFeesActionDetails();
    }
    if (feeActions != null && feeActions.size() > 0) {
        for (AccountFeesActionDetailEntity accountFeesActionDetail : feeActions) {
            bulkEntryFeeViews.add(getBulkEntryAccountFeeActionView(accountFeesActionDetail));
        }
    }
    return bulkEntryFeeViews;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) CollectionSheetEntryAccountFeeActionDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryAccountFeeActionDto) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) ArrayList(java.util.ArrayList)

Example 20 with LoanScheduleEntity

use of org.mifos.accounts.loan.business.LoanScheduleEntity in project head by mifos.

the class TestObjectFactory method getBulkEntryAccountActionView.

public static CollectionSheetEntryInstallmentDto getBulkEntryAccountActionView(final AccountActionDateEntity accountActionDateEntity) {
    CollectionSheetEntryInstallmentDto bulkEntryAccountActionView = null;
    if (accountActionDateEntity instanceof LoanScheduleEntity) {
        LoanScheduleEntity actionDate = (LoanScheduleEntity) accountActionDateEntity;
        CollectionSheetEntryLoanInstallmentDto installmentView = new CollectionSheetEntryLoanInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getPrincipal(), actionDate.getPrincipalPaid(), actionDate.getInterest(), actionDate.getInterestPaid(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getPenalty(), actionDate.getPenaltyPaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
        installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
        bulkEntryAccountActionView = installmentView;
    } else if (accountActionDateEntity instanceof SavingsScheduleEntity) {
        SavingsScheduleEntity actionDate = (SavingsScheduleEntity) accountActionDateEntity;
        CollectionSheetEntrySavingsInstallmentDto installmentView = new CollectionSheetEntrySavingsInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getDeposit(), actionDate.getDepositPaid());
        bulkEntryAccountActionView = installmentView;
    } else if (accountActionDateEntity instanceof CustomerScheduleEntity) {
        CustomerScheduleEntity actionDate = (CustomerScheduleEntity) accountActionDateEntity;
        CollectionSheetEntryCustomerAccountInstallmentDto installmentView = new CollectionSheetEntryCustomerAccountInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
        installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
        bulkEntryAccountActionView = installmentView;
    }
    return bulkEntryAccountActionView;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) CollectionSheetEntryLoanInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) CollectionSheetEntrySavingsInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) CollectionSheetEntryCustomerAccountInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto) CollectionSheetEntryInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)

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