1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.validation.impl;
17
18 import org.kuali.ole.module.purap.PurapConstants;
19 import org.kuali.ole.module.purap.PurapConstants.AccountsPayableStatuses;
20 import org.kuali.ole.module.purap.PurapKeyConstants;
21 import org.kuali.ole.module.purap.document.AccountsPayableDocument;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.ole.sys.document.validation.GenericValidation;
25 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
26 import org.kuali.rice.kew.api.WorkflowDocument;
27 import org.kuali.rice.krad.util.GlobalVariables;
28
29 public class AccountsPayableProcessApprovalAtAccountsPayableReviewAllowedValidation extends GenericValidation {
30
31
32
33
34
35
36
37
38 @Override
39 public boolean validate(AttributedDocumentEvent event) {
40 boolean valid = true;
41 GlobalVariables.getMessageMap().clearErrorPath();
42 GlobalVariables.getMessageMap().addToErrorPath(OLEPropertyConstants.DOCUMENT);
43
44 if (((AccountsPayableDocument) event.getDocument()).isDocumentStoppedInRouteNode(AccountsPayableStatuses.NODE_ACCOUNT_PAYABLE_REVIEW)) {
45 if (!((AccountsPayableDocument) event.getDocument()).approvalAtAccountsPayableReviewAllowed()) {
46 valid &= false;
47 WorkflowDocument workflowDoc = event.getDocument().getDocumentHeader().getWorkflowDocument();
48 if (PurapConstants.PurapDocTypeCodes.CREDIT_MEMO_DOCUMENT.equals(workflowDoc.getDocumentTypeName())) {
49 GlobalVariables.getMessageMap().putError(OLEConstants.GLOBAL_ERRORS, PurapKeyConstants.ERROR_CREDIT_MEMO_REQUIRES_ATTACHMENT);
50 } else {
51 GlobalVariables.getMessageMap().putError(OLEConstants.GLOBAL_ERRORS, PurapKeyConstants.ERROR_AP_REQUIRES_ATTACHMENT);
52 }
53
54
55 }
56 }
57 GlobalVariables.getMessageMap().clearErrorPath();
58 return valid;
59 }
60
61 }