View Javadoc
1   /*
2    * Copyright 2008 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.sys.document.service;
17  
18  import org.kuali.ole.sys.businessobject.AccountingLine;
19  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
20  import org.kuali.ole.sys.document.AccountingDocument;
21  import org.kuali.ole.sys.document.GeneralLedgerPendingEntrySource;
22  
23  /**
24   * A collection of methods that help accounting docs determine whether an accounting line represents a debit or not
25   */
26  public interface DebitDeterminerService {
27      /**
28       * @param debitCreditCode
29       * @return true if debitCreditCode equals the the debit constant
30       */
31      public abstract boolean isDebitCode(String debitCreditCode);
32      
33      /**
34       * <ol>
35       * <li>object type is included in determining if a line is debit or credit.
36       * </ol>
37       * the following are credits (return false)
38       * <ol>
39       * <li> (isIncome || isLiability) && (lineAmount > 0)
40       * <li> (isExpense || isAsset) && (lineAmount < 0)
41       * </ol>
42       * the following are debits (return true)
43       * <ol>
44       * <li> (isIncome || isLiability) && (lineAmount < 0)
45       * <li> (isExpense || isAsset) && (lineAmount > 0)
46       * </ol>
47       * the following are invalid ( throws an <code>IllegalStateException</code>)
48       * <ol>
49       * <li> document isErrorCorrection
50       * <li> lineAmount == 0
51       * <li> ! (isIncome || isLiability || isExpense || isAsset)
52       * </ol>
53       * 
54       * @param rule
55       * @param accountingDocument
56       * @param accountingLine
57       * @return boolean
58       */
59      public abstract boolean isDebitConsideringType(GeneralLedgerPendingEntrySource poster, GeneralLedgerPendingEntrySourceDetail postable);
60      
61      /**
62       * <ol>
63       * <li>object type is not included in determining if a line is debit or credit.
64       * <li>accounting line section (source/target) is not included in determining if a line is debit or credit.
65       * </ol>
66       * the following are credits (return false)
67       * <ol>
68       * <li> none
69       * </ol>
70       * the following are debits (return true)
71       * <ol>
72       * <li> (isIncome || isLiability || isExpense || isAsset) && (lineAmount > 0)
73       * </ol>
74       * the following are invalid ( throws an <code>IllegalStateException</code>)
75       * <ol>
76       * <li> lineAmount <= 0
77       * <li> ! (isIncome || isLiability || isExpense || isAsset)
78       * </ol>
79       * 
80       * @param rule
81       * @param accountingDocument
82       * @param accountingLine
83       * @return boolean
84       */
85      public abstract boolean isDebitConsideringNothingPositiveOnly(GeneralLedgerPendingEntrySource poster, GeneralLedgerPendingEntrySourceDetail postable);
86      
87      /**
88       * <ol>
89       * <li>accounting line section (source/target) type is included in determining if a line is debit or credit.
90       * <li> zero line amounts are never allowed
91       * </ol>
92       * the following are credits (return false)
93       * <ol>
94       * <li> isSourceLine && (isIncome || isExpense || isAsset || isLiability) && (lineAmount > 0)
95       * <li> isTargetLine && (isIncome || isExpense || isAsset || isLiability) && (lineAmount < 0)
96       * </ol>
97       * the following are debits (return true)
98       * <ol>
99       * <li> isSourceLine && (isIncome || isExpense || isAsset || isLiability) && (lineAmount < 0)
100      * <li> isTargetLine && (isIncome || isExpense || isAsset || isLiability) && (lineAmount > 0)
101      * </ol>
102      * the following are invalid ( throws an <code>IllegalStateException</code>)
103      * <ol>
104      * <li> lineAmount == 0
105      * <li> ! (isIncome || isLiability || isExpense || isAsset)
106      * </ol>
107      * 
108      * @param rule
109      * @param accountingDocument
110      * @param accountingLine
111      * @return boolean
112      */
113     public abstract boolean isDebitConsideringSection(AccountingDocument accountingDocument, AccountingLine accountingLine);
114     
115     /**
116      * <ol>
117      * <li>accounting line section (source/target) and object type is included in determining if a line is debit or credit.
118      * <li> negative line amounts are <b>Only</b> allowed during error correction
119      * </ol>
120      * the following are credits (return false)
121      * <ol>
122      * <li> isSourceLine && (isExpense || isAsset) && (lineAmount > 0)
123      * <li> isTargetLine && (isIncome || isLiability) && (lineAmount > 0)
124      * <li> isErrorCorrection && isSourceLine && (isIncome || isLiability) && (lineAmount < 0)
125      * <li> isErrorCorrection && isTargetLine && (isExpense || isAsset) && (lineAmount < 0)
126      * </ol>
127      * the following are debits (return true)
128      * <ol>
129      * <li> isSourceLine && (isIncome || isLiability) && (lineAmount > 0)
130      * <li> isTargetLine && (isExpense || isAsset) && (lineAmount > 0)
131      * <li> isErrorCorrection && (isExpense || isAsset) && (lineAmount < 0)
132      * <li> isErrorCorrection && (isIncome || isLiability) && (lineAmount < 0)
133      * </ol>
134      * the following are invalid ( throws an <code>IllegalStateException</code>)
135      * <ol>
136      * <li> !isErrorCorrection && !(lineAmount > 0)
137      * </ol>
138      * 
139      * @param rule
140      * @param accountingDocument
141      * @param accountingLine
142      * @return boolean
143      */
144     public abstract boolean isDebitConsideringSectionAndTypePositiveOnly(AccountingDocument accountingDocument, AccountingLine accountingLine);
145     
146     /**
147      * This method is to convert amount to positive or negative based on the object type and Debit CreditCode combination.
148      *
149      */
150     public  String getConvertedAmount(String objectType , String debitCreditCode, String amount) ;
151 
152     /**
153      * throws an <code>IllegalStateException</code> if the document is an error correction. otherwise does nothing
154      * 
155      * @param rule
156      * @param accountingDocument
157      */
158     public abstract void disallowErrorCorrectionDocumentCheck(GeneralLedgerPendingEntrySource poster);
159     
160     /**
161      * Convience method for determine if a document is an error correction document.
162      * 
163      * @param accountingDocument
164      * @return true if document is an error correct
165      */
166     public abstract boolean isErrorCorrection(GeneralLedgerPendingEntrySource poster);
167     
168     /**
169      * Determines whether an accounting line is an asset line.
170      * 
171      * @param accountingLine
172      * @return boolean True if a line is an asset line.
173      */
174     public abstract boolean isAsset(GeneralLedgerPendingEntrySourceDetail postable);
175     
176     /**
177      * Determines whether an accounting line is a liability line.
178      * 
179      * @param accountingLine
180      * @return boolean True if the line is a liability line.
181      */
182     public abstract boolean isLiability(GeneralLedgerPendingEntrySourceDetail postable);
183     
184     /**
185      * Determines whether an accounting line is an income line or not. This goes agains the configurable object type code list in
186      * the ApplicationParameter mechanism. This list can be configured externally.
187      * 
188      * @param accountingLine
189      * @return boolean True if the line is an income line.
190      */
191     public abstract boolean isIncome(GeneralLedgerPendingEntrySourceDetail postable);
192     
193     /**
194      * Check object code type to determine whether the accounting line is expense.
195      * 
196      * @param accountingLine
197      * @return boolean True if the line is an expense line.
198      */
199     public abstract boolean isExpense(GeneralLedgerPendingEntrySourceDetail postable);
200     
201     /**
202      * Determines whether an accounting line is an expense or asset.
203      * 
204      * @param line
205      * @return boolean True if it's an expense or asset.
206      */
207     public abstract boolean isExpenseOrAsset(GeneralLedgerPendingEntrySourceDetail postable);
208     
209     /**
210      * Determines whether an accounting line is an income or liability line.
211      * 
212      * @param line
213      * @return boolean True if the line is an income or liability line.
214      */
215     public abstract boolean isIncomeOrLiability(GeneralLedgerPendingEntrySourceDetail postable);
216     
217     /**
218      * Check object code type to determine whether the accounting line is revenue.
219      * 
220      * @param line
221      * @return boolean True if the line is a revenue line.
222      */
223     public abstract boolean isRevenue(GeneralLedgerPendingEntrySourceDetail postable);
224     
225     /**
226      * Determines whether the <code>objectTypeCode</code> is an asset.
227      * 
228      * @param objectTypeCode
229      * @return Is she asset or something completely different?
230      */
231     public abstract boolean isAssetTypeCode(String objectTypeCode);
232     
233     /**
234      * Determines whether the <code>objectTypeCode</code> is a liability.
235      * 
236      * @param objectTypeCode
237      * @return Is she liability or something completely different?
238      */
239     public abstract boolean isLiabilityTypeCode(String objectTypeCode);
240     
241     /**
242      * Gets the isDebitCalculationIllegalStateExceptionMessage attribute. 
243      * @return Returns the isDebitCalculationIllegalStateExceptionMessage.
244      */
245     public abstract String getDebitCalculationIllegalStateExceptionMessage();
246     
247     /**
248      * Gets the isErrorCorrectionIllegalStateExceptionMessage attribute. 
249      * @return Returns the isErrorCorrectionIllegalStateExceptionMessage.
250      */
251     public abstract String getErrorCorrectionIllegalStateExceptionMessage();
252     
253     /**
254      * Gets the isInvalidLineTypeIllegalArgumentExceptionMessage attribute. 
255      * @return Returns the isInvalidLineTypeIllegalArgumentExceptionMessage.
256      */
257     public abstract String getInvalidLineTypeIllegalArgumentExceptionMessage();
258 }