Search in sources :

Example 71 with OfficeBO

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

the class PersonAction method translateFormToCreatePersonnelInformationDto.

@SuppressWarnings("unchecked")
private CreateOrUpdatePersonnelInformation translateFormToCreatePersonnelInformationDto(HttpServletRequest request, PersonActionForm personActionForm) throws PageExpiredException, InvalidDateException {
    UserContext userContext = getUserContext(request);
    PersonnelLevel level = PersonnelLevel.fromInt(getShortValue(personActionForm.getLevel()));
    PersonnelStatus personnelStatus = PersonnelStatus.ACTIVE;
    if (StringUtils.isNotBlank(personActionForm.getStatus())) {
        personnelStatus = PersonnelStatus.getPersonnelStatus(getShortValue(personActionForm.getStatus()));
    }
    OfficeBO office = (OfficeBO) SessionUtils.getAttribute(PersonnelConstants.OFFICE, request);
    if (office == null) {
        Short officeId = getShortValue(personActionForm.getOfficeId());
        office = this.officeDao.findOfficeById(officeId);
    }
    Integer title = getIntegerValue(personActionForm.getTitle());
    Short preferredLocale = Localization.getInstance().getConfiguredLocaleId();
    preferredLocale = getPerefferedLocale(personActionForm, userContext);
    Date dob = null;
    if (personActionForm.getDob() != null && !personActionForm.getDob().equals("")) {
        dob = DateUtils.getDate(personActionForm.getDob());
    }
    Date dateOfJoiningMFI = null;
    if (personActionForm.getDateOfJoiningMFI() != null && !personActionForm.getDateOfJoiningMFI().equals("")) {
        dateOfJoiningMFI = DateUtils.getDateAsSentFromBrowser(personActionForm.getDateOfJoiningMFI());
    }
    Date passwordExpirationDate = null;
    if (personActionForm.getPasswordExpirationDate() != null && !personActionForm.getPasswordExpirationDate().equals("")) {
        passwordExpirationDate = DateUtils.getDate(personActionForm.getPasswordExpirationDate());
    }
    List<RoleBO> roles = new ArrayList<RoleBO>();
    boolean addFlag = false;
    List<RoleBO> selectList = new ArrayList<RoleBO>();
    List<RoleBO> masterList = (List<RoleBO>) SessionUtils.getAttribute(PersonnelConstants.ROLEMASTERLIST, request);
    if (personActionForm.getPersonnelRoles() != null) {
        for (RoleBO role : masterList) {
            for (String roleId : personActionForm.getPersonnelRoles()) {
                if (roleId != null && role.getId().intValue() == Integer.valueOf(roleId).intValue()) {
                    selectList.add(role);
                    addFlag = true;
                }
            }
        }
    }
    if (addFlag) {
        roles = selectList;
    }
    List<ListElement> roleList = new ArrayList<ListElement>();
    for (RoleBO element : roles) {
        ListElement listElement = new ListElement(new Integer(element.getId()), element.getName());
        roleList.add(listElement);
    }
    Address address = personActionForm.getAddress();
    AddressDto addressDto = new AddressDto(address.getLine1(), address.getLine2(), address.getLine3(), address.getCity(), address.getState(), address.getCountry(), address.getZip(), address.getPhoneNumber());
    Long id = null;
    if (StringUtils.isNotBlank(personActionForm.getPersonnelId())) {
        id = Long.valueOf(personActionForm.getPersonnelId());
    }
    CreateOrUpdatePersonnelInformation perosonnelInfo = new CreateOrUpdatePersonnelInformation(id, level.getValue(), office.getOfficeId(), title, preferredLocale, personActionForm.getUserPassword(), personActionForm.getLoginName(), personActionForm.getEmailId(), roleList, personActionForm.getCustomFields(), personActionForm.getFirstName(), personActionForm.getMiddleName(), personActionForm.getLastName(), personActionForm.getSecondLastName(), personActionForm.getGovernmentIdNumber(), new DateTime(dob), getIntegerValue(personActionForm.getMaritalStatus()), getIntegerValue(personActionForm.getGender()), new DateTime(dateOfJoiningMFI), new DateTimeService().getCurrentDateTime(), addressDto, personnelStatus.getValue(), new DateTime(passwordExpirationDate));
    return perosonnelInfo;
}
Also used : Address(org.mifos.framework.business.util.Address) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) Date(java.util.Date) DateTime(org.joda.time.DateTime) PersonnelStatus(org.mifos.customers.personnel.util.helpers.PersonnelStatus) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) OfficeBO(org.mifos.customers.office.business.OfficeBO) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) List(java.util.List) ArrayList(java.util.ArrayList) PersonnelLevel(org.mifos.customers.personnel.util.helpers.PersonnelLevel) DateTimeService(org.mifos.framework.util.DateTimeService) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO)

Example 72 with OfficeBO

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

the class PersonAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm personActionForm = (PersonActionForm) form;
    Short officeId = getShortValue(personActionForm.getOfficeId());
    OfficeBO office = this.officeDao.findOfficeById(officeId);
    SessionUtils.setAttribute(PersonnelConstants.OFFICE, office, request);
    personActionForm.clear();
    //Shahid - keeping the previous session objects for the sake of existing tests, once fully converted to spring
    //then we can get rid of the session objects made redundant by the dto
    DefinePersonnelDto definePersonnelDto = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId);
    SessionUtils.setAttribute("definePersonnelDto", definePersonnelDto, request);
    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();
    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> customFieldDefs1 = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs1, request);
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    personActionForm.setCustomFields(customFields);
    if (office.getOfficeLevel() != OfficeLevel.BRANCHOFFICE) {
        for (MasterDataEntity level : personnelLevels) {
            if (level.getId().equals(PersonnelLevel.LOAN_OFFICER.getValue())) {
                personnelLevels.remove(level);
                break;
            }
        }
    }
    personActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    personActionForm.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) OfficeBO(org.mifos.customers.office.business.OfficeBO) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 73 with OfficeBO

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

the class OffAction method edit.

@TransactionDemarcate(joinToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    OfficeDto sessionOffice = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
    OfficeBO office = this.officeDao.findOfficeById(sessionOffice.getOfficeId());
    checkVersionMismatch(sessionOffice.getVersionNum(), office.getVersionNo());
    String officeLevel = request.getParameter("officeLevel");
    OfficeDetailsForEdit officeDetailsForEdit = this.officeServiceFacade.retrieveOfficeDetailsForEdit(officeLevel);
    if (StringUtils.isNotBlank(officeLevel)) {
        offActionForm.setOfficeLevel(officeLevel);
        List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
        OfficeDto office1 = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
        if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office1 != null) {
            for (int i = 0; i < parents.size(); i++) {
                OfficeDetailsDto view = parents.get(i);
                if (view.getOfficeId().equals(office1.getOfficeId())) {
                    parents.remove(view);
                }
            }
        }
        SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
    }
    offActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeDetailsForEdit.getConfiguredOfficeLevels(), request);
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICESTATUSLIST, officeDetailsForEdit.getStatusList(), request);
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    return mapping.findForward(ActionForwards.edit_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsForEdit(org.mifos.dto.screen.OfficeDetailsForEdit) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 74 with OfficeBO

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

the class GroupServiceFacadeWebTierIntegrationTest method shouldTransferGroupFromOfficeToOffice.

@Test
public void shouldTransferGroupFromOfficeToOffice() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    ClientRules.setCenterHierarchyExists(false);
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId1 = branch1.getOfficeId();
    CustomerDetailsDto group1Details = createGroup("group1", officeId1);
    Short officeId2 = branch2.getOfficeId();
    CustomerDetailsDto group2Details = createGroup("group2", officeId2);
    CustomerDetailsDto newlyCreatedCustomerDetails = createClient(group1Details.getId().toString());
    GroupBO group1 = customerDao.findGroupBySystemId(group1Details.getGlobalCustNum());
    groupServiceFacade.transferGroupToBranch(group1Details.getGlobalCustNum(), officeId2, group1.getVersionNo());
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Example 75 with OfficeBO

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

the class GroupServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithActivationDateInPast.

@Test
public void shouldCreateGroupWithActivationDateInPast() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
    MeetingDto meetingDto = meeting.toDto();
    String displayName = "testGroup";
    String externalId = null;
    AddressDto addressDto = null;
    PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
    Short loanOfficerId = user.getPersonnelId();
    List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
    Short customerStatus = CustomerStatus.GROUP_ACTIVE.getValue();
    boolean trained = false;
    DateTime trainedOn = null;
    String parentSystemId = null;
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    // setup
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId = branch1.getOfficeId();
    DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
    DateTime activationDate = new DateTime().minusWeeks(1);
    GroupCreationDetail groupCenterDetail = new GroupCreationDetail(displayName, externalId, addressDto, loanOfficerId, feesToApply, customerStatus, trained, trainedOn, parentSystemId, officeId, mfiJoiningDate, activationDate);
    // exercise test
    ClientRules.setCenterHierarchyExists(false);
    CustomerDetailsDto newlyCreatedGroupDetails = groupServiceFacade.createNewGroup(groupCenterDetail, meetingDto);
    // verification
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
    GroupBO group = customerDao.findGroupBySystemId(newlyCreatedGroupDetails.getGlobalCustNum());
    Assert.assertThat(new LocalDate(group.getCustomerActivationDate()), is(activationDate.toLocalDate()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) MeetingDto(org.mifos.dto.domain.MeetingDto) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

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