Search in sources :

Example 1 with ClientInformationDto

use of org.mifos.dto.screen.ClientInformationDto in project head by mifos.

the class PictureFormFile method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String clientSystemId = ((ClientCustActionForm) form).getGlobalCustNum();
    ClientInformationDto clientInformationDto;
    try {
        clientInformationDto = clientServiceFacade.getClientInformationDto(clientSystemId);
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    // John W - for breadcrumb or another other action downstream that exists business_key set (until refactored)
    ClientBO clientBO = (ClientBO) this.customerDao.findCustomerById(clientInformationDto.getClientDisplay().getCustomerId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, clientBO, request);
    SessionUtils.setAttribute(ClientConstants.IS_PHOTO_FIELD_HIDDEN, FieldConfig.getInstance().isFieldHidden("Client.Photo"), request);
    setCurrentPageUrl(request, clientBO);
    setQuestionGroupInstances(request, clientBO);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.removeThenSetAttribute("clientInformationDto", clientInformationDto, request);
    request.getSession().setAttribute("guarantyClientInformation", loanAccountServiceFacade.retrieveGuarantyClientInformation(clientInformationDto));
    QuestionnaireServiceFacade questionnaireServiceFacade = questionnaireServiceFacadeLocator.getService(request);
    List<QuestionGroupInstanceDetail> questions = new ArrayList<QuestionGroupInstanceDetail>();
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(clientInformationDto.getClientDisplay().getCustomerId(), "Create", "Client"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(clientInformationDto.getClientDisplay().getCustomerId(), "View", "Client"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(clientInformationDto.getClientDisplay().getCustomerId(), "Close", "Client"));
    SessionUtils.setCollectionAttribute("questionGroups", questions, request);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("Client"), request);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) MifosRuntimeException(org.mifos.core.MifosRuntimeException) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with ClientInformationDto

use of org.mifos.dto.screen.ClientInformationDto in project head by mifos.

the class ClientServiceFacadeWebTier method getClientInformationDto.

@Override
public ClientInformationDto getClientInformationDto(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    ClientBO client = customerDao.findClientBySystemId(globalCustNum);
    if (client == null) {
        throw new MifosRuntimeException("Client not found for globalCustNum, levelId: " + globalCustNum);
    }
    try {
        personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    ClientDisplayDto clientDisplay = this.customerDao.getClientDisplayDto(client.getCustomerId(), userContext);
    Integer clientId = client.getCustomerId();
    CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(clientId);
    ClientPerformanceHistoryDto clientPerformanceHistory = assembleClientPerformanceHistoryDto(client.getClientPerformanceHistory(), clientId);
    CustomerAddressDto clientAddress = this.customerDao.getCustomerAddressDto(client);
    List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(clientId);
    List<CustomerFlagDto> customerFlags = customerDao.getCustomerFlagDto(client.getCustomerFlags());
    List<LoanDetailDto> loanDetail = customerDao.getLoanDetailDto(client.getOpenLoanAccounts());
    List<LoanDetailDto> groupLoanDetail = customerDao.getLoanDetailDto(client.getOpenGroupLoanAccounts());
    List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(clientId, userContext);
    CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(client.getCustomerMeeting(), userContext);
    List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(clientId);
    List<LoanDetailDto> closedLoanAccounts = new ArrayList<LoanDetailDto>();
    List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
    for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
        if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.LOAN_ACCOUNT.getValue().intValue()) {
            closedLoanAccounts.add(new LoanDetailDto(closedAccount.getGlobalAccountNum(), ((LoanBO) closedAccount).getLoanOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((LoanBO) closedAccount).getLoanSummary().getOutstandingBalance().toString(), closedAccount.getTotalAmountDue().toString(), closedAccount.getTotalAmountInArrears().toString()));
        } else {
            closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
        }
    }
    Boolean activeSurveys = Boolean.FALSE;
    //        Boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CLIENT);
    List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
    List<LoanDetailDto> guarantedLoanAccounts = new ArrayList<LoanDetailDto>();
    try {
        List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByGurantorId(clientId);
        if (guaranties != null && guaranties.size() > 0) {
            for (GuarantyEntity guaranty : guaranties) {
                if (guaranty != null && guaranty.getState() != null && guaranty.getState()) {
                    LoanBO loan = loanDao.findById(guaranty.getLoanId());
                    guarantedLoanAccounts.add(new LoanDetailDto(loan.getGlobalAccountNum(), loan.getLoanOffering().getPrdOfferingName(), loan.getAccountState().getId(), loan.getAccountState().getName(), loan.getLoanSummary().getOutstandingBalance().toString(), loan.getTotalAmountDue().toString(), loan.getAccountType().getAccountTypeId(), loan.getTotalAmountInArrears().toString()));
                }
            }
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException("Can not get guaranted loan accounts", e);
    }
    return new ClientInformationDto(clientDisplay, customerAccountSummary, clientPerformanceHistory, clientAddress, recentCustomerNotes, customerFlags, loanDetail, groupLoanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, closedLoanAccounts, closedSavingsAccounts, guarantedLoanAccounts);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) GuarantyEntity(org.mifos.accounts.loan.business.GuarantyEntity) AccountBO(org.mifos.accounts.business.AccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ClientPerformanceHistoryDto(org.mifos.dto.screen.ClientPerformanceHistoryDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) ClientDisplayDto(org.mifos.dto.screen.ClientDisplayDto) UserContext(org.mifos.security.util.UserContext) LoanDetailDto(org.mifos.dto.domain.LoanDetailDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) MifosUser(org.mifos.security.MifosUser) CustomerFlagDto(org.mifos.dto.domain.CustomerFlagDto) AccountException(org.mifos.accounts.exceptions.AccountException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with ClientInformationDto

use of org.mifos.dto.screen.ClientInformationDto in project head by mifos.

the class ClientCustActionStrutsTest method testGet.

@Ignore
@Test
public void testGet() throws Exception {
    createInitialCustomers();
    accountBO = getLoanAccount(client, meeting);
    ClientTestUtils.setDateOfBirth(client, offSetCurrentDate(50));
    TestObjectFactory.updateObject(client);
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "get");
    addRequestParameter("globalCustNum", client.getGlobalCustNum());
    addRequestParameter("recordOfficeId", "12");
    addRequestParameter("recordLoanOfficerId", "28");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.get_success.toString());
    ClientInformationDto clientInformationDto = (ClientInformationDto) SessionUtils.getAttribute("clientInformationDto", request);
    Assert.assertEquals("Age of customer should be 50 years", 50, (int) clientInformationDto.getClientDisplay().getAge());
    Assert.assertEquals("No of active loan accounts should be 1", 1, clientInformationDto.getLoanAccountsInUse().size());
    assertCurrentPageUrl(client.getGlobalCustNum(), 12, 28);
    StaticHibernateUtil.flushAndClearSession();
    group = (GroupBO) StaticHibernateUtil.getSessionTL().get(GroupBO.class, group.getCustomerId());
    center = (CenterBO) StaticHibernateUtil.getSessionTL().get(CenterBO.class, center.getCustomerId());
    client = (ClientBO) StaticHibernateUtil.getSessionTL().get(ClientBO.class, client.getCustomerId());
    accountBO = (LoanBO) StaticHibernateUtil.getSessionTL().get(LoanBO.class, accountBO.getAccountId());
}
Also used : ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with ClientInformationDto

use of org.mifos.dto.screen.ClientInformationDto in project head by mifos.

the class ViewCustomerDetailsController method showClientDetails.

@RequestMapping(value = "/viewClientDetails", method = RequestMethod.GET)
public ModelAndView showClientDetails(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewClientDetails", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String clientSystemId = request.getParameter("globalCustNum");
    ClientInformationDto clientInformationDto;
    clientInformationDto = clientServiceFacade.getClientInformationDto(clientSystemId);
    modelAndView.addObject("clientInformationDto", clientInformationDto);
    boolean isPhotoFieldHidden = this.adminServiceFacade.isHiddenMandatoryField("photo");
    modelAndView.addObject("isPhotoFieldHidden", isPhotoFieldHidden);
    modelAndView.addObject("currentPageUrl", UrlHelper.constructCurrentPageUrl(request));
    boolean containsQGForCloseClient = false;
    containsQGForCloseClient = questionnaireServiceFacade.getQuestionGroupInstances(clientInformationDto.getClientDisplay().getCustomerId(), "Close", "Client").size() > 0;
    modelAndView.addObject("containsQGForCloseClient", containsQGForCloseClient);
    request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
    clientServiceFacade.putClientBusinessKeyInSession(clientSystemId, request);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with ClientInformationDto

use of org.mifos.dto.screen.ClientInformationDto in project head by mifos.

the class ClientRESTController method createClient.

@RequestMapping(value = "client/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createClient(@RequestBody String request) throws Throwable {
    ObjectMapper om = createClientMapping();
    CreateClientCreationDetail creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateClientCreationDetail.class);
    } catch (JsonMappingException e) {
        e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    ClientCreationDetail client = createClient(creationDetail);
    CustomerDetailsDto clientDetails = clientServiceFacade.createNewClient(client, meetingBO.toDto(), null);
    ClientInformationDto clientInfo = clientServiceFacade.getClientInformationDto(clientDetails.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCustNum", clientInfo.getClientDisplay().getGlobalCustNum());
    map.put("accountNum", clientInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("address", clientInfo.getAddress().getDisplayAddress());
    map.put("city", clientInfo.getAddress().getCity());
    map.put("state", clientInfo.getAddress().getState());
    map.put("country", clientInfo.getAddress().getCountry());
    map.put("postal code", clientInfo.getAddress().getZip());
    map.put("phone", clientInfo.getAddress().getPhoneNumber());
    map.put("dispalyName", clientInfo.getClientDisplay().getDisplayName());
    map.put("externalId", clientInfo.getClientDisplay().getExternalId());
    map.put("loanOfficer", clientInfo.getClientDisplay().getLoanOfficerName());
    return map;
}
Also used : CreateClientCreationDetail(org.mifos.application.servicefacade.CreateClientCreationDetail) CreateClientCreationDetail(org.mifos.application.servicefacade.CreateClientCreationDetail) ClientCreationDetail(org.mifos.dto.domain.ClientCreationDetail) HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ClientInformationDto (org.mifos.dto.screen.ClientInformationDto)5 ArrayList (java.util.ArrayList)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 IncludePage (freemarker.ext.servlet.IncludePage)1 HashMap (java.util.HashMap)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 GuarantyEntity (org.mifos.accounts.loan.business.GuarantyEntity)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CreateClientCreationDetail (org.mifos.application.servicefacade.CreateClientCreationDetail)1 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)1 ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)1 CustomerAccountSummaryDto (org.mifos.dto.domain.CustomerAccountSummaryDto)1