Search in sources :

Example 1 with CashControlDocument

use of org.kuali.kfs.module.ar.document.CashControlDocument 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)

Aggregations

LinkedList (java.util.LinkedList)1 WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)1 CashControlDetail (org.kuali.kfs.module.ar.businessobject.CashControlDetail)1 CashControlDocument (org.kuali.kfs.module.ar.document.CashControlDocument)1 PaymentApplicationDocument (org.kuali.kfs.module.ar.document.PaymentApplicationDocument)1