Search in sources :

Example 31 with WorkflowDocument

use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAmendmentDocumentPresentationController method getEditModes.

@Override
public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
    if (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(poDocument.getApplicationDocumentStatus())) {
        WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
        // amendment doc needs to lock its field for initiator while enroute
        if (workflowDocument.isInitiated() || workflowDocument.isSaved() || workflowDocument.isCompletionRequested()) {
            editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
        }
    }
    // KFSUPGRADE-339
    if (PurchaseOrderStatuses.APPDOC_AWAITING_FISCAL_REVIEW.equals(((PurchaseOrderDocument) document).getApplicationDocumentStatus())) {
        editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
    }
    if (SpringContext.getBean(PurapService.class).isDocumentStoppedInRouteNode((PurchasingAccountsPayableDocument) document, "New Unordered Items")) {
        editModes.add(PurchaseOrderEditMode.UNORDERED_ITEM_ACCOUNT_ENTRY);
    }
    boolean showDisableRemoveAccounts = true;
    PurchaseOrderAmendmentDocument purchaseOrderAmendmentDocument = (PurchaseOrderAmendmentDocument) document;
    List<PurApItem> aboveTheLinePOItems = PurApItemUtils.getAboveTheLineOnly(purchaseOrderAmendmentDocument.getItems());
    PurchaseOrderDocument po = (PurchaseOrderDocument) document;
    boolean containsUnpaidPaymentRequestsOrCreditMemos = po.getContainsUnpaidPaymentRequestsOrCreditMemos();
    ItemLoop: for (PurApItem poItem : aboveTheLinePOItems) {
        boolean acctLinesEditable = allowAccountingLinesAreEditable((PurchaseOrderItem) poItem, containsUnpaidPaymentRequestsOrCreditMemos);
        for (PurApAccountingLine poAccoutingLine : poItem.getSourceAccountingLines()) {
            if (!acctLinesEditable) {
                showDisableRemoveAccounts = false;
                break ItemLoop;
            }
        }
    }
    if (!showDisableRemoveAccounts) {
        editModes.add(PurchaseOrderEditMode.DISABLE_REMOVE_ACCTS);
    }
    // KFSPTS-985
    if (document instanceof PurchaseOrderDocument && !editModes.contains(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION) && !hasEmptyAcctline((PurchaseOrderDocument) document)) {
        editModes.add(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION);
    }
    return editModes;
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument)

Example 32 with WorkflowDocument

use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class CuRequisitionAccountingLineAuthorizer method renderNewLine.

@Override
public boolean renderNewLine(AccountingDocument accountingDocument, String accountingGroupProperty) {
    WorkflowDocument workflowDocument = ((PurchasingAccountsPayableDocument) accountingDocument).getFinancialSystemDocumentHeader().getWorkflowDocument();
    Set<String> currentNodes = workflowDocument.getCurrentNodeNames();
    if (CollectionUtils.isNotEmpty(currentNodes) && (currentNodes.contains(RequisitionAccountingLineAuthorizer.INITIATOR_NODE) || currentNodes.contains(RequisitionAccountingLineAuthorizer.CONTENT_REVIEW_NODE)) || (currentNodes.contains(RequisitionStatuses.NODE_ACCOUNT) && SpringContext.getBean(CuPurapAccountingService.class).isFiscalOfficersForAllAcctLines((RequisitionDocument) accountingDocument))) {
        return true;
    }
    return super.renderNewLine(accountingDocument, accountingGroupProperty);
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument)

Example 33 with WorkflowDocument

use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method buildDocumentFinalizedMessage.

/**
 * Builds an email message to be sent when the input document has been finalized.
 *
 * @param iWantDocument
 * @return an email message to be sent when the input document has been finalized
 */
private BodyMailMessage buildDocumentFinalizedMessage(IWantDocument iWantDocument) {
    WorkflowDocument workflowDocument = iWantDocument.getDocumentHeader().getWorkflowDocument();
    String initiator = workflowDocument.getInitiatorPrincipalId();
    String documentNumber = iWantDocument.getDocumentNumber();
    Person initiatorPerson = personService.getPerson(initiator);
    String initiatorEmail = initiatorPerson.getEmailAddressUnmasked();
    BodyMailMessage message = new BodyMailMessage();
    message.addToAddress(initiatorEmail);
    message.setFromAddress(initiatorEmail);
    message.setSubject("I Want document: " + documentNumber + " has been finalized");
    StringBuilder emailBody = new StringBuilder();
    String vendorName = iWantDocument.getVendorName();
    if (vendorName == null) {
        vendorName = StringUtils.EMPTY;
    }
    emailBody.append("This is a message to inform you that the I Want document ").append(iWantDocument.getDocumentNumber()).append(" has been finalized: ").append(KRADConstants.NEWLINE).append(KRADConstants.NEWLINE);
    emailBody.append("From: ").append(initiatorPerson.getNameUnmasked()).append(KRADConstants.NEWLINE);
    emailBody.append("Title: ").append(iWantDocument.getDocumentTitle()).append(KRADConstants.NEWLINE);
    emailBody.append("Type: ").append(workflowDocument.getDocumentTypeName()).append(KRADConstants.NEWLINE);
    emailBody.append("Id: ").append(documentNumber).append(KRADConstants.NEWLINE);
    emailBody.append("Vendor Name: ").append(vendorName).append("\n\n");
    String docUrl = getDocumentURL(documentNumber, workflowDocument);
    emailBody.append(" Go here to view this item: ").append(docUrl).append(KRADConstants.NEWLINE);
    message.setMessage(emailBody.toString());
    return message;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) Person(org.kuali.rice.kim.api.identity.Person) BodyMailMessage(org.kuali.kfs.sys.mail.BodyMailMessage)

Example 34 with WorkflowDocument

use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method save.

@Override
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    // Only recreate document description if in INITIATED or SAVED status.
    WorkflowDocument workflowDocument = ((KualiDocumentFormBase) form).getDocument().getDocumentHeader().getWorkflowDocument();
    if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
        iWantDocumentService.setIWantDocumentDescription((IWantDocument) ((KualiDocumentFormBase) form).getDocument());
    }
    ActionForward actionForward = super.save(mapping, form, request, response);
    IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
    boolean added = true;
    // add new item and new accounting line if not empty
    IWantItem item = iWantDocForm.getNewIWantItemLine();
    if (StringUtils.isNotBlank(item.getItemDescription()) || item.getItemUnitPrice() != null || item.getItemQuantity() != null) {
        added &= addNewItem(iWantDocForm, iWantDocument, item);
    }
    added &= addNewFavoriteAccountIfNecessary(added, iWantDocument);
    if (added) {
        IWantAccount account = iWantDocForm.getNewSourceLine();
        if (StringUtils.isNotBlank(account.getAccountNumber()) || StringUtils.isNotBlank(account.getSubAccountNumber()) || StringUtils.isNotBlank(account.getFinancialObjectCode()) || StringUtils.isNotBlank(account.getFinancialSubObjectCode()) || StringUtils.isNotBlank(account.getProjectCode()) || StringUtils.isNotBlank(account.getOrganizationReferenceId())) {
            added &= addNewAccount(iWantDocForm, iWantDocument, account);
        }
    }
    // Do not save if item or account additions failed.
    if (!added) {
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    if (StringUtils.isNotBlank(iWantDocForm.getNewAdHocRoutePerson().getId())) {
        iWantDocument.setCurrentRouteToNetId(iWantDocForm.getNewAdHocRoutePerson().getId());
    }
    return actionForward;
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) ActionForward(org.apache.struts.action.ActionForward) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 35 with WorkflowDocument

use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method copy.

/**
 * Overridden to guarantee that form of copied document is set to whatever the entry
 * mode of the document is
 * @see org.kuali.kfs.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 * javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward forward = null;
    if (request.getParameter(KRADConstants.PARAMETER_DOC_ID) == null) {
        forward = super.copy(mapping, form, request, response);
    } else {
        // this is copy document from Procurement Gateway:
        // use this link to call: http://localhost:8080/kfs-dev/purapIWant.do?methodToCall=copy&docId=xxxx
        String docId = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
        KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
        IWantDocument document = null;
        document = (IWantDocument) getDocumentService().getByDocumentHeaderId(docId);
        document.toCopyFromGateway();
        kualiDocumentFormBase.setDocument(document);
        WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
        kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
        UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(), workflowDocument);
        forward = mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    return forward;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) ActionForward(org.apache.struts.action.ActionForward) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Aggregations

WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)36 ArrayList (java.util.ArrayList)4 FinancialSystemDocumentHeader (org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)4 Person (org.kuali.rice.kim.api.identity.Person)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 ActionForward (org.apache.struts.action.ActionForward)3 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)3 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)3 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)2 Iterator (java.util.Iterator)2 List (java.util.List)2 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)2 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)2 FinancialSystemWorkflowHelperService (org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService)2