001/*
002 * Copyright 2006 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 */
016package org.kuali.ole.fp.document;
017
018import java.util.ArrayList;
019import java.util.Arrays;
020import java.util.List;
021
022import org.apache.commons.beanutils.PropertyUtils;
023import org.kuali.ole.sys.OLEKeyConstants;
024import org.kuali.ole.sys.OLEPropertyConstants;
025import org.kuali.ole.sys.context.SpringContext;
026import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
027import org.kuali.rice.coreservice.framework.parameter.ParameterService;
028import org.kuali.rice.kim.api.KimConstants;
029
030/**
031 * Holds constants for disbursement voucher and payee documents.
032 */
033// TODO: after DisbursementVoucherDocumentRule is remove, it is good to change this interface into a class
034public interface DisbursementVoucherConstants {
035    public static final String DOCUMENT_TYPE_CODE = "DV";
036
037    // Text limits
038    public static final int MAX_NOTE_LINE_SIZE = 90;
039    
040    // payment methods
041    public static String PAYMENT_METHOD_CHECK = "P";
042    public static String PAYMENT_METHOD_WIRE = "W";
043    public static String PAYMENT_METHOD_DRAFT = "F";
044
045    // payee types
046    public static final String DV_PAYEE_TYPE_EMPLOYEE = "E";
047    public static final String DV_PAYEE_TYPE_EMPLOYEE_DESC = "Employee";
048    
049    public static final String DV_PAYEE_TYPE_VENDOR = "V";
050    public static final String DV_PAYEE_TYPE_SUBJECT_PAYMENT_VENDOR = "VSP";
051    public static final String DV_PAYEE_TYPE_REVOLVING_FUND_VENDOR = "VRF";
052    
053    public static final List<String> VENDOR_PAYEE_TYPE_CODES = Arrays.asList(DV_PAYEE_TYPE_VENDOR, DV_PAYEE_TYPE_SUBJECT_PAYMENT_VENDOR, DV_PAYEE_TYPE_REVOLVING_FUND_VENDOR);
054
055    // document location
056    public static final String NO_DOCUMENTATION_LOCATION = "N";
057
058    public static final String TAX_CONTROL_CODE_ALLOWS_EMPLOYEES = "A";
059    public static final String TAX_CONTROL_CODE_BEGIN_WITHHOLDING = "B";
060    public static final String TAX_CONTROL_CODE_HOLD_PAYMENT = "H";
061
062    public static class DocumentStatusCodes {
063        public static final String APPROVED = "A";
064        public static final String EXTRACTED = "E";
065    }
066
067  
068     public static class DvPdpExtractGroup {
069        public static final String DV_PDP_ORG_CODE = "PRE_DISBURSEMENT_EXTRACT_ORGANIZATION";
070        public static final String DV_PDP_SBUNT_CODE = "PRE_DISBURSEMENT_EXTRACT_SUB_UNIT";
071    }
072    
073    public static class TabKey {
074        public static final String NON_EMPLOYEE_TRAVEL_EXPENSE = "NonEmployeeTravelExpense";
075        public static final String PRE_PAID_TRAVEL_EXPENSES = "PrePaidTravelExpenses";
076    }
077    
078    public enum TabByReasonCode{
079        NON_EMPLOYEE_TRAVEL_TAB(NONEMPLOYEE_TRAVEL_PAY_REASONS_PARM_NM, TabKey.NON_EMPLOYEE_TRAVEL_EXPENSE, OLEPropertyConstants.DV_NON_EMPLOYEE_TRAVEL, 
080                OLEPropertyConstants.DISB_VCHR_NON_EMP_TRAVELER_NAME,OLEKeyConstants.WARNING_DV_NON_EMPLOYEE_TRAVEL_TAB),
081        PREPAID_TRAVEL_TAB(PREPAID_TRAVEL_PAYMENT_REASONS_PARM_NM, TabKey.PRE_PAID_TRAVEL_EXPENSES, OLEPropertyConstants.DV_PRE_CONFERENCE_DETAIL, 
082                OLEPropertyConstants.DV_CONFERENCE_DESTINATION_NAME,OLEKeyConstants.WARNING_DV_PREPAID_TRAVEL_TAB);
083        
084        public String paymentReasonParameterName;
085        public String tabKey;
086        public String propertyName;
087        public String reprentingFieldName;
088        public String messageKey;
089
090        private TabByReasonCode(String paymentReasonParameterName, String tabKey, String propertyName, String reprentingFieldName, String messageKey) {
091            this.paymentReasonParameterName = paymentReasonParameterName;
092            this.tabKey = tabKey;
093            this.propertyName = propertyName;
094            this.reprentingFieldName = reprentingFieldName;
095            this.messageKey = messageKey;
096        }
097        
098        private static ParameterService parameterService;
099        private static ParameterService getParameterService() {
100            if (parameterService == null) {
101                parameterService = SpringContext.getBean(ParameterService.class);
102            }
103            return parameterService;
104        }
105        
106        public static TabByReasonCode getTabByReasonCode(String paymentReasonCode) {
107            for(TabByReasonCode tab : TabByReasonCode.values()) {
108                if(/*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(DisbursementVoucherDocument.class, tab.paymentReasonParameterName, paymentReasonCode).evaluationSucceeds()){
109                    return tab;
110                }
111            }            
112            return null;
113        }
114        
115        public static List<String> getAllTabKeys() {
116            List<String> tabKeys = new ArrayList<String>();
117            for(TabByReasonCode tab : TabByReasonCode.values()) {
118                tabKeys.add(tab.tabKey);
119            }
120            return tabKeys;
121        } 
122        
123        public static List<String> getAllDocumentPropertyKeys(){
124            List<String> documentPropertyKeys = new ArrayList<String>();
125            
126            for(TabByReasonCode tab : TabByReasonCode.values()) {
127                String propertyKey = tab.getDocumentPropertyKey();
128                documentPropertyKeys.add(propertyKey);
129            }
130            
131            return documentPropertyKeys;
132        }
133        
134        public String getDocumentPropertyKey() {
135            return OLEPropertyConstants.DOCUMENT + PropertyUtils.NESTED_DELIM + this.propertyName + PropertyUtils.NESTED_DELIM + this.reprentingFieldName;
136        }
137    }
138
139    // system parameter parameter constants
140    public static final String OBJECT_TYPE_GLOBAL_RESTRICTION_PARM_NM = "OBJECT_TYPES";
141    public static final String OBJECT_LEVEL_GLOBAL_RESTRICTION_PARM_NM = "OBJECT_LEVELS";
142    public static final String OBJECT_SUB_TYPE_GLOBAL_RESTRICTION_PARM_NM = "OBJECT_SUB_TYPES";
143    public static final String SUB_FUND_GLOBAL_RESTRICTION_PARM_NM = "SUB_FUND_GROUPS";
144    public static final String FUNCTION_CODE_GLOBAL_RESTRICTION_PARM_NM = "HIGHER_ED_FUNCTIONS";
145
146    public static final String VALID_DOC_LOC_BY_PAYMENT_REASON_PARM = "VALID_DOCUMENTATION_LOCATIONS_BY_PAYMENT_REASON";
147    public static final String VALID_DOC_LOC_BY_CAMPUS_PARM = "VALID_DOCUMENTATION_LOCATIONS_BY_CAMPUS";
148    public static final String VALID_OBJ_LEVEL_BY_PAYMENT_REASON_PARM = "VALID_OBJECT_LEVELS_BY_PAYMENT_REASON";
149    public static final String VALID_OBJ_CODE_BY_PAYMENT_REASON_PARM = "VALID_OBJECT_CODES_BY_PAYMENT_REASON";
150    public static final String VALID_OBJECT_SUB_TYPES_BY_SUB_FUND_GROUP_PARM = "VALID_OBJECT_SUB_TYPES_BY_SUB_FUND_GROUP";
151    public static final String VALID_SUB_FUND_GROUPS_BY_PAYMENT_REASON_PARM = "VALID_SUB_FUND_GROUPS_BY_PAYMENT_REASON";
152    public static final String VALID_PAYEE_TYPES_BY_PAYMENT_REASON_PARM = "VALID_PAYEE_TYPES_BY_PAYMENT_REASON";
153    public static final String VALID_VENDOR_OWNERSHIP_TYPES_BY_PAYMENT_REASON = "VALID_VENDOR_OWNERSHIP_TYPES_BY_PAYMENT_REASON";
154
155    public static final String INVALID_DOC_LOC_BY_PAYMENT_REASON_PARM = "INVALID_DOCUMENTATION_LOCATIONS_BY_PAYMENT_REASON";
156    public static final String INVALID_DOC_LOC_BY_CAMPUS_PARM = "INVALID_DOCUMENTATION_LOCATIONS_BY_CAMPUS";
157    public static final String INVALID_OBJ_LEVEL_BY_PAYMENT_REASON_PARM = "INVALID_OBJECT_LEVELS_BY_PAYMENT_REASON";
158    public static final String INVALID_OBJ_CODE_BY_PAYMENT_REASON_PARM = "INVALID_OBJECT_CODES_BY_PAYMENT_REASON";
159    public static final String INVALID_OBJECT_SUB_TYPES_BY_SUB_FUND_GROUP_PARM = "INVALID_OBJECT_SUB_TYPES_BY_SUB_FUND_GROUP";
160    public static final String INVALID_SUB_FUND_GROUPS_BY_PAYMENT_REASON_PARM = "INVALID_SUB_FUND_GROUPS_BY_PAYMENT_REASON";
161    public static final String INVALID_PAYEE_TYPES_BY_PAYMENT_REASON_PARM = "INVALID_PAYEE_TYPES_BY_PAYMENT_REASON";
162
163    public static final String FEDERAL_TAX_PARM_PREFIX = "NON_RESIDENT_ALIEN_TAX_FEDERAL_";
164    public static final String STATE_TAX_PARM_PREFIX = "NON_RESIDENT_ALIEN_TAX_STATE_";
165    public static final String TAX_PARM_ACCOUNT_SUFFIX = "ACCOUNT";
166    public static final String TAX_PARM_CHART_SUFFIX = "CHART";
167    public static final String TAX_PARM_OBJECT_BY_INCOME_CLASS_SUFFIX = "OBJECT_CODE_BY_INCOME_CLASS";
168    public static final String ALIEN_INDICATOR_CHECKED_PARM_NM = "NON_RESIDENT_ALIEN_DOCUMENTATION_LOCATIONS";
169    public static final String ALIEN_PAYMENT_REASONS_PARM_NM = "NON_RESIDENT_ALIEN_PAYMENT_REASONS";
170    public static final String TRAVEL_PER_DIEM_MESSAGE_PARM_NM = "TRAVEL_PER_DIEM_LINK_PAGE_MESSAGE";
171    public static final String DEFAULT_DOC_LOCATION_PARM_NM = "DEFAULT_DOCUMENTATION_LOCATION";
172    public static final String ALLOW_OBJECT_CODE_EDITS = "ALLOW_ENROUTE_EDIT_OBJECT_CODES_IND";
173    public static final String TAX_DOCUMENTATION_LOCATION_CODE_PARM_NM = "TAX_DOCUMENTATION_LOCATION";
174    public static final String NONEMPLOYEE_TRAVEL_PAY_REASONS_PARM_NM = "NONEMPLOYEE_TRAVEL_PAYMENT_REASONS";
175    public static final String NONEMPLOYEE_TRAVEL_ACTUAL_MILEAGE_LIMIT_PARM_NM = "NONEMPLOYEE_TRAVEL_ACTUAL_MILEAGE_LIMIT_IND";
176    public static final String PREPAID_TRAVEL_PAYMENT_REASONS_PARM_NM = "PREPAID_TRAVEL_PAYMENT_REASONS";
177    public static final String REVOLVING_FUND_PAYMENT_REASONS_PARM_NM = "REVOLVING_FUND_PAYMENT_REASONS";
178    public static final String RESEARCH_PAYMENT_REASONS_PARM_NM = "RESEARCH_PAYMENT_REASONS";
179    public static final String RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT_PARM_NM = "RESEARCH_NON_VENDOR_PAY_LIMIT_AMOUNT";
180    public static final String PERFORM_PREPAID_EMPL_PARM_NM = "CHECK_PREPAID_ACTIVE_EMPLOYEE_IND";
181    public static final String CHECK_EMPLOYEE_PAID_OUTSIDE_PAYROLL_PARM_NM = "CHECK_EMPLOYEE_PAID_OUTSIDE_PAYROLL_IND";
182    public static final String MOVING_PAYMENT_REASONS_PARM_NM = "MOVING_PAYMENT_REASONS";
183    public static final String DECEDENT_COMPENSATION_PAYMENT_REASONS_PARM_NM = "DECEDENT_COMPENSATION_PAYMENT_REASONS";
184    
185    public static final String NON_VENDOR_EMPLOYEE_PAYEE_TYPE_LABEL_PARM_NM = "NON_VENDOR_EMPLOYEE_PAYEE_TYPE_LABEL";
186    public static final String PO_AND_DV_PAYEE_TYPE_LABEL_PARM_NM = "PO_AND_DV_PAYEE_TYPE_LABEL";
187    public static final String INDIVIDUAL_OWNERSHIP_TYPES_PARM_NM = "INDIVIDUAL_OWNERSHIP_TYPES";
188    public static final String PAYMENT_REASONS_REQUIRING_TAX_REVIEW_PARM_NM = "PAYMENT_REASONS_REQUIRING_TAX_REVIEW";
189    public static final String CAMPUSES_TAXED_FOR_MOVING_REIMBURSEMENTS_PARM_NM = "CAMPUSES_TAXED_FOR_MOVING_REIMBURSEMENTS";
190
191    public static final String IMMEDIATE_EXTRACT_FROM_ADDRESS_PARM_NM = "IMMEDIATE_EXTRACT_NOTIFICATION_FROM_EMAIL_ADDRESS";
192    public static final String IMMEDIATE_EXTRACT_TO_ADDRESSES_PARM_NM = "IMMEDIATE_EXTRACT_NOTIFICATION_TO_EMAIL_ADDRESSES";
193
194    public static final String TAX_TYPE_SSN = "1";
195    public static final String TAX_TYPE_FEIN = "0";
196    
197    public static final String TAX_ID_TYPE_SSN = KimConstants.PersonExternalIdentifierTypes.TAX;
198    //public static final String TAX_ID_TYPE_FEIN = "F";
199
200    public static final String NRA_TAX_INCOME_CLASS_FELLOWSHIP = "F";
201    public static final String NRA_TAX_INCOME_CLASS_INDEPENDENT_CONTRACTOR = "I";
202    public static final String NRA_TAX_INCOME_CLASS_ROYALTIES = "R";
203    public static final String NRA_TAX_INCOME_CLASS_NON_REPORTABLE = "N";
204
205    public static final String FEDERAL_TAX_TYPE_CODE = "F";
206    public static final String STATE_TAX_TYPE_CODE = "S";
207
208    public static final String DOCUMENT_TYPE_CHECKACH = "OLE_DVCA";
209    public static final String DOCUMENT_TYPE_WTFD = "OLE_DVWF";
210    
211    public static final String DV_COVER_SHEET_TEMPLATE_LINES_PARM_NM = "COVER_SHEET_TEMPLATE_LINES";
212    public static final String DV_COVER_SHEET_TEMPLATE_RLINES_PARM_NM = "COVER_SHEET_TEMPLATE_RLINES";
213    public static final String DV_COVER_SHEET_TEMPLATE_ALIEN_PARM_NM = "COVER_SHEET_TEMPLATE_NON_RESIDENT_ALIEN";
214    public static final String DV_COVER_SHEET_TEMPLATE_ATTACHMENT_PARM_NM = "COVER_SHEET_TEMPLATE_ATTACHMENT";
215    public static final String DV_COVER_SHEET_TEMPLATE_HANDLING_PARM_NM = "COVER_SHEET_TEMPLATE_HANDLING";
216    public static final String DV_COVER_SHEET_TEMPLATE_BAR_PARM_NM = "COVER_SHEET_TEMPLATE_BAR";
217    public static final String DV_COVER_SHEET_TEMPLATE_NM = "disbursementVoucherCoverSheetTemplate.pdf";
218    
219    public static final String PAYMENT_REASON_CODE_ROYALTIES_PARM_NM = "PAYMENT_REASON_CODE_ROYALTIES";
220    public static final String PAYMENT_REASON_CODE_RENTAL_PAYMENT_PARM_NM = "PAYMENT_REASON_CODE_RENTAL_PAYMENT";
221    public static final String PAYMENT_REASON_CODE_TRAVEL_HONORARIUM_PARM_NM = "PAYMENT_REASON_CODE_TRAVEL_HONORARIUM";
222   
223    
224    public static class RouteLevelNames {
225        public static final String PURCHASING = "Purchasing";
226        public static final String ACCOUNT = "Account";
227        public static final String ACCOUNTING_ORGANIZATION_HIERARCHY = "AccountingOrganizationHierarchy";
228        public static final String TAX = "Tax";
229        public static final String AWARD = "Award";
230        public static final String TRAVEL = "Travel";
231        public static final String CAMPUS = "Campus";
232        public static final String PAYMENT_METHOD = "PaymentMethod";
233    }
234}