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.bc.document.service.impl;
017    
018    import java.math.BigDecimal;
019    import java.util.ArrayList;
020    import java.util.Collection;
021    import java.util.List;
022    
023    import org.kuali.kfs.module.bc.BCConstants;
024    import org.kuali.kfs.module.bc.BCKeyConstants;
025    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionAccountSummary;
026    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgSubFundSummaryReport;
027    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgSubFundSummaryReportTotal;
028    import org.kuali.kfs.module.bc.document.dataaccess.BudgetConstructionAccountSummaryReportDao;
029    import org.kuali.kfs.module.bc.document.service.BudgetConstructionReportsServiceHelper;
030    import org.kuali.kfs.module.bc.document.service.BudgetConstructionSubFundSummaryReportService;
031    import org.kuali.kfs.module.bc.report.BudgetConstructionReportHelper;
032    import org.kuali.kfs.sys.KFSPropertyConstants;
033    import org.kuali.rice.kns.service.KualiConfigurationService;
034    import org.springframework.transaction.annotation.Transactional;
035    
036    /**
037     * Service implementation of BudgetConstructionAccountSummaryReportService.
038     */
039    @Transactional
040    public class BudgetConstructionSubFundSummaryReportServiceImpl implements BudgetConstructionSubFundSummaryReportService {
041    
042        private BudgetConstructionAccountSummaryReportDao budgetConstructionAccountSummaryReportDao;
043        private KualiConfigurationService kualiConfigurationService;
044        private BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper;
045        private boolean trExist = false;
046    
047        /**
048         * @see org.kuali.kfs.module.bc.document.service.BudgetReportsControlListService#updateSubFundSummaryReport(java.lang.String)
049         */
050        public void updateSubFundSummaryReport(String principalName) {
051            budgetConstructionAccountSummaryReportDao.cleanReportsAccountSummaryTable(principalName);
052            budgetConstructionAccountSummaryReportDao.updateSubFundSummaryReport(principalName);
053        }
054    
055        /**
056         * @see org.kuali.kfs.module.bc.document.service.BudgetConstructionSubFundSummaryReportService#buildReports(java.lang.Integer,
057         *      java.util.Collection)
058         */
059        public Collection<BudgetConstructionOrgSubFundSummaryReport> buildReports(Integer universityFiscalYear, String principalName) {
060            Collection<BudgetConstructionOrgSubFundSummaryReport> reportSet = new ArrayList();
061    
062            // build order list
063            Collection<BudgetConstructionAccountSummary> subFundSummaryList = budgetConstructionReportsServiceHelper.getDataForBuildingReports(BudgetConstructionAccountSummary.class, principalName, buildOrderByList());
064    
065            // Making a list with same organizationChartOfAccountsCode, organizationCode, chartOfAccountsCode, subFundGroupCode
066            List subTotalList = BudgetConstructionReportHelper.deleteDuplicated((List) subFundSummaryList, fieldsForSubTotal());
067            List totalList = BudgetConstructionReportHelper.deleteDuplicated((List) subFundSummaryList, fieldsForTotal());
068    
069            // Calculate Total Section
070            List<BudgetConstructionOrgSubFundSummaryReportTotal> orgSubFundSummaryReportSubTotalList = calculateSubTotal((List) subFundSummaryList, subTotalList);
071            List<BudgetConstructionOrgSubFundSummaryReportTotal> orgSubFundSummaryReportTotalList = calculateTotal((List) subFundSummaryList, totalList);
072    
073            for (BudgetConstructionAccountSummary subFundSummaryEntry : subFundSummaryList) {
074                BudgetConstructionOrgSubFundSummaryReport orgSubFundSummaryReportEntry = new BudgetConstructionOrgSubFundSummaryReport();
075                buildReportsHeader(universityFiscalYear, orgSubFundSummaryReportEntry, subFundSummaryEntry);
076                buildReportsBody(orgSubFundSummaryReportEntry, subFundSummaryEntry);
077                buildReportsTotal(orgSubFundSummaryReportEntry, subFundSummaryEntry, orgSubFundSummaryReportSubTotalList, orgSubFundSummaryReportTotalList);
078                reportSet.add(orgSubFundSummaryReportEntry);
079            }
080    
081            return reportSet;
082        }
083    
084        /**
085         * builds report Header
086         * 
087         * @param universityFiscalYear
088         * @param orgSubFundSummaryReportEntry
089         * @param subFundSummaryList
090         */
091        public void buildReportsHeader(Integer universityFiscalYear, BudgetConstructionOrgSubFundSummaryReport orgSubFundSummaryReportEntry, BudgetConstructionAccountSummary subFundSummaryList) {
092            String orgChartDesc = subFundSummaryList.getOrganizationChartOfAccounts().getFinChartOfAccountDescription();
093            String chartDesc = subFundSummaryList.getChartOfAccounts().getFinChartOfAccountDescription();
094            String orgName = subFundSummaryList.getOrganization().getOrganizationName();
095            String reportChartDesc = subFundSummaryList.getChartOfAccounts().getReportsToChartOfAccounts().getFinChartOfAccountDescription();
096            String subFundGroupName = subFundSummaryList.getFundGroup().getName();
097            String subFundGroupDes = subFundSummaryList.getSubFundGroup().getSubFundGroupDescription();
098            Integer prevFiscalyear = universityFiscalYear - 1;
099            orgSubFundSummaryReportEntry.setFiscalYear(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
100            orgSubFundSummaryReportEntry.setOrgChartOfAccountsCode(subFundSummaryList.getOrganizationChartOfAccountsCode());
101            if (orgChartDesc == null) {
102                orgSubFundSummaryReportEntry.setOrgChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
103            }
104            else {
105                orgSubFundSummaryReportEntry.setOrgChartOfAccountDescription(orgChartDesc);
106            }
107            orgSubFundSummaryReportEntry.setOrganizationCode(subFundSummaryList.getOrganizationCode());
108            if (orgName == null) {
109                orgSubFundSummaryReportEntry.setOrganizationName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_ORGANIZATION_NAME));
110            }
111            else {
112                orgSubFundSummaryReportEntry.setOrganizationName(orgName);
113            }
114            orgSubFundSummaryReportEntry.setChartOfAccountsCode(subFundSummaryList.getChartOfAccountsCode());
115            if (chartDesc == null) {
116                orgSubFundSummaryReportEntry.setChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
117            }
118            else {
119                orgSubFundSummaryReportEntry.setChartOfAccountDescription(chartDesc);
120            }
121            orgSubFundSummaryReportEntry.setFundGroupCode(subFundSummaryList.getFundGroupCode());
122            if (subFundGroupName == null) {
123                orgSubFundSummaryReportEntry.setFundGroupName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_FUNDGROUP_NAME));
124            }
125            else {
126                orgSubFundSummaryReportEntry.setFundGroupName(subFundGroupName);
127            }
128            orgSubFundSummaryReportEntry.setSubFundGroupCode(subFundSummaryList.getSubFundGroupCode());
129            if (subFundGroupName == null) {
130                orgSubFundSummaryReportEntry.setSubFundGroupDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_SUBFUNDGROUP_DESCRIPTION));
131            }
132            else {
133                orgSubFundSummaryReportEntry.setSubFundGroupDescription(subFundGroupDes);
134            }
135            Integer prevPrevFiscalyear = prevFiscalyear - 1;
136            orgSubFundSummaryReportEntry.setBaseFy(prevPrevFiscalyear.toString() + "-" + prevFiscalyear.toString().substring(2, 4));
137            orgSubFundSummaryReportEntry.setReqFy(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
138            orgSubFundSummaryReportEntry.setHeader1(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_SUBFUND));
139            orgSubFundSummaryReportEntry.setHeader2(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_SUBFUND_DESCRIPTION));
140            orgSubFundSummaryReportEntry.setHeader3(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_BASE_AMOUNT));
141            orgSubFundSummaryReportEntry.setHeader4(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_REQ_AMOUNT));
142            orgSubFundSummaryReportEntry.setHeader5(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_CHANGE));
143            orgSubFundSummaryReportEntry.setHeader6(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_CHANGE));
144            orgSubFundSummaryReportEntry.setConsHdr("");
145        }
146    
147        /**
148         * builds report body
149         * 
150         * @param orgSubFundSummaryReportEntry
151         * @param subFundSummary
152         */
153        public void buildReportsBody(BudgetConstructionOrgSubFundSummaryReport orgSubFundSummaryReportEntry, BudgetConstructionAccountSummary subFundSummary) {
154            
155            // build income expense description
156            if (subFundSummary.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_A)) {
157                orgSubFundSummaryReportEntry.setIncExpDesc(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_REVENUE));
158            }
159            else if (subFundSummary.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_E)) {
160                orgSubFundSummaryReportEntry.setIncExpDesc(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_EXP_GROSS));
161            }
162            else if (subFundSummary.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_T)) {
163                trExist = true;
164                orgSubFundSummaryReportEntry.setIncExpDesc(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_TRNFR_IN));
165            }
166            else {
167                if (trExist) {
168                    trExist = false;
169                    orgSubFundSummaryReportEntry.setIncExpDesc(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_EXP_NET_TRNFR));
170                }
171                else {
172                    orgSubFundSummaryReportEntry.setIncExpDesc(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_EXPENDITURE));
173                }
174            }
175            orgSubFundSummaryReportEntry.setBaseAmount(BudgetConstructionReportHelper.convertKualiInteger(subFundSummary.getFinancialBeginningBalanceLineAmount()));
176            orgSubFundSummaryReportEntry.setReqAmount(BudgetConstructionReportHelper.convertKualiInteger(subFundSummary.getAccountLineAnnualBalanceAmount()));
177            orgSubFundSummaryReportEntry.setAmountChange(orgSubFundSummaryReportEntry.getReqAmount() - orgSubFundSummaryReportEntry.getBaseAmount());
178            orgSubFundSummaryReportEntry.setPercentChange(BudgetConstructionReportHelper.calculatePercent(orgSubFundSummaryReportEntry.getAmountChange(), orgSubFundSummaryReportEntry.getBaseAmount()));
179        }
180    
181        /**
182         * builds report total
183         * 
184         * @param orgSubFundSummaryReportEntry
185         * @param subFundSummaryList
186         * @param reportTotalList
187         */
188        public void buildReportsTotal(BudgetConstructionOrgSubFundSummaryReport orgSubFundSummaryReportEntry, BudgetConstructionAccountSummary subFundSummaryList, List<BudgetConstructionOrgSubFundSummaryReportTotal> reportSubTotalList, List<BudgetConstructionOrgSubFundSummaryReportTotal> reportTotalList) {
189            for (BudgetConstructionOrgSubFundSummaryReportTotal subTotalEntry : reportSubTotalList) {
190                if (BudgetConstructionReportHelper.isSameEntry(subFundSummaryList, subTotalEntry.getBcas(), fieldsForSubTotal())) {
191                    orgSubFundSummaryReportEntry.setSubFundTotalRevenueBaseAmount(subTotalEntry.getSubFundTotalRevenueBaseAmount());
192                    orgSubFundSummaryReportEntry.setSubFundTotalRevenueReqAmount(subTotalEntry.getSubFundTotalRevenueReqAmount());
193                    orgSubFundSummaryReportEntry.setSubFundTotalRevenueAmountChange(subTotalEntry.getSubFundTotalRevenueReqAmount() - subTotalEntry.getSubFundTotalRevenueBaseAmount());
194                    BigDecimal percentChange = BigDecimal.ZERO;
195                    percentChange = BudgetConstructionReportHelper.calculatePercent(orgSubFundSummaryReportEntry.getSubFundTotalRevenueAmountChange(), orgSubFundSummaryReportEntry.getSubFundTotalRevenueBaseAmount());
196                    orgSubFundSummaryReportEntry.setSubFundTotalRevenuePercentChange(percentChange);
197                }
198    
199    
200                for (BudgetConstructionOrgSubFundSummaryReportTotal totalEntry : reportTotalList) {
201                    if (BudgetConstructionReportHelper.isSameEntry(subFundSummaryList, totalEntry.getBcas(), fieldsForTotal())) {
202                        BigDecimal percentChange = BigDecimal.ZERO;
203                        orgSubFundSummaryReportEntry.setTotalRevenueBaseAmount(totalEntry.getTotalRevenueBaseAmount());
204                        orgSubFundSummaryReportEntry.setTotalGrossBaseAmount(totalEntry.getTotalGrossBaseAmount());
205                        orgSubFundSummaryReportEntry.setTotalTransferInBaseAmount(totalEntry.getTotalTransferInBaseAmount());
206                        orgSubFundSummaryReportEntry.setTotalNetTransferBaseAmount(totalEntry.getTotalNetTransferBaseAmount());
207    
208                        orgSubFundSummaryReportEntry.setTotalRevenueReqAmount(totalEntry.getTotalRevenueReqAmount());
209                        orgSubFundSummaryReportEntry.setTotalGrossReqAmount(totalEntry.getTotalGrossReqAmount());
210                        orgSubFundSummaryReportEntry.setTotalTransferInReqAmount(totalEntry.getTotalTransferInReqAmount());
211                        orgSubFundSummaryReportEntry.setTotalNetTransferReqAmount(totalEntry.getTotalNetTransferReqAmount());
212                        orgSubFundSummaryReportEntry.setTotalRevenueAmountChange(orgSubFundSummaryReportEntry.getTotalRevenueReqAmount() - orgSubFundSummaryReportEntry.getTotalRevenueBaseAmount());
213                        percentChange = BudgetConstructionReportHelper.calculatePercent(orgSubFundSummaryReportEntry.getTotalRevenueAmountChange(), orgSubFundSummaryReportEntry.getTotalRevenueBaseAmount());
214                        orgSubFundSummaryReportEntry.setTotalRevenuePercentChange(percentChange);
215    
216                        orgSubFundSummaryReportEntry.setTotalGrossAmountChange(orgSubFundSummaryReportEntry.getTotalGrossReqAmount() - orgSubFundSummaryReportEntry.getTotalGrossBaseAmount());
217                        percentChange = BudgetConstructionReportHelper.calculatePercent(orgSubFundSummaryReportEntry.getTotalGrossAmountChange(), orgSubFundSummaryReportEntry.getTotalGrossBaseAmount());
218                        orgSubFundSummaryReportEntry.setTotalGrossPercentChange(percentChange);
219    
220                        orgSubFundSummaryReportEntry.setTotalTransferAmountChange(orgSubFundSummaryReportEntry.getTotalTransferInReqAmount() - orgSubFundSummaryReportEntry.getTotalTransferInBaseAmount());
221                        percentChange = BudgetConstructionReportHelper.calculatePercent(orgSubFundSummaryReportEntry.getTotalTransferAmountChange(), orgSubFundSummaryReportEntry.getTotalTransferInBaseAmount());
222                        orgSubFundSummaryReportEntry.setTotalTransferInPercentChange(percentChange);
223    
224    
225                        orgSubFundSummaryReportEntry.setTotalNetTransferAmountChange(orgSubFundSummaryReportEntry.getTotalNetTransferReqAmount() - orgSubFundSummaryReportEntry.getTotalNetTransferBaseAmount());
226                        percentChange = BudgetConstructionReportHelper.calculatePercent(orgSubFundSummaryReportEntry.getTotalNetTransferAmountChange(), orgSubFundSummaryReportEntry.getTotalNetTransferBaseAmount());
227                        orgSubFundSummaryReportEntry.setTotalNetTransferPercentChange(percentChange);
228    
229                        orgSubFundSummaryReportEntry.setRevExpDifferenceBaseAmount(orgSubFundSummaryReportEntry.getTotalRevenueBaseAmount() - orgSubFundSummaryReportEntry.getTotalNetTransferBaseAmount());
230                        orgSubFundSummaryReportEntry.setRevExpDifferenceReqAmount(orgSubFundSummaryReportEntry.getTotalRevenueReqAmount() - orgSubFundSummaryReportEntry.getTotalNetTransferReqAmount());
231                        orgSubFundSummaryReportEntry.setRevExpDifferenceAmountChange(orgSubFundSummaryReportEntry.getRevExpDifferenceReqAmount() - orgSubFundSummaryReportEntry.getRevExpDifferenceBaseAmount());
232                        percentChange = BudgetConstructionReportHelper.calculatePercent(orgSubFundSummaryReportEntry.getRevExpDifferenceAmountChange(), orgSubFundSummaryReportEntry.getRevExpDifferenceBaseAmount());
233                        orgSubFundSummaryReportEntry.setRevExpDifferencePercentChange(percentChange);
234                    }
235                }
236            }
237        }
238    
239    
240        /**
241         * Calculates total part of report
242         * 
243         * @param List bcasList
244         * @param List simpleList
245         */
246        public List calculateSubTotal(List<BudgetConstructionAccountSummary> bcasList, List<BudgetConstructionAccountSummary> subTotalList) {
247            Integer subFundTotalRevenueBaseAmount = 0;
248            Integer subFundTotalRevenueReqAmount = 0;
249    
250            List returnList = new ArrayList();
251            for (BudgetConstructionAccountSummary simpleBcasEntry : subTotalList) {
252                BudgetConstructionOrgSubFundSummaryReportTotal bcSubFundTotal = new BudgetConstructionOrgSubFundSummaryReportTotal();
253                for (BudgetConstructionAccountSummary bcasListEntry : bcasList) {
254                    if (BudgetConstructionReportHelper.isSameEntry(simpleBcasEntry, bcasListEntry, fieldsForSubTotal())) {
255                        if (bcasListEntry.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_A)) {
256                            subFundTotalRevenueBaseAmount -= BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getFinancialBeginningBalanceLineAmount());
257                            subFundTotalRevenueReqAmount -= BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getAccountLineAnnualBalanceAmount());
258                        }
259                        else if (bcasListEntry.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_X)) {
260                            subFundTotalRevenueBaseAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getFinancialBeginningBalanceLineAmount());
261                            subFundTotalRevenueReqAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getAccountLineAnnualBalanceAmount());
262                        }
263                    }
264                }
265                bcSubFundTotal.setBcas(simpleBcasEntry);
266                bcSubFundTotal.setSubFundTotalRevenueBaseAmount(subFundTotalRevenueBaseAmount);
267                bcSubFundTotal.setSubFundTotalRevenueReqAmount(subFundTotalRevenueReqAmount);
268                subFundTotalRevenueBaseAmount = 0;
269                subFundTotalRevenueReqAmount = 0;
270                returnList.add(bcSubFundTotal);
271    
272            }
273            return returnList;
274        }
275    
276    
277        /**
278         * Calculates total part of report
279         * 
280         * @param List bcasList
281         * @param List simpleList
282         */
283        public List calculateTotal(List<BudgetConstructionAccountSummary> bcasList, List<BudgetConstructionAccountSummary> totalList) {
284            Integer totalRevenueBaseAmount = 0;
285            Integer totalGrossBaseAmount = 0;
286            Integer totalTransferInBaseAmount = 0;
287            Integer totalNetTransferBaseAmount = 0;
288            Integer totalRevenueReqAmount = 0;
289            Integer totalGrossReqAmount = 0;
290            Integer totalTransferInReqAmount = 0;
291            Integer totalNetTransferReqAmount = 0;
292    
293            List returnList = new ArrayList();
294            for (BudgetConstructionAccountSummary simpleBcasEntry : totalList) {
295                BudgetConstructionOrgSubFundSummaryReportTotal bcSubFundTotal = new BudgetConstructionOrgSubFundSummaryReportTotal();
296                for (BudgetConstructionAccountSummary bcasListEntry : bcasList) {
297                    if (BudgetConstructionReportHelper.isSameEntry(simpleBcasEntry, bcasListEntry, fieldsForTotal())) {
298                        if (bcasListEntry.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_A)) {
299                            totalRevenueBaseAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getFinancialBeginningBalanceLineAmount());
300                            totalRevenueReqAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getAccountLineAnnualBalanceAmount());
301                        }
302                        else if (bcasListEntry.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_E)) {
303                            totalGrossBaseAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getFinancialBeginningBalanceLineAmount());
304                            totalGrossReqAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getAccountLineAnnualBalanceAmount());
305    
306                        }
307                        else if (bcasListEntry.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_T)) {
308                            totalTransferInBaseAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getFinancialBeginningBalanceLineAmount());
309                            totalTransferInReqAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getAccountLineAnnualBalanceAmount());
310                        }
311                        else if (bcasListEntry.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_X)) {
312                            totalNetTransferBaseAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getFinancialBeginningBalanceLineAmount());
313                            totalNetTransferReqAmount += BudgetConstructionReportHelper.convertKualiInteger(bcasListEntry.getAccountLineAnnualBalanceAmount());
314                        }
315                    }
316                }
317                bcSubFundTotal.setBcas(simpleBcasEntry);
318                bcSubFundTotal.setTotalGrossBaseAmount(totalGrossBaseAmount);
319                bcSubFundTotal.setTotalGrossReqAmount(totalGrossReqAmount);
320                bcSubFundTotal.setTotalNetTransferBaseAmount(totalNetTransferBaseAmount);
321                bcSubFundTotal.setTotalNetTransferReqAmount(totalNetTransferReqAmount);
322                bcSubFundTotal.setTotalRevenueBaseAmount(totalRevenueBaseAmount);
323                bcSubFundTotal.setTotalRevenueReqAmount(totalRevenueReqAmount);
324                bcSubFundTotal.setTotalTransferInBaseAmount(totalTransferInBaseAmount);
325                bcSubFundTotal.setTotalTransferInReqAmount(totalTransferInReqAmount);
326                returnList.add(bcSubFundTotal);
327                totalGrossBaseAmount = 0;
328                totalGrossReqAmount = 0;
329                totalNetTransferBaseAmount = 0;
330                totalNetTransferReqAmount = 0;
331                totalRevenueBaseAmount = 0;
332                totalRevenueReqAmount = 0;
333                totalTransferInBaseAmount = 0;
334                totalTransferInReqAmount = 0;
335            }
336            return returnList;
337        }
338    
339        protected List<String> fieldsForSubTotal() {
340            List<String> fieldList = fieldsForTotal();
341            fieldList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
342            return fieldList;
343        }
344    
345    
346        protected List<String> fieldsForTotal() {
347            List<String> fieldList = new ArrayList();
348            fieldList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
349            fieldList.add(KFSPropertyConstants.ORGANIZATION_CODE);
350            fieldList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
351            fieldList.add(KFSPropertyConstants.FUND_GROUP_CODE);
352            return fieldList;
353        }
354    
355    
356        /**
357         * builds orderByList for sort order.
358         * 
359         * @return returnList
360         */
361        public List<String> buildOrderByList() {
362            List<String> returnList = new ArrayList();
363            returnList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
364            returnList.add(KFSPropertyConstants.ORGANIZATION_CODE);
365            returnList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
366            returnList.add(KFSPropertyConstants.SUB_FUND_SORT_CODE);
367            returnList.add(KFSPropertyConstants.FUND_GROUP_CODE);
368            returnList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
369            returnList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
370            returnList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
371            returnList.add(KFSPropertyConstants.INCOME_EXPENSE_CODE);
372            return returnList;
373        }
374    
375    
376        /**
377         * sets budgetConstructionAccountSummaryReportDao
378         * 
379         * @param budgetConstructionAccountSummaryReportDao
380         */
381        public void setBudgetConstructionAccountSummaryReportDao(BudgetConstructionAccountSummaryReportDao budgetConstructionAccountSummaryReportDao) {
382            this.budgetConstructionAccountSummaryReportDao = budgetConstructionAccountSummaryReportDao;
383        }
384    
385        public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) {
386            this.kualiConfigurationService = kualiConfigurationService;
387        }
388    
389        public void setBudgetConstructionReportsServiceHelper(BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper) {
390            this.budgetConstructionReportsServiceHelper = budgetConstructionReportsServiceHelper;
391        }
392    }
393