Search in sources :

Example 6 with AccountPaymentDto

use of org.mifos.dto.domain.AccountPaymentDto in project head by mifos.

the class LoanAccountServiceFacadeWebTierTest method testValidateMakeEarlyRepayment.

@Test
public void testValidateMakeEarlyRepayment() throws AccountException, PersistenceException {
    setMifosUserFromContext();
    when(loanDao.findByGlobalAccountNum("1")).thenReturn(loanBO);
    when(loanDao.findById(0)).thenReturn(loanBO);
    boolean actualWaiveInterestValue = false;
    java.sql.Date date = mock(java.sql.Date.class);
    when(customerDao.getFirstMeetingDateForCustomer(2)).thenReturn(date);
    when(configurationPersistence.isRepaymentIndepOfMeetingEnabled()).thenReturn(false);
    when(loanBO.isInterestWaived()).thenReturn(actualWaiveInterestValue);
    when(loanBO.getOfficeId()).thenReturn((short) 1);
    when(loanBO.getCustomer()).thenReturn(customer);
    when(loanBO.isTrxnDateValid(date, date, false)).thenReturn(true);
    when(customer.getLoanOfficerId()).thenReturn((short) 1);
    when(customer.getCustomerId()).thenReturn(2);
    try {
        loanAccountServiceFacade.makeEarlyRepayment(new RepayLoanInfoDto("1", "100", "001", mock(java.sql.Date.class), "1", (short) 1, true, date, BigDecimal.ZERO, BigDecimal.ZERO));
    } catch (BusinessRuleException e) {
        verify(loanBO, never()).makeEarlyRepayment((AccountPaymentDto) anyObject(), (Short) anyObject(), anyBoolean(), Matchers.<Money>anyObject());
        verify(loanBO, never()).getCurrency();
        verify(loanBusinessService, never()).computeExtraInterest(eq(loanBO), Matchers.<Date>anyObject());
        assertThat(e.getMessageKey(), is(LoanConstants.WAIVER_INTEREST_NOT_CONFIGURED));
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) BusinessRuleException(org.mifos.service.BusinessRuleException) RepayLoanInfoDto(org.mifos.dto.screen.RepayLoanInfoDto) AccountPaymentDto(org.mifos.dto.domain.AccountPaymentDto) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

AccountPaymentDto (org.mifos.dto.domain.AccountPaymentDto)6 Money (org.mifos.framework.util.helpers.Money)6 Test (org.junit.Test)3 RepayLoanInfoDto (org.mifos.dto.screen.RepayLoanInfoDto)3 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 LocalDate (org.joda.time.LocalDate)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)1 AccountStatusChangeHistoryEntity (org.mifos.accounts.business.AccountStatusChangeHistoryEntity)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)1 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 AmountWithInterest (org.mifos.dto.domain.AccountPaymentDto.AmountWithInterest)1 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)1