1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.authorization;
17
18 import java.util.Set;
19
20 import org.kuali.ole.fp.businessobject.CashDrawer;
21 import org.kuali.ole.fp.document.CashReceiptDocument;
22 import org.kuali.ole.fp.service.CashDrawerService;
23 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.OLEKeyConstants;
25 import org.kuali.ole.sys.OleAuthorizationConstants;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.ole.sys.document.authorization.LedgerPostingDocumentPresentationControllerBase;
28 import org.kuali.ole.sys.service.FinancialSystemWorkflowHelperService;
29 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
30 import org.kuali.rice.kew.api.WorkflowDocument;
31 import org.kuali.rice.krad.document.Document;
32 import org.kuali.rice.krad.util.GlobalVariables;
33
34 public class CashReceiptDocumentPresentationController extends LedgerPostingDocumentPresentationControllerBase {
35 private static final String CASH_MANAGEMENT_NODE_NAME = "CashManagement";
36
37
38
39
40 @Override
41 public boolean canApprove(Document document) {
42 return this.canApproveOrBlanketApprove(document) ? super.canApprove(document) : false;
43 }
44
45
46
47
48 @Override
49 public boolean canBlanketApprove(Document document) {
50
51 if(!this.isInCashManageConfirmMode(document)){
52 return false;
53 }
54
55 return this.canApproveOrBlanketApprove(document) ? super.canBlanketApprove(document) : false;
56 }
57
58 protected boolean canApproveOrBlanketApprove(Document document) {
59 WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
60
61 if (workflowDocument.isApprovalRequested() ) {
62 if (!SpringContext.getBean(FinancialSystemWorkflowHelperService.class).isAdhocApprovalRequestedForPrincipal(workflowDocument, GlobalVariables.getUserSession().getPrincipalId())) {
63 CashReceiptDocument cashReceiptDocument = (CashReceiptDocument) document;
64
65 String campusCode = cashReceiptDocument.getCampusLocationCode();
66 CashDrawer cashDrawer = SpringContext.getBean(CashDrawerService.class).getByCampusCode(campusCode);
67 if (cashDrawer == null) {
68 GlobalVariables.getMessageMap().putError(OLEConstants.GLOBAL_ERRORS, OLEKeyConstants.CashReceipt.ERROR_CASH_DRAWER_DOES_NOT_EXIST, campusCode);
69 return false;
70 }
71 if (cashDrawer.isClosed()) {
72 return false;
73 }
74 }
75 }
76 return true;
77 }
78
79
80
81
82
83 @Override
84 public boolean canEdit(Document document) {
85 if (document.getDocumentHeader().getWorkflowDocument().getCurrentNodeNames().contains(CashReceiptDocumentPresentationController.CASH_MANAGEMENT_NODE_NAME)) {
86 return false;
87 }
88 return super.canEdit(document);
89 }
90
91
92
93
94 @Override
95 public Set<String> getEditModes(Document document) {
96 Set<String> editModes = super.getEditModes(document);
97 addFullEntryEntryMode(document, editModes);
98 addChangeRequestMode(document, editModes);
99
100 return editModes;
101 }
102
103 protected void addFullEntryEntryMode(Document document, Set<String> editModes) {
104 if (this.isInCashManageConfirmMode(document)){
105 editModes.add(OleAuthorizationConstants.CashReceiptEditMode.CASH_MANAGER_CONFIRM_MODE);
106 }
107 }
108
109 protected void addChangeRequestMode(Document document, Set<String> editModes) {
110 boolean IndValue = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(CashReceiptDocument.class, "CHANGE_REQUEST_ENABLED_IND");
111 if(IndValue) {
112 editModes.add(OleAuthorizationConstants.CashReceiptEditMode.CHANGE_REQUEST_MODE);
113 }
114 }
115
116
117
118
119 protected boolean isInCashManageConfirmMode(Document document){
120 WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
121
122 if (workflowDocument.isEnroute()) {
123 Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
124 if(currentRouteLevels.contains(CASH_MANAGEMENT_NODE_NAME)) {
125 return true;
126 }
127 }
128 return false;
129 }
130
131 }