use of org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm in project head by mifos.
the class LoanBusinessServiceTest method shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfVariableInstallmentsIsEnabledAndInstallmentsArePassed.
@Test
public void shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfVariableInstallmentsIsEnabledAndInstallmentsArePassed() {
RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
when(loanAccountActionForm.getLoanAmount()).thenReturn("1000");
when(loanAccountActionForm.getLoanAmountValue()).thenReturn(new Money(rupee, "1000"));
when(loanAccountActionForm.getInterestRate()).thenReturn("24");
when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(true);
loanBusinessService.applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010), loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(), loanAccountActionForm.getInterestDoubleValue()), installments);
verify(loanBO).updateInstallmentSchedule(installments);
}
use of org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm in project head by mifos.
the class LoanAccountActionIndividualLoansIntegrationTest method testShouldCallDeleteMethodIfExistingMembersRemoved.
@Test
public void testShouldCallDeleteMethodIfExistingMembersRemoved() throws Exception {
GlimLoanUpdater glimLoanUpdaterMock = createMock(GlimLoanUpdater.class);
LoanAccountAction loanAccountAction = new LoanAccountAction(ApplicationContextProvider.getBean(LoanBusinessService.class), new ConfigurationBusinessService(), glimLoanUpdaterMock);
LoanBO loanMock = createMock(LoanBO.class);
Locale locale = Locale.ENGLISH;
expect(loanMock.getAccountId()).andReturn(2).anyTimes();
ClientBO customerMock = createMock(ClientBO.class);
expect(loanMock.getCustomer()).andReturn(customerMock).anyTimes();
expect(customerMock.getGlobalCustNum()).andReturn("3").anyTimes();
LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
List<LoanBO> loans = new ArrayList<LoanBO>();
loans.add(loanMock);
glimLoanUpdaterMock.delete(loanMock);
expectLastCall().atLeastOnce();
replay(glimLoanUpdaterMock, loanMock, customerMock);
loanAccountAction.handleIndividualLoans(loanMock, loanAccountActionForm, true, clientDetails, loans, locale);
verify(glimLoanUpdaterMock, loanMock, customerMock);
}
use of org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm in project head by mifos.
the class LoanAccountActionIndividualLoansIntegrationTest method testShouldCallUpdateMethodIfExistingMembersChanged.
@Test
public void testShouldCallUpdateMethodIfExistingMembersChanged() throws Exception {
GlimLoanUpdater glimLoanUpdaterMock = createMock(GlimLoanUpdater.class);
LoanAccountAction loanAccountAction = new LoanAccountAction(ApplicationContextProvider.getBean(LoanBusinessService.class), new ConfigurationBusinessService(), glimLoanUpdaterMock);
LoanBO loanMock = createMock(LoanBO.class);
Locale locale = Locale.ENGLISH;
expect(loanMock.getAccountId()).andReturn(2).anyTimes();
ClientBO customerMock = createMock(ClientBO.class);
expect(loanMock.getCustomer()).andReturn(customerMock).anyTimes();
expect(customerMock.getCustomerId()).andReturn(3).anyTimes();
LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
LoanAccountDetailsDto LOAN_ACCOUNT_DETAILS_WITH_LOAN_AMOUNT_300 = LoanAccountDetailsDto.createInstanceForTest("3", "2", "300.0", "2");
clientDetails.add(LOAN_ACCOUNT_DETAILS_WITH_LOAN_AMOUNT_300);
List<LoanBO> loans = new ArrayList<LoanBO>();
loans.add(loanMock);
glimLoanUpdaterMock.updateIndividualLoan(null, null, null, LOAN_ACCOUNT_DETAILS_WITH_LOAN_AMOUNT_300, loanMock);
expectLastCall().atLeastOnce();
replay(glimLoanUpdaterMock, loanMock, customerMock);
loanAccountAction.handleIndividualLoans(loanMock, loanAccountActionForm, true, clientDetails, loans, locale);
verify(glimLoanUpdaterMock, loanMock, customerMock);
}
use of org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm in project head by mifos.
the class LoanAccountAction method getLoanRepaymentSchedule.
@TransactionDemarcate(saveToken = true)
public ActionForward getLoanRepaymentSchedule(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 loanId = Integer.valueOf(request.getParameter(ACCOUNT_ID));
Locale locale = userContext.getPreferredLocale();
Date viewDate = loanAccountActionForm.getScheduleViewDateValue(locale);
LoanBO loan = getLoan(loanId);
setSessionAtributeForGLIM(request, loan);
loan.updateDetails(userContext);
Errors errors = loanBusinessService.computeExtraInterest(loan, viewDate);
if (errors.hasErrors()) {
loanAccountActionForm.resetScheduleViewDate();
}
OriginalScheduleInfoDto originalSchedule = this.loanServiceFacade.retrieveOriginalLoanSchedule(loanId);
String memberAccountIdParam = request.getParameter("memberAccountId");
if (StringUtils.isNotBlank(memberAccountIdParam)) {
Integer memberId = Integer.valueOf(memberAccountIdParam);
LoanBO member = loan.findMemberById(memberId);
if (member != null) {
SessionUtils.setAttribute(CustomerConstants.CUSTOMER_NAME, member.getCustomer().getDisplayName(), request);
SessionUtils.setAttribute(CustomerConstants.GLOBAL_CUST_NUM, member.getCustomer().getGlobalCustNum(), request);
}
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
SessionUtils.setAttribute(Constants.ORIGINAL_SCHEDULE_AVAILABLE, originalSchedule.hasOriginalInstallments(), request);
SessionUtils.setAttribute(Constants.VIEW_DATE, viewDate, request);
String forward = errors.hasErrors() ? ActionForwards.getLoanRepaymentScheduleFailure.toString() : ActionForwards.getLoanRepaymentSchedule.toString();
addErrors(request, getActionErrors(errors));
return mapping.findForward(forward);
}
use of org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm in project head by mifos.
the class LoanAccountAction method manage.
@TransactionDemarcate(joinToken = true)
public ActionForward manage(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
LoanAccountActionForm loanActionForm = (LoanAccountActionForm) form;
String globalAccountNum = request.getParameter(GLOBAL_ACCOUNT_NUM);
CustomerBO customer = getCustomerFromRequest(request);
if (isGlimEnabled() || isNewGlimEnabled()) {
populateGlimAttributes(request, loanActionForm, globalAccountNum, customer);
}
String recurMonth = customer.getCustomerMeeting().getMeeting().getMeetingDetails().getRecurAfter().toString();
handleRepaymentsIndependentOfMeetingIfConfigured(request, loanActionForm, recurMonth);
LoanBO loanBO = new LoanDaoHibernate(new GenericDaoHibernate()).findByGlobalAccountNum(globalAccountNum);
UserContext userContext = getUserContext(request);
loanBO.setUserContext(userContext);
SessionUtils.setAttribute(PROPOSED_DISBURSAL_DATE, loanBO.getDisbursementDate(), request);
SessionUtils.removeAttribute(LOANOFFERING, request);
LoanOfferingBO loanOffering = getLoanOffering(loanBO.getLoanOffering().getPrdOfferingId(), userContext.getLocaleId());
loanActionForm.setInstallmentRange(loanBO.getMaxMinNoOfInstall());
loanActionForm.setLoanAmountRange(loanBO.getMaxMinLoanAmount());
MaxMinInterestRate interestRateRange = loanBO.getMaxMinInterestRate();
loanActionForm.setMaxInterestRate(interestRateRange.getMaxLoanAmount());
loanActionForm.setMinInterestRate(interestRateRange.getMinLoanAmount());
loanActionForm.setExternalId(loanBO.getExternalId());
if (null != loanBO.getFund()) {
loanActionForm.setLoanOfferingFund(loanBO.getFund().getFundId().toString());
}
if (configService.isRepaymentIndepOfMeetingEnabled()) {
MeetingDetailsEntity meetingDetail = loanBO.getLoanMeeting().getMeetingDetails();
loanActionForm.setMonthDay("");
loanActionForm.setMonthWeek("0");
loanActionForm.setMonthRank("0");
if (meetingDetail.getRecurrenceTypeEnum() == RecurrenceType.MONTHLY) {
setMonthlySchedule(loanActionForm, meetingDetail);
} else {
setWeeklySchedule(loanActionForm, meetingDetail);
}
}
setSessionAtributeForGLIM(request, loanBO);
SessionUtils.setAttribute(LOANOFFERING, loanOffering, request);
// Retrieve and set into the session all collateral types from the
// lookup_value_locale table associated with the current user context
// locale
SessionUtils.setCollectionAttribute(MasterConstants.COLLATERAL_TYPES, legacyMasterDao.getLookUpEntity(MasterConstants.COLLATERAL_TYPES).getCustomValueListElements(), request);
SessionUtils.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, legacyMasterDao.findValueListElements(MasterConstants.LOAN_PURPOSES), request);
SessionUtils.setCollectionAttribute(CUSTOM_FIELDS, new ArrayList<CustomFieldDefinitionEntity>(), request);
SessionUtils.setAttribute(RECURRENCEID, loanBO.getLoanMeeting().getMeetingDetails().getRecurrenceTypeEnum().getValue(), request);
SessionUtils.setAttribute(RECURRENCENAME, loanBO.getLoanMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceName(), request);
SessionUtils.setCollectionAttribute(LOANFUNDS, getFunds(loanOffering), request);
setRequestAttributesForEditPage(request, loanBO);
InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
SessionUtils.setCollectionAttribute("detailsInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateLoan"), request);
setFormAttributes(loanBO, form, request);
return mapping.findForward(ActionForwards.manage_success.toString());
}
Aggregations