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.service;
017
018 import org.kuali.kfs.coa.businessobject.AccountingPeriod;
019 import org.kuali.kfs.coa.businessobject.BalanceType;
020 import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
021
022 /**
023 * A collection of methods that assist in rule validation for accounting documents
024 */
025 public interface AccountingDocumentRuleHelperService {
026 /**
027 * This method checks for the existence of the provided balance type, in the system and also checks to see if it is active.
028 *
029 * @param balanceType
030 * @param errorPropertyName also used as the BalanceTyp DD attribute name
031 * @return True if the balance type is valid, false otherwise.
032 */
033 public abstract boolean isValidBalanceType(BalanceType balanceType, String errorPropertyName);
034
035 /**
036 * This method checks for the existence of the provided balance type, in the system and also checks to see if it is active.
037 *
038 * @param balanceType
039 * @param entryClass the Class of the DataDictionary entry containing the attribute with the label for the error message
040 * @param attributeName the name of the attribute in the DataDictionary entry
041 * @param errorPropertyName
042 * @return True if the balance type is valid, false otherwise.
043 */
044 public abstract boolean isValidBalanceType(BalanceType balanceType, Class entryClass, String attributeName, String errorPropertyName);
045
046 /**
047 * This method checks for the existence of the accounting period in the system and also makes sure that the accounting period is
048 * open for posting.
049 *
050 * @param accountingPeriod
051 * @param entryClass
052 * @param attribueName
053 * @param errorPropertyName
054 * @return True if the accounting period exists in the system and is open for posting, false otherwise.
055 */
056 public abstract boolean isValidOpenAccountingPeriod(AccountingPeriod accountingPeriod, Class entryClass, String attribueName, String errorPropertyName);
057
058 /**
059 * Some documents have reversal dates. This method represents the common implementation that transactional documents follow for
060 * reversal dates - that they must not be before the current date.
061 *
062 * @param reversalDate
063 * @param errorPropertyName
064 * @return boolean True if the reversal date is not earlier than the current date, false otherwise.
065 */
066 public abstract boolean isValidReversalDate(java.sql.Date reversalDate, String errorPropertyName);
067
068 /**
069 * Determines whether an accounting line is an income line or not. This goes agains the configurable object type code list in
070 * the ApplicationParameter mechanism. This list can be configured externally.
071 *
072 * @param accountingLine
073 * @return boolean True if the line is an income line.
074 */
075 public abstract boolean isIncome(GeneralLedgerPendingEntrySourceDetail postable);
076
077 /**
078 * Check object code type to determine whether the accounting line is expense.
079 *
080 * @param accountingLine
081 * @return boolean True if the line is an expense line.
082 */
083 public abstract boolean isExpense(GeneralLedgerPendingEntrySourceDetail postable);
084
085 /**
086 * Makes sure that the objectCode attribute is fully populated b/c we are using proxying in our persistence layer.
087 *
088 * @param accountingLine
089 * @return the object type code of the object code of the given accounting line
090 */
091 public abstract String getObjectCodeTypeCodeWithoutSideEffects(GeneralLedgerPendingEntrySourceDetail postable);
092
093 /**
094 * Gets the named property from KualiConfigurationService (i.e., from ApplicationResources.properties) and formats it with the
095 * given arguments (if any).
096 *
097 * @param propertyName
098 * @param arguments
099 * @return the formatted property (i.e., message), with any {@code {0}} replaced with the first argument, {@code {1}} with the
100 * second argument, etc.
101 */
102 public abstract String formatProperty(String propertyName, Object... arguments);
103 }