View Javadoc
1   /*
2    * Copyright 2007 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.service;
17  
18  import java.util.Collection;
19  import java.util.Iterator;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.kuali.ole.coa.businessobject.Account;
24  import org.kuali.ole.coa.businessobject.ObjectCode;
25  import org.kuali.ole.gl.businessobject.Balance;
26  import org.kuali.ole.gl.businessobject.Encumbrance;
27  import org.kuali.ole.sys.businessobject.Bank;
28  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry;
29  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper;
30  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
31  import org.kuali.ole.sys.document.GeneralLedgerPendingEntrySource;
32  import org.kuali.ole.sys.document.GeneralLedgerPostingDocument;
33  import org.kuali.ole.sys.document.OLEGeneralLedgerPendingEntrySource;
34  import org.kuali.rice.core.api.util.type.KualiDecimal;
35  
36  /**
37   * This interface defines methods that a GeneralLedgerPendingEntry Service must provide
38   */
39  public interface GeneralLedgerPendingEntryService {
40  
41      /**
42       * This method...
43       * 
44       * @param universityFiscalYears
45       * @param chartOfAccountsCode
46       * @param accountNumber
47       * @param isDebit
48       * @return
49       */
50      public KualiDecimal getCashSummary(List universityFiscalYears, String chartOfAccountsCode, String accountNumber, boolean isDebit);
51  
52      /**
53       * This method...
54       * 
55       * @param universityFiscalYears
56       * @param chartOfAccountsCode
57       * @param accountNumber
58       * @param isDebit
59       * @return
60       */
61      public KualiDecimal getActualSummary(List universityFiscalYears, String chartOfAccountsCode, String accountNumber, boolean isDebit);
62  
63      /**
64       * This method...
65       * 
66       * @param universityFiscalYear
67       * @param chartOfAccountsCode
68       * @param accountNumber
69       * @param sufficientFundsObjectCode
70       * @param isDebit
71       * @param isYearEnd
72       * @return
73       */
74      public KualiDecimal getExpenseSummary(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber, String sufficientFundsObjectCode, boolean isDebit, boolean isYearEnd);
75  
76      /**
77       * This method...
78       * 
79       * @param universityFiscalYear
80       * @param chartOfAccountsCode
81       * @param accountNumber
82       * @param sufficientFundsObjectCode
83       * @param isDebit
84       * @param isYearEnd
85       * @return
86       */
87      public KualiDecimal getEncumbranceSummary(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber, String sufficientFundsObjectCode, boolean isDebit, boolean isYearEnd);
88  
89      /**
90       * This method...
91       * 
92       * @param universityFiscalYear
93       * @param chartOfAccountsCode
94       * @param accountNumber
95       * @param sufficientFundsObjectCode
96       * @param isYearEnd
97       * @return
98       */
99      public KualiDecimal getBudgetSummary(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber, String sufficientFundsObjectCode, boolean isYearEnd);
100 
101     /**
102      * @param transactionEntrySequenceId
103      * @param documentHeaderId
104      */
105     public GeneralLedgerPendingEntry getByPrimaryId(Integer transactionEntrySequenceId, String documentHeaderId);
106 
107     /**
108      * Invokes generateGeneralLedgerPendingEntries method on the transactional document.
109      * 
110      * @param document - document whose pending entries need generated
111      * @return whether the business rules succeeded
112      */
113     public boolean generateGeneralLedgerPendingEntries(GeneralLedgerPendingEntrySource document);
114 
115   /**
116      * Invokes generateGeneralLedgerPendingEntries method on the transactional document.
117      *
118      * @param document - document whose pending entries need generated
119      * @return whether the business rules succeeded
120      */
121     public boolean generateGeneralLedgerPendingEntries(OLEGeneralLedgerPendingEntrySource document);
122 
123     /**
124      * The fiscal year and period is null in quite a few glpe's. This will put in a sensible default.
125      * 
126      * @param glpe
127      */
128     public void fillInFiscalPeriodYear(GeneralLedgerPendingEntry glpe);
129 
130     /**
131      * @param generalLedgerPendingEntry
132      */
133     public void save(GeneralLedgerPendingEntry generalLedgerPendingEntry);
134 
135     /**
136      * @param documentHeaderId
137      */
138     public void delete(String documentHeaderId);
139 
140     /**
141      * Delete all pending entries for a specific document approved code
142      * 
143      * @param financialDocumentApprovedCode
144      */
145     public void deleteByFinancialDocumentApprovedCode(String financialDocumentApprovedCode);
146 
147     /**
148      * Does the given account have any general ledger entries? It is necessary to check this before closing an account.
149      * 
150      * @param account
151      * @return
152      */
153     public boolean hasPendingGeneralLedgerEntry(Account account);
154 
155     /**
156      * The method finds all pending ledger entries
157      * 
158      * @return all pending ledger entries
159      */
160     public Iterator findApprovedPendingLedgerEntries();
161 
162     /**
163      * This method retrieves all pending ledger entries for the given encumbrance
164      * 
165      * @param encumbrance the encumbrance entry
166      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
167      * @return all pending ledger entries of the given encumbrance
168      */
169     public Iterator findPendingLedgerEntries(Encumbrance encumbrance, boolean isApproved);
170 
171     /**
172      * This method retrieves all pending ledger entries for the given encumbrance
173      * 
174      * @param balance the balance entry
175      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
176      * @param isConsolidated determine whether the search results are consolidated
177      * @return all pending ledger entries of the given encumbrance
178      */
179     public Iterator findPendingLedgerEntries(Balance balance, boolean isApproved, boolean isConsolidated);
180 
181     /**
182      * This method retrieves all pending ledger entries matching the given entry criteria
183      * 
184      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
185      * @param fieldValues the input fields and values
186      * @return all pending ledger entries matching the given balance criteria
187      */
188     public Iterator findPendingLedgerEntriesForEntry(Map fieldValues, boolean isApproved);
189 
190     /**
191      * This method retrieves all pending ledger entries matching the given balance criteria
192      * 
193      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
194      * @param fieldValues the input fields and values
195      * @return all pending ledger entries matching the given balance criteria
196      */
197     public Iterator findPendingLedgerEntriesForBalance(Map fieldValues, boolean isApproved);
198 
199     /**
200      * This method retrieves all pending ledger entries that may belong to cash balance in the future
201      * 
202      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
203      * @return all pending ledger entries that may belong to cash balance
204      */
205     public Iterator findPendingLedgerEntriesForCashBalance(Map fieldValues, boolean isApproved);
206 
207     /**
208      * This method retrieves all pending ledger entries that may belong to encumbrance table in the future
209      * 
210      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
211      * @return all pending ledger entries that may belong to encumbrance table
212      */
213     public Iterator findPendingLedgerEntriesForEncumbrance(Map fieldValues, boolean isApproved);
214 
215     /**
216      * This method retrieves all pending ledger entries that may belong to the given account balance record in the future
217      * 
218      * @param fieldValues
219      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
220      * @return all pending ledger entries that may belong to encumbrance table
221      */
222     public Iterator findPendingLedgerEntrySummaryForAccountBalance(Map fieldValues, boolean isApproved);
223 
224     /**
225      * This method retrieves all pending ledger entries that may belong to the given account balance record in the future
226      * 
227      * @param fieldValues
228      * @param isApproved the flag that indicates whether the pending entries are approved or don't care
229      * @return all pending ledger entries that may belong to encumbrance table
230      */
231     public Iterator findPendingLedgerEntriesForAccountBalance(Map fieldValues, boolean isApproved);
232 
233     /**
234      * @param fieldValues
235      * @return
236      */
237     public Collection findPendingEntries(Map fieldValues, boolean isApproved);
238 
239     /**
240      * This populates an empty GeneralLedgerPendingEntry explicitEntry object instance with default values.
241      * 
242      * @param accountingDocument
243      * @param accountingLine
244      * @param sequenceHelper
245      * @param explicitEntry
246      */
247     public void populateExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySource poster, GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntry explicitEntry);
248 
249     /**
250      * Convenience method to build a GLPE without a generalLedgerPendingEntrySourceDetail
251      * 
252      * @param document a GeneralLedgerPostingDocument
253      * @param account the account for use in the GLPE
254      * @param objectCode the object code for use in the GLPE
255      * @param subAccountNumber the sub account number for use in the GLPE
256      * @param subObjectCode the subobject code for use in the GLPE
257      * @param organizationReferenceId the organization reference id to use in the GLPE
258      * @param projectCode the project code to use in the GLPE
259      * @param referenceNumber the reference number to use in the GLPE
260      * @param referenceTypeCode the reference type code to use in the GLPE
261      * @param referenceOriginCode the reference origin code to use in the GLPE
262      * @param description the description to put in the GLPE
263      * @param isDebit true if the GLPE represents a debit, false if it represents a credit
264      * @param amount the amount of the GLPE
265      * @param sequenceHelper the sequence helper to use
266      * @return a populated general ledger pending entry
267      */
268     public GeneralLedgerPendingEntry buildGeneralLedgerPendingEntry(GeneralLedgerPostingDocument document, Account account, ObjectCode objectCode, String subAccountNumber, String subObjectCode, String organizationReferenceId, String projectCode, String referenceNumber, String referenceTypeCode, String referenceOriginCode, String description, boolean isDebit, KualiDecimal amount, GeneralLedgerPendingEntrySequenceHelper sequenceHelper);
269 
270     /**
271      * This populates an GeneralLedgerPendingEntry offsetEntry object instance with values that differ from the values supplied in
272      * the explicit entry that it was cloned from. Note that the entries do not contain BOs now.
273      * 
274      * @param universityFiscalYear
275      * @param explicitEntry
276      * @param sequenceHelper
277      * @param offsetEntry Cloned from the explicit entry
278      */
279     public boolean populateOffsetGeneralLedgerPendingEntry(Integer universityFiscalYear, GeneralLedgerPendingEntry explicitEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntry offsetEntry);
280 
281     /**
282      * This populates an empty GeneralLedgerPendingEntry instance with default values for a bank offset. A global error will be
283      * posted as a side-effect if the given Bank has not defined the necessary bank offset relations.
284      * 
285      * @param bank
286      * @param depositAmount
287      * @param financialDocument
288      * @param universityFiscalYear
289      * @param sequenceHelper
290      * @param bankOffsetEntry
291      * @param errorPropertyName
292      */
293     public boolean populateBankOffsetGeneralLedgerPendingEntry(Bank bank, KualiDecimal depositAmount, GeneralLedgerPostingDocument financialDocument, Integer universityFiscalYear, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntry bankOffsetEntry, String errorPropertyName);
294 
295     /**
296      * Adds up the amounts of all cash to offset GeneralLedgerPendingEntry records on the given AccountingDocument
297      * 
298      * @param glPostingDocument the accounting document total the offset to cash amount for
299      * @return the offset to cash amount, where debited values have been subtracted and credited values have been added
300      */
301     public abstract KualiDecimal getOffsetToCashAmount(GeneralLedgerPostingDocument glPostingDocument);
302 
303     /**
304      * Determines if the given GeneralLedgerPendingEntry represents offsets to cash
305      * 
306      * @param generalLedgerPendingEntry the GeneralLedgerPendingEntry to check
307      * @return true if the GeneralLedgerPendingEntry represents an offset to cash; false otherwise
308      */
309     public abstract boolean isOffsetToCash(GeneralLedgerPendingEntry generalLedgerPendingEntry);
310 
311     /**
312      * Gets the encumbrance balance type. It returns the encumbrance balance type for the given universityFiscalYear if one is
313      * passed in the fieldValues or the current year encumbrance balance types.
314      * 
315      * @param fieldValues
316      * @param currentFiscalYear
317      * @return the encumbrance balance type for the given universityFiscalYear if one is passed in the fieldValues or the current
318      *         year encumbrance balance types.
319      */
320     public List<String> getEncumbranceBalanceTypes(Map fieldValues, Integer currentFiscalYear);
321 
322 
323     public void populateExplicitGeneralLedgerPendingEntry(OLEGeneralLedgerPendingEntrySource poster, GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntry explicitEntry);
324 }