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.util.ArrayList;
019    import java.util.Collection;
020    import java.util.List;
021    
022    import org.kuali.kfs.coa.businessobject.ObjectCode;
023    import org.kuali.kfs.module.bc.BCConstants;
024    import org.kuali.kfs.module.bc.BCKeyConstants;
025    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionMonthSummary;
026    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgMonthSummaryReport;
027    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgMonthSummaryReportTotal;
028    import org.kuali.kfs.module.bc.document.dataaccess.BudgetConstructionMonthSummaryReportDao;
029    import org.kuali.kfs.module.bc.document.service.BudgetConstructionMonthSummaryReportService;
030    import org.kuali.kfs.module.bc.document.service.BudgetConstructionReportsServiceHelper;
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 BudgetConstructionLevelSummaryReportService.
038     */
039    @Transactional
040    public class BudgetConstructionMonthSummaryReportServiceImpl implements BudgetConstructionMonthSummaryReportService {
041    
042        BudgetConstructionMonthSummaryReportDao budgetConstructionMonthSummaryReportDao;
043        KualiConfigurationService kualiConfigurationService;
044        BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper;
045    
046        /**
047         * @see org.kuali.kfs.module.bc.document.service.BudgetReportsControlListService#updateRepotsMonthSummaryTable(java.lang.String)
048         */
049        public void updateMonthSummaryReport(String principalName, boolean consolidateToObjectCodeLevel) {
050            budgetConstructionMonthSummaryReportDao.updateReportsMonthSummaryTable(principalName, consolidateToObjectCodeLevel);
051    
052        }
053    
054        /**
055         * @see org.kuali.kfs.module.bc.document.service.BudgetConstructionMonthSummaryReportService#buildReports(java.lang.Integer,
056         *      java.util.Collection)
057         */
058        public Collection<BudgetConstructionOrgMonthSummaryReport> buildReports(Integer universityFiscalYear, String principalName, boolean consolidateToObjectCodeLevel) {
059            Collection<BudgetConstructionOrgMonthSummaryReport> reportSet = new ArrayList();
060            Collection<BudgetConstructionMonthSummary> monthSummaryList = budgetConstructionReportsServiceHelper.getDataForBuildingReports(BudgetConstructionMonthSummary.class, principalName, buildOrderByList());
061            // Calculate Total Section
062            List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalLevelList = calculateLevelTotal((List) monthSummaryList, monthSummaryList);
063            List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalConsList = calculateConsTotal((List) monthSummaryList, monthSummaryList);
064            List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalTypeList = calculateTypeTotal((List) monthSummaryList, monthSummaryList);
065            List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalIncexpList = calculateIncexpTotal((List) monthSummaryList, monthSummaryList);
066    
067            for (BudgetConstructionMonthSummary monthSummaryEntry : monthSummaryList) {
068                BudgetConstructionOrgMonthSummaryReport orgMonthSummaryReportEntry = new BudgetConstructionOrgMonthSummaryReport();
069                buildReportsHeader(universityFiscalYear, orgMonthSummaryReportEntry, monthSummaryEntry, consolidateToObjectCodeLevel);
070                buildReportsBody(universityFiscalYear, orgMonthSummaryReportEntry, monthSummaryEntry);
071                buildReportsTotal(orgMonthSummaryReportEntry, monthSummaryEntry, monthSummaryTotalLevelList, monthSummaryTotalConsList, monthSummaryTotalTypeList, monthSummaryTotalIncexpList);
072                reportSet.add(orgMonthSummaryReportEntry);
073            }
074            return reportSet;
075        }
076    
077        /**
078         * builds report Header
079         * 
080         * @param universityFiscalYear
081         * @param orgMonthSummaryReportEntry
082         * @param monthSummary
083         * @param consolidateToObjectCodeLevel
084         */
085        public void buildReportsHeader(Integer universityFiscalYear, BudgetConstructionOrgMonthSummaryReport orgMonthSummaryReportEntry, BudgetConstructionMonthSummary monthSummary, boolean consolidateToObjectCodeLevel) {
086            String orgChartDesc = monthSummary.getOrganizationChartOfAccounts().getFinChartOfAccountDescription();
087            String chartDesc = monthSummary.getChartOfAccounts().getFinChartOfAccountDescription();
088            String orgName = monthSummary.getOrganization().getOrganizationName();
089            String subFundGroupDes = monthSummary.getSubFundGroup().getSubFundGroupDescription();
090            String fundGroupDes = monthSummary.getSubFundGroup().getFundGroup().getName();
091    
092            Integer prevFiscalyear = universityFiscalYear - 1;
093            orgMonthSummaryReportEntry.setFiscalYear(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
094            orgMonthSummaryReportEntry.setOrgChartOfAccountsCode(monthSummary.getOrganizationChartOfAccountsCode());
095    
096            if (orgChartDesc == null) {
097                orgMonthSummaryReportEntry.setOrgChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
098            }
099            else {
100                orgMonthSummaryReportEntry.setOrgChartOfAccountDescription(orgChartDesc);
101            }
102            orgMonthSummaryReportEntry.setOrganizationCode(monthSummary.getOrganizationCode());
103            if (orgName == null) {
104                orgMonthSummaryReportEntry.setOrganizationName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_ORGANIZATION_NAME));
105            }
106            else {
107                orgMonthSummaryReportEntry.setOrganizationName(orgName);
108            }
109            orgMonthSummaryReportEntry.setChartOfAccountsCode(monthSummary.getChartOfAccountsCode());
110            if (chartDesc == null) {
111                orgMonthSummaryReportEntry.setChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
112            }
113            else {
114                orgMonthSummaryReportEntry.setChartOfAccountDescription(chartDesc);
115            }
116            orgMonthSummaryReportEntry.setFundGroupCode(monthSummary.getSubFundGroup().getFundGroupCode());
117            if (fundGroupDes == null) {
118                orgMonthSummaryReportEntry.setFundGroupName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_FUNDGROUP_NAME));
119            }
120            else {
121                orgMonthSummaryReportEntry.setFundGroupName(fundGroupDes);
122            }
123            orgMonthSummaryReportEntry.setSubFundGroupCode(monthSummary.getSubFundGroupCode());
124            if (subFundGroupDes == null) {
125                orgMonthSummaryReportEntry.setSubFundGroupDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_SUBFUNDGROUP_DESCRIPTION));
126            }
127            else {
128                orgMonthSummaryReportEntry.setSubFundGroupDescription(subFundGroupDes);
129            }
130            if (consolidateToObjectCodeLevel) {
131                orgMonthSummaryReportEntry.setConsHdr(BCConstants.Report.CONSOLIIDATED);
132            }
133            else {
134                orgMonthSummaryReportEntry.setConsHdr(BCConstants.Report.BLANK);
135            }
136            orgMonthSummaryReportEntry.setIncomeExpenseCode(monthSummary.getIncomeExpenseCode());
137            orgMonthSummaryReportEntry.setFinancialConsolidationSortCode(monthSummary.getFinancialConsolidationSortCode());
138            orgMonthSummaryReportEntry.setFinancialLevelSortCode(monthSummary.getFinancialLevelSortCode());
139            orgMonthSummaryReportEntry.setFinancialObjectCode(monthSummary.getFinancialObjectCode());
140            orgMonthSummaryReportEntry.setFinancialSubObjectCode(monthSummary.getFinancialSubObjectCode());
141        }
142    
143        /**
144         * builds report body
145         * 
146         * @param universityFiscalYear
147         * @param orgMonthSummaryReportEntry
148         * @param monthSummary
149         */
150        public void buildReportsBody(Integer universityFiscalYear, BudgetConstructionOrgMonthSummaryReport orgMonthSummaryReportEntry, BudgetConstructionMonthSummary monthSummary) {
151            ObjectCode objectCode = budgetConstructionReportsServiceHelper.getObjectCode(universityFiscalYear, monthSummary.getChartOfAccountsCode(), monthSummary.getFinancialObjectCode());
152            if (objectCode != null) {
153                orgMonthSummaryReportEntry.setFinancialObjectCodeName(objectCode.getFinancialObjectCodeName());
154            }
155            else {
156                orgMonthSummaryReportEntry.setFinancialObjectCodeName("NULL");
157            }
158            orgMonthSummaryReportEntry.setAccountLineAnnualBalanceAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getAccountLineAnnualBalanceAmount()));
159            orgMonthSummaryReportEntry.setFinancialDocumentMonth1LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth1LineAmount()));
160            orgMonthSummaryReportEntry.setFinancialDocumentMonth2LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth2LineAmount()));
161            orgMonthSummaryReportEntry.setFinancialDocumentMonth3LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth3LineAmount()));
162            orgMonthSummaryReportEntry.setFinancialDocumentMonth4LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth4LineAmount()));
163            orgMonthSummaryReportEntry.setFinancialDocumentMonth5LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth5LineAmount()));
164            orgMonthSummaryReportEntry.setFinancialDocumentMonth6LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth6LineAmount()));
165            orgMonthSummaryReportEntry.setFinancialDocumentMonth7LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth7LineAmount()));
166            orgMonthSummaryReportEntry.setFinancialDocumentMonth8LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth8LineAmount()));
167            orgMonthSummaryReportEntry.setFinancialDocumentMonth9LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth9LineAmount()));
168            orgMonthSummaryReportEntry.setFinancialDocumentMonth10LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth10LineAmount()));
169            orgMonthSummaryReportEntry.setFinancialDocumentMonth11LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth11LineAmount()));
170            orgMonthSummaryReportEntry.setFinancialDocumentMonth12LineAmount(BudgetConstructionReportHelper.convertKualiInteger(monthSummary.getFinancialDocumentMonth12LineAmount()));
171        }
172    
173        /**
174         * builds report total
175         * 
176         * @param orgMonthSummaryReportEntry
177         * @param monthSummary
178         * @param monthSummaryTotalLevelList
179         * @param monthSummaryTotalConsList
180         * @param monthSummaryTotalTypeList
181         * @param monthSummaryTotalIncexpList
182         */
183        public void buildReportsTotal(BudgetConstructionOrgMonthSummaryReport orgMonthSummaryReportEntry, BudgetConstructionMonthSummary monthSummary, List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalLevelList, List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalConsList, List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalTypeList, List<BudgetConstructionOrgMonthSummaryReportTotal> monthSummaryTotalIncexpList) {
184            // set total part of level
185            for (BudgetConstructionOrgMonthSummaryReportTotal levelTotal : monthSummaryTotalLevelList) {
186                if (BudgetConstructionReportHelper.isSameEntry(monthSummary, levelTotal.getBudgetConstructionMonthSummary(), fieldsForLevel())) {
187                    orgMonthSummaryReportEntry.setLevelTotalDescription(monthSummary.getFinancialObjectLevel().getFinancialObjectLevelName());
188                    orgMonthSummaryReportEntry.setLevelAccountLineAnnualBalanceAmount(levelTotal.getLevelAccountLineAnnualBalanceAmount());
189                    orgMonthSummaryReportEntry.setLevelMonth1LineAmount(levelTotal.getLevelMonth1LineAmount());
190                    orgMonthSummaryReportEntry.setLevelMonth2LineAmount(levelTotal.getLevelMonth2LineAmount());
191                    orgMonthSummaryReportEntry.setLevelMonth3LineAmount(levelTotal.getLevelMonth3LineAmount());
192                    orgMonthSummaryReportEntry.setLevelMonth4LineAmount(levelTotal.getLevelMonth4LineAmount());
193                    orgMonthSummaryReportEntry.setLevelMonth5LineAmount(levelTotal.getLevelMonth5LineAmount());
194                    orgMonthSummaryReportEntry.setLevelMonth6LineAmount(levelTotal.getLevelMonth6LineAmount());
195                    orgMonthSummaryReportEntry.setLevelMonth7LineAmount(levelTotal.getLevelMonth7LineAmount());
196                    orgMonthSummaryReportEntry.setLevelMonth8LineAmount(levelTotal.getLevelMonth8LineAmount());
197                    orgMonthSummaryReportEntry.setLevelMonth9LineAmount(levelTotal.getLevelMonth9LineAmount());
198                    orgMonthSummaryReportEntry.setLevelMonth10LineAmount(levelTotal.getLevelMonth10LineAmount());
199                    orgMonthSummaryReportEntry.setLevelMonth11LineAmount(levelTotal.getLevelMonth11LineAmount());
200                    orgMonthSummaryReportEntry.setLevelMonth12LineAmount(levelTotal.getLevelMonth12LineAmount());
201                }
202            }
203            // set total part of cons
204            for (BudgetConstructionOrgMonthSummaryReportTotal consTotal : monthSummaryTotalConsList) {
205                if (BudgetConstructionReportHelper.isSameEntry(monthSummary, consTotal.getBudgetConstructionMonthSummary(), fieldsForCons())) {
206                    orgMonthSummaryReportEntry.setConsTotalDescription(monthSummary.getFinancialConsolidationObject().getFinConsolidationObjectName());
207                    orgMonthSummaryReportEntry.setConsAccountLineAnnualBalanceAmount(consTotal.getConsAccountLineAnnualBalanceAmount());
208                    orgMonthSummaryReportEntry.setConsMonth1LineAmount(consTotal.getConsMonth1LineAmount());
209                    orgMonthSummaryReportEntry.setConsMonth2LineAmount(consTotal.getConsMonth2LineAmount());
210                    orgMonthSummaryReportEntry.setConsMonth3LineAmount(consTotal.getConsMonth3LineAmount());
211                    orgMonthSummaryReportEntry.setConsMonth4LineAmount(consTotal.getConsMonth4LineAmount());
212                    orgMonthSummaryReportEntry.setConsMonth5LineAmount(consTotal.getConsMonth5LineAmount());
213                    orgMonthSummaryReportEntry.setConsMonth6LineAmount(consTotal.getConsMonth6LineAmount());
214                    orgMonthSummaryReportEntry.setConsMonth7LineAmount(consTotal.getConsMonth7LineAmount());
215                    orgMonthSummaryReportEntry.setConsMonth8LineAmount(consTotal.getConsMonth8LineAmount());
216                    orgMonthSummaryReportEntry.setConsMonth9LineAmount(consTotal.getConsMonth9LineAmount());
217                    orgMonthSummaryReportEntry.setConsMonth10LineAmount(consTotal.getConsMonth10LineAmount());
218                    orgMonthSummaryReportEntry.setConsMonth11LineAmount(consTotal.getConsMonth11LineAmount());
219                    orgMonthSummaryReportEntry.setConsMonth12LineAmount(consTotal.getConsMonth12LineAmount());
220                }
221            }
222            // set total part of type
223            for (BudgetConstructionOrgMonthSummaryReportTotal typeTotal : monthSummaryTotalTypeList) {
224                if (BudgetConstructionReportHelper.isSameEntry(monthSummary, typeTotal.getBudgetConstructionMonthSummary(), fieldsForType())) {
225                    // get Type desc
226                    if (monthSummary.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_A)) {
227                        orgMonthSummaryReportEntry.setTypeTotalDescription(BCConstants.Report.REVENUE);
228                    }
229                    else {
230                        orgMonthSummaryReportEntry.setTypeTotalDescription(BCConstants.Report.EXPENDITURE);
231                    }
232                    orgMonthSummaryReportEntry.setTypeAccountLineAnnualBalanceAmount(typeTotal.getTypeAccountLineAnnualBalanceAmount());
233                    orgMonthSummaryReportEntry.setTypeMonth1LineAmount(typeTotal.getTypeMonth1LineAmount());
234                    orgMonthSummaryReportEntry.setTypeMonth2LineAmount(typeTotal.getTypeMonth2LineAmount());
235                    orgMonthSummaryReportEntry.setTypeMonth3LineAmount(typeTotal.getTypeMonth3LineAmount());
236                    orgMonthSummaryReportEntry.setTypeMonth4LineAmount(typeTotal.getTypeMonth4LineAmount());
237                    orgMonthSummaryReportEntry.setTypeMonth5LineAmount(typeTotal.getTypeMonth5LineAmount());
238                    orgMonthSummaryReportEntry.setTypeMonth6LineAmount(typeTotal.getTypeMonth6LineAmount());
239                    orgMonthSummaryReportEntry.setTypeMonth7LineAmount(typeTotal.getTypeMonth7LineAmount());
240                    orgMonthSummaryReportEntry.setTypeMonth8LineAmount(typeTotal.getTypeMonth8LineAmount());
241                    orgMonthSummaryReportEntry.setTypeMonth9LineAmount(typeTotal.getTypeMonth9LineAmount());
242                    orgMonthSummaryReportEntry.setTypeMonth10LineAmount(typeTotal.getTypeMonth10LineAmount());
243                    orgMonthSummaryReportEntry.setTypeMonth11LineAmount(typeTotal.getTypeMonth11LineAmount());
244                    orgMonthSummaryReportEntry.setTypeMonth12LineAmount(typeTotal.getTypeMonth12LineAmount());
245                }
246            }
247            // set total part of encexp
248            for (BudgetConstructionOrgMonthSummaryReportTotal incexpTotal : monthSummaryTotalIncexpList) {
249                if (BudgetConstructionReportHelper.isSameEntry(monthSummary, incexpTotal.getBudgetConstructionMonthSummary(), fieldsForIncexp())) {
250                    orgMonthSummaryReportEntry.setRevAccountLineAnnualBalanceAmount(incexpTotal.getRevAccountLineAnnualBalanceAmount());
251                    orgMonthSummaryReportEntry.setRevMonth1LineAmount(incexpTotal.getRevMonth1LineAmount());
252                    orgMonthSummaryReportEntry.setRevMonth2LineAmount(incexpTotal.getRevMonth2LineAmount());
253                    orgMonthSummaryReportEntry.setRevMonth3LineAmount(incexpTotal.getRevMonth3LineAmount());
254                    orgMonthSummaryReportEntry.setRevMonth4LineAmount(incexpTotal.getRevMonth4LineAmount());
255                    orgMonthSummaryReportEntry.setRevMonth5LineAmount(incexpTotal.getRevMonth5LineAmount());
256                    orgMonthSummaryReportEntry.setRevMonth6LineAmount(incexpTotal.getRevMonth6LineAmount());
257                    orgMonthSummaryReportEntry.setRevMonth7LineAmount(incexpTotal.getRevMonth7LineAmount());
258                    orgMonthSummaryReportEntry.setRevMonth8LineAmount(incexpTotal.getRevMonth8LineAmount());
259                    orgMonthSummaryReportEntry.setRevMonth9LineAmount(incexpTotal.getRevMonth9LineAmount());
260                    orgMonthSummaryReportEntry.setRevMonth10LineAmount(incexpTotal.getRevMonth10LineAmount());
261                    orgMonthSummaryReportEntry.setRevMonth11LineAmount(incexpTotal.getRevMonth11LineAmount());
262                    orgMonthSummaryReportEntry.setRevMonth12LineAmount(incexpTotal.getRevMonth12LineAmount());
263    
264                    orgMonthSummaryReportEntry.setExpAccountLineAnnualBalanceAmount(incexpTotal.getExpAccountLineAnnualBalanceAmount());
265                    orgMonthSummaryReportEntry.setExpMonth1LineAmount(incexpTotal.getExpMonth1LineAmount());
266                    orgMonthSummaryReportEntry.setExpMonth2LineAmount(incexpTotal.getExpMonth2LineAmount());
267                    orgMonthSummaryReportEntry.setExpMonth3LineAmount(incexpTotal.getExpMonth3LineAmount());
268                    orgMonthSummaryReportEntry.setExpMonth4LineAmount(incexpTotal.getExpMonth4LineAmount());
269                    orgMonthSummaryReportEntry.setExpMonth5LineAmount(incexpTotal.getExpMonth5LineAmount());
270                    orgMonthSummaryReportEntry.setExpMonth6LineAmount(incexpTotal.getExpMonth6LineAmount());
271                    orgMonthSummaryReportEntry.setExpMonth7LineAmount(incexpTotal.getExpMonth7LineAmount());
272                    orgMonthSummaryReportEntry.setExpMonth8LineAmount(incexpTotal.getExpMonth8LineAmount());
273                    orgMonthSummaryReportEntry.setExpMonth9LineAmount(incexpTotal.getExpMonth9LineAmount());
274                    orgMonthSummaryReportEntry.setExpMonth10LineAmount(incexpTotal.getExpMonth10LineAmount());
275                    orgMonthSummaryReportEntry.setExpMonth11LineAmount(incexpTotal.getExpMonth11LineAmount());
276                    orgMonthSummaryReportEntry.setExpMonth12LineAmount(incexpTotal.getExpMonth12LineAmount());
277    
278                    Integer differenceAccountLineAnnualBalanceAmount = incexpTotal.getRevAccountLineAnnualBalanceAmount() - incexpTotal.getExpAccountLineAnnualBalanceAmount();
279                    Integer differenceMonth1LineAmount = incexpTotal.getRevMonth1LineAmount() - incexpTotal.getExpMonth1LineAmount();
280                    Integer differenceMonth2LineAmount = incexpTotal.getRevMonth2LineAmount() - incexpTotal.getExpMonth2LineAmount();
281                    Integer differenceMonth3LineAmount = incexpTotal.getRevMonth3LineAmount() - incexpTotal.getExpMonth3LineAmount();
282                    Integer differenceMonth4LineAmount = incexpTotal.getRevMonth4LineAmount() - incexpTotal.getExpMonth4LineAmount();
283                    Integer differenceMonth5LineAmount = incexpTotal.getRevMonth5LineAmount() - incexpTotal.getExpMonth5LineAmount();
284                    Integer differenceMonth6LineAmount = incexpTotal.getRevMonth6LineAmount() - incexpTotal.getExpMonth6LineAmount();
285                    Integer differenceMonth7LineAmount = incexpTotal.getRevMonth7LineAmount() - incexpTotal.getExpMonth7LineAmount();
286                    Integer differenceMonth8LineAmount = incexpTotal.getRevMonth8LineAmount() - incexpTotal.getExpMonth8LineAmount();
287                    Integer differenceMonth9LineAmount = incexpTotal.getRevMonth9LineAmount() - incexpTotal.getExpMonth9LineAmount();
288                    Integer differenceMonth10LineAmount = incexpTotal.getRevMonth10LineAmount() - incexpTotal.getExpMonth10LineAmount();
289                    Integer differenceMonth11LineAmount = incexpTotal.getRevMonth11LineAmount() - incexpTotal.getExpMonth11LineAmount();
290                    Integer differenceMonth12LineAmount = incexpTotal.getRevMonth12LineAmount() - incexpTotal.getExpMonth12LineAmount();
291    
292                    orgMonthSummaryReportEntry.setDifferenceAccountLineAnnualBalanceAmount(differenceAccountLineAnnualBalanceAmount);
293                    orgMonthSummaryReportEntry.setDifferenceMonth1LineAmount(differenceMonth1LineAmount);
294                    orgMonthSummaryReportEntry.setDifferenceMonth2LineAmount(differenceMonth2LineAmount);
295                    orgMonthSummaryReportEntry.setDifferenceMonth3LineAmount(differenceMonth3LineAmount);
296                    orgMonthSummaryReportEntry.setDifferenceMonth4LineAmount(differenceMonth4LineAmount);
297                    orgMonthSummaryReportEntry.setDifferenceMonth5LineAmount(differenceMonth5LineAmount);
298                    orgMonthSummaryReportEntry.setDifferenceMonth6LineAmount(differenceMonth6LineAmount);
299                    orgMonthSummaryReportEntry.setDifferenceMonth7LineAmount(differenceMonth7LineAmount);
300                    orgMonthSummaryReportEntry.setDifferenceMonth8LineAmount(differenceMonth8LineAmount);
301                    orgMonthSummaryReportEntry.setDifferenceMonth9LineAmount(differenceMonth9LineAmount);
302                    orgMonthSummaryReportEntry.setDifferenceMonth10LineAmount(differenceMonth10LineAmount);
303                    orgMonthSummaryReportEntry.setDifferenceMonth11LineAmount(differenceMonth11LineAmount);
304                    orgMonthSummaryReportEntry.setDifferenceMonth12LineAmount(differenceMonth12LineAmount);
305                }
306            }
307        }
308    
309        /**
310         * calculates total part of level
311         * 
312         * @param bcmsList
313         * @param monthSummaryList
314         * @return
315         */
316        public List calculateLevelTotal(List<BudgetConstructionMonthSummary> bcmsList, Collection<BudgetConstructionMonthSummary> monthSummaryList) {
317            List returnList = new ArrayList();
318            Integer levelAccountLineAnnualBalanceAmount = new Integer(0);
319            Integer levelMonth1LineAmount = new Integer(0);
320            Integer levelMonth2LineAmount = new Integer(0);
321            Integer levelMonth3LineAmount = new Integer(0);
322            Integer levelMonth4LineAmount = new Integer(0);
323            Integer levelMonth5LineAmount = new Integer(0);
324            Integer levelMonth6LineAmount = new Integer(0);
325            Integer levelMonth7LineAmount = new Integer(0);
326            Integer levelMonth8LineAmount = new Integer(0);
327            Integer levelMonth9LineAmount = new Integer(0);
328            Integer levelMonth10LineAmount = new Integer(0);
329            Integer levelMonth11LineAmount = new Integer(0);
330            Integer levelMonth12LineAmount = new Integer(0);
331    
332            List<BudgetConstructionMonthSummary> listForCalculateLevel = BudgetConstructionReportHelper.deleteDuplicated((List) monthSummaryList, fieldsForLevel());
333            for (BudgetConstructionMonthSummary levelEntry : listForCalculateLevel) {
334                BudgetConstructionOrgMonthSummaryReportTotal bcMonthTotal = new BudgetConstructionOrgMonthSummaryReportTotal();
335                for (BudgetConstructionMonthSummary bcmsListEntry : bcmsList) {
336                    if (BudgetConstructionReportHelper.isSameEntry(levelEntry, bcmsListEntry, fieldsForLevel())) {
337                        levelAccountLineAnnualBalanceAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getAccountLineAnnualBalanceAmount());
338                        levelMonth1LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth1LineAmount());
339                        levelMonth2LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth2LineAmount());
340                        levelMonth3LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth3LineAmount());
341                        levelMonth4LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth4LineAmount());
342                        levelMonth5LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth5LineAmount());
343                        levelMonth6LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth6LineAmount());
344                        levelMonth7LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth7LineAmount());
345                        levelMonth8LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth8LineAmount());
346                        levelMonth9LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth9LineAmount());
347                        levelMonth10LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth10LineAmount());
348                        levelMonth11LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth11LineAmount());
349                        levelMonth12LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth12LineAmount());
350                    }
351                }
352                bcMonthTotal.setBudgetConstructionMonthSummary(levelEntry);
353                bcMonthTotal.setLevelAccountLineAnnualBalanceAmount(levelAccountLineAnnualBalanceAmount);
354                bcMonthTotal.setLevelMonth1LineAmount(levelMonth1LineAmount);
355                bcMonthTotal.setLevelMonth2LineAmount(levelMonth2LineAmount);
356                bcMonthTotal.setLevelMonth3LineAmount(levelMonth3LineAmount);
357                bcMonthTotal.setLevelMonth4LineAmount(levelMonth4LineAmount);
358                bcMonthTotal.setLevelMonth5LineAmount(levelMonth5LineAmount);
359                bcMonthTotal.setLevelMonth6LineAmount(levelMonth6LineAmount);
360                bcMonthTotal.setLevelMonth7LineAmount(levelMonth7LineAmount);
361                bcMonthTotal.setLevelMonth8LineAmount(levelMonth8LineAmount);
362                bcMonthTotal.setLevelMonth9LineAmount(levelMonth9LineAmount);
363                bcMonthTotal.setLevelMonth10LineAmount(levelMonth10LineAmount);
364                bcMonthTotal.setLevelMonth11LineAmount(levelMonth11LineAmount);
365                bcMonthTotal.setLevelMonth12LineAmount(levelMonth12LineAmount);
366                returnList.add(bcMonthTotal);
367                levelAccountLineAnnualBalanceAmount = new Integer(0);
368                levelMonth1LineAmount = new Integer(0);
369                levelMonth2LineAmount = new Integer(0);
370                levelMonth3LineAmount = new Integer(0);
371                levelMonth4LineAmount = new Integer(0);
372                levelMonth5LineAmount = new Integer(0);
373                levelMonth6LineAmount = new Integer(0);
374                levelMonth7LineAmount = new Integer(0);
375                levelMonth8LineAmount = new Integer(0);
376                levelMonth9LineAmount = new Integer(0);
377                levelMonth10LineAmount = new Integer(0);
378                levelMonth11LineAmount = new Integer(0);
379                levelMonth12LineAmount = new Integer(0);
380            }
381            return returnList;
382        }
383    
384        /**
385         * calculates total part of cons
386         * 
387         * @param bcmsList
388         * @param monthSummaryList
389         * @return
390         */
391        public List calculateConsTotal(List<BudgetConstructionMonthSummary> bcmsList, Collection<BudgetConstructionMonthSummary> monthSummaryList) {
392            List returnList = new ArrayList();
393            Integer consAccountLineAnnualBalanceAmount = new Integer(0);
394            Integer consMonth1LineAmount = new Integer(0);
395            Integer consMonth2LineAmount = new Integer(0);
396            Integer consMonth3LineAmount = new Integer(0);
397            Integer consMonth4LineAmount = new Integer(0);
398            Integer consMonth5LineAmount = new Integer(0);
399            Integer consMonth6LineAmount = new Integer(0);
400            Integer consMonth7LineAmount = new Integer(0);
401            Integer consMonth8LineAmount = new Integer(0);
402            Integer consMonth9LineAmount = new Integer(0);
403            Integer consMonth10LineAmount = new Integer(0);
404            Integer consMonth11LineAmount = new Integer(0);
405            Integer consMonth12LineAmount = new Integer(0);
406    
407            List<BudgetConstructionMonthSummary> listForCalculateCons = BudgetConstructionReportHelper.deleteDuplicated((List) monthSummaryList, fieldsForCons());
408            for (BudgetConstructionMonthSummary consEntry : listForCalculateCons) {
409                BudgetConstructionOrgMonthSummaryReportTotal bcMonthTotal = new BudgetConstructionOrgMonthSummaryReportTotal();
410                for (BudgetConstructionMonthSummary bcmsListEntry : bcmsList) {
411                    if (BudgetConstructionReportHelper.isSameEntry(consEntry, bcmsListEntry, fieldsForCons())) {
412                        consAccountLineAnnualBalanceAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getAccountLineAnnualBalanceAmount());
413                        consMonth1LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth1LineAmount());
414                        consMonth2LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth2LineAmount());
415                        consMonth3LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth3LineAmount());
416                        consMonth4LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth4LineAmount());
417                        consMonth5LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth5LineAmount());
418                        consMonth6LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth6LineAmount());
419                        consMonth7LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth7LineAmount());
420                        consMonth8LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth8LineAmount());
421                        consMonth9LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth9LineAmount());
422                        consMonth10LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth10LineAmount());
423                        consMonth11LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth11LineAmount());
424                        consMonth12LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth12LineAmount());
425                    }
426                }
427                bcMonthTotal.setBudgetConstructionMonthSummary(consEntry);
428                bcMonthTotal.setConsAccountLineAnnualBalanceAmount(consAccountLineAnnualBalanceAmount);
429                bcMonthTotal.setConsMonth1LineAmount(consMonth1LineAmount);
430                bcMonthTotal.setConsMonth2LineAmount(consMonth2LineAmount);
431                bcMonthTotal.setConsMonth3LineAmount(consMonth3LineAmount);
432                bcMonthTotal.setConsMonth4LineAmount(consMonth4LineAmount);
433                bcMonthTotal.setConsMonth5LineAmount(consMonth5LineAmount);
434                bcMonthTotal.setConsMonth6LineAmount(consMonth6LineAmount);
435                bcMonthTotal.setConsMonth7LineAmount(consMonth7LineAmount);
436                bcMonthTotal.setConsMonth8LineAmount(consMonth8LineAmount);
437                bcMonthTotal.setConsMonth9LineAmount(consMonth9LineAmount);
438                bcMonthTotal.setConsMonth10LineAmount(consMonth10LineAmount);
439                bcMonthTotal.setConsMonth11LineAmount(consMonth11LineAmount);
440                bcMonthTotal.setConsMonth12LineAmount(consMonth12LineAmount);
441                returnList.add(bcMonthTotal);
442    
443                consAccountLineAnnualBalanceAmount = new Integer(0);
444                consMonth1LineAmount = new Integer(0);
445                consMonth2LineAmount = new Integer(0);
446                consMonth3LineAmount = new Integer(0);
447                consMonth4LineAmount = new Integer(0);
448                consMonth5LineAmount = new Integer(0);
449                consMonth6LineAmount = new Integer(0);
450                consMonth7LineAmount = new Integer(0);
451                consMonth8LineAmount = new Integer(0);
452                consMonth9LineAmount = new Integer(0);
453                consMonth10LineAmount = new Integer(0);
454                consMonth11LineAmount = new Integer(0);
455                consMonth12LineAmount = new Integer(0);
456            }
457            return returnList;
458        }
459    
460        /**
461         * calculates total part of type
462         * 
463         * @param bcmsList
464         * @param monthSummaryList
465         * @return
466         */
467        public List calculateTypeTotal(List<BudgetConstructionMonthSummary> bcmsList, Collection<BudgetConstructionMonthSummary> monthSummaryList) {
468            List returnList = new ArrayList();
469            Integer typeAccountLineAnnualBalanceAmount = new Integer(0);
470            Integer typeMonth1LineAmount = new Integer(0);
471            Integer typeMonth2LineAmount = new Integer(0);
472            Integer typeMonth3LineAmount = new Integer(0);
473            Integer typeMonth4LineAmount = new Integer(0);
474            Integer typeMonth5LineAmount = new Integer(0);
475            Integer typeMonth6LineAmount = new Integer(0);
476            Integer typeMonth7LineAmount = new Integer(0);
477            Integer typeMonth8LineAmount = new Integer(0);
478            Integer typeMonth9LineAmount = new Integer(0);
479            Integer typeMonth10LineAmount = new Integer(0);
480            Integer typeMonth11LineAmount = new Integer(0);
481            Integer typeMonth12LineAmount = new Integer(0);
482    
483            List<BudgetConstructionMonthSummary> listForCalculateType = BudgetConstructionReportHelper.deleteDuplicated((List) monthSummaryList, fieldsForType());
484            for (BudgetConstructionMonthSummary typeEntry : listForCalculateType) {
485                BudgetConstructionOrgMonthSummaryReportTotal bcMonthTotal = new BudgetConstructionOrgMonthSummaryReportTotal();
486                for (BudgetConstructionMonthSummary bcmsListEntry : bcmsList) {
487                    if (BudgetConstructionReportHelper.isSameEntry(typeEntry, bcmsListEntry, fieldsForType())) {
488                        typeAccountLineAnnualBalanceAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getAccountLineAnnualBalanceAmount());
489                        typeMonth1LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth1LineAmount());
490                        typeMonth2LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth2LineAmount());
491                        typeMonth3LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth3LineAmount());
492                        typeMonth4LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth4LineAmount());
493                        typeMonth5LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth5LineAmount());
494                        typeMonth6LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth6LineAmount());
495                        typeMonth7LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth7LineAmount());
496                        typeMonth8LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth8LineAmount());
497                        typeMonth9LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth9LineAmount());
498                        typeMonth10LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth10LineAmount());
499                        typeMonth11LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth11LineAmount());
500                        typeMonth12LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth12LineAmount());
501                    }
502                }
503                bcMonthTotal.setBudgetConstructionMonthSummary(typeEntry);
504                bcMonthTotal.setTypeAccountLineAnnualBalanceAmount(typeAccountLineAnnualBalanceAmount);
505                bcMonthTotal.setTypeMonth1LineAmount(typeMonth1LineAmount);
506                bcMonthTotal.setTypeMonth2LineAmount(typeMonth2LineAmount);
507                bcMonthTotal.setTypeMonth3LineAmount(typeMonth3LineAmount);
508                bcMonthTotal.setTypeMonth4LineAmount(typeMonth4LineAmount);
509                bcMonthTotal.setTypeMonth5LineAmount(typeMonth5LineAmount);
510                bcMonthTotal.setTypeMonth6LineAmount(typeMonth6LineAmount);
511                bcMonthTotal.setTypeMonth7LineAmount(typeMonth7LineAmount);
512                bcMonthTotal.setTypeMonth8LineAmount(typeMonth8LineAmount);
513                bcMonthTotal.setTypeMonth9LineAmount(typeMonth9LineAmount);
514                bcMonthTotal.setTypeMonth10LineAmount(typeMonth10LineAmount);
515                bcMonthTotal.setTypeMonth11LineAmount(typeMonth11LineAmount);
516                bcMonthTotal.setTypeMonth12LineAmount(typeMonth12LineAmount);
517                returnList.add(bcMonthTotal);
518    
519                typeAccountLineAnnualBalanceAmount = new Integer(0);
520                typeMonth1LineAmount = new Integer(0);
521                typeMonth2LineAmount = new Integer(0);
522                typeMonth3LineAmount = new Integer(0);
523                typeMonth4LineAmount = new Integer(0);
524                typeMonth5LineAmount = new Integer(0);
525                typeMonth6LineAmount = new Integer(0);
526                typeMonth7LineAmount = new Integer(0);
527                typeMonth8LineAmount = new Integer(0);
528                typeMonth9LineAmount = new Integer(0);
529                typeMonth10LineAmount = new Integer(0);
530                typeMonth11LineAmount = new Integer(0);
531                typeMonth12LineAmount = new Integer(0);
532            }
533            return returnList;
534        }
535    
536        /**
537         * calculates total part of incexp
538         * 
539         * @param bcmsList
540         * @param monthSummaryList
541         * @return
542         */
543        public List calculateIncexpTotal(List<BudgetConstructionMonthSummary> bcmsList, Collection<BudgetConstructionMonthSummary> monthSummaryList) {
544            List returnList = new ArrayList();
545            Integer revAccountLineAnnualBalanceAmount = new Integer(0);
546            Integer revMonth1LineAmount = new Integer(0);
547            Integer revMonth2LineAmount = new Integer(0);
548            Integer revMonth3LineAmount = new Integer(0);
549            Integer revMonth4LineAmount = new Integer(0);
550            Integer revMonth5LineAmount = new Integer(0);
551            Integer revMonth6LineAmount = new Integer(0);
552            Integer revMonth7LineAmount = new Integer(0);
553            Integer revMonth8LineAmount = new Integer(0);
554            Integer revMonth9LineAmount = new Integer(0);
555            Integer revMonth10LineAmount = new Integer(0);
556            Integer revMonth11LineAmount = new Integer(0);
557            Integer revMonth12LineAmount = new Integer(0);
558    
559            Integer expAccountLineAnnualBalanceAmount = new Integer(0);
560            Integer expMonth1LineAmount = new Integer(0);
561            Integer expMonth2LineAmount = new Integer(0);
562            Integer expMonth3LineAmount = new Integer(0);
563            Integer expMonth4LineAmount = new Integer(0);
564            Integer expMonth5LineAmount = new Integer(0);
565            Integer expMonth6LineAmount = new Integer(0);
566            Integer expMonth7LineAmount = new Integer(0);
567            Integer expMonth8LineAmount = new Integer(0);
568            Integer expMonth9LineAmount = new Integer(0);
569            Integer expMonth10LineAmount = new Integer(0);
570            Integer expMonth11LineAmount = new Integer(0);
571            Integer expMonth12LineAmount = new Integer(0);
572    
573            List<BudgetConstructionMonthSummary> listForCalculateIncexp = BudgetConstructionReportHelper.deleteDuplicated((List) monthSummaryList, fieldsForIncexp());
574            for (BudgetConstructionMonthSummary incexpEntry : listForCalculateIncexp) {
575                BudgetConstructionOrgMonthSummaryReportTotal bcMonthTotal = new BudgetConstructionOrgMonthSummaryReportTotal();
576                for (BudgetConstructionMonthSummary bcmsListEntry : bcmsList) {
577                    if (BudgetConstructionReportHelper.isSameEntry(incexpEntry, bcmsListEntry, fieldsForIncexp())) {
578                        if (bcmsListEntry.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_A)) {
579                            revAccountLineAnnualBalanceAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getAccountLineAnnualBalanceAmount());
580                            revMonth1LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth1LineAmount());
581                            revMonth2LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth2LineAmount());
582                            revMonth3LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth3LineAmount());
583                            revMonth4LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth4LineAmount());
584                            revMonth5LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth5LineAmount());
585                            revMonth6LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth6LineAmount());
586                            revMonth7LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth7LineAmount());
587                            revMonth8LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth8LineAmount());
588                            revMonth9LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth9LineAmount());
589                            revMonth10LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth10LineAmount());
590                            revMonth11LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth11LineAmount());
591                            revMonth12LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth12LineAmount());
592                        }
593                        else {
594                            expAccountLineAnnualBalanceAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getAccountLineAnnualBalanceAmount());
595                            expMonth1LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth1LineAmount());
596                            expMonth2LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth2LineAmount());
597                            expMonth3LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth3LineAmount());
598                            expMonth4LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth4LineAmount());
599                            expMonth5LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth5LineAmount());
600                            expMonth6LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth6LineAmount());
601                            expMonth7LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth7LineAmount());
602                            expMonth8LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth8LineAmount());
603                            expMonth9LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth9LineAmount());
604                            expMonth10LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth10LineAmount());
605                            expMonth11LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth11LineAmount());
606                            expMonth12LineAmount += BudgetConstructionReportHelper.convertKualiInteger(bcmsListEntry.getFinancialDocumentMonth12LineAmount());
607                        }
608                    }
609                }
610                bcMonthTotal.setBudgetConstructionMonthSummary(incexpEntry);
611                bcMonthTotal.setRevAccountLineAnnualBalanceAmount(revAccountLineAnnualBalanceAmount);
612                bcMonthTotal.setRevMonth1LineAmount(revMonth1LineAmount);
613                bcMonthTotal.setRevMonth2LineAmount(revMonth2LineAmount);
614                bcMonthTotal.setRevMonth3LineAmount(revMonth3LineAmount);
615                bcMonthTotal.setRevMonth4LineAmount(revMonth4LineAmount);
616                bcMonthTotal.setRevMonth5LineAmount(revMonth5LineAmount);
617                bcMonthTotal.setRevMonth6LineAmount(revMonth6LineAmount);
618                bcMonthTotal.setRevMonth7LineAmount(revMonth7LineAmount);
619                bcMonthTotal.setRevMonth8LineAmount(revMonth8LineAmount);
620                bcMonthTotal.setRevMonth9LineAmount(revMonth9LineAmount);
621                bcMonthTotal.setRevMonth10LineAmount(revMonth10LineAmount);
622                bcMonthTotal.setRevMonth11LineAmount(revMonth11LineAmount);
623                bcMonthTotal.setRevMonth12LineAmount(revMonth12LineAmount);
624    
625                bcMonthTotal.setBudgetConstructionMonthSummary(incexpEntry);
626                bcMonthTotal.setExpAccountLineAnnualBalanceAmount(expAccountLineAnnualBalanceAmount);
627                bcMonthTotal.setExpMonth1LineAmount(expMonth1LineAmount);
628                bcMonthTotal.setExpMonth2LineAmount(expMonth2LineAmount);
629                bcMonthTotal.setExpMonth3LineAmount(expMonth3LineAmount);
630                bcMonthTotal.setExpMonth4LineAmount(expMonth4LineAmount);
631                bcMonthTotal.setExpMonth5LineAmount(expMonth5LineAmount);
632                bcMonthTotal.setExpMonth6LineAmount(expMonth6LineAmount);
633                bcMonthTotal.setExpMonth7LineAmount(expMonth7LineAmount);
634                bcMonthTotal.setExpMonth8LineAmount(expMonth8LineAmount);
635                bcMonthTotal.setExpMonth9LineAmount(expMonth9LineAmount);
636                bcMonthTotal.setExpMonth10LineAmount(expMonth10LineAmount);
637                bcMonthTotal.setExpMonth11LineAmount(expMonth11LineAmount);
638                bcMonthTotal.setExpMonth12LineAmount(expMonth12LineAmount);
639                returnList.add(bcMonthTotal);
640    
641                revAccountLineAnnualBalanceAmount = new Integer(0);
642                revMonth1LineAmount = new Integer(0);
643                revMonth2LineAmount = new Integer(0);
644                revMonth3LineAmount = new Integer(0);
645                revMonth4LineAmount = new Integer(0);
646                revMonth5LineAmount = new Integer(0);
647                revMonth6LineAmount = new Integer(0);
648                revMonth7LineAmount = new Integer(0);
649                revMonth8LineAmount = new Integer(0);
650                revMonth9LineAmount = new Integer(0);
651                revMonth10LineAmount = new Integer(0);
652                revMonth11LineAmount = new Integer(0);
653                revMonth12LineAmount = new Integer(0);
654    
655                expAccountLineAnnualBalanceAmount = new Integer(0);
656                expMonth1LineAmount = new Integer(0);
657                expMonth2LineAmount = new Integer(0);
658                expMonth3LineAmount = new Integer(0);
659                expMonth4LineAmount = new Integer(0);
660                expMonth5LineAmount = new Integer(0);
661                expMonth6LineAmount = new Integer(0);
662                expMonth7LineAmount = new Integer(0);
663                expMonth8LineAmount = new Integer(0);
664                expMonth9LineAmount = new Integer(0);
665                expMonth10LineAmount = new Integer(0);
666                expMonth11LineAmount = new Integer(0);
667                expMonth12LineAmount = new Integer(0);
668            }
669            return returnList;
670        }
671    
672        protected List<String> fieldsForLevel() {
673            List<String> fieldList = new ArrayList();
674            fieldList.addAll(fieldsForCons());
675            fieldList.add(KFSPropertyConstants.FINANCIAL_LEVEL_SORT_CODE);
676            return fieldList;
677    
678            // firstBcms.getFinancialLevelSortCode().equals(secondBcms.getFinancialLevelSortCode())) {
679        }
680    
681        protected List<String> fieldsForCons() {
682            List<String> fieldList = new ArrayList();
683            fieldList.addAll(fieldsForType());
684            fieldList.add(KFSPropertyConstants.FINANCIAL_CONSOLIDATION_SORT_CODE);
685            return fieldList;
686            // firstBcms.getFinancialConsolidationSortCode().equals(secondBcms.getFinancialConsolidationSortCode()))
687    
688        }
689    
690        protected List<String> fieldsForType() {
691            List<String> fieldList = new ArrayList();
692            fieldList.addAll(fieldsForIncexp());
693            fieldList.add(KFSPropertyConstants.INCOME_EXPENSE_CODE);
694            return fieldList;
695            // firstBcms.getIncomeExpenseCode().equals(secondBcms.getIncomeExpenseCode())) {
696        }
697    
698        protected List<String> fieldsForIncexp() {
699            // firstBcms.getOrganizationChartOfAccountsCode().equals(secondBcms.getOrganizationChartOfAccountsCode())
700            // firstBcms.getOrganizationCode().equals(secondBcms.getOrganizationCode()) &&
701            // firstBcms.getSubFundGroupCode().equals(secondBcms.getSubFundGroupCode()) &&
702            // firstBcms.getChartOfAccountsCode().equals(secondBcms.getChartOfAccountsCode()))
703    
704            List<String> fieldList = new ArrayList();
705            fieldList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
706            fieldList.add(KFSPropertyConstants.ORGANIZATION_CODE);
707            fieldList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
708            fieldList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
709            return fieldList;
710        }
711    
712        /**
713         * builds orderByList for sort order.
714         * 
715         * @return returnList
716         */
717        public List<String> buildOrderByList() {
718            List<String> returnList = new ArrayList();
719            returnList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
720            returnList.add(KFSPropertyConstants.ORGANIZATION_CODE);
721            returnList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
722            returnList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
723            returnList.add(KFSPropertyConstants.INCOME_EXPENSE_CODE);
724            returnList.add(KFSPropertyConstants.FINANCIAL_CONSOLIDATION_SORT_CODE);
725            returnList.add(KFSPropertyConstants.FINANCIAL_LEVEL_SORT_CODE);
726            return returnList;
727        }
728    
729        public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) {
730            this.kualiConfigurationService = kualiConfigurationService;
731        }
732    
733        /**
734         * sets budgetConstructionMonthSummaryReportDao
735         * 
736         * @param budgetConstructionMonthSummaryReportDao
737         */
738        public void setBudgetConstructionMonthSummaryReportDao(BudgetConstructionMonthSummaryReportDao budgetConstructionMonthSummaryReportDao) {
739            this.budgetConstructionMonthSummaryReportDao = budgetConstructionMonthSummaryReportDao;
740        }
741    
742        public void setBudgetConstructionReportsServiceHelper(BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper) {
743            this.budgetConstructionReportsServiceHelper = budgetConstructionReportsServiceHelper;
744        }
745    
746    }
747