001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.fp.document.authorization;
017
018 import java.util.List;
019 import java.util.Set;
020
021 import org.kuali.kfs.fp.document.DisbursementVoucherConstants;
022 import org.kuali.kfs.fp.document.DisbursementVoucherDocument;
023 import org.kuali.kfs.sys.KfsAuthorizationConstants;
024 import org.kuali.kfs.sys.document.authorization.AccountingDocumentPresentationControllerBase;
025 import org.kuali.rice.kns.document.Document;
026 import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument;
027
028 public class DisbursementVoucherDocumentPresentationController extends AccountingDocumentPresentationControllerBase {
029 /**
030 * @see org.kuali.rice.kns.document.authorization.DocumentPresentationControllerBase#canBlanketApprove(org.kuali.rice.kns.document.Document)
031 */
032 @Override
033 protected boolean canBlanketApprove(Document document) {
034 return false;
035 }
036
037 /**
038 * @see org.kuali.kfs.sys.document.authorization.FinancialSystemTransactionalDocumentPresentationControllerBase#getEditModes(org.kuali.rice.kns.document.Document)
039 */
040 @Override
041 public Set<String> getEditModes(Document document) {
042 Set<String> editModes = super.getEditModes(document);
043
044 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.TAX_ENTRY);
045 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.FRN_ENTRY);
046 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.WIRE_ENTRY);
047
048 addFullEntryEntryMode(document, editModes);
049 addPayeeEditEntryMode(document, editModes);
050 addTravelEntryMode(document, editModes);
051 addPaymentHandlingEntryMode(document, editModes);
052 addVoucherDeadlineEntryMode(document, editModes);
053 addSpecialHandlingChagingEntryMode(document, editModes);
054
055 return editModes;
056 }
057
058 protected void addPayeeEditEntryMode(Document document, Set<String> editModes) {
059 KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
060
061 if ((workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved())) {
062 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.PAYEE_ENTRY);
063 }
064 else if (workflowDocument.stateIsEnroute()) {
065 List<String> currentRouteLevels = getCurrentRouteLevels(workflowDocument);
066 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)) {
067 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.PAYEE_ENTRY);
068 }
069 }
070 }
071
072 protected void addFullEntryEntryMode(Document document, Set<String> editModes) {
073 KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
074
075 if ((workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved())) {
076 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.FULL_ENTRY);
077 }
078 }
079
080 /**
081 * If at a proper route node, adds the ability to edit payment handling fields
082 * @param document the disbursement voucher document authorization is being sought on
083 * @param editModes the edit modes so far, which can be added to
084 */
085 protected void addPaymentHandlingEntryMode(Document document, Set<String> editModes) {
086 final KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
087
088 if ((workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved())) {
089 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.PAYMENT_HANDLING_ENTRY);
090 }
091 final List<String> currentRouteLevels = getCurrentRouteLevels(workflowDocument);
092 if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.CAMPUS) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TRAVEL) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TAX)) {
093 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.PAYMENT_HANDLING_ENTRY);
094 }
095 }
096
097 /**
098 * If at a proper route node, adds the ability to edit the due date for the voucher
099 * @param document the disbursement voucher document authorization is being sought on
100 * @param editModes the edit modes so far, which can be added to
101 */
102 protected void addVoucherDeadlineEntryMode(Document document, Set<String> editModes) {
103 final KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
104
105 if ((workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved())) {
106 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.VOUCHER_DEADLINE_ENTRY);
107 }
108 final List<String> currentRouteLevels = getCurrentRouteLevels(workflowDocument);
109 if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.CAMPUS) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TAX) || currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TRAVEL)) {
110 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.VOUCHER_DEADLINE_ENTRY);
111 }
112 }
113
114 /**
115 * If at a proper route node, adds the ability to edit the travel information on the disbursement voucher
116 * @param document the disbursement voucher document authorization is being sought on
117 * @param editModes the edit modes so far, which can be added to
118 */
119 protected void addTravelEntryMode(Document document, Set<String> editModes) {
120 final KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
121
122 final List<String> currentRouteLevels = getCurrentRouteLevels(workflowDocument);
123 if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT)) { //FO?
124 } else if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.TAX)) { //tax manager? Then only allow this if we're going to route to travel node anyway
125 if (((DisbursementVoucherDocument)document).isTravelReviewRequired()) {
126 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY);
127 }
128 } else if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.PAYMENT_METHOD) && ((DisbursementVoucherDocument)document).getDisbVchrPaymentMethodCode().equals(DisbursementVoucherConstants.PAYMENT_METHOD_DRAFT)) {
129 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY);
130 } else {
131 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY); // we're not FO? Then always add it, as KIM permissions will take it out if we shouldn't have it
132 }
133 }
134
135 /**
136 * If at a proper route node, adds the ability to edit whether special handling is needed on the disbursement voucher
137 * @param document the disbursement voucher document authorization is being sought on
138 * @param editModes the edit modes so far, which can be added to
139 */
140 protected void addSpecialHandlingChagingEntryMode(Document document, Set<String> editModes) {
141 final KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
142 final List<String> currentRouteLevels = getCurrentRouteLevels(workflowDocument);
143
144 if (!currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.PURCHASING)) {
145 editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.SPECIAL_HANDLING_CHANGING_ENTRY);
146 }
147 }
148 }