Search in sources :

Example 41 with Person

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

the class SubmitTripWebServiceImpl method isValidDocumentInitiator.

/**
 * NOTE: The current document names that are supported by KFS are
 * - Disbursement Voucher
 * - Distribution of Income and Expense
 */
public boolean isValidDocumentInitiator(String initiatorNetId, String documentName) throws Exception {
    Person initiator = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(initiatorNetId);
    Class docClass;
    if (StringUtils.equalsIgnoreCase(documentName, "Disbursement Voucher")) {
        docClass = DisbursementVoucherDocument.class;
    } else if (StringUtils.equalsIgnoreCase(documentName, "Distribution of Income and Expense")) {
        docClass = CuDistributionOfIncomeAndExpenseDocument.class;
    }
    String documentTypeName = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(DisbursementVoucherDocument.class);
    DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(documentTypeName);
    return documentAuthorizer.canInitiate(documentTypeName, initiator);
}
Also used : PersonService(org.kuali.rice.kim.api.identity.PersonService) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) Person(org.kuali.rice.kim.api.identity.Person) DataDictionaryService(org.kuali.kfs.krad.service.DataDictionaryService) CuDistributionOfIncomeAndExpenseDocument(edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 42 with Person

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

the class CuDisbursementVoucherDocument method initiateDocument.

public void initiateDocument() {
    PhoneNumberService phoneNumberService = SpringContext.getBean(PhoneNumberService.class);
    Person currentUser = GlobalVariables.getUserSession().getPerson();
    setDisbVchrContactPersonName(currentUser.getName());
    setDisbVchrContactEmailId(currentUser.getEmailAddressUnmasked());
    String phoneNumber = currentUser.getPhoneNumber();
    if (StringUtils.isNotBlank(phoneNumber) && !StringUtils.equalsIgnoreCase("null", phoneNumber)) {
        if (!phoneNumberService.isDefaultFormatPhoneNumber(currentUser.getPhoneNumber())) {
            setDisbVchrContactPhoneNumber(phoneNumberService.formatNumberIfPossible(currentUser.getPhoneNumber()));
        } else if (StringUtils.equalsIgnoreCase(phoneNumber, "null")) {
        // do nothing... we don't want phone number set to invalid value
        } else {
            setDisbVchrContactPhoneNumber(phoneNumber);
        }
    }
    if (!phoneNumberService.isDefaultFormatPhoneNumber(currentUser.getPhoneNumber())) {
        setDisbVchrContactPhoneNumber(phoneNumberService.formatNumberIfPossible(currentUser.getPhoneNumber()));
    }
    setDisbVchrContactEmailId(currentUser.getEmailAddress());
    ChartOrgHolder chartOrg = SpringContext.getBean(org.kuali.kfs.sys.service.FinancialSystemUserService.class).getPrimaryOrganization(currentUser, KFSConstants.ParameterNamespaces.FINANCIAL);
    // the campus code via the business object service.
    if (chartOrg != null && chartOrg.getOrganization() != null) {
        setCampusCode(chartOrg.getOrganization().getOrganizationPhysicalCampusCode());
    } else // A valid campus code was not found; therefore, use the default affiliated
    // campus code.
    {
        String affiliatedCampusCode = currentUser.getCampusCode();
        setCampusCode(affiliatedCampusCode);
    }
    // due date
    Calendar calendar = getDateTimeService().getCurrentCalendar();
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    setDisbursementVoucherDueDate(new Date(calendar.getTimeInMillis()));
    // default doc location
    if (StringUtils.isBlank(getDisbursementVoucherDocumentationLocationCode())) {
        setDisbursementVoucherDocumentationLocationCode(getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.DEFAULT_DOC_LOCATION_PARM_NM));
    }
    // default bank code
    Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(this.getClass());
    if (defaultBank != null) {
        this.disbVchrBankCode = defaultBank.getBankCode();
        this.bank = defaultBank;
    }
}
Also used : PhoneNumberService(org.kuali.kfs.vnd.service.PhoneNumberService) BankService(org.kuali.kfs.sys.service.BankService) Bank(org.kuali.kfs.sys.businessobject.Bank) ChartOrgHolder(org.kuali.kfs.sys.businessobject.ChartOrgHolder) Calendar(java.util.Calendar) Person(org.kuali.rice.kim.api.identity.Person) Date(java.sql.Date) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 43 with Person

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

the class CuDisbursementVoucherEmployeeInformationValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("validate start");
    boolean isValid = true;
    CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) getAccountingDocumentForValidation();
    DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
    if (!payeeDetail.isEmployee() || payeeDetail.isVendor() || !(document.getDocumentHeader().getWorkflowDocument().isInitiated() || document.getDocumentHeader().getWorkflowDocument().isSaved())) {
        return true;
    }
    String employeeId = payeeDetail.getDisbVchrPayeeIdNumber();
    Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(employeeId);
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    boolean stateIsInitiated = workflowDocument.isInitiated() || workflowDocument.isSaved();
    if (ObjectUtils.isNull(employee)) {
        employee = SpringContext.getBean(PersonService.class).getPerson(employeeId);
    } else {
        if (!KFSConstants.EMPLOYEE_ACTIVE_STATUS.equals(employee.getEmployeeStatusCode()) && !CUKFSConstants.EMPLOYEE_RETIRED_STATUS.equals(employee.getEmployeeStatusCode())) {
            // If employee is found, then check that employee is active or retired if the doc has not already been routed.
            if (stateIsInitiated) {
                String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
                errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_INACTIVE, label);
                isValid = false;
            }
        }
    }
    // check existence of employee
    if (employee == null) {
        // If employee is not found, report existence error
        String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
        errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_EXISTENCE, label);
        isValid = false;
    }
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PersonService(org.kuali.rice.kim.api.identity.PersonService) DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) Person(org.kuali.rice.kim.api.identity.Person) MessageMap(org.kuali.kfs.krad.util.MessageMap) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Example 44 with Person

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

the class CuDisbursementVoucherPayeeInitiatorValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("validate start");
    boolean isValid = true;
    CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) accountingDocumentForValidation;
    CuDisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    String uuid = null;
    // If payee is a vendor, then look up SSN and look for SSN in the employee table
    if (payeeDetail.isVendor() && StringUtils.isNotBlank(payeeDetail.getDisbVchrVendorHeaderIdNumber())) {
        VendorDetail dvVendor = retrieveVendorDetail(payeeDetail.getDisbVchrVendorHeaderIdNumberAsInteger(), payeeDetail.getDisbVchrVendorDetailAssignedIdNumberAsInteger());
        // if the vendor tax type is SSN, then check the tax number
        if (dvVendor != null && TAX_TYPE_SSN.equals(dvVendor.getVendorHeader().getVendorTaxTypeCode())) {
            // check ssn against employee table
            Person user = retrieveEmployeeBySSN(dvVendor.getVendorHeader().getVendorTaxNumber());
            if (user != null) {
                uuid = user.getPrincipalId();
            }
        }
    } else if (payeeDetail.isEmployee()) {
        Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeDetail.getDisbVchrEmployeeIdNumber());
        uuid = employee.getPrincipalId();
    } else if (payeeDetail.isStudent() || payeeDetail.isAlumni()) {
        uuid = payeeDetail.getDisbVchrPayeeIdNumber();
    }
    // If a uuid was found for payee, check it against the initiator uuid
    if (StringUtils.isNotBlank(uuid)) {
        Person initUser = getInitiator(document);
        if (uuid.equals(initUser.getPrincipalId())) {
            errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_PAYEE_INITIATOR);
            isValid = false;
        }
    }
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) CuDisbursementVoucherPayeeDetail(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail) Person(org.kuali.rice.kim.api.identity.Person) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 45 with Person

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

the class DisbursementVoucherAction method setupPayeeAsEmployee.

/**
 * setup the payee as an employee with the given id number
 */
protected void setupPayeeAsEmployee(DisbursementVoucherForm dvForm, String payeeIdNumber) {
    Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
    if (person != null) {
        ((DisbursementVoucherDocument) dvForm.getDocument()).templateEmployee(person);
        dvForm.setTempPayeeIdNumber(payeeIdNumber);
        dvForm.setOldPayeeType(KFSConstants.PaymentPayeeTypes.EMPLOYEE);
    } else {
        LOG.error("Exception while attempting to retrieve universal user by universal user id " + payeeIdNumber);
    }
}
Also used : PersonService(org.kuali.rice.kim.api.identity.PersonService) Person(org.kuali.rice.kim.api.identity.Person) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

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