Search in sources :

Example 66 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class OfficeServiceFacadeWebTier method retrieveOfficeById.

@Override
public OfficeDto retrieveOfficeById(Short id) {
    OfficeBO officeBO = officeDao.findOfficeById(id);
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    Short parentOfficeId = null;
    String parentOffineName = null;
    if (officeBO.getParentOffice() != null) {
        parentOfficeId = officeBO.getParentOffice().getOfficeId();
        parentOffineName = officeBO.getParentOffice().getOfficeName();
    }
    Address address = officeBO.getAddress() != null ? officeBO.getAddress().getAddress() : null;
    AddressDto addressDto = address != null ? Address.toDto(officeBO.getAddress().getAddress()) : null;
    String officeLevelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getLevel().getLookUpValue());
    String officeStatusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getStatus().getLookUpValue());
    OfficeDto officeDto = new OfficeDto(officeBO.getOfficeId(), officeBO.getOfficeName(), officeBO.getSearchId(), officeBO.getShortName(), officeBO.getGlobalOfficeNum(), parentOfficeId, officeBO.getStatus().getId(), officeBO.getLevel().getId(), parentOffineName, officeBO.getVersionNo(), officeStatusName, officeLevelName, addressDto, customFields);
    return officeDto;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto)

Example 67 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class ClientBO method createNewInGroupHierarchy.

public static ClientBO createNewInGroupHierarchy(UserContext userContext, String clientName, CustomerStatus clientStatus, DateTime mfiJoiningDate, CustomerBO group, PersonnelBO formedBy, ClientNameDetailEntity clientNameDetailEntity, DateTime dateOfBirth, String governmentId, boolean trained, DateTime trainedDate, Short groupFlag, String clientFirstName, String clientLastName, String secondLastName, ClientNameDetailEntity spouseFatherNameDetailEntity, ClientDetailEntity clientDetailEntity, List<ClientInitialSavingsOfferingEntity> associatedOfferings, String externalId, Address address, LocalDate activationDate) {
    // inherit settings from parent (group)
    OfficeBO office = group.getOffice();
    MeetingBO meeting = group.getCustomerMeetingValue();
    if (clientStatus.isClientActive()) {
        Assert.notNull(meeting, "meeting inherited from parent group should not be null when client is active");
    }
    PersonnelBO loanOfficer = group.getPersonnel();
    ClientBO client = new ClientBO(userContext, clientName, clientStatus, mfiJoiningDate, office, meeting, loanOfficer, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientFirstName, clientLastName, secondLastName, clientDetailEntity);
    client.setParentCustomer(group);
    client.generateSearchId();
    client.updateAddress(address);
    client.setExternalId(externalId);
    client.addNameDetailSet(clientNameDetailEntity);
    client.addNameDetailSet(spouseFatherNameDetailEntity);
    if (clientStatus.isClientActive()) {
        CustomerHierarchyEntity hierarchy = new CustomerHierarchyEntity(client, group);
        client.addCustomerHierarchy(hierarchy);
        client.setCustomerActivationDate(activationDate.toDateMidnight().toDate());
    }
    for (ClientInitialSavingsOfferingEntity clientInitialSavingsOfferingEntity : associatedOfferings) {
        client.addOfferingAssociatedInCreate(clientInitialSavingsOfferingEntity);
    }
    return client;
}
Also used : CustomerHierarchyEntity(org.mifos.customers.business.CustomerHierarchyEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO)

Example 68 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class GroupBO method transferTo.

public boolean transferTo(CenterBO receivingCenter) {
    boolean regenerateGroupSchedules = false;
    this.setParentCustomer(receivingCenter);
    this.setPersonnel(receivingCenter.getPersonnel());
    CustomerHierarchyEntity currentHierarchy = this.getActiveCustomerHierarchy();
    if (null != currentHierarchy) {
        currentHierarchy.makeInactive(this.getUserContext().getId());
    }
    this.addCustomerHierarchy(new CustomerHierarchyEntity(this, receivingCenter));
    MeetingBO centerMeeting = receivingCenter.getCustomerMeetingValue();
    MeetingBO groupMeeting = this.getCustomerMeetingValue();
    if (centerMeeting != null) {
        if (groupMeeting != null) {
            regenerateGroupSchedules = receivingCenter.hasMeetingDifferentTo(groupMeeting);
            CustomerMeetingEntity groupMeetingEntity = this.getCustomerMeeting();
            groupMeetingEntity.setMeeting(receivingCenter.getCustomerMeetingValue());
        } else {
            CustomerMeetingEntity customerMeeting = this.createCustomerMeeting(centerMeeting);
            this.setCustomerMeeting(customerMeeting);
        }
    } else if (groupMeeting != null) {
        this.setCustomerMeeting(null);
    }
    OfficeBO centerOffice = receivingCenter.getOffice();
    if (this.isDifferentBranch(centerOffice)) {
        this.makeCustomerMovementEntries(centerOffice);
        if (this.isActive()) {
            this.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
        }
        regenerateGroupSchedules = true;
    }
    this.generateSearchId();
    return regenerateGroupSchedules;
}
Also used : CustomerHierarchyEntity(org.mifos.customers.business.CustomerHierarchyEntity) CustomerMeetingEntity(org.mifos.customers.business.CustomerMeetingEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Example 69 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class OfficeListTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    try {
        String officeListString = "";
        OnlyBranchOfficeHierarchyDto officeHierarchyDto = (OnlyBranchOfficeHierarchyDto) pageContext.getAttribute(OnlyBranchOfficeHierarchyDto.IDENTIFIER);
        if (officeHierarchyDto != null) {
            officeListString = getOfficeList(officeHierarchyDto);
        } else {
            // FIXME - #00006 - keithw - personnel creation use this still
            UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USERCONTEXT);
            OfficePersistence officePersistence = new OfficePersistence();
            OfficeBO officeBO = officePersistence.getOffice(userContext.getBranchId());
            List<OfficeDetailsDto> levels = officePersistence.getActiveLevels();
            OfficeBO loggedInOffice = officePersistence.getOffice(userContext.getBranchId());
            List<OfficeBO> branchParents = officePersistence.getBranchParents(officeBO.getSearchId());
            List<OfficeHierarchyDto> officeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
            List<OfficeBO> officesTillBranchOffice = officePersistence.getOfficesTillBranchOffice(officeBO.getSearchId());
            officeListString = getOfficeList(userContext.getPreferredLocale(), levels, loggedInOffice.getSearchId(), officeHierarchy, officesTillBranchOffice);
        }
        TagUtils.getInstance().write(pageContext, officeListString);
    } catch (Exception e) {
        /**
             * This turns into a (rather ugly) error 500. TODO: make it more reasonable.
             */
        throw new JspException(e);
    }
    return EVAL_PAGE;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) JspException(javax.servlet.jsp.JspException) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) UserContext(org.mifos.security.util.UserContext) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) JspException(javax.servlet.jsp.JspException)

Example 70 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class PersonAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm actionform = (PersonActionForm) form;
    actionform.clear();
    PersonnelBO personnelInSession = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    PersonnelBO personnel = this.personnelDao.findPersonnelById(personnelInSession.getPersonnelId());
    List<ValueListElement> titles = this.customerDao.retrieveTitles();
    List<ValueListElement> genders = this.customerDao.retrieveGenders();
    List<ValueListElement> maritalStatuses = this.customerDao.retrieveMaritalStatuses();
    List<ValueListElement> languages = Localization.getInstance().getLocaleForUI();
    List<RoleBO> roles = legacyRolesPermissionsDao.getRoles();
    List<PersonnelLevelEntity> personnelLevels = this.customerDao.retrievePersonnelLevels();
    for (PersonnelLevelEntity personnelLevelEntity : personnelLevels) {
        String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelLevelEntity.getLookUpValue().getPropertiesKey());
        personnelLevelEntity.setName(messageTextLookup);
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.TITLE_LIST, titles, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_LEVEL_LIST, personnelLevels, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.GENDER_LIST, genders, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.MARITAL_STATUS_LIST, maritalStatuses, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.LANGUAGE_LIST, languages, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, roles, request);
    SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, roles, request);
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    UserContext userContext = getUserContext(request);
    List<PersonnelStatusEntity> statuses = legacyMasterDao.findMasterDataEntitiesWithLocale(PersonnelStatusEntity.class);
    for (PersonnelStatusEntity personnelStatusEntity : statuses) {
        String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelStatusEntity.getLookUpValue().getPropertiesKey());
        personnelStatusEntity.setName(messageTextLookup);
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.STATUS_LIST, statuses, request);
    OfficeBO loggedInOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    List<OfficeDetailsDto> officeHierarchy = new OfficePersistence().getChildOffices(loggedInOffice.getSearchId());
    SessionUtils.setCollectionAttribute(PersonnelConstants.OFFICE_LIST, officeHierarchy, request);
    actionform.setPersonnelId(personnel.getPersonnelId().toString());
    if (personnel.getOffice() != null) {
        actionform.setOfficeId(personnel.getOffice().getOfficeId().toString());
    }
    if (personnel.getTitle() != null) {
        actionform.setTitle(personnel.getTitle().toString());
    }
    if (personnel.getLevel() != null) {
        actionform.setLevel(personnel.getLevelEnum().getValue().toString());
    }
    if (personnel.getStatus() != null) {
        actionform.setStatus(personnel.getStatus().getId().toString());
    }
    actionform.setLoginName(personnel.getUserName());
    actionform.setGlobalPersonnelNum(personnel.getGlobalPersonnelNum());
    actionform.setCustomFields(new ArrayList<CustomFieldDto>());
    if (personnel.getPersonnelDetails() != null) {
        PersonnelDetailsEntity personnelDetails = personnel.getPersonnelDetails();
        actionform.setFirstName(personnelDetails.getName().getFirstName());
        actionform.setMiddleName(personnelDetails.getName().getMiddleName());
        actionform.setSecondLastName(personnelDetails.getName().getSecondLastName());
        actionform.setLastName(personnelDetails.getName().getLastName());
        if (personnelDetails.getGender() != null) {
            actionform.setGender(personnelDetails.getGender().toString());
        }
        if (personnelDetails.getMaritalStatus() != null) {
            actionform.setMaritalStatus(personnelDetails.getMaritalStatus().toString());
        }
        actionform.setAddress(personnelDetails.getAddress());
        if (personnelDetails.getDateOfJoiningMFI() != null) {
            actionform.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDateOfJoiningMFI()));
        }
        if (personnelDetails.getDob() != null) {
            actionform.setDob(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDob()));
        }
    }
    actionform.setEmailId(personnel.getEmailId());
    if (personnel.getPreferredLocale() != null) {
        actionform.setPreferredLocale(personnel.getPreferredLocale());
    }
    if (personnel.getPasswordExpirationDate() != null) {
        actionform.setPasswordExpirationDate(DateUtils.makeDateAsSentFromBrowser(personnel.getPasswordExpirationDate()));
    }
    List<RoleBO> selectList = new ArrayList<RoleBO>();
    for (PersonnelRoleEntity personnelRole : personnel.getPersonnelRoles()) {
        selectList.add(personnelRole.getRole());
    }
    SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, selectList, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, personnel, request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : PersonnelDetailsEntity(org.mifos.customers.personnel.business.PersonnelDetailsEntity) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelRoleEntity(org.mifos.customers.personnel.business.PersonnelRoleEntity) MessageLookup(org.mifos.application.master.MessageLookup) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

OfficeBO (org.mifos.customers.office.business.OfficeBO)115 Test (org.junit.Test)62 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)45 DateTime (org.joda.time.DateTime)33 ArrayList (java.util.ArrayList)31 MeetingBO (org.mifos.application.meeting.business.MeetingBO)28 UserContext (org.mifos.security.util.UserContext)25 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)23 CenterBO (org.mifos.customers.center.business.CenterBO)21 CenterBuilder (org.mifos.domain.builders.CenterBuilder)21 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)19 MifosUser (org.mifos.security.MifosUser)18 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)17 Address (org.mifos.framework.business.util.Address)17 GroupBO (org.mifos.customers.group.business.GroupBO)16 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 GroupBuilder (org.mifos.domain.builders.GroupBuilder)14 AddressDto (org.mifos.dto.domain.AddressDto)13