Search in sources :

Example 1 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.

@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
    final Short branchId = userContext.getBranchId();
    final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
    List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
    List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
    List<CustomerDto> customerList = new ArrayList<CustomerDto>();
    List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
    Short reloadFormAutomatically = Constants.YES;
    final Short backDatedTransactionAllowed = Constants.NO;
    try {
        final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
        paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
        activeBranches = officePersistence.getActiveOffices(branchId);
        if (activeBranches.size() == 1) {
            loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
            if (loanOfficerList.size() == 1) {
                Short customerLevel;
                if (centerHierarchyExists.equals(Constants.YES)) {
                    customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
                } else {
                    customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
                }
                customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
                if (customerList.size() == 1) {
                    reloadFormAutomatically = Constants.YES;
                }
                reloadFormAutomatically = Constants.NO;
            }
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
    return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class ClientServiceFacadeWebTier method retreiveClientDetailsForRemovalFromGroup.

@Override
public ClientRemovalFromGroupDto retreiveClientDetailsForRemovalFromGroup(String globalCustNum) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
        client.updateDetails(userContext);
        client.checkIfClientIsATitleHolder();
        List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
        boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
        boolean isActive = client.isActive();
        Short loanOfficerId = client.getPersonnel().getPersonnelId();
        CenterCreation clientDetails = new CenterCreation(client.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(clientDetails);
        return new ClientRemovalFromGroupDto(client.getGlobalCustNum(), isActive, isCenterHierarchyExists, loanOfficerId, loanOfficers, activeBranches);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ClientRemovalFromGroupDto(org.mifos.dto.screen.ClientRemovalFromGroupDto) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) BusinessRuleException(org.mifos.service.BusinessRuleException) CenterCreation(org.mifos.dto.domain.CenterCreation)

Example 3 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class OfficeServiceFacadeWebTier method retrieveOfficeDetailsForEdit.

@Override
public OfficeDetailsForEdit retrieveOfficeDetailsForEdit(String officeLevel) {
    List<OfficeDetailsDto> parents = new ArrayList<OfficeDetailsDto>();
    if (StringUtils.isNotBlank(officeLevel)) {
        parents = retrieveActiveParentOffices(Short.valueOf(officeLevel));
    }
    try {
        List<OfficeDetailsDto> configuredOfficeLevels = new OfficePersistence().getActiveLevels();
        for (OfficeDetailsDto officeDetailsDto : configuredOfficeLevels) {
            String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
            officeDetailsDto.setLevelName(levelName);
        }
        List<OfficeDetailsDto> statusList = new OfficePersistence().getStatusList();
        for (OfficeDetailsDto officeDetailsDto : statusList) {
            officeDetailsDto.setLevelName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey()));
        }
        return new OfficeDetailsForEdit(parents, statusList, configuredOfficeLevels);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficeDetailsForEdit(org.mifos.dto.screen.OfficeDetailsForEdit) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class OfficeServiceFacadeWebTier method retrieveActiveParentOffices.

@Override
public List<OfficeDetailsDto> retrieveActiveParentOffices(Short officeLevelId) {
    OfficeLevel Level = OfficeLevel.getOfficeLevel(officeLevelId);
    try {
        List<OfficeDetailsDto> officeParents = new OfficePersistence().getActiveParents(Level);
        for (OfficeDetailsDto officeDetailsDto : officeParents) {
            String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
            officeDetailsDto.setLevelName(levelName);
        }
        return officeParents;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : MessageLookup(org.mifos.application.master.MessageLookup) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) OfficeLevel(org.mifos.customers.office.util.helpers.OfficeLevel) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class OfficeListTag method getOfficeList.

String getOfficeList(Locale preferredUserLocale, List<OfficeDetailsDto> levels, String loggedInOfficeSearchId, List<OfficeHierarchyDto> officeHierarchy, List<OfficeBO> officesTillBranchOffice) {
    String termForBranch = "";
    String regional = "";
    String subregional = "";
    String area = "";
    for (OfficeDetailsDto level : levels) {
        if (level.getLevelId().equals(OfficeLevel.BRANCHOFFICE.getValue())) {
            termForBranch = level.getLevelName();
        } else if (level.getLevelId().equals(OfficeLevel.AREAOFFICE.getValue())) {
            area = level.getLevelName();
        } else if (level.getLevelId().equals(OfficeLevel.REGIONALOFFICE.getValue())) {
            regional = level.getLevelName();
        } else if (level.getLevelId().equals(OfficeLevel.SUBREGIONALOFFICE.getValue())) {
            subregional = level.getLevelName();
        }
    }
    XmlBuilder result = new XmlBuilder();
    if (onlyBranchOffices != null) {
        getBranchOffices(result, officeHierarchy, preferredUserLocale, loggedInOfficeSearchId, termForBranch);
    } else {
        getAboveBranches(result, officesTillBranchOffice, regional, subregional, area);
        getBranchOffices(result, officeHierarchy, preferredUserLocale, loggedInOfficeSearchId, termForBranch);
    }
    return result.getOutput();
}
Also used : XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

Aggregations

OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)37 PersonnelDto (org.mifos.dto.domain.PersonnelDto)19 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)13 CustomerDto (org.mifos.dto.domain.CustomerDto)10 Date (java.util.Date)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 UserContext (org.mifos.security.util.UserContext)6 CollectionSheetEntryGridDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)5 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)5 OfficeDto (org.mifos.dto.domain.OfficeDto)5 CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)4 MessageLookup (org.mifos.application.master.MessageLookup)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 MifosUser (org.mifos.security.MifosUser)4 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)3