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.sys.document.validation.impl;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.kuali.kfs.sys.KFSPropertyConstants;
020 import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
021 import org.kuali.kfs.sys.context.SpringContext;
022 import org.kuali.rice.kns.service.DataDictionaryService;
023
024 /**
025 * Holds common constants for all Transaction Processing eDoc rule classes.
026 */
027 public interface AccountingDocumentRuleBaseConstants {
028
029 // Application parameter lookup constants to be used in conjunction with the grouping constants above
030 public static final class APPLICATION_PARAMETER {
031 public static final String RESTRICTED_OBJECT_CODES = "OBJECT_CODES";
032 public static final String RESTRICTED_OBJECT_TYPE_CODES = "OBJECT_TYPES";
033 public static final String RESTRICTED_OBJECT_SUB_TYPE_CODES = "OBJECT_SUB_TYPES";
034 public static final String RESTRICTED_OBJECT_LEVELS = "OBJECT_LEVELS";
035 public static final String RESTRICTED_OBJECT_CONSOLIDATIONS = "OBJECT_CONSOLIDATIONS";
036 public static final String RESTRICTED_FUND_GROUP_CODES = "FUND_GROUPS";
037 public static final String RESTRICTED_SUB_FUND_GROUP_CODES = "SUB_FUND_GROUPS";
038 public static final String MANDATORY_TRANSFER_SUBTYPE_CODES = "MANDATORY_TRANSFER_OBJECT_SUB_TYPES";
039 public static final String NONMANDATORY_TRANSFER_SUBTYPE_CODES = "NON_MANDATORY_TRANSFER_OBJECT_SUB_TYPES";
040 public static final String FUND_GROUP_BALANCING_SET = "FUND_GROUP_BALANCING_SET";
041 // doctype parameter
042 public static final String DOCTYPE_SALES_TAX_CHECK = "SALES_TAX_APPLICABLE_DOCUMENT_TYPES";
043
044 // combination object code and account parameter
045 public static final String SALES_TAX_APPLICABLE_ACCOUNTS_AND_OBJECT_CODES = "SALES_TAX_APPLICABLE_ACCOUNTS_AND_OBJECT_CODES";
046 }
047
048 /**
049 * Constant to statically define reusable error paths
050 */
051 public static final class ERROR_PATH {
052 public static final String DELIMITER = ".";
053 public static final String DOCUMENT_ERROR_PREFIX = "document" + DELIMITER;
054 }
055
056 // GLPE KFSConstants
057 public static final class GENERAL_LEDGER_PENDING_ENTRY_CODE {
058 public static final String NO = "N";
059 public static final String YES = "Y";
060 private static String BLANK_PROJECT_STRING = null; // Max length is 10 for this field
061 private static String BLANK_SUB_OBJECT_CODE = null; // Max length is 3 for this field
062 private static String BLANK_SUB_ACCOUNT_NUMBER = null; // Max length is 5 for this field
063 private static String BLANK_OBJECT_CODE = null; // Max length is 4 for this field
064 private static String BLANK_OBJECT_TYPE_CODE = null; // Max length is 4 for this field
065 public static final int GLPE_DESCRIPTION_MAX_LENGTH = 40;
066
067 public static String getBlankProjectCode() {
068 if (BLANK_PROJECT_STRING == null) {
069 BLANK_PROJECT_STRING = StringUtils.rightPad("", SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(GeneralLedgerPendingEntry.class, KFSPropertyConstants.PROJECT_CODE), '-');
070 }
071 return BLANK_PROJECT_STRING;
072 }
073
074 public static String getBlankFinancialSubObjectCode() {
075 if (BLANK_SUB_OBJECT_CODE == null) {
076 BLANK_SUB_OBJECT_CODE = StringUtils.rightPad("", SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE), '-');
077 }
078 return BLANK_SUB_OBJECT_CODE;
079 }
080
081 public static String getBlankSubAccountNumber() {
082 if (BLANK_SUB_ACCOUNT_NUMBER == null) {
083 BLANK_SUB_ACCOUNT_NUMBER = StringUtils.rightPad("", SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(GeneralLedgerPendingEntry.class, KFSPropertyConstants.SUB_ACCOUNT_NUMBER), '-');
084 }
085 return BLANK_SUB_ACCOUNT_NUMBER;
086 }
087
088 public static String getBlankFinancialObjectCode() {
089 if (BLANK_OBJECT_CODE == null) {
090 BLANK_OBJECT_CODE = StringUtils.rightPad("", SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_OBJECT_CODE), '-');
091 }
092 return BLANK_OBJECT_CODE;
093 }
094
095 public static String getBlankFinancialObjectType() {
096 if (BLANK_OBJECT_TYPE_CODE == null) {
097 BLANK_OBJECT_TYPE_CODE = StringUtils.rightPad("", SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE), '-');
098 }
099 return BLANK_OBJECT_TYPE_CODE;
100 }
101 }
102
103 // account constants
104 public static final class ACCOUNT_NUMBER {
105 public static final String BUDGET_LEVEL_NO_BUDGET = "N";
106 }
107 }