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());
}
Aggregations