View Javadoc
1   /*
2    * Copyright 2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.fp.document.authorization;
17  
18  import java.util.Set;
19  
20  import org.kuali.ole.fp.document.DisbursementVoucherConstants;
21  import org.kuali.ole.fp.document.DisbursementVoucherDocument;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.OleAuthorizationConstants;
24  import org.kuali.ole.sys.document.authorization.AccountingDocumentPresentationControllerBase;
25  import org.kuali.rice.kew.api.WorkflowDocument;
26  import org.kuali.rice.krad.document.Document;
27  
28  public class DisbursementVoucherDocumentPresentationController extends AccountingDocumentPresentationControllerBase {
29      /**
30       * @see org.kuali.rice.krad.document.authorization.DocumentPresentationControllerBase#canBlanketApprove(org.kuali.rice.krad.document.Document)
31       */
32      @Override
33      public boolean canBlanketApprove(Document document) {
34          return false;
35      }
36  
37      @Override
38      public Set<String> getDocumentActions(Document document) {
39  
40          Set<String> documentActions = super.getDocumentActions(document);
41  
42          documentActions.remove(OLEConstants.YEAR_END_ACCOUNTING_PERIOD_VIEW_DOCUMENT_ACTION);
43          
44          return documentActions;
45      }
46      
47      /**
48       * @see org.kuali.ole.sys.document.authorization.FinancialSystemTransactionalDocumentPresentationControllerBase#getEditModes(org.kuali.rice.krad.document.Document)
49       */
50      @Override
51      public Set<String> getEditModes(Document document) {
52          Set<String> editModes = super.getEditModes(document);
53  
54          editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.TAX_ENTRY);
55          editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.FRN_ENTRY);
56          editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.WIRE_ENTRY);
57          editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.IMMEDIATE_DISBURSEMENT_ENTRY);
58  
59          addFullEntryEntryMode(document, editModes);
60          addPayeeEditEntryMode(document, editModes);
61          addTravelEntryMode(document, editModes);
62          addPaymentHandlingEntryMode(document, editModes);
63          addVoucherDeadlineEntryMode(document, editModes);
64          addSpecialHandlingChagingEntryMode(document, editModes);
65  
66          return editModes;
67      }
68  
69      protected void addPayeeEditEntryMode(Document document, Set<String> editModes) {
70          WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
71  
72          if ((workflowDocument.isInitiated() || workflowDocument.isSaved())) {
73              editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.PAYEE_ENTRY);
74          }
75          else if (workflowDocument.isEnroute()) {
76              Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
77              if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TAX) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.AWARD) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.CAMPUS) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TRAVEL)) {
78                  editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.PAYEE_ENTRY);
79              }
80          }
81      }
82      
83      protected void addFullEntryEntryMode(Document document, Set<String> editModes) {
84          WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
85  
86          if ((workflowDocument.isInitiated() || workflowDocument.isSaved())) {
87              editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.FULL_ENTRY);
88          }
89      }
90      
91      /**
92       * If at a proper route node, adds the ability to edit payment handling fields
93       * @param document the disbursement voucher document authorization is being sought on
94       * @param editModes the edit modes so far, which can be added to
95       */
96      protected void addPaymentHandlingEntryMode(Document document, Set<String> editModes) {
97          final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
98          
99          if ((workflowDocument.isInitiated() || workflowDocument.isSaved())) {
100             editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.PAYMENT_HANDLING_ENTRY);
101         }
102         final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
103         if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.CAMPUS) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TRAVEL) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TAX)) {
104             editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.PAYMENT_HANDLING_ENTRY);
105         }
106     }
107     
108     /**
109      * If at a proper route node, adds the ability to edit the due date for the voucher
110      * @param document the disbursement voucher document authorization is being sought on
111      * @param editModes the edit modes so far, which can be added to
112      */
113     protected void addVoucherDeadlineEntryMode(Document document, Set<String> editModes) {
114         final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
115         
116         if ((workflowDocument.isInitiated() || workflowDocument.isSaved())) {
117             editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.VOUCHER_DEADLINE_ENTRY);
118         }
119         final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
120         if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.CAMPUS) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TAX) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TRAVEL)) {
121             editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.VOUCHER_DEADLINE_ENTRY);
122         }
123     }
124     
125     /**
126      * If at a proper route node, adds the ability to edit the travel information on the disbursement voucher
127      * @param document the disbursement voucher document authorization is being sought on
128      * @param editModes the edit modes so far, which can be added to
129      */
130     protected void addTravelEntryMode(Document document, Set<String> editModes) {
131         final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
132         
133         final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
134         if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT)) {  //FO? 
135         } else if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TAX)) { //tax manager? Then only allow this if we're going to route to travel node anyway
136             //Commented for the jira issue OLE-3415
137             /*if (((DisbursementVoucherDocument)document).isTravelReviewRequired()) {
138                editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY);
139             }*/
140         } else if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.PAYMENT_METHOD) && ((DisbursementVoucherDocument)document).getDisbVchrPaymentMethodCode().equals(DisbursementVoucherConstants.PAYMENT_METHOD_DRAFT)) {
141             editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY);
142         } else {
143             editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY); // we're not FO? Then always add it, as KIM permissions will take it out if we shouldn't have it
144         }
145     }
146     
147     /**
148      * If at a proper route node, adds the ability to edit whether special handling is needed on the disbursement voucher
149      * @param document the disbursement voucher document authorization is being sought on
150      * @param editModes the edit modes so far, which can be added to
151      */
152     protected void addSpecialHandlingChagingEntryMode(Document document, Set<String> editModes) {
153         final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
154         final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
155         
156         if (!currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.PURCHASING)) {
157             editModes.add(OleAuthorizationConstants.DisbursementVoucherEditMode.SPECIAL_HANDLING_CHANGING_ENTRY);
158         }
159     }
160 }