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.module.ld.service;
017    
018    import java.util.Collection;
019    import java.util.Iterator;
020    import java.util.List;
021    import java.util.Map;
022    import java.util.Set;
023    
024    import org.kuali.kfs.module.ld.businessobject.EmployeeFunding;
025    import org.kuali.kfs.module.ld.businessobject.LaborBalanceSummary;
026    import org.kuali.kfs.module.ld.businessobject.LaborTransaction;
027    import org.kuali.kfs.module.ld.businessobject.LedgerBalance;
028    import org.kuali.kfs.module.ld.businessobject.LedgerBalanceForYearEndBalanceForward;
029    
030    public interface LaborLedgerBalanceService {
031    
032        /**
033         * @param fiscalYear the given fiscal year
034         * @return an Iterator over all balances for a given year
035         */
036        public Iterator<LedgerBalance> findBalancesForFiscalYear(Integer fiscalYear);
037    
038        /**
039         * @param fiscalYear the given fiscal year
040         * @param fieldValues the input fields and values
041         * @return an Iterator over all balances for a given year and search criteria
042         */
043        public Iterator<LedgerBalance> findBalancesForFiscalYear(Integer fiscalYear, Map<String, String> fieldValues);
044    
045        /**
046         * @param fiscalYear the given fiscal year
047         * @param fieldValues the input fields and values
048         * @param subFundGroupCodes the given list of qualified sub fund group codes
049         * @param fundGroupCodes the given list of qualified group codes
050         * @return an Iterator over all balances for a given year and search criteria that include the accounts of balances must belong
051         *         to the given sub fund group or fund group
052         */
053        public Iterator<LedgerBalanceForYearEndBalanceForward> findBalancesForFiscalYear(Integer fiscalYear, Map<String, String> fieldValues, List<String> subFundGroupCodes, List<String> fundGroupCodes);
054    
055        /**
056         * This method gets the size of balance entries according to input fields and values
057         * 
058         * @param fieldValues the input fields and values
059         * @param isConsolidated consolidation option is applied or not
060         * @return the size of balance entries
061         */
062        public Iterator findBalance(Map fieldValues, boolean isConsolidated);
063    
064        /**
065         * This method finds the summary records of balance entries according to input fields and values
066         * 
067         * @param fieldValues the input fields and values
068         * @param isConsolidated consolidation option is applied or not
069         * @return the summary records of balance entries
070         */
071        public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated);
072    
073        /**
074         * find a ledger balance from the given ledger balance collection with the given transaction information
075         * 
076         * @param ledgerBalanceCollection the given ledger balance collection
077         * @param transaction the given transaction information
078         * @param keyList the given list of keys that need to be compared
079         * @return a matching ledger balance from the given ledger balance
080         */
081        public <T extends LedgerBalance> T findLedgerBalance(Collection<T> ledgerBalanceCollection, LaborTransaction transaction, List<String> keyList);
082    
083        /**
084         * find a ledger balance from the given ledger balance collection with the given transaction information
085         * 
086         * @param ledgerBalanceCollection the given ledger balance collection
087         * @param transaction the given transaction information
088         * @return a matching ledger balance from the given ledger balance
089         */
090        public <T extends LedgerBalance> T findLedgerBalance(Collection<T> ledgerBalanceCollection, LaborTransaction transaction);
091    
092        /**
093         * convert the given transaction information into a ledger balance and add it into the given ledger balance collection with
094         * 
095         * @param ledgerBalanceCollection the given ledger balance collection
096         * @param transaction the given transaction information
097         * @return the ledger balance that has been added; otherwise, null;
098         */
099        public LedgerBalance addLedgerBalance(Collection<LedgerBalance> ledgerBalanceCollection, LaborTransaction transaction);
100    
101        /**
102         * update the given ledger balance with the given transaction information
103         * 
104         * @param ledgerBalance the given ledger balance
105         * @param transaction the given transaction information
106         */
107        public <T extends LedgerBalance> void updateLedgerBalance(T ledgerBalance, LaborTransaction transaction);
108    
109        /**
110         * find the funding by employee
111         * 
112         * @param fieldValues the given field values
113         * @return the funding by employee
114         */
115        public List<EmployeeFunding> findEmployeeFunding(Map fieldValues, boolean isConsolidated);
116    
117        /**
118         * find the employee funding with the corresponding CSF trakers
119         * 
120         * @param fieldValues the given field values
121         * @return the employee funding with the corresponding CSF trakers
122         */
123        public List<EmployeeFunding> findEmployeeFundingWithCSFTracker(Map fieldValues, boolean isConsolidated);
124    
125        /**
126         * find the summary of the ledger balances for the given fiscal year and balance types
127         * 
128         * @param fiscalYear the given fiscal year
129         * @param balanceTypes the given balance type codes
130         * @return the ledger balances for the given fiscal year and balance types
131         */
132        public List<LaborBalanceSummary> findBalanceSummary(Integer fiscalYear, Collection<String> balanceTypes);
133    
134        /**
135         * save the given ledger balance into the underlying data store
136         * 
137         * @param ledgerBalance the given ledger balance
138         */
139        public void save(LedgerBalance ledgerBalance);
140    
141        /**
142         * find the accounts (chart of accounts code + account number) in the given fund groups
143         * 
144         * @param fiscalYear the given fiscal year
145         * @param fieldValues the input fields and values
146         * @param subFundGroupCodes the given list of qualified sub fund group codes
147         * @param fundGroupCodes the given list of qualified group codes
148         * @return the accounts (chart of accounts code + account number) in the given fund groups
149         */
150        public List<List<String>> findAccountsInFundGroups(Integer fiscalYear, Map<String, String> fieldValues, List<String> subFundGroupCodes, List<String> fundGroupCodes);
151    
152        /**
153         * find all ledger balances matching the given criteria within the given fiscal years
154         * 
155         * @param fieldValues the given field values
156         * @param excludedFieldValues the given field values that must not be matched
157         * @param fiscalYears the given fiscal years
158         * @param balanceTypeList the given balance type code list
159         * @param positionObjectGroupCodes the specified position obejct group codes
160         * @return all ledger balances matching the given criteria within the given fiscal years
161         */
162        public Collection<LedgerBalance> findLedgerBalances(Map<String, List<String>> fieldValues, Map<String, List<String>> excludedFieldValues, Set<Integer> fiscalYears, List<String> balanceTypeList, List<String> positionObjectGroupCodes);
163    
164        /**
165         * delete the ledger balance records that were posted prior to the given fiscal year
166         * 
167         * @param fiscalYear the given fiscal year
168         * @param chartOfAccountsCode the given chart of account code
169         */
170        public void deleteLedgerBalancesPriorToYear(Integer fiscalYear, String chartOfAccountsCode);
171    }