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.gl.dataaccess; 017 018 import java.util.Collection; 019 import java.util.Iterator; 020 import java.util.List; 021 import java.util.Map; 022 023 import org.kuali.kfs.coa.businessobject.Account; 024 import org.kuali.kfs.gl.businessobject.Balance; 025 import org.kuali.kfs.gl.businessobject.Transaction; 026 027 /** 028 * The DAO interface that declares methods needed to query the database about balances 029 */ 030 public interface BalanceDao { 031 032 /** 033 * Get the GL Summary data 034 * 035 * @param universityFiscalYear the fiscal year of balances to search for 036 * @param balanceTypeCodes a list of balance type codes of balances to search for 037 * @return iterator of reported on java.lang.Object arrays with the report data 038 */ 039 public Iterator<Object[]> getGlSummary(int universityFiscalYear, List<String> balanceTypeCodes); 040 041 /** 042 * Given a transaction, finds the balance record it would affect 043 * 044 * @param t a transaction 045 * @return the balance record it would affect 046 */ 047 public Balance getBalanceByTransaction(Transaction t); 048 049 /** 050 * Given the primary keys of a balance, finds the balance in the database. Although not all of the 051 * primary keys are sent into this method... 052 * 053 * Programmers are seriously advised not to use this method; the default implementation does not work 054 * 055 * @param universityFiscalYear the university fiscal year of the balance to find 056 * @param chartOfAccountsCode the chart of accounts code of the balance to find 057 * @param accountNumber the account number of the balance to find 058 * @return the balance that is specified by those...er...partially defined primary keys. 059 */ 060 public Balance getBalanceByPrimaryId(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber); 061 062 /** 063 * Based on specific query types, return an Iterator of balance records 064 * 065 * @param account the account of balances to find 066 * @param fiscalYear the fiscal year of balances to find 067 * @param includedObjectCodes a Collection of object codes found balances should have one of 068 * @param excludedObjectCodes a Collection of object codes found balances should not have one of 069 * @param objectTypeCodes a Collection of object type codes found balances should have one of 070 * @param balanceTypeCodes a Collection of balance type codes found balances should have one of 071 * @return an Iterator of Balances 072 */ 073 public Iterator findBalances(Account account, Integer fiscalYear, Collection includedObjectCodes, Collection excludedObjectCodes, Collection objectTypeCodes, Collection balanceTypeCodes); 074 075 /** 076 * Saves a balance to the database 077 * 078 * @param b a balance to save 079 */ 080 public void save(Balance b); 081 082 /** 083 * This method finds the cash balance entries according to input fields and values 084 * 085 * @param fieldValues the input fields and values 086 * @param isConsolidated consolidation option is applied or not 087 * @return the records of cash balance entries 088 */ 089 public Iterator<Balance> findCashBalance(Map fieldValues, boolean isConsolidated); 090 091 /** 092 * This method gets the size collection of cash balance entries or entry groups according to input fields and values 093 * 094 * @param fieldValues the input fields and values 095 * @param isConsolidated consolidation option is applied or not 096 * @return the size collection of cash balance entry groups 097 */ 098 public Integer getDetailedCashBalanceRecordCount(Map fieldValues); 099 100 /** 101 * This method gets the size collection of cash balance entry groups according to input fields and values if the entries are 102 * required to be consolidated 103 * 104 * @param fieldValues the input fields and values 105 * @return the size collection of cash balance entry groups 106 */ 107 public Iterator getConsolidatedCashBalanceRecordCount(Map fieldValues); 108 109 /** 110 * This method finds the records of balance entries according to input fields and values 111 * 112 * @param fieldValues the input fields and values 113 * @param isConsolidated consolidation option is applied or not 114 * @return the records of balance entries 115 */ 116 public Iterator findBalance(Map fieldValues, boolean isConsolidated); 117 118 /** 119 * This method gets the size collection of balance entry groups according to input fields and values if the entries are required 120 * to be consolidated 121 * 122 * @param fieldValues the input fields and values 123 * @return the size collection of balance entry groups 124 */ 125 public Iterator getConsolidatedBalanceRecordCount(Map fieldValues); 126 127 /** 128 * Returns the balance entries for the given year, chart, and account. 129 * 130 * @param universityFiscalYear the unversity fiscal year of balances to return 131 * @param chartOfAccountsCode the chart of accounts code of balances to return 132 * @param accountNumber the account number of balances to return 133 * @param sfCode Sufficient Funds Code (used to determine sorting) 134 * @return balance entries matching above 135 */ 136 public Iterator<Balance> findAccountBalances(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber, String sfCode); 137 138 /** 139 * Returns the balance entries for the given year, chart, and account. 140 * 141 * @param universityFiscalYear the fiscal year of balances to return 142 * @param chartOfAccountsCode the chart of accounts code of balances to return 143 * @param accountNumber the account number of balances to return 144 * @return balance entries matching above sorted by object code 145 */ 146 public Iterator<Balance> findAccountBalances(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber); 147 148 /** 149 * Returns the CB (current budget) record for the given year, chart, account, and object code if one is found. 150 * 151 * @param universityFiscalYear the fiscal year of the CB balance to return 152 * @param chartOfAccountsCode the chart of the accounts code of the CB balanes to return 153 * @param accountNumber the account number of the CB balance to return 154 * @param objectCode the object code of the CB balance to return 155 * @return the CB Balance record 156 */ 157 public Balance getCurrentBudgetForObjectCode(Integer universityFiscalYear, String chartOfAccountsCode, String accountNumber, String objectCode); 158 159 /** 160 * Purge the sufficient funds balance table by year/chart 161 * 162 * @param chart the chart of balances to purge 163 * @param year the university fiscal year of balances to purge 164 */ 165 public void purgeYearByChart(String chart, int year); 166 167 /** 168 * Returns all of the balances of a given fiscal year 169 * 170 * @param year the university fiscal year of balances to return 171 * @return an iterator over all balances for a given fiscal year 172 */ 173 public Iterator<Balance> findBalancesForFiscalYear(Integer year); 174 175 /** 176 * This method returns the total count of balances for a fiscal year 177 * 178 * @param year fiscal year to check 179 * @return the count of balances 180 */ 181 public int countBalancesForFiscalYear(Integer year); 182 183 /** 184 * This method returns all of the balances specifically for the nominal activity closing job 185 * 186 * @param year year to find balances for 187 * @return an Iterator of nominal activity balances 188 */ 189 public Iterator<Balance> findNominalActivityBalancesForFiscalYear(Integer year); 190 191 /** 192 * Returns the balances specifically to be forwarded to the next fiscal year, based on the "general" rule 193 * 194 * @param year the fiscal year to find balances for 195 * @return an Iterator full of Balances 196 */ 197 public Iterator<Balance> findGeneralBalancesToForwardForFiscalYear(Integer year); 198 199 /** 200 * Returns the C&G balances specifically to be forwarded to the next fiscal year, based on the "cumulative" rule 201 * 202 * @param year the fiscal year to find balances for 203 * @return and Iterator chuck full of Balances 204 */ 205 public Iterator<Balance> findCumulativeBalancesToForwardForFiscalYear(Integer year); 206 207 /** 208 * Returns the balances that would specifically be picked up by the Organization Reversion year end process 209 * 210 * @param year the year to find balances for 211 * @return an iterator of the balances to process 212 */ 213 public Iterator<Balance> findOrganizationReversionBalancesForFiscalYear(Integer year, boolean endOfYear); 214 }