use of org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto in project head by mifos.
the class LoanServiceFacadeWebTierTest method retrieveOriginalLoanSchedule.
@Test
public void retrieveOriginalLoanSchedule() throws PersistenceException {
Integer accountId = new Integer(1);
List<OriginalLoanScheduleEntity> loanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
OriginalLoanScheduleEntity originalLoanScheduleEntity1 = mock(OriginalLoanScheduleEntity.class);
OriginalLoanScheduleEntity originalLoanScheduleEntity2 = mock(OriginalLoanScheduleEntity.class);
loanScheduleEntities.add(originalLoanScheduleEntity1);
loanScheduleEntities.add(originalLoanScheduleEntity2);
RepaymentScheduleInstallment installment1 = new RepaymentScheduleInstallment();
RepaymentScheduleInstallment installment2 = new RepaymentScheduleInstallment();
when(originalLoanScheduleEntity1.toDto()).thenReturn(installment1);
when(originalLoanScheduleEntity2.toDto()).thenReturn(installment2);
List<RepaymentScheduleInstallment> expected = new ArrayList<RepaymentScheduleInstallment>();
expected.add(installment1);
expected.add(installment2);
Date date = new Date();
when(loanBO.getDisbursementDate()).thenReturn(date);
Money money = new Money(rupee, "4.9");
when(loanBO.getLoanAmount()).thenReturn(money);
when(loanBusinessService.retrieveOriginalLoanSchedule(accountId)).thenReturn(loanScheduleEntities);
when(loanDao.findById(accountId)).thenReturn(loanBO);
OriginalScheduleInfoDto expectedOriginalScheduleInfoDto = new OriginalScheduleInfoDto(money.toString(), date, expected);
OriginalScheduleInfoDto originalScheduleInfoDto = loanServiceFacade.retrieveOriginalLoanSchedule(accountId);
assertThat(originalScheduleInfoDto, is(new OriginalScheduleInfoDtoMatcher(expectedOriginalScheduleInfoDto)));
}
use of org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto in project head by mifos.
the class LoanAccountActionTest method shouldViewOriginalSchedule.
@SuppressWarnings("unchecked")
@Test
public void shouldViewOriginalSchedule() throws Exception {
ActionForward viewOriginalScheduleForward = new ActionForward("viewOriginalSchedule");
int loanId = 1;
String loanAmount = "123";
List<RepaymentScheduleInstallment> installments = Collections.EMPTY_LIST;
java.sql.Date disbursementDate = new java.sql.Date(new DateTime().toDate().getTime());
OriginalScheduleInfoDto dto = mock(OriginalScheduleInfoDto.class);
when(dto.getOriginalLoanScheduleInstallment()).thenReturn(installments);
when(dto.getLoanAmount()).thenReturn(loanAmount);
when(dto.getDisbursementDate()).thenReturn(disbursementDate);
when(request.getParameter(LoanAccountAction.ACCOUNT_ID)).thenReturn(String.valueOf(loanId));
when(loanServiceFacade.retrieveOriginalLoanSchedule(loanId)).thenReturn(dto);
when(mapping.findForward("viewOriginalSchedule")).thenReturn(viewOriginalScheduleForward);
ActionForward forward = loanAccountAction.viewOriginalSchedule(mapping, form, request, response);
assertThat(forward, is(viewOriginalScheduleForward));
verify(request).getParameter(LoanAccountAction.ACCOUNT_ID);
verify(loanServiceFacade).retrieveOriginalLoanSchedule(loanId);
verify(dto).getOriginalLoanScheduleInstallment();
verify(dto).getLoanAmount();
verify(dto).getDisbursementDate();
verify(mapping).findForward("viewOriginalSchedule");
}
use of org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto in project head by mifos.
the class LoanAccountActionTest method getLoanRepaymentScheduleShouldCalculateExtraInterest.
@Test
public void getLoanRepaymentScheduleShouldCalculateExtraInterest() throws Exception {
when(loanBusinessService.computeExtraInterest(eq(loanBO), Matchers.<Date>any())).thenReturn(new Errors());
when(request.getParameter("accountId")).thenReturn("1");
when(loanServiceFacade.retrieveOriginalLoanSchedule(Matchers.<Integer>any())).thenReturn(new OriginalScheduleInfoDto("100", new Date(), Collections.<RepaymentScheduleInstallment>emptyList()));
loanAccountAction.getLoanRepaymentSchedule(mapping, form, request, response);
verify(loanBusinessService, times(1)).computeExtraInterest(Matchers.<LoanBO>any(), Matchers.<Date>any());
}
use of org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto in project head by mifos.
the class LoanAccountAction method getGroupLoanRepaymentSchedule.
@TransactionDemarcate(joinToken = true)
public ActionForward getGroupLoanRepaymentSchedule(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
LoanAccountActionForm loanAccountActionForm = (LoanAccountActionForm) form;
UserContext userContext = getUserContext(request);
Integer grouploanId = Integer.valueOf(request.getParameter(ACCOUNT_ID));
Locale locale = userContext.getPreferredLocale();
Date viewDate = loanAccountActionForm.getScheduleViewDateValue(locale);
LoanBO groupLoan = getLoan(grouploanId);
LoanAccountAction.setSessionAtributeForGLIM(request, groupLoan);
groupLoan.updateDetails(userContext);
Errors errors = loanBusinessService.computeExtraInterest(groupLoan, viewDate);
if (errors.hasErrors()) {
loanAccountActionForm.resetScheduleViewDate();
}
List<LoanBO> membersAccount = this.loanDao.findIndividualLoans(grouploanId);
List<Integer> membersAccountIds = getMembersAccountId(membersAccount);
OriginalScheduleInfoDto generatedSchedule = OriginalScheduleInfoHelper.sumRepaymentSchedule(getMembersSchedule(membersAccountIds));
SessionUtils.setAttribute(Constants.BUSINESS_KEY, groupLoan, request);
SessionUtils.setAttribute(Constants.VIEW_DATE, viewDate, request);
SessionUtils.setAttribute(Constants.ORIGINAL_SCHEDULE_AVAILABLE, generatedSchedule.hasOriginalInstallments(), request);
SessionUtils.setAttribute("isNewGropLoan", Boolean.TRUE, request);
String forward = errors.hasErrors() ? ActionForwards.getLoanRepaymentScheduleFailure.toString() : ActionForwards.getLoanRepaymentSchedule.toString();
addErrors(request, getActionErrors(errors));
return mapping.findForward(forward);
}
Aggregations