Search in sources :

Example 11 with CuDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method buildCuDisbursementVoucherDocument.

private CuDisbursementVoucherDocument buildCuDisbursementVoucherDocument(RecurringDisbursementVoucherDocument recurringDV) throws WorkflowException {
    CuDisbursementVoucherDocument dv = (CuDisbursementVoucherDocument) getDocumentService().getNewDocument(CuDisbursementVoucherDocument.class);
    dv.setDisbVchrContactPersonName(recurringDV.getDisbVchrContactPersonName());
    dv.setDisbVchrContactPhoneNumber(recurringDV.getDisbVchrContactPhoneNumber());
    dv.setDisbVchrContactEmailId(recurringDV.getDisbVchrContactEmailId());
    dv.setDisbVchrAttachmentCode(recurringDV.isDisbVchrAttachmentCode());
    dv.setDisbVchrSpecialHandlingCode(recurringDV.isDisbVchrSpecialHandlingCode());
    dv.setDisbVchrForeignCurrencyInd(recurringDV.isDisbVchrForeignCurrencyInd());
    dv.setDisbursementVoucherDocumentationLocationCode(recurringDV.getDisbursementVoucherDocumentationLocationCode());
    dv.setDisbVchrCheckStubText(recurringDV.getDisbVchrCheckStubText());
    dv.setDvCheckStubOverflowCode(recurringDV.getDvCheckStubOverflowCode());
    dv.setCampusCode(recurringDV.getCampusCode());
    dv.setDisbVchrPayeeTaxControlCode(recurringDV.getDisbVchrPayeeTaxControlCode());
    dv.setDisbVchrPayeeChangedInd(recurringDV.isDisbVchrPayeeChangedInd());
    dv.setExceptionIndicator(recurringDV.isExceptionIndicator());
    dv.setDisbursementVoucherPdpStatus(recurringDV.getDisbursementVoucherPdpStatus());
    dv.setDisbVchrBankCode(recurringDV.getDisbVchrBankCode());
    dv.setPayeeAssigned(recurringDV.isPayeeAssigned());
    dv.setEditW9W8BENbox(recurringDV.isEditW9W8BENbox());
    dv.setDisbVchrPdpBankCode(recurringDV.getDisbVchrPdpBankCode());
    dv.setImmediatePaymentIndicator(recurringDV.isImmediatePaymentIndicator());
    dv.setDisbExcptAttachedIndicator(recurringDV.isDisbExcptAttachedIndicator());
    dv.setDisbVchrPayeeW9CompleteCode(recurringDV.getDisbVchrPayeeW9CompleteCode());
    dv.setDisbVchrPaymentMethodCode(recurringDV.getDisbVchrPaymentMethodCode());
    CuDisbursementVoucherPayeeDetail payeeDetail = (CuDisbursementVoucherPayeeDetail) ObjectUtils.deepCopy(recurringDV.getDvPayeeDetail());
    payeeDetail.setDocumentNumber(dv.getDocumentNumber());
    dv.setDvPayeeDetail(payeeDetail);
    PaymentSourceWireTransfer wireTransfer = (PaymentSourceWireTransfer) ObjectUtils.deepCopy(recurringDV.getWireTransfer());
    wireTransfer.setDocumentNumber(dv.getDocumentNumber());
    dv.setWireTransfer(wireTransfer);
    DisbursementVoucherNonEmployeeTravel nonEmployeeTravel = (DisbursementVoucherNonEmployeeTravel) ObjectUtils.deepCopy(recurringDV.getDvNonEmployeeTravel());
    nonEmployeeTravel.setDocumentNumber(dv.getDocumentNumber());
    dv.setDvNonEmployeeTravel(nonEmployeeTravel);
    DisbursementVoucherNonResidentAlienTax nonAlienTax = (DisbursementVoucherNonResidentAlienTax) ObjectUtils.deepCopy(recurringDV.getDvNonResidentAlienTax());
    nonAlienTax.setDocumentNumber(dv.getDocumentNumber());
    dv.setDvNonResidentAlienTax(nonAlienTax);
    DisbursementVoucherPreConferenceDetail conferenceDetail = (DisbursementVoucherPreConferenceDetail) ObjectUtils.deepCopy(recurringDV.getDvPreConferenceDetail());
    conferenceDetail.setDocumentNumber(dv.getDocumentNumber());
    dv.setDvPreConferenceDetail(conferenceDetail);
    return dv;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) DisbursementVoucherNonEmployeeTravel(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel) DisbursementVoucherPreConferenceDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceDetail) PaymentSourceWireTransfer(org.kuali.kfs.sys.businessobject.PaymentSourceWireTransfer) CuDisbursementVoucherPayeeDetail(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail) DisbursementVoucherNonResidentAlienTax(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonResidentAlienTax)

Example 12 with CuDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method autoApproveDisbursementVouchersSpawnedByRecurringDvs.

@Override
public boolean autoApproveDisbursementVouchersSpawnedByRecurringDvs() {
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Entered.");
    int approvalCount = 0;
    int errorCount = 0;
    List<String> dvDocIdsCausingError = new ArrayList<String>();
    Collection<String> dvDocIds = getRecurringDisbursementVoucherSearchDao().findSavedDvIdsSpawnedByRecurringDvForCurrentAndPastFiscalPeriods(getCurrentFiscalPeriodEndDate());
    if (ObjectUtils.isNotNull(dvDocIds) && !(dvDocIds.isEmpty())) {
        for (String dvDocId : dvDocIds) {
            LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Processing start for DV ID:: " + dvDocId);
            CuDisbursementVoucherDocument dv = null;
            try {
                dv = getDisbursementVoucher(dvDocId);
            } catch (WorkflowException e) {
                dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                errorCount++;
            }
            if (ObjectUtils.isNotNull(dv)) {
                if (isKfsSystemUserDvInitiator(dv)) {
                    try {
                        addNoteToAutoApproveDv(dv, "Batch job Submit and Blanket Approve performed for DV spawned by Recurring DV.");
                        try {
                            blanketApproveDisbursementVoucherDocument(dv);
                            approvalCount++;
                        } catch (WorkflowException e) {
                            dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                            errorCount++;
                        }
                    } catch (WorkflowException e) {
                        dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                        errorCount++;
                    }
                } else {
                    LOG.error("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Detected document initiator was not KFS System user. Auto blanket approval was NOT attemtped for document ID: " + dv.getDocumentNumber());
                    dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                    errorCount++;
                }
            }
        }
    } else {
        LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: No DV's spwned by Recurring DV found. Nothing will be auto approved. ");
    }
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: **************** Batch Job Processing Results ****************");
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Number of Disbursement Vouchers that generated Errors:: " + errorCount);
    for (Iterator iterator = dvDocIdsCausingError.iterator(); iterator.hasNext(); ) {
        LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Erroring " + (String) iterator.next());
    }
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Number of Disbursement Vouchers successfuly Blanket Approved (fully processed):: " + approvalCount);
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Leaving.");
    return errorCount == 0;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 13 with CuDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument 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 14 with CuDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument 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 15 with CuDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherAction method setupPayeeAsStudent.

/**
 * setup the payee as an student with the given id number
 */
protected void setupPayeeAsStudent(CuDisbursementVoucherForm dvForm, String payeeIdNumber) {
    Person person = (Person) SpringContext.getBean(PersonService.class).getPerson(payeeIdNumber);
    if (person != null) {
        ((CuDisbursementVoucherDocument) dvForm.getDocument()).templateStudent(person);
        dvForm.setTempPayeeIdNumber(payeeIdNumber);
        dvForm.setOldPayeeType(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_STUDENT);
    } else {
        LOG.error("Exception while attempting to retrieve universal user by universal user id " + payeeIdNumber);
    }
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Person(org.kuali.rice.kim.api.identity.Person)

Aggregations

CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)20 Person (org.kuali.rice.kim.api.identity.Person)7 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)5 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 CULegacyTravelService (edu.cornell.kfs.fp.document.service.CULegacyTravelService)3 Date (java.sql.Date)3 DocumentService (org.kuali.kfs.krad.service.DocumentService)3 MessageMap (org.kuali.kfs.krad.util.MessageMap)3 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)3 VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)3 PersonService (org.kuali.rice.kim.api.identity.PersonService)3 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)2 RecurringDisbursementVoucherDetail (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail)2 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)2 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)2 VendorService (org.kuali.kfs.vnd.document.service.VendorService)2