Search in sources :

Example 6 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class SaveCollectionSheetAssembler method clientAttendanceAssemblerfromDto.

public List<ClientAttendanceBO> clientAttendanceAssemblerfromDto(final List<SaveCollectionSheetCustomerDto> saveCollectionSheetCustomers, final LocalDate transactionDate, final Short branchId, final String searchId) {
    List<ClientAttendanceBO> clientAttendanceList = null;
    try {
        clientAttendanceList = clientAttendanceDao.findClientAttendance(branchId, searchId, transactionDate);
        for (SaveCollectionSheetCustomerDto saveCollectionSheetCustomer : saveCollectionSheetCustomers) {
            ClientBO client = customerDao.findClientById(saveCollectionSheetCustomer.getCustomerId());
            if (null != client) {
                ClientAttendanceBO clientAttendance = findClientAttendance(clientAttendanceList, client);
                if (clientAttendance == null) {
                    clientAttendance = new ClientAttendanceBO();
                    clientAttendance.setCustomer(client);
                    clientAttendance.setMeetingDate(DateUtils.getDateFromLocalDate(transactionDate));
                }
                clientAttendance.setAttendance(saveCollectionSheetCustomer.getAttendanceId());
                clientAttendanceList.add(clientAttendance);
            }
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException("Failure assembling client attendance list.", e);
    }
    return clientAttendanceList;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ClientAttendanceBO(org.mifos.customers.client.business.ClientAttendanceBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class TestClients method add.

public ClientBO add(String firstName, OfficeBO office, MeetingBO meeting, PersonnelBO loanOfficer, short groupFlag) {
    UserContext userContext = new UserContext();
    ClientDetailEntity clientDetailEntity = new ClientDetailEntity();
    ClientBO clientBO = new ClientBO(userContext, firstName, CustomerStatus.CLIENT_ACTIVE, TestDates.RECENT, office, meeting, loanOfficer, testPersonnels.any(), TestDates.OLD_ENOUGH, "123456", true, TestDates.RECENT, groupFlag, firstName, "Brown", "James", clientDetailEntity);
    session.saveOrUpdate(clientBO);
    return clientBO;
}
Also used : UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) ClientDetailEntity(org.mifos.customers.client.business.ClientDetailEntity)

Example 8 with ClientBO

use of org.mifos.customers.client.business.ClientBO 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 9 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class PictureFormFile method editFamilyInfo.

@TransactionDemarcate(joinToken = true)
public ActionForward editFamilyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.clearMostButNotAllFieldsOnActionForm();
    ClientBO clientFromSession = getClientFromSession(request);
    ClientFamilyInfoDto clientFamilyInfo = this.clientServiceFacade.retrieveFamilyInfoForEdit(clientFromSession.getGlobalCustNum());
    SessionUtils.setCollectionAttribute(ClientConstants.LIVING_STATUS_ENTITY, clientFamilyInfo.getClientDropdowns().getLivingStatus(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.GENDER_ENTITY, clientFamilyInfo.getClientDropdowns().getGenders(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    UserContext userContext = getUserContext(request);
    List<SpouseFatherLookupEntity> spouseFather = legacyMasterDao.findMasterDataEntitiesWithLocale(SpouseFatherLookupEntity.class);
    SessionUtils.setCollectionAttribute(ClientConstants.SPOUSE_FATHER_ENTITY, spouseFather, request);
    SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_MANDATORY, isFamilyDetailsMandatory(), request);
    // customer specific
    actionForm.setCustomerId(clientFamilyInfo.getCustomerDetail().getCustomerId().toString());
    actionForm.setLoanOfficerId(clientFamilyInfo.getCustomerDetail().getLoanOfficerIdAsString());
    actionForm.setGlobalCustNum(clientFamilyInfo.getCustomerDetail().getGlobalCustNum());
    actionForm.setExternalId(clientFamilyInfo.getCustomerDetail().getExternalId());
    // client specific
    actionForm.setGovernmentId(clientFamilyInfo.getClientDetail().getGovernmentId());
    actionForm.setDateOfBirth(clientFamilyInfo.getClientDetail().getDateOfBirth());
    actionForm.initializeFamilyMember();
    actionForm.setClientDetailView(clientFamilyInfo.getClientDetail().getCustomerDetail());
    actionForm.setClientName(clientFamilyInfo.getClientDetail().getClientName());
    actionForm.setSpouseName(clientFamilyInfo.getClientDetail().getSpouseName());
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    // client family specific
    int familyMemberCount = 0;
    for (ClientNameDetailDto familyMember : clientFamilyInfo.getFamilyMembers()) {
        actionForm.addFamilyMember();
        actionForm.setFamilyPrimaryKey(familyMemberCount, familyMember.getCustomerNameId());
        actionForm.setFamilyFirstName(familyMemberCount, familyMember.getFirstName());
        actionForm.setFamilyMiddleName(familyMemberCount, familyMember.getMiddleName());
        actionForm.setFamilyLastName(familyMemberCount, familyMember.getLastName());
        actionForm.setFamilySecondLastName(familyMemberCount, familyMember.getSecondLastName());
        actionForm.setFamilyRelationship(familyMemberCount, familyMember.getNameType());
        Map<Integer, List<ClientFamilyDetailDto>> clientFamilyDetailsMap = clientFamilyInfo.getClientFamilyDetails();
        Integer key = Integer.valueOf(familyMemberCount);
        List<ClientFamilyDetailDto> clientFamilyDetails = clientFamilyDetailsMap.get(key);
        if (clientFamilyDetails != null) {
            for (ClientFamilyDetailDto clientFamilyDetailDto : clientFamilyDetails) {
                Calendar cal = Calendar.getInstance();
                if (clientFamilyDetailDto.getDateOfBirth() != null) {
                    String date1 = DateUtils.makeDateAsSentFromBrowser(clientFamilyDetailDto.getDateOfBirth());
                    java.util.Date date = DateUtils.getDate(date1);
                    cal.setTime(date);
                    actionForm.setFamilyDateOfBirthDD(familyMemberCount, String.valueOf(cal.get(Calendar.DAY_OF_MONTH)));
                    actionForm.setFamilyDateOfBirthMM(familyMemberCount, String.valueOf(cal.get(Calendar.MONTH) + 1));
                    actionForm.setFamilyDateOfBirthYY(familyMemberCount, String.valueOf(cal.get(Calendar.YEAR)));
                }
                actionForm.setFamilyGender(familyMemberCount, clientFamilyDetailDto.getGender());
                actionForm.setFamilyLivingStatus(familyMemberCount, clientFamilyDetailDto.getLivingStatus());
            }
        }
        familyMemberCount++;
    }
    ClientBO client = this.customerDao.findClientBySystemId(clientFromSession.getGlobalCustNum());
    actionForm.setAddress(Address.toAddress(client.getAddress()));
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.editFamilyInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) Calendar(java.util.Calendar) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) SpouseFatherLookupEntity(org.mifos.application.master.business.SpouseFatherLookupEntity) List(java.util.List) ArrayList(java.util.ArrayList) ClientFamilyInfoDto(org.mifos.dto.screen.ClientFamilyInfoDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 10 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class PictureFormFile method updateFamilyInfo.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateFamilyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    ClientBO clientInSession = getClientFromSession(request);
    Integer customerId = clientInSession.getCustomerId();
    ClientFamilyInfoUpdate clientFamilyInfoUpdate = new ClientFamilyInfoUpdate(customerId, clientInSession.getVersionNo(), actionForm.getFamilyPrimaryKey(), actionForm.getFamilyNames(), actionForm.getFamilyDetails());
    this.clientServiceFacade.updateFamilyInfo(clientFamilyInfoUpdate);
    actionForm.setFamilyDateOfBirth();
    actionForm.constructFamilyDetails();
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    return mapping.findForward(ActionForwards.updateFamilyInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ClientBO(org.mifos.customers.client.business.ClientBO) ClientFamilyInfoUpdate(org.mifos.dto.domain.ClientFamilyInfoUpdate) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

ClientBO (org.mifos.customers.client.business.ClientBO)93 ArrayList (java.util.ArrayList)27 Test (org.junit.Test)27 CustomerException (org.mifos.customers.exceptions.CustomerException)25 CustomerBO (org.mifos.customers.business.CustomerBO)23 GroupBO (org.mifos.customers.group.business.GroupBO)22 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)22 UserContext (org.mifos.security.util.UserContext)21 MifosRuntimeException (org.mifos.core.MifosRuntimeException)19 CenterBO (org.mifos.customers.center.business.CenterBO)19 BusinessRuleException (org.mifos.service.BusinessRuleException)17 ClientBuilder (org.mifos.domain.builders.ClientBuilder)16 PersistenceException (org.mifos.framework.exceptions.PersistenceException)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)14 GroupBuilder (org.mifos.domain.builders.GroupBuilder)14 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)14 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)14 Date (java.util.Date)13 DateTime (org.joda.time.DateTime)13 AccountException (org.mifos.accounts.exceptions.AccountException)13