Search in sources :

Example 1 with CuDisbursementVoucherDocument

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

the class CuDisbursementVoucherAction method createDVFromIWantDoc.

/**
 * Creates a DV document based on information on an I Want document.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward createDVFromIWantDoc(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    String iWantDocumentNumber = request.getParameter("docId");
    CuDisbursementVoucherForm disbursementVoucherForm = (CuDisbursementVoucherForm) form;
    IWantDocument iWantDocument = (IWantDocument) getDocumentService().getByDocumentHeaderId(iWantDocumentNumber);
    // Do not allow the DV to be created if the IWNT doc is already associated with another DV.
    if (iWantDocument != null && (StringUtils.isNotBlank(iWantDocument.getReqsDocId()) || StringUtils.isNotBlank(iWantDocument.getDvDocId()))) {
        GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, CUPurapKeyConstants.ERROR_DV_OR_REQ_ALREADY_CREATED_FROM_IWNT, iWantDocumentNumber);
        return mapping.findForward("error");
    }
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    createDocument(disbursementVoucherForm);
    CuDisbursementVoucherDocument disbursementVoucherDocument = (CuDisbursementVoucherDocument) disbursementVoucherForm.getDocument();
    iWantDocumentService.setUpDVDetailsFromIWantDoc(iWantDocument, disbursementVoucherDocument, disbursementVoucherForm);
    // Set the DV doc ID reference on the IWantDocument.
    iWantDocument.setDvDocId(disbursementVoucherDocument.getDocumentNumber());
    SpringContext.getBean(PurapService.class).saveDocumentNoValidation(iWantDocument);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Example 2 with CuDisbursementVoucherDocument

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

the class CuDisbursementVoucherAction method setupPayeeAsEmployee.

protected void setupPayeeAsEmployee(CuDisbursementVoucherForm dvForm, String payeeIdNumber) {
    Person person = (Person) SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
    if (person == null) {
        person = (Person) SpringContext.getBean(PersonService.class).getPerson(payeeIdNumber);
    }
    if (person != null) {
        ((CuDisbursementVoucherDocument) 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 : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) PersonService(org.kuali.kfs.kim.api.identity.PersonService) Person(org.kuali.kfs.kim.api.identity.Person)

Example 3 with CuDisbursementVoucherDocument

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

the class CuDisbursementVoucherAction method setupPayeeAsAlumni.

/**
 * setup the payee as an alumni with the given id number
 */
protected void setupPayeeAsAlumni(CuDisbursementVoucherForm dvForm, String payeeIdNumber) {
    Person person = (Person) SpringContext.getBean(PersonService.class).getPerson(payeeIdNumber);
    if (person != null) {
        ((CuDisbursementVoucherDocument) dvForm.getDocument()).templateAlumni(person);
        dvForm.setTempPayeeIdNumber(payeeIdNumber);
        dvForm.setOldPayeeType(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_ALUMNI);
    } 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.kfs.kim.api.identity.Person)

Example 4 with CuDisbursementVoucherDocument

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

the class SubmitTripWebServiceImpl method buildDisbursementVoucher.

/**
 * @param dvDescription
 * @param dvExplanation
 * @param tripNumber
 * @param travelerNetId
 * @param initiatorNetId
 * @param totalAmount
 * @param checkStubText
 * @return
 * @throws Exception
 */
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
    try {
        if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
            throw new RuntimeException("Initiator identified does not have permission to create a DV.");
        }
    } catch (Exception ex) {
        throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
    }
    // create and route doc as system user
    GlobalVariables.setUserSession(new UserSession(initiatorNetId));
    MessageMap documentErrorMap = new MessageMap();
    GlobalVariables.setMessageMap(documentErrorMap);
    // Create document with description provided
    CuDisbursementVoucherDocument dvDoc = null;
    try {
        dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (dvDoc != null) {
        dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
        dvDoc.getDocumentHeader().setExplanation(dvExplanation);
        dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
        dvDoc.initiateDocument();
        // Set vendor to traveler using netID provided
        Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
        for (EntityAffiliation entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
            if (entityAffiliation.isDefaultValue()) {
                if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
                    dvDoc.templateStudent(traveler);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
                    dvDoc.templateAlumni(traveler);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
                    dvDoc.templateEmployee(traveler);
                }
            }
        }
        dvDoc.setPayeeAssigned(true);
        dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
        dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
        dvDoc.setDisbVchrPaymentMethodCode("P");
        dvDoc.setDisbVchrCheckStubText(checkStubText);
        dvDoc.setTripId(tripNumber);
        dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
        // Persist document
        SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
        return dvDoc.getDocumentNumber();
    } else {
        return "";
    }
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) EntityAffiliation(org.kuali.kfs.kim.impl.identity.affiliation.EntityAffiliation) PersonImpl(org.kuali.kfs.kim.impl.identity.PersonImpl) UserSession(org.kuali.kfs.krad.UserSession) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) PersonService(org.kuali.kfs.kim.api.identity.PersonService) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) Person(org.kuali.kfs.kim.api.identity.Person) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) MessageMap(org.kuali.kfs.krad.util.MessageMap) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 5 with CuDisbursementVoucherDocument

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

the class CuDisbursementVoucherDocumentPresentationController method addTravelSystemGeneratedEntryMode.

/**
 * If the DV was generated from a connection with the Cornell Travel System, enforces special edit rules regarding information on the disbursement voucher.
 *
 * Added condition that DV is not in the Payment Method Reviewers' queue, as the check amount needs to be editable for that circustance.
 *
 * @param document the disbursement voucher document authorization is being sought on
 * @param editModes the edit modes so far, which can be added to
 */
protected void addTravelSystemGeneratedEntryMode(Document document, Set<String> editModes) {
    final CuDisbursementVoucherDocument dvDocument = (CuDisbursementVoucherDocument) document;
    final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
    boolean isAssociatedWithTrip = SpringContext.getBean(CULegacyTravelService.class).isCULegacyTravelIntegrationInterfaceAssociatedWithTrip(dvDocument);
    if (isAssociatedWithTrip && !currentRouteLevels.contains(KFSConstants.RouteLevelNames.PAYMENT_METHOD)) {
        LOG.info("Checking travel system generated entry permissions.");
        editModes.add(CUKFSAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_SYSTEM_GENERATED_ENTRY);
    }
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) CULegacyTravelService(edu.cornell.kfs.fp.document.service.CULegacyTravelService)

Aggregations

CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)21 Person (org.kuali.kfs.kim.api.identity.Person)7 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)5 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)4 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)4 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)3 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 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 DisbursementVoucherNonEmployeeTravel (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel)2 DisbursementVoucherPreConferenceDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceDetail)2 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)2