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);
}
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));
}
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));
}
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;
}
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;
}
Aggregations