use of org.kuali.kfs.module.purap.businessobject.PaymentRequestView in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderForm method canVoid.
// KFSUPGRADE-411
/**
* Determines whether to display the void button for the purchase order document. Conditions:
* PO is in Pending Print status, or is in Open status and has no PREQs against it;
* PO's current indicator is true and pending indicator is false;
* and the user is a member of the purchasing group).
*
* @return boolean true if the void button can be displayed.
*/
protected boolean canVoid() {
// check PO status etc
boolean can = getPurchaseOrderDocument().isPurchaseOrderCurrentIndicator() && !getPurchaseOrderDocument().isPendingActionIndicator();
if (can) {
boolean pendingPrint = PurapConstants.PurchaseOrderStatuses.APPDOC_PENDING_PRINT.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
boolean open = PurapConstants.PurchaseOrderStatuses.APPDOC_OPEN.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
boolean errorFax = PurapConstants.PurchaseOrderStatuses.APPDOC_FAX_ERROR.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
List<PaymentRequestView> preqViews = SpringContext.getBean(PurapService.class).getRelatedViews(PaymentRequestView.class, getPurchaseOrderDocument().getAccountsPayablePurchasingDocumentLinkIdentifier());
boolean hasPaymentRequest = preqViews != null && preqViews.size() > 0;
can = pendingPrint || (open && !hasPaymentRequest) || errorFax;
}
// check user authorization
if (can) {
DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
can = documentAuthorizer.canInitiate(KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_VOID, GlobalVariables.getUserSession().getPerson());
}
return can;
}
Aggregations