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