Search in sources :

Example 51 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class AccountingLineAccessibleValidation method isAccountingLineFo.

// CU customization
/*
     * KFSPTS-1273
     */
private boolean isAccountingLineFo(Document document) {
    Person currentUser = GlobalVariables.getUserSession().getPerson();
    List<String> roleIds = new ArrayList<String>();
    roleIds.add(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_KIM_ROLE_NAME));
    roleIds.add(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_PRIMARY_DELEGATE_KIM_ROLE_NAME));
    roleIds.add(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_SECONDARY_DELEGATE_KIM_ROLE_NAME));
    Map<String, String> roleQualifier = new HashMap<String, String>();
    roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, document.getDocumentNumber());
    roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
    roleQualifier.put(KfsKimAttributes.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, ((FinancialSystemDocumentHeader) document.getDocumentHeader()).getFinancialDocumentTotalAmount().toString());
    roleQualifier.put(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE, accountingLineForValidation.getChartOfAccountsCode());
    roleQualifier.put(KfsKimAttributes.ACCOUNT_NUMBER, accountingLineForValidation.getAccountNumber());
    return KimApiServiceLocator.getRoleService().principalHasRole(currentUser.getPrincipalId(), roleIds, roleQualifier);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) Person(org.kuali.rice.kim.api.identity.Person)

Example 52 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImpl method processACHBatchDetail.

/**
 * Processes a single ACH batch detail, and routes a Payee ACH Account maintenance document accordingly.
 */
protected String processACHBatchDetail(PayeeACHAccountExtractDetail achDetail) {
    LOG.info("processACHBatchDetail: Starting processACHBatchDetail for: " + achDetail.getLogData());
    String processingError = null;
    Person payee = personService.getPersonByPrincipalName(achDetail.getNetID());
    processingError = validateACHBatchDetail(achDetail, payee);
    if (StringUtils.isNotBlank(processingError)) {
        return processingError;
    }
    // Check for existing ACH accounts.
    PayeeACHAccount entityAccount = achService.getAchInformation(PayeeIdTypeCodes.ENTITY, payee.getEntityId(), getDirectDepositTransactionType());
    PayeeACHAccount employeeAccount = achService.getAchInformation(PayeeIdTypeCodes.EMPLOYEE, payee.getEmployeeId(), getDirectDepositTransactionType());
    // Add or update Entity ID account.
    if (ObjectUtils.isNull(entityAccount)) {
        processingError = addACHAccount(payee, achDetail, PayeeIdTypeCodes.ENTITY);
        if (ObjectUtils.isNull(processingError)) {
            LOG.info("processACHBatchDetail: Created new ACH Account of Entity type for payee " + payee.getPrincipalName());
        } else {
            return processingError;
        }
    } else {
        processingError = updateACHAccountIfNecessary(payee, achDetail, entityAccount);
        if (ObjectUtils.isNull(processingError)) {
            LOG.info("processACHBatchDetail: Any necessary update processing performed to ACH Account of Entity type for payee " + payee.getPrincipalName());
        } else {
            return processingError;
        }
    }
    // Add or update Employee ID account.
    if (ObjectUtils.isNull(employeeAccount)) {
        processingError = addACHAccount(payee, achDetail, PayeeIdTypeCodes.EMPLOYEE);
        if (ObjectUtils.isNull(processingError)) {
            LOG.info("processACHBatchDetail: Created new ACH Account of Employee type for payee " + payee.getPrincipalName());
        } else {
            return processingError;
        }
    } else {
        processingError = updateACHAccountIfNecessary(payee, achDetail, employeeAccount);
        if (ObjectUtils.isNull(processingError)) {
            LOG.info("processACHBatchDetail: Any necessary update processing performed to ACH Account of Employee type for payee " + payee.getPrincipalName());
        } else {
            return processingError;
        }
    }
    return KFSConstants.EMPTY_STRING;
}
Also used : PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) Person(org.kuali.rice.kim.api.identity.Person)

Example 53 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuFormatAction method start.

@Override
public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CuFormatForm formatForm = (CuFormatForm) form;
    Person kualiUser = GlobalVariables.getUserSession().getPerson();
    FormatSelection formatSelection = formatService.getDataForFormat(kualiUser);
    DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
    formatForm.setCampus(kualiUser.getCampusCode());
    // no data for format because another format process is already running
    if (formatSelection.getStartDate() != null) {
        GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.Format.ERROR_PDP_FORMAT_PROCESS_ALREADY_RUNNING, dateTimeService.toDateTimeString(formatSelection.getStartDate()));
    } else {
        List<CustomerProfile> customers = formatSelection.getCustomerList();
        for (CustomerProfile element : customers) {
            if (formatSelection.getCampus().equals(element.getDefaultPhysicalCampusProcessingCode())) {
                element.setSelectedForFormat(Boolean.TRUE);
            } else {
                element.setSelectedForFormat(Boolean.FALSE);
            }
        }
        formatForm.setPaymentDate(dateTimeService.toDateString(dateTimeService.getCurrentTimestamp()));
        formatForm.setPaymentTypes(PdpConstants.PaymentTypes.ALL);
        formatForm.setPaymentDistribution(CUPdpConstants.PaymentDistributions.PROCESS_ALL);
        formatForm.setCustomers(customers);
        formatForm.setRanges(formatSelection.getRangeList());
    }
    return mapping.findForward(PdpConstants.MAPPING_SELECTION);
}
Also used : FormatSelection(org.kuali.kfs.pdp.businessobject.FormatSelection) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) Person(org.kuali.rice.kim.api.identity.Person) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService)

Example 54 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuPaymentFileServiceImpl method updatePaymentFieldsForEmployeePayee.

private void updatePaymentFieldsForEmployeePayee(PaymentFileLoad paymentFile, PaymentGroup paymentGroup) {
    LOG.debug("updatePaymentFieldsForEmployeePayee, entering");
    if (cuPdpEmployeeService.shouldPayeeBeProcessedAsEmployeeForThisCustomer(paymentFile)) {
        Person employee = personService.getPersonByEmployeeId(paymentGroup.getPayeeId());
        LOG.debug("updatePaymentFieldsForEmployeePayee, processing payee as emoployee: " + employee.getName());
        updatePayeeAddressFieldsFromPerson(paymentGroup, employee);
        paymentGroup.setEmployeeIndicator(true);
    }
}
Also used : Person(org.kuali.rice.kim.api.identity.Person)

Example 55 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuPayeeACHAccountLookupableHelperServiceImpl method getSearchResultsHelper.

/**
 * Overridden to perform custom searching when a principal name is specified on the search screen.
 *
 * @see org.kuali.kfs.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResultsHelper(java.util.Map, boolean)
 */
@SuppressWarnings("unchecked")
@Override
protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
    if (StringUtils.isNotBlank(fieldValues.get(CUPdpPropertyConstants.PAYEE_PRINCIPAL_NAME))) {
        List<PayeeACHAccount> results = null;
        // Search for people with the given principal name(s), in a manner that respects lookup criteria Strings.
        List<Person> people = personService.findPeople(Collections.singletonMap(KIMPropertyConstants.Principal.PRINCIPAL_NAME, fieldValues.get(CUPdpPropertyConstants.PAYEE_PRINCIPAL_NAME)));
        if (!people.isEmpty()) {
            // Get the users' entity IDs and employee IDs for searching.
            List<String> entityIds = new ArrayList<String>();
            List<String> employeeIds = new ArrayList<String>();
            for (Person person : people) {
                entityIds.add(person.getEntityId());
                if (StringUtils.isNotBlank(person.getEmployeeId())) {
                    employeeIds.add(person.getEmployeeId());
                }
            }
            // Create a map without blank values and with all encrypted values decrypted, similar to the ancestor class's logic.
            Map<String, String> finalFieldValues = new HashMap<String, String>();
            for (Map.Entry<String, String> entry : fieldValues.entrySet()) {
                // Only add non-blank values.
                if (StringUtils.isBlank(entry.getValue())) {
                // Do nothing.
                } else if (entry.getValue().endsWith(EncryptionService.ENCRYPTION_POST_PREFIX)) {
                    // Decrypt encrypted values accordingly, as in the ancestor class.
                    String newValue = StringUtils.removeEnd(entry.getValue(), EncryptionService.ENCRYPTION_POST_PREFIX);
                    if (getEncryptionService().isEnabled()) {
                        try {
                            newValue = getEncryptionService().decrypt(newValue);
                        } catch (GeneralSecurityException e) {
                            throw new RuntimeException("Error decrypting Payee ACH Account attribute value", e);
                        }
                    }
                    finalFieldValues.put(entry.getKey(), newValue);
                } else {
                    finalFieldValues.put(entry.getKey(), entry.getValue());
                }
            }
            // Remove "payeePrincipalName" from the map, along with any hidden or non-BO-property-related entries (like back location).
            LookupUtils.removeHiddenCriteriaFields(getBusinessObjectClass(), finalFieldValues);
            finalFieldValues.remove(CUPdpPropertyConstants.PAYEE_PRINCIPAL_NAME);
            finalFieldValues.remove(KRADConstants.BACK_LOCATION);
            finalFieldValues.remove(KRADConstants.DOC_FORM_KEY);
            finalFieldValues.remove(KRADConstants.REFERENCES_TO_REFRESH);
            // Build the sub-predicate to limit by the entity or employee IDs for the given principal names.
            Predicate principalNameEquivalentPredicate;
            if (employeeIds.isEmpty()) {
                principalNameEquivalentPredicate = PredicateFactory.and(PredicateFactory.equal(PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE, PayeeIdTypeCodes.ENTITY), PredicateFactory.in(PdpPropertyConstants.PAYEE_ID_NUMBER, entityIds.toArray(new String[entityIds.size()])));
            } else {
                principalNameEquivalentPredicate = PredicateFactory.or(PredicateFactory.and(PredicateFactory.equal(PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE, PayeeIdTypeCodes.ENTITY), PredicateFactory.in(PdpPropertyConstants.PAYEE_ID_NUMBER, entityIds.toArray(new String[entityIds.size()]))), PredicateFactory.and(PredicateFactory.equal(PdpPropertyConstants.PAYEE_IDENTIFIER_TYPE_CODE, PayeeIdTypeCodes.EMPLOYEE), PredicateFactory.in(PdpPropertyConstants.PAYEE_ID_NUMBER, employeeIds.toArray(new String[employeeIds.size()]))));
            }
            // Build the criteria and run the search.
            QueryByCriteria.Builder crit = QueryByCriteria.Builder.create();
            if (!unbounded) {
                crit.setMaxResults(LookupUtils.getSearchResultsLimit(getBusinessObjectClass()));
            }
            if (!finalFieldValues.isEmpty()) {
                crit.setPredicates(PredicateUtils.convertMapToPredicate(finalFieldValues), principalNameEquivalentPredicate);
            } else {
                crit.setPredicates(principalNameEquivalentPredicate);
            }
            results = criteriaLookupService.lookup(getBusinessObjectClass(), crit.build()).getResults();
            // Move results to a mutable list, since the result list from CriteriaLookupService is immutable.
            results = new ArrayList<PayeeACHAccount>(results);
            // Sort results accordingly using code from the ancestor class's version of the method.
            List<String> defaultSortColumns = getDefaultSortColumns();
            if (defaultSortColumns.size() > 0) {
                Collections.sort(results, new BeanPropertyComparator(defaultSortColumns, true));
            }
        }
        // If no people were found with the given principal names, then return an empty list accordingly; otherwise, return the results.
        return (results != null) ? results : new ArrayList<PayeeACHAccount>();
    } else {
        // If principal name is not specified, then do the normal superclass processing.
        return super.getSearchResultsHelper(fieldValues, unbounded);
    }
}
Also used : HashMap(java.util.HashMap) BeanPropertyComparator(org.kuali.kfs.krad.util.BeanPropertyComparator) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) GeneralSecurityException(java.security.GeneralSecurityException) ArrayList(java.util.ArrayList) Predicate(org.kuali.rice.core.api.criteria.Predicate) QueryByCriteria(org.kuali.rice.core.api.criteria.QueryByCriteria) Person(org.kuali.rice.kim.api.identity.Person) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Person (org.kuali.rice.kim.api.identity.Person)64 ArrayList (java.util.ArrayList)12 PersonService (org.kuali.rice.kim.api.identity.PersonService)12 HashMap (java.util.HashMap)10 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)8 List (java.util.List)6 AdHocRoutePerson (org.kuali.kfs.krad.bo.AdHocRoutePerson)6 Map (java.util.Map)5 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)5 Note (org.kuali.kfs.krad.bo.Note)5 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)5 DateTimeService (org.kuali.rice.core.api.datetime.DateTimeService)5 MessageMap (org.kuali.kfs.krad.util.MessageMap)4 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 Date (java.util.Date)3 ChartOrgHolder (org.kuali.kfs.sys.businessobject.ChartOrgHolder)3 AccountingXmlDocumentNote (edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentNote)2