Search in sources :

Example 21 with WorkflowDocument

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

the class PurchasingAccountsPayableDocumentBase method isDocumentStoppedInRouteNode.

// for app doc status
@Override
public boolean isDocumentStoppedInRouteNode(String nodeName) {
    WorkflowDocument workflowDocument = this.getFinancialSystemDocumentHeader().getWorkflowDocument();
    Set<String> names = workflowDocument.getCurrentNodeNames();
    if (CollectionUtils.isNotEmpty(names)) {
        List<String> currentRouteLevels = new ArrayList<String>(names);
        for (String routeLevel : currentRouteLevels) {
            if (routeLevel.contains(nodeName) && workflowDocument.isApprovalRequested()) {
                return true;
            }
        }
    }
    return false;
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) ArrayList(java.util.ArrayList)

Example 22 with WorkflowDocument

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

the class PurchasingCommodityCodeValidation method shouldCheckCommodityCodeIsActive.

/**
 * This method analyzes the document status and determines if the commodity codes associated with this item should be verified as active.
 * The current implementation only checks that a commodity code is active if the document associated is in either INITIATED or SAVED status.
 * For all other statuses the document may be in, the commodity code will not be checked for active status and the method will simply return
 * true unconditionally.
 *
 * @param item
 * @return
 */
private boolean shouldCheckCommodityCodeIsActive(PurApItem item) {
    if (ObjectUtils.isNotNull(item.getPurapDocument())) {
        String docNum = item.getPurapDocument().getDocumentNumber();
        PurchasingAccountsPayableDocument purapDoc = item.getPurapDocument();
        // Ran into issues with workflow doc not being populated in doc header for some PURAP docs, so needed to add check and retrieval.
        FinancialSystemDocumentHeader docHdr = (FinancialSystemDocumentHeader) purapDoc.getDocumentHeader();
        WorkflowDocument kwd = null;
        kwd = WorkflowDocumentFactory.loadDocument(GlobalVariables.getUserSession().getPrincipalId(), docNum);
        docHdr.setWorkflowDocument(kwd);
        // Only check for active commodity codes if the doc is in initiated or saved status.
        if (ObjectUtils.isNull(kwd)) {
            kwd = docHdr.getWorkflowDocument();
        }
        if (!(kwd.isInitiated() || kwd.isSaved())) {
            return false;
        }
    }
    return true;
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 23 with WorkflowDocument

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

the class PaymentApplicationForm method isFinalOrProcessed.

private boolean isFinalOrProcessed() {
    final Collection<WorkflowDocument> workflowDocuments = new LinkedList<>();
    final PaymentApplicationDocument appDocument = getPaymentApplicationDocument();
    // Include this APP
    final WorkflowDocument appWorkflowDocument = extractWorkFlowDocument(appDocument);
    workflowDocuments.add(appWorkflowDocument);
    if (appDocument.hasCashControlDetail()) {
        final CashControlDocument cashControlDocument = appDocument.getCashControlDocument();
        // Include this APP's CashControl
        final WorkflowDocument ccWorkflowDocument = extractWorkFlowDocument(cashControlDocument);
        workflowDocuments.add(ccWorkflowDocument);
        // Include any other APPs associated with the CashControl
        final List<CashControlDetail> cashControlDetails = cashControlDocument.getCashControlDetails();
        for (final CashControlDetail cashControlDetail : cashControlDetails) {
            final PaymentApplicationDocument otherAppDocument = cashControlDetail.getReferenceFinancialDocument();
            if (otherAppDocument.getDocumentNumber().equals(appDocument.getDocumentNumber())) {
                // Do not add this Document again; it was added above
                continue;
            }
            final WorkflowDocument otherAppWorkflowDocument = extractWorkFlowDocument(otherAppDocument);
            workflowDocuments.add(otherAppWorkflowDocument);
        }
    }
    return workflowDocuments.stream().allMatch(wfDocument -> wfDocument.isFinal() || wfDocument.isProcessed());
}
Also used : CashControlDocument(org.kuali.kfs.module.ar.document.CashControlDocument) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) CashControlDetail(org.kuali.kfs.module.ar.businessobject.CashControlDetail) PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument) LinkedList(java.util.LinkedList)

Example 24 with WorkflowDocument

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

the class PaymentApplicationAdjustmentDocument method postProcessingShouldBeDone.

private boolean postProcessingShouldBeDone() {
    LOG.debug("postProcessingShouldBeDone(...) - Enter");
    final WorkflowDocument workflowDocument = getDocumentHeader().getWorkflowDocument();
    final boolean postProcessingShouldBeDone = workflowDocument.isFinal();
    LOG.debug("postProcessingShouldBeDone(...) - Exit : postProcessingShouldBeDone={}", postProcessingShouldBeDone);
    return postProcessingShouldBeDone;
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument)

Example 25 with WorkflowDocument

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

the class CuProcurementCardAccountingLineAuthorizer method determineEditPermissionByFieldName.

@Override
protected boolean determineEditPermissionByFieldName(AccountingDocument accountingDocument, AccountingLine accountingLine, String fieldName, Person currentUser, Set<String> currentNodes) {
    WorkflowDocument workflowDocument = accountingDocument.getDocumentHeader().getWorkflowDocument();
    List<ActionRequest> actionRequests = workflowDocument.getRootActionRequests();
    Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
    boolean isAddHocRoute = CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains(PurapWorkflowConstants.DOC_ADHOC_NODE_NAME);
    if (!isAddHocRoute) {
        for (ActionRequest actionRequest : actionRequests) {
            isAddHocRoute = actionRequest.getActionTaken() == null && StringUtils.startsWith(actionRequest.getAnnotation(), "Ad Hoc Routed by") && StringUtils.equals(actionRequest.getPrincipalId(), currentUser.getPrincipalId());
            if (isAddHocRoute) {
                return false;
            }
        }
    } else {
        return false;
    }
    // 2. Check that the document is at AccountFullEdit route node
    if (accountingDocument.getDocumentHeader() != null && accountingDocument.getDocumentHeader().getWorkflowDocument() != null) {
        if (currentNodes != null && currentNodes.contains(RouteLevelNames.ACCOUNT_REVIEW_FULL_EDIT)) {
            // can edit the accounting line
            if (getDocumentAuthorizer(accountingDocument).canEdit(accountingDocument, currentUser)) {
                // any user that can edit the accounting lines will be able to add/change it to any other account
                return true;
            }
        }
    }
    return super.determineEditPermissionByFieldName(accountingDocument, accountingLine, fieldName, currentUser, currentNodes);
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) ActionRequest(org.kuali.kfs.kew.actionrequest.ActionRequest)

Aggregations

WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)36 Person (org.kuali.kfs.kim.api.identity.Person)5 ArrayList (java.util.ArrayList)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 Iterator (java.util.Iterator)3 List (java.util.List)3 ActionForward (org.apache.struts.action.ActionForward)3 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)3 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)2 HashMap (java.util.HashMap)2 ActionRequest (org.kuali.kfs.kew.actionrequest.ActionRequest)2 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)2 FinancialSystemWorkflowHelperService (org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService)2 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)1 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)1 CULegacyTravelService (edu.cornell.kfs.fp.document.service.CULegacyTravelService)1