1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.module.bc.document.service.impl;
20
21 import java.math.BigDecimal;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.List;
25
26 import org.kuali.kfs.coa.businessobject.ObjectCode;
27 import org.kuali.kfs.module.bc.BCConstants;
28 import org.kuali.kfs.module.bc.BCKeyConstants;
29 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionObjectSummary;
30 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgObjectSummaryReport;
31 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgObjectSummaryReportTotal;
32 import org.kuali.kfs.module.bc.document.dataaccess.BudgetConstructionObjectSummaryReportDao;
33 import org.kuali.kfs.module.bc.document.service.BudgetConstructionObjectSummaryReportService;
34 import org.kuali.kfs.module.bc.document.service.BudgetConstructionReportsServiceHelper;
35 import org.kuali.kfs.module.bc.report.BudgetConstructionReportHelper;
36 import org.kuali.kfs.module.bc.util.BudgetConstructionUtils;
37 import org.kuali.kfs.sys.KFSPropertyConstants;
38 import org.kuali.rice.core.api.config.property.ConfigurationService;
39 import org.kuali.rice.core.api.util.type.KualiInteger;
40 import org.springframework.transaction.annotation.Transactional;
41
42
43
44
45 @Transactional
46 public class BudgetConstructionObjectSummaryReportServiceImpl implements BudgetConstructionObjectSummaryReportService {
47
48 protected BudgetConstructionObjectSummaryReportDao budgetConstructionObjectSummaryReportDao;
49 protected ConfigurationService kualiConfigurationService;
50 protected BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper;
51
52
53
54
55 public void updateObjectSummaryReport(String principalName) {
56 String expenditureINList = BudgetConstructionUtils.getExpenditureINList();
57 String revenueINList = BudgetConstructionUtils.getRevenueINList();
58 budgetConstructionObjectSummaryReportDao.cleanGeneralLedgerObjectSummaryTable(principalName);
59 budgetConstructionObjectSummaryReportDao.updateGeneralLedgerObjectSummaryTable(principalName, revenueINList, expenditureINList);
60 }
61
62
63
64
65
66
67 public void setBudgetConstructionObjectSummaryReportDao(BudgetConstructionObjectSummaryReportDao budgetConstructionObjectSummaryReportDao) {
68 this.budgetConstructionObjectSummaryReportDao = budgetConstructionObjectSummaryReportDao;
69 }
70
71
72
73
74
75 public Collection<BudgetConstructionOrgObjectSummaryReport> buildReports(Integer universityFiscalYear, String principalName) {
76 Collection<BudgetConstructionOrgObjectSummaryReport> reportSet = new ArrayList();
77 Collection<BudgetConstructionObjectSummary> objectSummaryList = budgetConstructionReportsServiceHelper.getDataForBuildingReports(BudgetConstructionObjectSummary.class, principalName, buildOrderByList());
78
79
80 List listForCalculateLevel = BudgetConstructionReportHelper.deleteDuplicated((List) objectSummaryList, fieldsForLevel());
81 List listForCalculateCons = BudgetConstructionReportHelper.deleteDuplicated((List) objectSummaryList, fieldsForCons());
82 List listForCalculateGexpAndType = BudgetConstructionReportHelper.deleteDuplicated((List) objectSummaryList, fieldsForGexpAndType());
83 List listForCalculateTotal = BudgetConstructionReportHelper.deleteDuplicated((List) objectSummaryList, fieldsForTotal());
84
85
86 List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalLevelList = calculateLevelTotal((List) objectSummaryList, listForCalculateLevel);
87 List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalConsList = calculateConsTotal((List) objectSummaryList, listForCalculateCons);
88 List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalGexpAndTypeList = calculateGexpAndTypeTotal((List) objectSummaryList, listForCalculateGexpAndType);
89 List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalList = calculateTotal((List) objectSummaryList, listForCalculateTotal);
90
91 for (BudgetConstructionObjectSummary objectSummaryEntry : objectSummaryList) {
92 BudgetConstructionOrgObjectSummaryReport orgObjectSummaryReportEntry = new BudgetConstructionOrgObjectSummaryReport();
93 buildReportsHeader(universityFiscalYear, orgObjectSummaryReportEntry, objectSummaryEntry);
94 buildReportsBody(universityFiscalYear, orgObjectSummaryReportEntry, objectSummaryEntry);
95 buildReportsTotal(orgObjectSummaryReportEntry, objectSummaryEntry, objectSummaryTotalLevelList, objectSummaryTotalConsList, objectSummaryTotalGexpAndTypeList, objectSummaryTotalList);
96 reportSet.add(orgObjectSummaryReportEntry);
97 }
98
99 return reportSet;
100 }
101
102
103
104
105
106
107 protected void buildReportsHeader(Integer universityFiscalYear, BudgetConstructionOrgObjectSummaryReport orgObjectSummaryReportEntry, BudgetConstructionObjectSummary objectSummary) {
108 String orgChartDesc = objectSummary.getOrganizationChartOfAccounts().getFinChartOfAccountDescription();
109 String chartDesc = objectSummary.getChartOfAccounts().getFinChartOfAccountDescription();
110 String orgName = objectSummary.getOrganization().getOrganizationName();
111 String reportChartDesc = objectSummary.getChartOfAccounts().getReportsToChartOfAccounts().getFinChartOfAccountDescription();
112 String subFundGroupName = objectSummary.getSubFundGroup().getSubFundGroupCode();
113 String subFundGroupDes = objectSummary.getSubFundGroup().getSubFundGroupDescription();
114 String fundGroupName = objectSummary.getSubFundGroup().getFundGroupCode();
115 String fundGroupDes = objectSummary.getSubFundGroup().getFundGroup().getName();
116
117 Integer prevFiscalyear = universityFiscalYear - 1;
118 orgObjectSummaryReportEntry.setFiscalYear(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
119 orgObjectSummaryReportEntry.setOrgChartOfAccountsCode(objectSummary.getOrganizationChartOfAccountsCode());
120
121 if (orgChartDesc == null) {
122 orgObjectSummaryReportEntry.setOrgChartOfAccountDescription(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
123 }
124 else {
125 orgObjectSummaryReportEntry.setOrgChartOfAccountDescription(orgChartDesc);
126 }
127
128 orgObjectSummaryReportEntry.setOrganizationCode(objectSummary.getOrganizationCode());
129 if (orgName == null) {
130 orgObjectSummaryReportEntry.setOrganizationName(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.ERROR_REPORT_GETTING_ORGANIZATION_NAME));
131 }
132 else {
133 orgObjectSummaryReportEntry.setOrganizationName(orgName);
134 }
135
136 orgObjectSummaryReportEntry.setChartOfAccountsCode(objectSummary.getChartOfAccountsCode());
137 if (chartDesc == null) {
138 orgObjectSummaryReportEntry.setChartOfAccountDescription(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
139 }
140 else {
141 orgObjectSummaryReportEntry.setChartOfAccountDescription(chartDesc);
142 }
143
144 orgObjectSummaryReportEntry.setFundGroupCode(objectSummary.getSubFundGroup().getFundGroupCode());
145 if (fundGroupDes == null) {
146 orgObjectSummaryReportEntry.setFundGroupName(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.ERROR_REPORT_GETTING_FUNDGROUP_NAME));
147 }
148 else {
149 orgObjectSummaryReportEntry.setFundGroupName(fundGroupDes);
150 }
151
152 orgObjectSummaryReportEntry.setSubFundGroupCode(objectSummary.getSubFundGroupCode());
153 if (subFundGroupDes == null) {
154 orgObjectSummaryReportEntry.setSubFundGroupDescription(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.ERROR_REPORT_GETTING_SUBFUNDGROUP_DESCRIPTION));
155 }
156 else {
157 orgObjectSummaryReportEntry.setSubFundGroupDescription(subFundGroupDes);
158 }
159
160 Integer prevPrevFiscalyear = prevFiscalyear - 1;
161 orgObjectSummaryReportEntry.setBaseFy(prevPrevFiscalyear.toString() + "-" + prevFiscalyear.toString().substring(2, 4));
162 orgObjectSummaryReportEntry.setReqFy(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
163 orgObjectSummaryReportEntry.setHeader1("Object Name");
164 orgObjectSummaryReportEntry.setHeader2a("Lv. FTE");
165 orgObjectSummaryReportEntry.setHeader2("FTE");
166 orgObjectSummaryReportEntry.setHeader3("Amount");
167 orgObjectSummaryReportEntry.setHeader31("FTE");
168 orgObjectSummaryReportEntry.setHeader40("FTE");
169 orgObjectSummaryReportEntry.setHeader4("Amount");
170 orgObjectSummaryReportEntry.setHeader5(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.MSG_REPORT_HEADER_CHANGE));
171 orgObjectSummaryReportEntry.setHeader6(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.MSG_REPORT_HEADER_CHANGE));
172 orgObjectSummaryReportEntry.setConsHdr("");
173
174
175 orgObjectSummaryReportEntry.setFinancialObjectLevelCode(objectSummary.getFinancialObjectLevelCode());
176 orgObjectSummaryReportEntry.setIncomeExpenseCode(objectSummary.getIncomeExpenseCode());
177 orgObjectSummaryReportEntry.setFinancialConsolidationSortCode(objectSummary.getFinancialConsolidationSortCode());
178 orgObjectSummaryReportEntry.setFinancialLevelSortCode(objectSummary.getFinancialLevelSortCode());
179 }
180
181
182
183
184
185
186 protected void buildReportsBody(Integer universityFiscalYear, BudgetConstructionOrgObjectSummaryReport orgObjectSummaryReportEntry, BudgetConstructionObjectSummary objectSummary) {
187
188 orgObjectSummaryReportEntry.setFinancialObjectCode(objectSummary.getFinancialObjectCode());
189
190
191 ObjectCode objectCode = budgetConstructionReportsServiceHelper.getObjectCode(universityFiscalYear, objectSummary.getChartOfAccountsCode(), objectSummary.getFinancialObjectCode());
192 String objectName = null;
193
194 if (objectCode == null) {
195 orgObjectSummaryReportEntry.setFinancialObjectName(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.ERROR_REPORT_GETTING_OBJECT_CODE));
196 }
197 else {
198 objectName = objectCode.getFinancialObjectCodeName();
199 if (objectName == null) {
200 orgObjectSummaryReportEntry.setFinancialObjectName(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.ERROR_REPORT_GETTING_OBJECT_NAME));
201 }
202 else {
203 orgObjectSummaryReportEntry.setFinancialObjectName(objectName);
204 }
205 }
206 orgObjectSummaryReportEntry.setPositionCsfLeaveFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(objectSummary.getPositionCsfLeaveFteQuantity(), 2, true));
207 orgObjectSummaryReportEntry.setCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(objectSummary.getCsfFullTimeEmploymentQuantity(), 2, true));
208 orgObjectSummaryReportEntry.setAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(objectSummary.getAppointmentRequestedCsfFteQuantity(), 2, true));
209 orgObjectSummaryReportEntry.setAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(objectSummary.getAppointmentRequestedFteQuantity(), 2, true));
210
211 if (objectSummary.getAccountLineAnnualBalanceAmount() != null) {
212 orgObjectSummaryReportEntry.setAccountLineAnnualBalanceAmount(objectSummary.getAccountLineAnnualBalanceAmount());
213 }
214
215 if (objectSummary.getFinancialBeginningBalanceLineAmount() != null) {
216 orgObjectSummaryReportEntry.setFinancialBeginningBalanceLineAmount(objectSummary.getFinancialBeginningBalanceLineAmount());
217 }
218
219 if (objectSummary.getAccountLineAnnualBalanceAmount() != null && objectSummary.getFinancialBeginningBalanceLineAmount() != null) {
220 orgObjectSummaryReportEntry.setAmountChange(objectSummary.getAccountLineAnnualBalanceAmount().subtract(objectSummary.getFinancialBeginningBalanceLineAmount()));
221 }
222
223 orgObjectSummaryReportEntry.setPercentChange(BudgetConstructionReportHelper.calculatePercent(orgObjectSummaryReportEntry.getAmountChange(), orgObjectSummaryReportEntry.getFinancialBeginningBalanceLineAmount()));
224 }
225
226
227
228
229
230
231
232 protected void buildReportsTotal(BudgetConstructionOrgObjectSummaryReport orgObjectSummaryReportEntry, BudgetConstructionObjectSummary objectSummary, List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalLevelList, List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalConsList, List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalGexpAndTypeList, List<BudgetConstructionOrgObjectSummaryReportTotal> objectSummaryTotalList) {
233
234 for (BudgetConstructionOrgObjectSummaryReportTotal levelTotal : objectSummaryTotalLevelList) {
235 if (BudgetConstructionReportHelper.isSameEntry(objectSummary, levelTotal.getBcos(), fieldsForLevel())) {
236 orgObjectSummaryReportEntry.setTotalLevelDescription(objectSummary.getFinancialObjectLevel().getFinancialObjectLevelName());
237
238 orgObjectSummaryReportEntry.setTotalLevelPositionCsfLeaveFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelTotal.getTotalLevelPositionCsfLeaveFteQuantity(), 2, true));
239 orgObjectSummaryReportEntry.setTotalLevelPositionCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelTotal.getTotalLevelPositionCsfFullTimeEmploymentQuantity(), 2, true));
240 orgObjectSummaryReportEntry.setTotalLevelFinancialBeginningBalanceLineAmount(levelTotal.getTotalLevelFinancialBeginningBalanceLineAmount());
241 orgObjectSummaryReportEntry.setTotalLevelAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelTotal.getTotalLevelAppointmentRequestedCsfFteQuantity(), 2, true));
242 orgObjectSummaryReportEntry.setTotalLevelAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(levelTotal.getTotalLevelAppointmentRequestedFteQuantity(), 2, true));
243 orgObjectSummaryReportEntry.setTotalLevelAccountLineAnnualBalanceAmount(levelTotal.getTotalLevelAccountLineAnnualBalanceAmount());
244
245 KualiInteger totalLevelAmountChange = levelTotal.getTotalLevelAccountLineAnnualBalanceAmount().subtract(levelTotal.getTotalLevelFinancialBeginningBalanceLineAmount());
246 orgObjectSummaryReportEntry.setTotalLevelAmountChange(totalLevelAmountChange);
247 orgObjectSummaryReportEntry.setTotalLevelPercentChange(BudgetConstructionReportHelper.calculatePercent(totalLevelAmountChange, levelTotal.getTotalLevelFinancialBeginningBalanceLineAmount()));
248 }
249 }
250
251 for (BudgetConstructionOrgObjectSummaryReportTotal consTotal : objectSummaryTotalConsList) {
252 if (BudgetConstructionReportHelper.isSameEntry(objectSummary, consTotal.getBcos(), fieldsForCons())) {
253 orgObjectSummaryReportEntry.setTotalConsolidationDescription(objectSummary.getFinancialConsolidationObject().getFinConsolidationObjectName());
254
255 orgObjectSummaryReportEntry.setTotalConsolidationPositionCsfLeaveFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationPositionCsfLeaveFteQuantity(), 2, true));
256 orgObjectSummaryReportEntry.setTotalConsolidationPositionCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationPositionCsfFullTimeEmploymentQuantity(), 2, true));
257 orgObjectSummaryReportEntry.setTotalConsolidationFinancialBeginningBalanceLineAmount(consTotal.getTotalConsolidationFinancialBeginningBalanceLineAmount());
258 orgObjectSummaryReportEntry.setTotalConsolidationAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationAppointmentRequestedCsfFteQuantity(), 2, true));
259 orgObjectSummaryReportEntry.setTotalConsolidationAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(consTotal.getTotalConsolidationAppointmentRequestedFteQuantity(), 2, true));
260 orgObjectSummaryReportEntry.setTotalConsolidationAccountLineAnnualBalanceAmount(consTotal.getTotalConsolidationAccountLineAnnualBalanceAmount());
261 KualiInteger totalConsolidationAmountChange = consTotal.getTotalConsolidationAccountLineAnnualBalanceAmount().subtract(consTotal.getTotalConsolidationFinancialBeginningBalanceLineAmount());
262 orgObjectSummaryReportEntry.setTotalConsolidationAmountChange(totalConsolidationAmountChange);
263 orgObjectSummaryReportEntry.setTotalConsolidationPercentChange(BudgetConstructionReportHelper.calculatePercent(totalConsolidationAmountChange, consTotal.getTotalConsolidationFinancialBeginningBalanceLineAmount()));
264
265 }
266 }
267
268 for (BudgetConstructionOrgObjectSummaryReportTotal gexpAndTypeTotal : objectSummaryTotalGexpAndTypeList) {
269 if (BudgetConstructionReportHelper.isSameEntry(objectSummary, gexpAndTypeTotal.getBcos(), fieldsForGexpAndType())) {
270
271 orgObjectSummaryReportEntry.setGrossFinancialBeginningBalanceLineAmount(gexpAndTypeTotal.getGrossFinancialBeginningBalanceLineAmount());
272 orgObjectSummaryReportEntry.setGrossAccountLineAnnualBalanceAmount(gexpAndTypeTotal.getGrossAccountLineAnnualBalanceAmount());
273 KualiInteger grossAmountChange = gexpAndTypeTotal.getGrossAccountLineAnnualBalanceAmount().subtract(gexpAndTypeTotal.getGrossFinancialBeginningBalanceLineAmount());
274 orgObjectSummaryReportEntry.setGrossAmountChange(grossAmountChange);
275 orgObjectSummaryReportEntry.setGrossPercentChange(BudgetConstructionReportHelper.calculatePercent(grossAmountChange, gexpAndTypeTotal.getGrossFinancialBeginningBalanceLineAmount()));
276
277 if (objectSummary.getIncomeExpenseCode().equals(BCConstants.Report.INCOME_EXP_TYPE_A)) {
278 orgObjectSummaryReportEntry.setTypeDesc(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_UPPERCASE_REVENUE));
279 }
280 else {
281 orgObjectSummaryReportEntry.setTypeDesc(kualiConfigurationService.getPropertyValueAsString(BCKeyConstants.MSG_REPORT_INCOME_EXP_DESC_EXPENDITURE_NET_TRNFR));
282 }
283 orgObjectSummaryReportEntry.setTypePositionCsfLeaveFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypePositionCsfLeaveFteQuantity(), 2, true));
284 orgObjectSummaryReportEntry.setTypePositionCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypePositionCsfFullTimeEmploymentQuantity(), 2, true));
285 orgObjectSummaryReportEntry.setTypeFinancialBeginningBalanceLineAmount(gexpAndTypeTotal.getTypeFinancialBeginningBalanceLineAmount());
286 orgObjectSummaryReportEntry.setTypeAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypeAppointmentRequestedCsfFteQuantity(), 2, true));
287 orgObjectSummaryReportEntry.setTypeAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(gexpAndTypeTotal.getTypeAppointmentRequestedFteQuantity(), 2, true));
288 orgObjectSummaryReportEntry.setTypeAccountLineAnnualBalanceAmount(gexpAndTypeTotal.getTypeAccountLineAnnualBalanceAmount());
289 KualiInteger typeAmountChange = gexpAndTypeTotal.getTypeAccountLineAnnualBalanceAmount().subtract(gexpAndTypeTotal.getTypeFinancialBeginningBalanceLineAmount());
290 orgObjectSummaryReportEntry.setTypeAmountChange(typeAmountChange);
291 orgObjectSummaryReportEntry.setTypePercentChange(BudgetConstructionReportHelper.calculatePercent(typeAmountChange, gexpAndTypeTotal.getTypeFinancialBeginningBalanceLineAmount()));
292 }
293 }
294
295 for (BudgetConstructionOrgObjectSummaryReportTotal total : objectSummaryTotalList) {
296 if (BudgetConstructionReportHelper.isSameEntry(objectSummary, total.getBcos(), fieldsForTotal())) {
297 orgObjectSummaryReportEntry.setTotalSubFundGroupDesc(objectSummary.getSubFundGroup().getSubFundGroupDescription());
298 orgObjectSummaryReportEntry.setRevenueFinancialBeginningBalanceLineAmount(total.getRevenueFinancialBeginningBalanceLineAmount());
299 orgObjectSummaryReportEntry.setRevenueAccountLineAnnualBalanceAmount(total.getRevenueAccountLineAnnualBalanceAmount());
300 orgObjectSummaryReportEntry.setExpenditureFinancialBeginningBalanceLineAmount(total.getExpenditureFinancialBeginningBalanceLineAmount());
301 orgObjectSummaryReportEntry.setExpenditureAccountLineAnnualBalanceAmount(total.getExpenditureAccountLineAnnualBalanceAmount());
302
303 KualiInteger revenueAmountChange = total.getRevenueAccountLineAnnualBalanceAmount().subtract(total.getRevenueFinancialBeginningBalanceLineAmount());
304 orgObjectSummaryReportEntry.setRevenueAmountChange(revenueAmountChange);
305 orgObjectSummaryReportEntry.setRevenuePercentChange(BudgetConstructionReportHelper.calculatePercent(revenueAmountChange, total.getRevenueFinancialBeginningBalanceLineAmount()));
306
307 KualiInteger expenditureAmountChange = total.getExpenditureAccountLineAnnualBalanceAmount().subtract(total.getExpenditureFinancialBeginningBalanceLineAmount());
308 orgObjectSummaryReportEntry.setExpenditureAmountChange(expenditureAmountChange);
309 orgObjectSummaryReportEntry.setExpenditurePercentChange(BudgetConstructionReportHelper.calculatePercent(expenditureAmountChange, total.getExpenditureFinancialBeginningBalanceLineAmount()));
310
311 orgObjectSummaryReportEntry.setDifferenceFinancialBeginningBalanceLineAmount(total.getDifferenceFinancialBeginningBalanceLineAmount());
312 orgObjectSummaryReportEntry.setDifferenceAccountLineAnnualBalanceAmount(total.getDifferenceAccountLineAnnualBalanceAmount());
313
314 KualiInteger differenceAmountChange = total.getDifferenceAccountLineAnnualBalanceAmount().subtract(total.getDifferenceFinancialBeginningBalanceLineAmount());
315 orgObjectSummaryReportEntry.setDifferenceAmountChange(differenceAmountChange);
316 orgObjectSummaryReportEntry.setDifferencePercentChange(BudgetConstructionReportHelper.calculatePercent(differenceAmountChange, total.getDifferenceFinancialBeginningBalanceLineAmount()));
317 }
318 }
319 }
320
321 protected List calculateLevelTotal(List<BudgetConstructionObjectSummary> bcosList, List<BudgetConstructionObjectSummary> simpleList) {
322
323 BigDecimal totalLevelPositionCsfLeaveFteQuantity = BigDecimal.ZERO;
324 BigDecimal totalLevelPositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO;
325 KualiInteger totalLevelFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
326 BigDecimal totalLevelAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO;
327 BigDecimal totalLevelAppointmentRequestedFteQuantity = BigDecimal.ZERO;
328 KualiInteger totalLevelAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
329
330 List returnList = new ArrayList();
331
332 for (BudgetConstructionObjectSummary simpleBcosEntry : simpleList) {
333 BudgetConstructionOrgObjectSummaryReportTotal bcObjectTotal = new BudgetConstructionOrgObjectSummaryReportTotal();
334 for (BudgetConstructionObjectSummary bcosListEntry : bcosList) {
335 if (BudgetConstructionReportHelper.isSameEntry(simpleBcosEntry, bcosListEntry, fieldsForLevel())) {
336 totalLevelFinancialBeginningBalanceLineAmount = totalLevelFinancialBeginningBalanceLineAmount.add(bcosListEntry.getFinancialBeginningBalanceLineAmount());
337 totalLevelAccountLineAnnualBalanceAmount = totalLevelAccountLineAnnualBalanceAmount.add(bcosListEntry.getAccountLineAnnualBalanceAmount());
338 totalLevelPositionCsfLeaveFteQuantity = totalLevelPositionCsfLeaveFteQuantity.add(bcosListEntry.getPositionCsfLeaveFteQuantity());
339 totalLevelPositionCsfFullTimeEmploymentQuantity = totalLevelPositionCsfFullTimeEmploymentQuantity.add(bcosListEntry.getCsfFullTimeEmploymentQuantity());
340 totalLevelAppointmentRequestedCsfFteQuantity = totalLevelAppointmentRequestedCsfFteQuantity.add(bcosListEntry.getAppointmentRequestedCsfFteQuantity());
341 totalLevelAppointmentRequestedFteQuantity = totalLevelAppointmentRequestedFteQuantity.add(bcosListEntry.getAppointmentRequestedFteQuantity());
342 }
343 }
344 bcObjectTotal.setBcos(simpleBcosEntry);
345 bcObjectTotal.setTotalLevelPositionCsfLeaveFteQuantity(totalLevelPositionCsfLeaveFteQuantity);
346 bcObjectTotal.setTotalLevelPositionCsfFullTimeEmploymentQuantity(totalLevelPositionCsfFullTimeEmploymentQuantity);
347 bcObjectTotal.setTotalLevelFinancialBeginningBalanceLineAmount(totalLevelFinancialBeginningBalanceLineAmount);
348 bcObjectTotal.setTotalLevelAppointmentRequestedCsfFteQuantity(totalLevelAppointmentRequestedCsfFteQuantity);
349 bcObjectTotal.setTotalLevelAppointmentRequestedFteQuantity(totalLevelAppointmentRequestedFteQuantity);
350 bcObjectTotal.setTotalLevelAccountLineAnnualBalanceAmount(totalLevelAccountLineAnnualBalanceAmount);
351 returnList.add(bcObjectTotal);
352
353 totalLevelPositionCsfLeaveFteQuantity = BigDecimal.ZERO;
354 totalLevelPositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO;
355 totalLevelFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
356 totalLevelAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO;
357 totalLevelAppointmentRequestedFteQuantity = BigDecimal.ZERO;
358 totalLevelAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
359 }
360 return returnList;
361
362 }
363
364 protected List calculateConsTotal(List<BudgetConstructionObjectSummary> bcosList, List<BudgetConstructionObjectSummary> simpleList) {
365
366 BigDecimal totalConsolidationPositionCsfLeaveFteQuantity = BigDecimal.ZERO;
367 BigDecimal totalConsolidationPositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO;
368 KualiInteger totalConsolidationFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
369 BigDecimal totalConsolidationAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO;
370 BigDecimal totalConsolidationAppointmentRequestedFteQuantity = BigDecimal.ZERO;
371 KualiInteger totalConsolidationAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
372
373 List returnList = new ArrayList();
374 for (BudgetConstructionObjectSummary simpleBcosEntry : simpleList) {
375 BudgetConstructionOrgObjectSummaryReportTotal bcObjectTotal = new BudgetConstructionOrgObjectSummaryReportTotal();
376 for (BudgetConstructionObjectSummary bcosListEntry : bcosList) {
377 if (BudgetConstructionReportHelper.isSameEntry(simpleBcosEntry, bcosListEntry, fieldsForCons())) {
378 totalConsolidationFinancialBeginningBalanceLineAmount = totalConsolidationFinancialBeginningBalanceLineAmount.add(bcosListEntry.getFinancialBeginningBalanceLineAmount());
379 totalConsolidationAccountLineAnnualBalanceAmount = totalConsolidationAccountLineAnnualBalanceAmount.add(bcosListEntry.getAccountLineAnnualBalanceAmount());
380 totalConsolidationPositionCsfLeaveFteQuantity = totalConsolidationPositionCsfLeaveFteQuantity.add(bcosListEntry.getPositionCsfLeaveFteQuantity());
381 totalConsolidationPositionCsfFullTimeEmploymentQuantity = totalConsolidationPositionCsfFullTimeEmploymentQuantity.add(bcosListEntry.getCsfFullTimeEmploymentQuantity());
382 totalConsolidationAppointmentRequestedCsfFteQuantity = totalConsolidationAppointmentRequestedCsfFteQuantity.add(bcosListEntry.getAppointmentRequestedCsfFteQuantity());
383 totalConsolidationAppointmentRequestedFteQuantity = totalConsolidationAppointmentRequestedFteQuantity.add(bcosListEntry.getAppointmentRequestedFteQuantity());
384 }
385 }
386 bcObjectTotal.setBcos(simpleBcosEntry);
387 bcObjectTotal.setTotalConsolidationPositionCsfLeaveFteQuantity(totalConsolidationPositionCsfLeaveFteQuantity);
388 bcObjectTotal.setTotalConsolidationPositionCsfFullTimeEmploymentQuantity(totalConsolidationPositionCsfFullTimeEmploymentQuantity);
389 bcObjectTotal.setTotalConsolidationFinancialBeginningBalanceLineAmount(totalConsolidationFinancialBeginningBalanceLineAmount);
390 bcObjectTotal.setTotalConsolidationAppointmentRequestedCsfFteQuantity(totalConsolidationAppointmentRequestedCsfFteQuantity);
391 bcObjectTotal.setTotalConsolidationAppointmentRequestedFteQuantity(totalConsolidationAppointmentRequestedFteQuantity);
392 bcObjectTotal.setTotalConsolidationAccountLineAnnualBalanceAmount(totalConsolidationAccountLineAnnualBalanceAmount);
393 returnList.add(bcObjectTotal);
394
395 totalConsolidationPositionCsfLeaveFteQuantity = BigDecimal.ZERO;
396 totalConsolidationPositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO;
397 totalConsolidationFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
398 totalConsolidationAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO;
399 totalConsolidationAppointmentRequestedFteQuantity = BigDecimal.ZERO;
400 totalConsolidationAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
401 }
402 return returnList;
403 }
404
405 protected List calculateGexpAndTypeTotal(List<BudgetConstructionObjectSummary> bcosList, List<BudgetConstructionObjectSummary> simpleList) {
406
407 KualiInteger grossFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
408 KualiInteger grossAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
409
410 BigDecimal typePositionCsfLeaveFteQuantity = BigDecimal.ZERO;
411 BigDecimal typePositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO;
412 KualiInteger typeFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
413 BigDecimal typeAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO;
414 BigDecimal typeAppointmentRequestedFteQuantity = BigDecimal.ZERO;
415 KualiInteger typeAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
416
417 List returnList = new ArrayList();
418 for (BudgetConstructionObjectSummary simpleBcosEntry : simpleList) {
419 BudgetConstructionOrgObjectSummaryReportTotal bcObjectTotal = new BudgetConstructionOrgObjectSummaryReportTotal();
420 for (BudgetConstructionObjectSummary bcosListEntry : bcosList) {
421 if (BudgetConstructionReportHelper.isSameEntry(simpleBcosEntry, bcosListEntry, fieldsForGexpAndType())) {
422
423 typeFinancialBeginningBalanceLineAmount = typeFinancialBeginningBalanceLineAmount.add(bcosListEntry.getFinancialBeginningBalanceLineAmount());
424 typeAccountLineAnnualBalanceAmount = typeAccountLineAnnualBalanceAmount.add(bcosListEntry.getAccountLineAnnualBalanceAmount());
425 typePositionCsfLeaveFteQuantity = typePositionCsfLeaveFteQuantity.add(bcosListEntry.getPositionCsfLeaveFteQuantity());
426 typePositionCsfFullTimeEmploymentQuantity = typePositionCsfFullTimeEmploymentQuantity.add(bcosListEntry.getCsfFullTimeEmploymentQuantity());
427 typeAppointmentRequestedCsfFteQuantity = typeAppointmentRequestedCsfFteQuantity.add(bcosListEntry.getAppointmentRequestedCsfFteQuantity());
428 typeAppointmentRequestedFteQuantity = typeAppointmentRequestedFteQuantity.add(bcosListEntry.getAppointmentRequestedFteQuantity());
429
430 if (bcosListEntry.getIncomeExpenseCode().equals("B") && !bcosListEntry.getFinancialObjectLevelCode().equals("CORI") && !bcosListEntry.getFinancialObjectLevelCode().equals("TRIN")) {
431 grossFinancialBeginningBalanceLineAmount = grossFinancialBeginningBalanceLineAmount.add(bcosListEntry.getFinancialBeginningBalanceLineAmount());
432 grossAccountLineAnnualBalanceAmount = grossAccountLineAnnualBalanceAmount.add(bcosListEntry.getAccountLineAnnualBalanceAmount());
433 }
434 }
435 }
436 bcObjectTotal.setBcos(simpleBcosEntry);
437
438 bcObjectTotal.setGrossFinancialBeginningBalanceLineAmount(grossFinancialBeginningBalanceLineAmount);
439 bcObjectTotal.setGrossAccountLineAnnualBalanceAmount(grossAccountLineAnnualBalanceAmount);
440
441 bcObjectTotal.setTypePositionCsfLeaveFteQuantity(typePositionCsfLeaveFteQuantity);
442 bcObjectTotal.setTypePositionCsfFullTimeEmploymentQuantity(typePositionCsfFullTimeEmploymentQuantity);
443 bcObjectTotal.setTypeFinancialBeginningBalanceLineAmount(typeFinancialBeginningBalanceLineAmount);
444 bcObjectTotal.setTypeAppointmentRequestedCsfFteQuantity(typeAppointmentRequestedCsfFteQuantity);
445 bcObjectTotal.setTypeAppointmentRequestedFteQuantity(typeAppointmentRequestedFteQuantity);
446 bcObjectTotal.setTypeAccountLineAnnualBalanceAmount(typeAccountLineAnnualBalanceAmount);
447
448 returnList.add(bcObjectTotal);
449 grossFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
450 grossAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
451
452 typePositionCsfLeaveFteQuantity = BigDecimal.ZERO;
453 typePositionCsfFullTimeEmploymentQuantity = BigDecimal.ZERO;
454 typeFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
455 typeAppointmentRequestedCsfFteQuantity = BigDecimal.ZERO;
456 typeAppointmentRequestedFteQuantity = BigDecimal.ZERO;
457 typeAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
458 }
459
460 return returnList;
461 }
462
463
464 protected List calculateTotal(List<BudgetConstructionObjectSummary> bcosList, List<BudgetConstructionObjectSummary> simpleList) {
465
466 KualiInteger revenueFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
467 KualiInteger revenueAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
468
469 KualiInteger expenditureFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
470 KualiInteger expenditureAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
471
472 KualiInteger differenceFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
473 KualiInteger differenceAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
474
475 List returnList = new ArrayList();
476
477 for (BudgetConstructionObjectSummary simpleBcosEntry : simpleList) {
478 BudgetConstructionOrgObjectSummaryReportTotal bcObjectTotal = new BudgetConstructionOrgObjectSummaryReportTotal();
479 for (BudgetConstructionObjectSummary bcosListEntry : bcosList) {
480 if (BudgetConstructionReportHelper.isSameEntry(simpleBcosEntry, bcosListEntry, fieldsForTotal())) {
481
482 if (bcosListEntry.getIncomeExpenseCode().equals("A")) {
483 revenueFinancialBeginningBalanceLineAmount = revenueFinancialBeginningBalanceLineAmount.add(bcosListEntry.getFinancialBeginningBalanceLineAmount());
484 revenueAccountLineAnnualBalanceAmount = revenueAccountLineAnnualBalanceAmount.add(bcosListEntry.getAccountLineAnnualBalanceAmount());
485 }
486 else {
487 expenditureFinancialBeginningBalanceLineAmount = expenditureFinancialBeginningBalanceLineAmount.add(bcosListEntry.getFinancialBeginningBalanceLineAmount());
488 expenditureAccountLineAnnualBalanceAmount = expenditureAccountLineAnnualBalanceAmount.add(bcosListEntry.getAccountLineAnnualBalanceAmount());
489 }
490 }
491 }
492
493 bcObjectTotal.setBcos(simpleBcosEntry);
494
495 bcObjectTotal.setRevenueFinancialBeginningBalanceLineAmount(revenueFinancialBeginningBalanceLineAmount);
496 bcObjectTotal.setRevenueAccountLineAnnualBalanceAmount(revenueAccountLineAnnualBalanceAmount);
497
498 bcObjectTotal.setExpenditureFinancialBeginningBalanceLineAmount(expenditureFinancialBeginningBalanceLineAmount);
499 bcObjectTotal.setExpenditureAccountLineAnnualBalanceAmount(expenditureAccountLineAnnualBalanceAmount);
500
501 differenceFinancialBeginningBalanceLineAmount = revenueFinancialBeginningBalanceLineAmount.subtract(expenditureFinancialBeginningBalanceLineAmount);
502 differenceAccountLineAnnualBalanceAmount = revenueAccountLineAnnualBalanceAmount.subtract(expenditureAccountLineAnnualBalanceAmount);
503 bcObjectTotal.setDifferenceFinancialBeginningBalanceLineAmount(differenceFinancialBeginningBalanceLineAmount);
504 bcObjectTotal.setDifferenceAccountLineAnnualBalanceAmount(differenceAccountLineAnnualBalanceAmount);
505
506 returnList.add(bcObjectTotal);
507
508 revenueFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
509 revenueAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
510
511 expenditureFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
512 expenditureAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
513
514 differenceFinancialBeginningBalanceLineAmount = KualiInteger.ZERO;
515 differenceAccountLineAnnualBalanceAmount = KualiInteger.ZERO;
516 }
517 return returnList;
518 }
519
520
521 protected List<String> fieldsForLevel() {
522 List<String> fieldList = new ArrayList();
523 fieldList.addAll(fieldsForCons());
524 fieldList.add(KFSPropertyConstants.FINANCIAL_LEVEL_SORT_CODE);
525 return fieldList;
526 }
527
528 protected List<String> fieldsForCons() {
529 List<String> fieldList = new ArrayList();
530 fieldList.addAll(fieldsForGexpAndType());
531 fieldList.add(KFSPropertyConstants.FINANCIAL_CONSOLIDATION_SORT_CODE);
532 return fieldList;
533 }
534
535
536 protected List<String> fieldsForGexpAndType() {
537 List<String> fieldList = new ArrayList();
538 fieldList.addAll(fieldsForTotal());
539 fieldList.add(KFSPropertyConstants.INCOME_EXPENSE_CODE);
540 return fieldList;
541 }
542
543
544 protected List<String> fieldsForTotal() {
545 List<String> fieldList = new ArrayList();
546 fieldList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
547 fieldList.add(KFSPropertyConstants.ORGANIZATION_CODE);
548 fieldList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
549 fieldList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
550
551
552
553
554
555 return fieldList;
556 }
557
558
559
560
561
562
563 protected List<String> buildOrderByList() {
564 List<String> returnList = new ArrayList();
565 returnList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
566 returnList.add(KFSPropertyConstants.ORGANIZATION_CODE);
567 returnList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
568 returnList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
569 returnList.add(KFSPropertyConstants.INCOME_EXPENSE_CODE);
570 returnList.add(KFSPropertyConstants.FINANCIAL_CONSOLIDATION_SORT_CODE);
571 returnList.add(KFSPropertyConstants.FINANCIAL_LEVEL_SORT_CODE);
572 returnList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
573
574 return returnList;
575 }
576
577 public void setConfigurationService(ConfigurationService kualiConfigurationService) {
578 this.kualiConfigurationService = kualiConfigurationService;
579 }
580
581 public void setBudgetConstructionReportsServiceHelper(BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper) {
582 this.budgetConstructionReportsServiceHelper = budgetConstructionReportsServiceHelper;
583 }
584 }