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.BudgetConstructionLevelSummary; 026 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgLevelSummaryReport; 027 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgLevelSummaryReportTotal; 028 import org.kuali.kfs.module.bc.document.dataaccess.BudgetConstructionLevelSummaryReportDao; 029 import org.kuali.kfs.module.bc.document.service.BudgetConstructionLevelSummaryReportService; 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 BudgetConstructionLevelSummaryReportServiceImpl implements BudgetConstructionLevelSummaryReportService { 041 042 BudgetConstructionLevelSummaryReportDao budgetConstructionLevelSummaryReportDao; 043 KualiConfigurationService kualiConfigurationService; 044 BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper; 045 046 /** 047 * @see org.kuali.kfs.module.bc.document.service.BudgetReportsControlListService#updateRepotsLevelSummaryTable(java.lang.String) 048 */ 049 public void updateLevelSummaryReport(String principalName) { 050 budgetConstructionLevelSummaryReportDao.cleanReportsLevelSummaryTable(principalName); 051 budgetConstructionLevelSummaryReportDao.updateReportsLevelSummaryTable(principalName); 052 } 053 054 /** 055 * sets budgetConstructionLevelSummaryReportDao 056 * 057 * @param budgetConstructionLevelSummaryReportDao 058 */ 059 public void setBudgetConstructionLevelSummaryReportDao(BudgetConstructionLevelSummaryReportDao budgetConstructionLevelSummaryReportDao) { 060 this.budgetConstructionLevelSummaryReportDao = budgetConstructionLevelSummaryReportDao; 061 } 062 063 /** 064 * @see org.kuali.kfs.module.bc.document.service.BudgetConstructionLevelSummaryReportService#buildReports(java.lang.Integer, 065 * java.util.Collection) 066 */ 067 public Collection<BudgetConstructionOrgLevelSummaryReport> buildReports(Integer universityFiscalYear, String principalName) { 068 Collection<BudgetConstructionOrgLevelSummaryReport> reportSet = new ArrayList(); 069 070 BudgetConstructionOrgLevelSummaryReport orgLevelSummaryReportEntry; 071 Collection<BudgetConstructionLevelSummary> levelSummaryList = budgetConstructionReportsServiceHelper.getDataForBuildingReports(BudgetConstructionLevelSummary.class, principalName, buildOrderByList()); 072 073 074 // Making a list with same organizationChartOfAccountsCode, organizationCode, chartOfAccountsCode, subFundGroupCode 075 List listForCalculateCons = BudgetConstructionReportHelper.deleteDuplicated((List) levelSummaryList, fieldsForCons()); 076 List listForCalculateGexpAndType = BudgetConstructionReportHelper.deleteDuplicated((List) levelSummaryList, fieldsForGexpAndType()); 077 List listForCalculateTotal = BudgetConstructionReportHelper.deleteDuplicated((List) levelSummaryList, fieldsForTotal()); 078 079 // Calculate Total Section 080 List<BudgetConstructionOrgLevelSummaryReportTotal> levelSummaryTotalConsList = calculateConsTotal((List) levelSummaryList, listForCalculateCons); 081 List<BudgetConstructionOrgLevelSummaryReportTotal> levelSummaryTotalGexpAndTypeList = calculateGexpAndTypeTotal((List) levelSummaryList, listForCalculateGexpAndType); 082 List<BudgetConstructionOrgLevelSummaryReportTotal> levelSummaryTotalList = calculateTotal((List) levelSummaryList, listForCalculateTotal); 083 084 for (BudgetConstructionLevelSummary levelSummaryEntry : levelSummaryList) { 085 orgLevelSummaryReportEntry = new BudgetConstructionOrgLevelSummaryReport(); 086 buildReportsHeader(universityFiscalYear, orgLevelSummaryReportEntry, levelSummaryEntry); 087 buildReportsBody(orgLevelSummaryReportEntry, levelSummaryEntry); 088 buildReportsTotal(orgLevelSummaryReportEntry, levelSummaryEntry, levelSummaryTotalConsList, levelSummaryTotalGexpAndTypeList, levelSummaryTotalList); 089 reportSet.add(orgLevelSummaryReportEntry); 090 } 091 092 return reportSet; 093 } 094 095 /** 096 * builds report Header 097 * 098 * @param BudgetConstructionLevelSummary bcas 099 */ 100 public void buildReportsHeader(Integer universityFiscalYear, BudgetConstructionOrgLevelSummaryReport orgLevelSummaryReportEntry, BudgetConstructionLevelSummary levelSummary) { 101 String orgChartDesc = levelSummary.getOrganizationChartOfAccounts().getFinChartOfAccountDescription(); 102 String chartDesc = levelSummary.getChartOfAccounts().getFinChartOfAccountDescription(); 103 String orgName = levelSummary.getOrganization().getOrganizationName(); 104 String reportChartDesc = levelSummary.getChartOfAccounts().getReportsToChartOfAccounts().getFinChartOfAccountDescription(); 105 String subFundGroupName = levelSummary.getSubFundGroup().getSubFundGroupCode(); 106 String subFundGroupDes = levelSummary.getSubFundGroup().getSubFundGroupDescription(); 107 String fundGroupName = levelSummary.getSubFundGroup().getFundGroupCode(); 108 String fundGroupDes = levelSummary.getSubFundGroup().getFundGroup().getName(); 109 110 Integer prevFiscalyear = universityFiscalYear - 1; 111 orgLevelSummaryReportEntry.setFiscalYear(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4)); 112 orgLevelSummaryReportEntry.setOrgChartOfAccountsCode(levelSummary.getOrganizationChartOfAccountsCode()); 113 114 if (orgChartDesc == null) { 115 orgLevelSummaryReportEntry.setOrgChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION)); 116 } 117 else { 118 orgLevelSummaryReportEntry.setOrgChartOfAccountDescription(orgChartDesc); 119 } 120 121 orgLevelSummaryReportEntry.setOrganizationCode(levelSummary.getOrganizationCode()); 122 if (orgName == null) { 123 orgLevelSummaryReportEntry.setOrganizationName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_ORGANIZATION_NAME)); 124 } 125 else { 126 orgLevelSummaryReportEntry.setOrganizationName(orgName); 127 } 128 129 orgLevelSummaryReportEntry.setChartOfAccountsCode(levelSummary.getChartOfAccountsCode()); 130 if (chartDesc == null) { 131 orgLevelSummaryReportEntry.setChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION)); 132 } 133 else { 134 orgLevelSummaryReportEntry.setChartOfAccountDescription(chartDesc); 135 } 136 137 orgLevelSummaryReportEntry.setFundGroupCode(levelSummary.getSubFundGroup().getFundGroupCode()); 138 if (fundGroupDes == null) { 139 orgLevelSummaryReportEntry.setFundGroupName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_FUNDGROUP_NAME)); 140 } 141 else { 142 orgLevelSummaryReportEntry.setFundGroupName(fundGroupDes); 143 } 144 145 orgLevelSummaryReportEntry.setSubFundGroupCode(levelSummary.getSubFundGroupCode()); 146 if (subFundGroupDes == null) { 147 orgLevelSummaryReportEntry.setSubFundGroupDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_SUBFUNDGROUP_DESCRIPTION)); 148 } 149 else { 150 orgLevelSummaryReportEntry.setSubFundGroupDescription(subFundGroupDes); 151 } 152 153 Integer prevPrevFiscalyear = prevFiscalyear - 1; 154 orgLevelSummaryReportEntry.setBaseFy(prevPrevFiscalyear.toString() + "-" + prevFiscalyear.toString().substring(2, 4)); 155 orgLevelSummaryReportEntry.setReqFy(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4)); 156 orgLevelSummaryReportEntry.setHeader1("Object Level Name"); 157 orgLevelSummaryReportEntry.setHeader2a("Lv. FTE"); 158 orgLevelSummaryReportEntry.setHeader2("FTE"); 159 orgLevelSummaryReportEntry.setHeader3("Amount"); 160 orgLevelSummaryReportEntry.setHeader31("FTE"); 161 orgLevelSummaryReportEntry.setHeader40("FTE"); 162 orgLevelSummaryReportEntry.setHeader4("Amount"); 163 orgLevelSummaryReportEntry.setHeader5(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_CHANGE)); 164 orgLevelSummaryReportEntry.setHeader6(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_HEADER_CHANGE)); 165 orgLevelSummaryReportEntry.setConsHdr(""); 166 167 // For page break for objectLevelCode 168 orgLevelSummaryReportEntry.setFinancialObjectLevelCode(levelSummary.getFinancialObjectLevelCode()); 169 orgLevelSummaryReportEntry.setIncomeExpenseCode(levelSummary.getIncomeExpenseCode()); 170 orgLevelSummaryReportEntry.setFinancialConsolidationSortCode(levelSummary.getFinancialConsolidationSortCode()); 171 172 } 173 174 /** 175 * builds report body 176 * 177 * @param BudgetConstructionLevelSummary bcas 178 */ 179 public void buildReportsBody(BudgetConstructionOrgLevelSummaryReport orgLevelSummaryReportEntry, BudgetConstructionLevelSummary levelSummary) { 180 181 if (levelSummary.getFinancialObjectLevel() == null) { 182 orgLevelSummaryReportEntry.setFinancialObjectLevelName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_OBJECT_LEVEL_NAME)); 183 } 184 else { 185 orgLevelSummaryReportEntry.setFinancialObjectLevelName(levelSummary.getFinancialObjectLevel().getFinancialObjectLevelName()); 186 } 187 188 orgLevelSummaryReportEntry.setPositionCsfLeaveFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelSummary.getPositionCsfLeaveFteQuantity(), 2, true)); 189 orgLevelSummaryReportEntry.setCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelSummary.getCsfFullTimeEmploymentQuantity(), 2, true)); 190 orgLevelSummaryReportEntry.setAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelSummary.getAppointmentRequestedCsfFteQuantity(), 2, true)); 191 orgLevelSummaryReportEntry.setAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelSummary.getAppointmentRequestedFteQuantity(), 2, true)); 192 193 if (levelSummary.getAccountLineAnnualBalanceAmount() != null) { 194 orgLevelSummaryReportEntry.setAccountLineAnnualBalanceAmount(new Integer(levelSummary.getAccountLineAnnualBalanceAmount().intValue())); 195 } 196 197 if (levelSummary.getFinancialBeginningBalanceLineAmount() != null) { 198 orgLevelSummaryReportEntry.setFinancialBeginningBalanceLineAmount(new Integer(levelSummary.getFinancialBeginningBalanceLineAmount().intValue())); 199 } 200 201 if (levelSummary.getAccountLineAnnualBalanceAmount() != null && levelSummary.getFinancialBeginningBalanceLineAmount() != null) { 202 int changeAmount = levelSummary.getAccountLineAnnualBalanceAmount().subtract(levelSummary.getFinancialBeginningBalanceLineAmount()).intValue(); 203 orgLevelSummaryReportEntry.setAmountChange(new Integer(changeAmount)); 204 } 205 206 orgLevelSummaryReportEntry.setPercentChange(BudgetConstructionReportHelper.calculatePercent(orgLevelSummaryReportEntry.getAmountChange(), orgLevelSummaryReportEntry.getFinancialBeginningBalanceLineAmount())); 207 } 208 209 /** 210 * builds report total 211 * 212 * @param BudgetConstructionLevelSummary bcas 213 * @param List reportTotalList 214 */ 215 public void buildReportsTotal(BudgetConstructionOrgLevelSummaryReport orgLevelSummaryReportEntry, BudgetConstructionLevelSummary levelSummary, List<BudgetConstructionOrgLevelSummaryReportTotal> levelSummaryTotalConsList, List<BudgetConstructionOrgLevelSummaryReportTotal> levelSummaryTotalGexpAndTypeList, List<BudgetConstructionOrgLevelSummaryReportTotal> levelSummaryTotalList) { 216 217 for (BudgetConstructionOrgLevelSummaryReportTotal consTotal : levelSummaryTotalConsList) { 218 if (BudgetConstructionReportHelper.isSameEntry(levelSummary, consTotal.getBcls(), fieldsForCons())) { 219 orgLevelSummaryReportEntry.setTotalConsolidationDescription(levelSummary.getFinancialConsolidationObject().getFinConsolidationObjectName()); 220 221 // The total part shouldn't have null value, so just checking '0' 222 orgLevelSummaryReportEntry.setTotalConsolidationPositionCsfLeaveFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationPositionCsfLeaveFteQuantity(), 2, true)); 223 orgLevelSummaryReportEntry.setTotalConsolidationPositionCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationPositionCsfFullTimeEmploymentQuantity(), 2, true)); 224 orgLevelSummaryReportEntry.setTotalConsolidationFinancialBeginningBalanceLineAmount(consTotal.getTotalConsolidationFinancialBeginningBalanceLineAmount()); 225 orgLevelSummaryReportEntry.setTotalConsolidationAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationAppointmentRequestedCsfFteQuantity(), 2, true)); 226 orgLevelSummaryReportEntry.setTotalConsolidationAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationAppointmentRequestedFteQuantity(), 2, true)); 227 orgLevelSummaryReportEntry.setTotalConsolidationAccountLineAnnualBalanceAmount(consTotal.getTotalConsolidationAccountLineAnnualBalanceAmount()); 228 229 Integer amountChange = consTotal.getTotalConsolidationAccountLineAnnualBalanceAmount() - consTotal.getTotalConsolidationFinancialBeginningBalanceLineAmount(); 230 orgLevelSummaryReportEntry.setTotalConsolidationAmountChange(amountChange); 231 orgLevelSummaryReportEntry.setTotalConsolidationPercentChange(BudgetConstructionReportHelper.calculatePercent(amountChange, consTotal.getTotalConsolidationFinancialBeginningBalanceLineAmount())); 232 } 233 } 234 235 for (BudgetConstructionOrgLevelSummaryReportTotal gexpAndTypeTotal : levelSummaryTotalGexpAndTypeList) { 236 if (BudgetConstructionReportHelper.isSameEntry(levelSummary, gexpAndTypeTotal.getBcls(), fieldsForGexpAndType())) { 237 238 orgLevelSummaryReportEntry.setGrossFinancialBeginningBalanceLineAmount(gexpAndTypeTotal.getGrossFinancialBeginningBalanceLineAmount()); 239 orgLevelSummaryReportEntry.setGrossAccountLineAnnualBalanceAmount(gexpAndTypeTotal.getGrossAccountLineAnnualBalanceAmount()); 240 Integer gexpAndTypeAmountChange = gexpAndTypeTotal.getGrossAccountLineAnnualBalanceAmount() - gexpAndTypeTotal.getGrossFinancialBeginningBalanceLineAmount(); 241 orgLevelSummaryReportEntry.setGrossAmountChange(gexpAndTypeAmountChange); 242 orgLevelSummaryReportEntry.setGrossPercentChange(BudgetConstructionReportHelper.calculatePercent(gexpAndTypeAmountChange, gexpAndTypeTotal.getGrossFinancialBeginningBalanceLineAmount())); 243 244 if (levelSummary.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_A)) { 245 orgLevelSummaryReportEntry.setTypeDesc(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_UPPERCASE_REVENUE)); 246 } 247 else { 248 orgLevelSummaryReportEntry.setTypeDesc(kualiConfigurationService.getPropertyString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_EXPENDITURE_NET_TRNFR)); 249 } 250 orgLevelSummaryReportEntry.setTypePositionCsfLeaveFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypePositionCsfLeaveFteQuantity(), 2, true)); 251 orgLevelSummaryReportEntry.setTypePositionCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypePositionCsfFullTimeEmploymentQuantity(), 2, true)); 252 orgLevelSummaryReportEntry.setTypeFinancialBeginningBalanceLineAmount(gexpAndTypeTotal.getTypeFinancialBeginningBalanceLineAmount()); 253 orgLevelSummaryReportEntry.setTypeAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypeAppointmentRequestedCsfFteQuantity(), 2, true)); 254 orgLevelSummaryReportEntry.setTypeAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypeAppointmentRequestedFteQuantity(), 2, true)); 255 256 orgLevelSummaryReportEntry.setTypeAccountLineAnnualBalanceAmount(gexpAndTypeTotal.getTypeAccountLineAnnualBalanceAmount()); 257 Integer typeAmountChange = gexpAndTypeTotal.getTypeAccountLineAnnualBalanceAmount() - gexpAndTypeTotal.getTypeFinancialBeginningBalanceLineAmount(); 258 orgLevelSummaryReportEntry.setTypeAmountChange(typeAmountChange); 259 orgLevelSummaryReportEntry.setTypePercentChange(BudgetConstructionReportHelper.calculatePercent(typeAmountChange, gexpAndTypeTotal.getTypeFinancialBeginningBalanceLineAmount())); 260 } 261 } 262 263 for (BudgetConstructionOrgLevelSummaryReportTotal total : levelSummaryTotalList) { 264 if (BudgetConstructionReportHelper.isSameEntry(levelSummary, total.getBcls(), fieldsForTotal())) { 265 266 orgLevelSummaryReportEntry.setTotalSubFundGroupDesc(levelSummary.getSubFundGroup().getSubFundGroupDescription()); 267 orgLevelSummaryReportEntry.setRevenueFinancialBeginningBalanceLineAmount(total.getRevenueFinancialBeginningBalanceLineAmount()); 268 orgLevelSummaryReportEntry.setRevenueAccountLineAnnualBalanceAmount(total.getRevenueAccountLineAnnualBalanceAmount()); 269 orgLevelSummaryReportEntry.setExpenditureFinancialBeginningBalanceLineAmount(total.getExpenditureFinancialBeginningBalanceLineAmount()); 270 orgLevelSummaryReportEntry.setExpenditureAccountLineAnnualBalanceAmount(total.getExpenditureAccountLineAnnualBalanceAmount()); 271 272 Integer revenueAmountChange = total.getRevenueAccountLineAnnualBalanceAmount() - total.getRevenueFinancialBeginningBalanceLineAmount(); 273 orgLevelSummaryReportEntry.setRevenueAmountChange(revenueAmountChange); 274 orgLevelSummaryReportEntry.setRevenuePercentChange(BudgetConstructionReportHelper.calculatePercent(revenueAmountChange, total.getRevenueFinancialBeginningBalanceLineAmount())); 275 276 Integer expenditureAmountChange = total.getExpenditureAccountLineAnnualBalanceAmount() - total.getExpenditureFinancialBeginningBalanceLineAmount(); 277 orgLevelSummaryReportEntry.setExpenditureAmountChange(expenditureAmountChange); 278 orgLevelSummaryReportEntry.setExpenditurePercentChange(BudgetConstructionReportHelper.calculatePercent(expenditureAmountChange, total.getExpenditureFinancialBeginningBalanceLineAmount())); 279 280 orgLevelSummaryReportEntry.setDifferenceFinancialBeginningBalanceLineAmount(total.getDifferenceFinancialBeginningBalanceLineAmount()); 281 orgLevelSummaryReportEntry.setDifferenceAccountLineAnnualBalanceAmount(total.getDifferenceAccountLineAnnualBalanceAmount()); 282 283 Integer differenceAmountChange = total.getDifferenceAccountLineAnnualBalanceAmount() - total.getDifferenceFinancialBeginningBalanceLineAmount(); 284 orgLevelSummaryReportEntry.setDifferenceAmountChange(differenceAmountChange); 285 orgLevelSummaryReportEntry.setDifferencePercentChange(BudgetConstructionReportHelper.calculatePercent(differenceAmountChange, total.getDifferenceFinancialBeginningBalanceLineAmount())); 286 } 287 } 288 } 289 290 291 public List calculateConsTotal(List<BudgetConstructionLevelSummary> bclsList, List<BudgetConstructionLevelSummary> simpleList) { 292 293 BigDecimal totalConsolidationPositionCsfLeaveFteQuantity = BigDecimal.ZERO; 294 BigDecimal totalConsolidationPositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO; 295 Integer totalConsolidationFinancialBeginningBalanceLineAmount = new Integer(0); 296 BigDecimal totalConsolidationAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO; 297 BigDecimal totalConsolidationAppointmentRequestedFteQuantity = BigDecimal.ZERO; 298 Integer totalConsolidationAccountLineAnnualBalanceAmount = new Integer(0); 299 300 List returnList = new ArrayList(); 301 for (BudgetConstructionLevelSummary simpleBclsEntry : simpleList) { 302 BudgetConstructionOrgLevelSummaryReportTotal bcLevelTotal = new BudgetConstructionOrgLevelSummaryReportTotal(); 303 for (BudgetConstructionLevelSummary bclsListEntry : bclsList) { 304 if (BudgetConstructionReportHelper.isSameEntry(simpleBclsEntry, bclsListEntry, fieldsForCons())) { 305 totalConsolidationFinancialBeginningBalanceLineAmount += new Integer(bclsListEntry.getFinancialBeginningBalanceLineAmount().intValue()); 306 totalConsolidationAccountLineAnnualBalanceAmount += new Integer(bclsListEntry.getAccountLineAnnualBalanceAmount().intValue()); 307 totalConsolidationPositionCsfLeaveFteQuantity = totalConsolidationPositionCsfLeaveFteQuantity.add(bclsListEntry.getPositionCsfLeaveFteQuantity()); 308 totalConsolidationPositionCsfFullTimeEmploymentQuantity = totalConsolidationPositionCsfFullTimeEmploymentQuantity.add(bclsListEntry.getCsfFullTimeEmploymentQuantity()); 309 totalConsolidationAppointmentRequestedCsfFteQuantity = totalConsolidationAppointmentRequestedCsfFteQuantity.add(bclsListEntry.getAppointmentRequestedCsfFteQuantity()); 310 totalConsolidationAppointmentRequestedFteQuantity = totalConsolidationAppointmentRequestedFteQuantity.add(bclsListEntry.getAppointmentRequestedFteQuantity()); 311 } 312 } 313 bcLevelTotal.setBcls(simpleBclsEntry); 314 bcLevelTotal.setTotalConsolidationPositionCsfLeaveFteQuantity(totalConsolidationPositionCsfLeaveFteQuantity); 315 bcLevelTotal.setTotalConsolidationPositionCsfFullTimeEmploymentQuantity(totalConsolidationPositionCsfFullTimeEmploymentQuantity); 316 bcLevelTotal.setTotalConsolidationFinancialBeginningBalanceLineAmount(totalConsolidationFinancialBeginningBalanceLineAmount); 317 bcLevelTotal.setTotalConsolidationAppointmentRequestedCsfFteQuantity(totalConsolidationAppointmentRequestedCsfFteQuantity); 318 bcLevelTotal.setTotalConsolidationAppointmentRequestedFteQuantity(totalConsolidationAppointmentRequestedFteQuantity); 319 bcLevelTotal.setTotalConsolidationAccountLineAnnualBalanceAmount(totalConsolidationAccountLineAnnualBalanceAmount); 320 returnList.add(bcLevelTotal); 321 322 totalConsolidationPositionCsfLeaveFteQuantity = BigDecimal.ZERO; 323 totalConsolidationPositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO; 324 totalConsolidationFinancialBeginningBalanceLineAmount = new Integer(0); 325 totalConsolidationAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO; 326 totalConsolidationAppointmentRequestedFteQuantity = BigDecimal.ZERO; 327 totalConsolidationAccountLineAnnualBalanceAmount = new Integer(0); 328 } 329 return returnList; 330 } 331 332 public List calculateGexpAndTypeTotal(List<BudgetConstructionLevelSummary> bclsList, List<BudgetConstructionLevelSummary> simpleList) { 333 334 Integer grossFinancialBeginningBalanceLineAmount = new Integer(0); 335 Integer grossAccountLineAnnualBalanceAmount = new Integer(0); 336 337 BigDecimal typePositionCsfLeaveFteQuantity = BigDecimal.ZERO; 338 BigDecimal typePositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO; 339 Integer typeFinancialBeginningBalanceLineAmount = new Integer(0); 340 BigDecimal typeAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO; 341 BigDecimal typeAppointmentRequestedFteQuantity = BigDecimal.ZERO; 342 Integer typeAccountLineAnnualBalanceAmount = new Integer(0); 343 Integer typeAmountChange = new Integer(0); 344 BigDecimal typePercentChange = BigDecimal.ZERO; 345 346 List returnList = new ArrayList(); 347 for (BudgetConstructionLevelSummary simpleBclsEntry : simpleList) { 348 BudgetConstructionOrgLevelSummaryReportTotal bcLevelTotal = new BudgetConstructionOrgLevelSummaryReportTotal(); 349 for (BudgetConstructionLevelSummary bclsListEntry : bclsList) { 350 if (BudgetConstructionReportHelper.isSameEntry(simpleBclsEntry, bclsListEntry, fieldsForGexpAndType())) { 351 352 typeFinancialBeginningBalanceLineAmount += new Integer(bclsListEntry.getFinancialBeginningBalanceLineAmount().intValue()); 353 typeAccountLineAnnualBalanceAmount += new Integer(bclsListEntry.getAccountLineAnnualBalanceAmount().intValue()); 354 typePositionCsfLeaveFteQuantity = typePositionCsfLeaveFteQuantity.add(bclsListEntry.getPositionCsfLeaveFteQuantity()); 355 typePositionCsfFullTimeEmploymentQuantity = typePositionCsfFullTimeEmploymentQuantity.add(bclsListEntry.getCsfFullTimeEmploymentQuantity()); 356 typeAppointmentRequestedCsfFteQuantity = typeAppointmentRequestedCsfFteQuantity.add(bclsListEntry.getAppointmentRequestedCsfFteQuantity()); 357 typeAppointmentRequestedFteQuantity = typeAppointmentRequestedFteQuantity.add(bclsListEntry.getAppointmentRequestedFteQuantity()); 358 359 if (bclsListEntry.getIncomeExpenseCode().equals("B") && !bclsListEntry.getFinancialObjectLevelCode().equals("CORI") && !bclsListEntry.getFinancialObjectLevelCode().equals("TRIN")) { 360 grossFinancialBeginningBalanceLineAmount += new Integer(bclsListEntry.getFinancialBeginningBalanceLineAmount().intValue()); 361 grossAccountLineAnnualBalanceAmount += new Integer(bclsListEntry.getAccountLineAnnualBalanceAmount().intValue()); 362 } 363 } 364 } 365 bcLevelTotal.setBcls(simpleBclsEntry); 366 367 bcLevelTotal.setGrossFinancialBeginningBalanceLineAmount(grossFinancialBeginningBalanceLineAmount); 368 bcLevelTotal.setGrossAccountLineAnnualBalanceAmount(grossAccountLineAnnualBalanceAmount); 369 370 bcLevelTotal.setTypePositionCsfLeaveFteQuantity(typePositionCsfLeaveFteQuantity); 371 bcLevelTotal.setTypePositionCsfFullTimeEmploymentQuantity(typePositionCsfFullTimeEmploymentQuantity); 372 bcLevelTotal.setTypeFinancialBeginningBalanceLineAmount(typeFinancialBeginningBalanceLineAmount); 373 bcLevelTotal.setTypeAppointmentRequestedCsfFteQuantity(typeAppointmentRequestedCsfFteQuantity); 374 bcLevelTotal.setTypeAppointmentRequestedFteQuantity(typeAppointmentRequestedFteQuantity); 375 bcLevelTotal.setTypeAccountLineAnnualBalanceAmount(typeAccountLineAnnualBalanceAmount); 376 377 378 returnList.add(bcLevelTotal); 379 grossFinancialBeginningBalanceLineAmount = new Integer(0); 380 grossAccountLineAnnualBalanceAmount = new Integer(0); 381 382 typePositionCsfLeaveFteQuantity = BigDecimal.ZERO; 383 typePositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO; 384 typeFinancialBeginningBalanceLineAmount = new Integer(0); 385 typeAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO; 386 typeAppointmentRequestedFteQuantity = BigDecimal.ZERO; 387 typeAccountLineAnnualBalanceAmount = new Integer(0); 388 typeAmountChange = new Integer(0); 389 typePercentChange = BigDecimal.ZERO; 390 } 391 return returnList; 392 } 393 394 395 public List calculateTotal(List<BudgetConstructionLevelSummary> bclsList, List<BudgetConstructionLevelSummary> simpleList) { 396 397 Integer revenueFinancialBeginningBalanceLineAmount = new Integer(0); 398 Integer revenueAccountLineAnnualBalanceAmount = new Integer(0); 399 400 Integer expenditureFinancialBeginningBalanceLineAmount = new Integer(0); 401 Integer expenditureAccountLineAnnualBalanceAmount = new Integer(0); 402 403 Integer differenceFinancialBeginningBalanceLineAmount = new Integer(0); 404 Integer differenceAccountLineAnnualBalanceAmount = new Integer(0); 405 406 List returnList = new ArrayList(); 407 for (BudgetConstructionLevelSummary simpleBclsEntry : simpleList) { 408 BudgetConstructionOrgLevelSummaryReportTotal bcLevelTotal = new BudgetConstructionOrgLevelSummaryReportTotal(); 409 for (BudgetConstructionLevelSummary bclsListEntry : bclsList) { 410 if (BudgetConstructionReportHelper.isSameEntry(simpleBclsEntry, bclsListEntry, fieldsForTotal())) { 411 412 if (bclsListEntry.getIncomeExpenseCode().equals("A")) { 413 revenueFinancialBeginningBalanceLineAmount += new Integer(bclsListEntry.getFinancialBeginningBalanceLineAmount().intValue()); 414 revenueAccountLineAnnualBalanceAmount += new Integer(bclsListEntry.getAccountLineAnnualBalanceAmount().intValue()); 415 } 416 else { 417 expenditureFinancialBeginningBalanceLineAmount += new Integer(bclsListEntry.getFinancialBeginningBalanceLineAmount().intValue()); 418 expenditureAccountLineAnnualBalanceAmount += new Integer(bclsListEntry.getAccountLineAnnualBalanceAmount().intValue()); 419 } 420 } 421 } 422 423 bcLevelTotal.setBcls(simpleBclsEntry); 424 425 bcLevelTotal.setRevenueFinancialBeginningBalanceLineAmount(revenueFinancialBeginningBalanceLineAmount); 426 bcLevelTotal.setRevenueAccountLineAnnualBalanceAmount(revenueAccountLineAnnualBalanceAmount); 427 428 bcLevelTotal.setExpenditureFinancialBeginningBalanceLineAmount(expenditureFinancialBeginningBalanceLineAmount); 429 bcLevelTotal.setExpenditureAccountLineAnnualBalanceAmount(expenditureAccountLineAnnualBalanceAmount); 430 431 differenceFinancialBeginningBalanceLineAmount = revenueFinancialBeginningBalanceLineAmount - expenditureFinancialBeginningBalanceLineAmount; 432 differenceAccountLineAnnualBalanceAmount = revenueAccountLineAnnualBalanceAmount - expenditureAccountLineAnnualBalanceAmount; 433 bcLevelTotal.setDifferenceFinancialBeginningBalanceLineAmount(differenceFinancialBeginningBalanceLineAmount); 434 bcLevelTotal.setDifferenceAccountLineAnnualBalanceAmount(differenceAccountLineAnnualBalanceAmount); 435 436 returnList.add(bcLevelTotal); 437 438 revenueFinancialBeginningBalanceLineAmount = new Integer(0); 439 revenueAccountLineAnnualBalanceAmount = new Integer(0); 440 441 expenditureFinancialBeginningBalanceLineAmount = new Integer(0); 442 expenditureAccountLineAnnualBalanceAmount = new Integer(0); 443 444 differenceFinancialBeginningBalanceLineAmount = new Integer(0); 445 differenceAccountLineAnnualBalanceAmount = new Integer(0); 446 } 447 return returnList; 448 } 449 450 451 /** 452 * builds orderByList for sort order. 453 * 454 * @return returnList 455 */ 456 public List<String> buildOrderByList() { 457 List<String> returnList = new ArrayList(); 458 returnList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE); 459 returnList.add(KFSPropertyConstants.ORGANIZATION_CODE); 460 returnList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE); 461 returnList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE); 462 returnList.add(KFSPropertyConstants.INCOME_EXPENSE_CODE); 463 returnList.add(KFSPropertyConstants.FINANCIAL_CONSOLIDATION_SORT_CODE); 464 returnList.add(KFSPropertyConstants.FINANCIAL_LEVEL_SORT_CODE); 465 return returnList; 466 } 467 468 protected List<String> fieldsForCons() { 469 List<String> fieldList = new ArrayList(); 470 fieldList.addAll(fieldsForGexpAndType()); 471 fieldList.add(KFSPropertyConstants.FINANCIAL_CONSOLIDATION_SORT_CODE); 472 return fieldList; 473 } 474 475 protected List<String> fieldsForGexpAndType() { 476 List<String> fieldList = new ArrayList(); 477 fieldList.addAll(fieldsForTotal()); 478 fieldList.add(KFSPropertyConstants.INCOME_EXPENSE_CODE); 479 return fieldList; 480 } 481 482 protected List<String> fieldsForTotal() { 483 List<String> fieldList = new ArrayList(); 484 fieldList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE); 485 fieldList.add(KFSPropertyConstants.ORGANIZATION_CODE); 486 fieldList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE); 487 fieldList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE); 488 return fieldList; 489 } 490 491 public void setBudgetConstructionReportsServiceHelper(BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper) { 492 this.budgetConstructionReportsServiceHelper = budgetConstructionReportsServiceHelper; 493 } 494 495 public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) { 496 this.kualiConfigurationService = kualiConfigurationService; 497 } 498 }