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.HashMap;
022 import java.util.List;
023 import java.util.Map;
024
025 import org.apache.ojb.broker.PersistenceBrokerException;
026 import org.kuali.kfs.module.bc.BCConstants;
027 import org.kuali.kfs.module.bc.BCKeyConstants;
028 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionAdministrativePost;
029 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionCalculatedSalaryFoundationTracker;
030 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionIntendedIncumbent;
031 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionObjectDump;
032 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgAccountFundingDetailReport;
033 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgAccountFundingDetailReportTotal;
034 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionPosition;
035 import org.kuali.kfs.module.bc.businessobject.PendingBudgetConstructionAppointmentFunding;
036 import org.kuali.kfs.module.bc.document.dataaccess.BudgetConstructionAccountFundingDetailReportDao;
037 import org.kuali.kfs.module.bc.document.service.BudgetConstructionAccountFundingDetailReportService;
038 import org.kuali.kfs.module.bc.document.service.BudgetConstructionReportsServiceHelper;
039 import org.kuali.kfs.module.bc.report.BudgetConstructionReportHelper;
040 import org.kuali.kfs.sys.KFSPropertyConstants;
041 import org.kuali.rice.kns.service.KualiConfigurationService;
042 import org.springframework.transaction.annotation.Transactional;
043
044 /**
045 * Service implementation of BudgetConstructionAccountFundingDetailReportService.
046 */
047 @Transactional
048 public class BudgetConstructionAccountFundingDetailReportServiceImpl implements BudgetConstructionAccountFundingDetailReportService {
049
050 BudgetConstructionAccountFundingDetailReportDao budgetConstructionAccountFundingDetailReportDao;
051 BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper;
052 KualiConfigurationService kualiConfigurationService;
053
054 /**
055 * @see org.kuali.kfs.module.bc.document.service.BudgetReportsControlListService#updateRepotsAccountFundingDetailTable(java.lang.String)
056 */
057 public void updateAccountFundingDetailTable(String principalName) {
058 budgetConstructionAccountFundingDetailReportDao.updateReportsAccountFundingDetailTable(principalName);
059 }
060
061 /**
062 * @see org.kuali.kfs.module.bc.document.service.BudgetConstructionAccountFundingDetailReportService#buildReports(java.lang.Integer,
063 * java.util.Collection)
064 */
065 public Collection<BudgetConstructionOrgAccountFundingDetailReport> buildReports(Integer universityFiscalYear, String principalName) {
066 Collection<BudgetConstructionOrgAccountFundingDetailReport> reportSet = new ArrayList();
067 List<BudgetConstructionOrgAccountFundingDetailReportTotal> orgAccountFundingDetailReportTotalList;
068 BudgetConstructionOrgAccountFundingDetailReport orgAccountFundingDetailReportEntry;
069 Collection<BudgetConstructionObjectDump> accountFundingDetailList = budgetConstructionReportsServiceHelper.getDataForBuildingReports(BudgetConstructionObjectDump.class, principalName, buildOrderByList());
070
071 Map<BudgetConstructionObjectDump, Collection<PendingBudgetConstructionAppointmentFunding>> appointmentFundingEntireMap = new HashMap();
072 for (BudgetConstructionObjectDump accountFundingDetailEntry : accountFundingDetailList) {
073 appointmentFundingEntireMap.put(accountFundingDetailEntry, budgetConstructionReportsServiceHelper.getPendingBudgetConstructionAppointmentFundingList(universityFiscalYear, accountFundingDetailEntry));
074 }
075
076 String objectCodes = budgetConstructionReportsServiceHelper.getSelectedObjectCodes(principalName);
077
078 List<BudgetConstructionObjectDump> listForCalculateTotalObject = BudgetConstructionReportHelper.deleteDuplicated((List) accountFundingDetailList, fieldsForObject());
079 List<BudgetConstructionObjectDump> listForCalculateTotalAccount = BudgetConstructionReportHelper.deleteDuplicated((List) accountFundingDetailList, fieldsForAccount());
080
081 // Calculate Total Section
082 Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> fundingDetailTotalObject = calculateObjectTotal(appointmentFundingEntireMap, listForCalculateTotalObject);
083 Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> fundingDetailTotalAccount = calculateAccountTotal(fundingDetailTotalObject, listForCalculateTotalAccount);
084
085 for (BudgetConstructionObjectDump accountFundingDetailEntry : accountFundingDetailList) {
086 Collection<PendingBudgetConstructionAppointmentFunding> appointmentFundingCollection = appointmentFundingEntireMap.get(accountFundingDetailEntry);
087 for (PendingBudgetConstructionAppointmentFunding appointmentFundingEntry : appointmentFundingCollection) {
088
089 orgAccountFundingDetailReportEntry = new BudgetConstructionOrgAccountFundingDetailReport();
090 buildReportsHeader(universityFiscalYear, objectCodes, orgAccountFundingDetailReportEntry, accountFundingDetailEntry);
091 buildReportsBody(universityFiscalYear, orgAccountFundingDetailReportEntry, appointmentFundingEntry);
092 buildReportsTotal(orgAccountFundingDetailReportEntry, accountFundingDetailEntry, fundingDetailTotalObject, fundingDetailTotalAccount);
093
094 reportSet.add(orgAccountFundingDetailReportEntry);
095 }
096 }
097
098 return reportSet;
099 }
100
101 /**
102 * builds report Header
103 *
104 * @param BudgetConstructionObjectDump bcod
105 */
106 public void buildReportsHeader(Integer universityFiscalYear, String objectCodes, BudgetConstructionOrgAccountFundingDetailReport orgAccountFundingDetailReportEntry, BudgetConstructionObjectDump accountFundingDetail) {
107 String orgChartDesc = accountFundingDetail.getOrganizationChartOfAccounts().getFinChartOfAccountDescription();
108 String chartDesc = accountFundingDetail.getChartOfAccounts().getFinChartOfAccountDescription();
109 String orgName = accountFundingDetail.getOrganization().getOrganizationName();
110 String reportChartDesc = accountFundingDetail.getChartOfAccounts().getReportsToChartOfAccounts().getFinChartOfAccountDescription();
111 String subFundGroupName = accountFundingDetail.getSubFundGroup().getSubFundGroupCode();
112 String subFundGroupDes = accountFundingDetail.getSubFundGroup().getSubFundGroupDescription();
113 String fundGroupName = accountFundingDetail.getSubFundGroup().getFundGroupCode();
114 String fundGroupDes = accountFundingDetail.getSubFundGroup().getFundGroup().getName();
115
116 Integer prevFiscalyear = universityFiscalYear - 1;
117 orgAccountFundingDetailReportEntry.setFiscalYear(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
118 orgAccountFundingDetailReportEntry.setOrgChartOfAccountsCode(accountFundingDetail.getOrganizationChartOfAccountsCode());
119
120 if (orgChartDesc == null) {
121 orgAccountFundingDetailReportEntry.setOrgChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
122 }
123 else {
124 orgAccountFundingDetailReportEntry.setOrgChartOfAccountDescription(orgChartDesc);
125 }
126
127 orgAccountFundingDetailReportEntry.setOrganizationCode(accountFundingDetail.getOrganizationCode());
128 if (orgName == null) {
129 orgAccountFundingDetailReportEntry.setOrganizationName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_ORGANIZATION_NAME));
130 }
131 else {
132 orgAccountFundingDetailReportEntry.setOrganizationName(orgName);
133 }
134
135 orgAccountFundingDetailReportEntry.setChartOfAccountsCode(accountFundingDetail.getChartOfAccountsCode());
136 if (chartDesc == null) {
137 orgAccountFundingDetailReportEntry.setChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
138 }
139 else {
140 orgAccountFundingDetailReportEntry.setChartOfAccountDescription(chartDesc);
141 }
142
143 orgAccountFundingDetailReportEntry.setFundGroupCode(accountFundingDetail.getSubFundGroup().getFundGroupCode());
144 if (fundGroupDes == null) {
145 orgAccountFundingDetailReportEntry.setFundGroupName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_FUNDGROUP_NAME));
146 }
147 else {
148 orgAccountFundingDetailReportEntry.setFundGroupName(fundGroupDes);
149 }
150
151 orgAccountFundingDetailReportEntry.setSubFundGroupCode(accountFundingDetail.getSubFundGroupCode());
152 if (subFundGroupDes == null) {
153 orgAccountFundingDetailReportEntry.setSubFundGroupDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_SUBFUNDGROUP_DESCRIPTION));
154 }
155 else {
156 orgAccountFundingDetailReportEntry.setSubFundGroupDescription(subFundGroupDes);
157 }
158
159
160 Integer prevPrevFiscalyear = prevFiscalyear - 1;
161 orgAccountFundingDetailReportEntry.setReqFy(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
162 orgAccountFundingDetailReportEntry.setConsHdr("");
163
164 orgAccountFundingDetailReportEntry.setFinancialObjectCode(accountFundingDetail.getFinancialObjectCode());
165 orgAccountFundingDetailReportEntry.setFinancialObjectCodeName(accountFundingDetail.getFinancialObject().getFinancialObjectCodeName());
166 // group
167 orgAccountFundingDetailReportEntry.setSubAccountNumber(accountFundingDetail.getSubAccountNumber() + accountFundingDetail.getAccountNumber());
168 orgAccountFundingDetailReportEntry.setObjectCodes(objectCodes);
169
170 String subAccountName = "";
171 String subAccountNumberAndName = "";
172 String divider = "";
173 // set accountNumber and name, subAccountNumber and name
174 if (accountFundingDetail.getAccount() != null) {
175 orgAccountFundingDetailReportEntry.setAccountNumberAndName(accountFundingDetail.getAccountNumber() + " " + accountFundingDetail.getAccount().getAccountName());
176 orgAccountFundingDetailReportEntry.setAccountName(accountFundingDetail.getAccount().getAccountName());
177 }
178
179 if (!accountFundingDetail.getSubAccountNumber().equals(BCConstants.Report.DASHES_SUB_ACCOUNT_CODE)) {
180 divider = BCConstants.Report.DIVIDER;
181 try {
182 subAccountName = accountFundingDetail.getSubAccount().getSubAccountName();
183 subAccountNumberAndName = accountFundingDetail.getSubAccount().getSubAccountNumber() + " " + accountFundingDetail.getSubAccount().getSubAccountName();
184 }
185 catch (PersistenceBrokerException e) {
186 subAccountName = kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_SUB_ACCOUNT_DESCRIPTION);
187 subAccountNumberAndName = subAccountName;
188 }
189 }
190 orgAccountFundingDetailReportEntry.setSubAccountName(subAccountName);
191 orgAccountFundingDetailReportEntry.setSubAccountNumberAndName(subAccountNumberAndName);
192 orgAccountFundingDetailReportEntry.setDivider(divider);
193 }
194
195
196 /**
197 * builds report body
198 *
199 * @param BudgetConstructionObjectDump bcod
200 */
201 public void buildReportsBody(Integer universityFiscalYear, BudgetConstructionOrgAccountFundingDetailReport orgAccountFundingDetailReportEntry, PendingBudgetConstructionAppointmentFunding appointmentFundingEntry) {
202
203 // get budgetConstructionIntendedIncumbent, budgetConstructionAdministrativePost, budgetConstructionPosition objects
204 BudgetConstructionIntendedIncumbent budgetConstructionIntendedIncumbent = budgetConstructionReportsServiceHelper.getBudgetConstructionIntendedIncumbent(appointmentFundingEntry);
205 BudgetConstructionAdministrativePost budgetConstructionAdministrativePost = budgetConstructionReportsServiceHelper.getBudgetConstructionAdministrativePost(appointmentFundingEntry);
206 BudgetConstructionPosition budgetConstructionPosition = budgetConstructionReportsServiceHelper.getBudgetConstructionPosition(universityFiscalYear, appointmentFundingEntry);
207
208 // set report body
209 if (budgetConstructionIntendedIncumbent != null) {
210 if (budgetConstructionIntendedIncumbent.getName() == null) {
211 orgAccountFundingDetailReportEntry.setName(BCConstants.Report.VACANT);
212 }
213 else {
214 int nameLength = budgetConstructionIntendedIncumbent.getName().length();
215 orgAccountFundingDetailReportEntry.setName(budgetConstructionIntendedIncumbent.getName().substring(0, (nameLength > 33) ? 33 : nameLength));
216 }
217
218 orgAccountFundingDetailReportEntry.setIuClassificationLevel(budgetConstructionIntendedIncumbent.getIuClassificationLevel());
219 }
220 else {
221 orgAccountFundingDetailReportEntry.setName(BCConstants.Report.VACANT);
222 orgAccountFundingDetailReportEntry.setIuClassificationLevel(BCConstants.Report.BLANK);
223 }
224
225
226 if (budgetConstructionAdministrativePost != null) {
227 orgAccountFundingDetailReportEntry.setAdministrativePost(budgetConstructionAdministrativePost.getAdministrativePost());
228 }
229
230 if (budgetConstructionPosition != null) {
231 orgAccountFundingDetailReportEntry.setPositionNumber(budgetConstructionPosition.getPositionNumber());
232 orgAccountFundingDetailReportEntry.setNormalWorkMonthsAndiuPayMonths(budgetConstructionPosition.getIuNormalWorkMonths() + "/" + budgetConstructionPosition.getIuPayMonths());
233 orgAccountFundingDetailReportEntry.setPositionFte(BudgetConstructionReportHelper.setDecimalDigit(budgetConstructionPosition.getPositionFullTimeEquivalency(), 5, true));
234 orgAccountFundingDetailReportEntry.setPositionSalaryPlanDefault(budgetConstructionPosition.getPositionSalaryPlanDefault());
235 orgAccountFundingDetailReportEntry.setPositionGradeDefault(budgetConstructionPosition.getPositionGradeDefault());
236 orgAccountFundingDetailReportEntry.setPositionStandardHoursDefault(budgetConstructionPosition.getPositionStandardHoursDefault());
237 }
238
239 BudgetConstructionCalculatedSalaryFoundationTracker csfTracker = appointmentFundingEntry.getEffectiveCSFTracker();
240 orgAccountFundingDetailReportEntry.setAmountChange(new Integer(0));
241 orgAccountFundingDetailReportEntry.setPercentChange(BigDecimal.ZERO);
242 if (csfTracker != null) {
243 orgAccountFundingDetailReportEntry.setCsfTimePercent(BudgetConstructionReportHelper.setDecimalDigit(csfTracker.getCsfTimePercent(), 2, false));
244 orgAccountFundingDetailReportEntry.setCsfAmount(new Integer(csfTracker.getCsfAmount().intValue()));
245 orgAccountFundingDetailReportEntry.setCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(csfTracker.getCsfFullTimeEmploymentQuantity(), 5, true));
246
247 // calculate amountChange and percentChange
248 Integer amountChange = new Integer(0);
249 BigDecimal percentChange = BigDecimal.ZERO;
250 BigDecimal csfFte = BudgetConstructionReportHelper.setDecimalDigit(csfTracker.getCsfFullTimeEmploymentQuantity(), 5, false);
251 BigDecimal reqFte = BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedFteQuantity(), 5, false);
252 if (reqFte.compareTo(csfFte) == 0) {
253 amountChange = appointmentFundingEntry.getAppointmentRequestedAmount().subtract(csfTracker.getCsfAmount()).intValue();
254 percentChange = BudgetConstructionReportHelper.calculatePercent(new BigDecimal(amountChange.intValue()), csfTracker.getCsfAmount().bigDecimalValue());
255 }
256 orgAccountFundingDetailReportEntry.setAmountChange(amountChange);
257 orgAccountFundingDetailReportEntry.setPercentChange(percentChange);
258 }
259
260 if (appointmentFundingEntry != null) {
261 if (appointmentFundingEntry.getFinancialSubObjectCode().equals(BCConstants.Report.BLANK_SUB_OBJECT_CODE)) {
262 orgAccountFundingDetailReportEntry.setFinancialSubObjectCode(BCConstants.Report.BLANK);
263 }
264 else {
265 orgAccountFundingDetailReportEntry.setFinancialSubObjectCode(appointmentFundingEntry.getFinancialSubObjectCode());
266 }
267
268 orgAccountFundingDetailReportEntry.setAppointmentFundingMonth(appointmentFundingEntry.getAppointmentFundingMonth());
269 orgAccountFundingDetailReportEntry.setAppointmentRequestedAmount(new Integer(appointmentFundingEntry.getAppointmentRequestedAmount().intValue()));
270 orgAccountFundingDetailReportEntry.setAppointmentRequestedTimePercent(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedTimePercent(), 2, false));
271 orgAccountFundingDetailReportEntry.setAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedFteQuantity(), 5, false));
272 orgAccountFundingDetailReportEntry.setAppointmentFundingDurationCode(appointmentFundingEntry.getAppointmentFundingDurationCode());
273
274 orgAccountFundingDetailReportEntry.setAppointmentRequestedCsfAmount(BudgetConstructionReportHelper.convertKualiInteger(appointmentFundingEntry.getAppointmentRequestedCsfAmount()));
275 orgAccountFundingDetailReportEntry.setAppointmentRequestedCsfTimePercent(appointmentFundingEntry.getAppointmentRequestedCsfTimePercent());
276 orgAccountFundingDetailReportEntry.setAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedCsfFteQuantity(), 5, false));
277
278 orgAccountFundingDetailReportEntry.setAppointmentTotalIntendedAmount(BudgetConstructionReportHelper.convertKualiInteger(appointmentFundingEntry.getAppointmentTotalIntendedAmount()));
279 orgAccountFundingDetailReportEntry.setAppointmentTotalIntendedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentTotalIntendedFteQuantity(), 5, false));
280
281 orgAccountFundingDetailReportEntry.setEmplid(appointmentFundingEntry.getEmplid());
282 }
283
284
285 if (appointmentFundingEntry.isAppointmentFundingDeleteIndicator()) {
286 orgAccountFundingDetailReportEntry.setDeleteBox(BCConstants.Report.DELETE_MARK);
287 }
288 else {
289 orgAccountFundingDetailReportEntry.setDeleteBox(BCConstants.Report.BLANK);
290 }
291 }
292
293 public void buildReportsTotal(BudgetConstructionOrgAccountFundingDetailReport orgAccountFundingDetailReportEntry, BudgetConstructionObjectDump accountFundingDetail, Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> fundingDetailTotalObject, Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> fundingDetailTotalAccount) {
294 for (BudgetConstructionOrgAccountFundingDetailReportTotal fundingDetailTotalObjectEntry : fundingDetailTotalObject) {
295 if (BudgetConstructionReportHelper.isSameEntry(fundingDetailTotalObjectEntry.getBudgetConstructionObjectDump(), accountFundingDetail, fieldsForObject())) {
296 if (accountFundingDetail.getFinancialObject() != null) {
297 orgAccountFundingDetailReportEntry.setTotalObjectname(accountFundingDetail.getFinancialObject().getName());
298 }
299 orgAccountFundingDetailReportEntry.setTotalObjectPositionCsfAmount(fundingDetailTotalObjectEntry.getTotalObjectPositionCsfAmount());
300 orgAccountFundingDetailReportEntry.setTotalObjectAppointmentRequestedAmount(fundingDetailTotalObjectEntry.getTotalObjectAppointmentRequestedAmount());
301 orgAccountFundingDetailReportEntry.setTotalObjectPositionCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalObjectEntry.getTotalObjectPositionCsfFteQuantity(), 5, true));
302 orgAccountFundingDetailReportEntry.setTotalObjectAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalObjectEntry.getTotalObjectAppointmentRequestedFteQuantity(), 5, true));
303 // calculate amountChange and percentChange
304 Integer amountChange = fundingDetailTotalObjectEntry.getTotalObjectAppointmentRequestedAmount() - fundingDetailTotalObjectEntry.getTotalObjectPositionCsfAmount();
305 orgAccountFundingDetailReportEntry.setTotalObjectAmountChange(amountChange);
306 orgAccountFundingDetailReportEntry.setTotalObjectPercentChange(BudgetConstructionReportHelper.calculatePercent(amountChange, fundingDetailTotalObjectEntry.getTotalObjectPositionCsfAmount()));
307 }
308 }
309
310 for (BudgetConstructionOrgAccountFundingDetailReportTotal fundingDetailTotalAccountEntry : fundingDetailTotalAccount) {
311 if (BudgetConstructionReportHelper.isSameEntry(fundingDetailTotalAccountEntry.getBudgetConstructionObjectDump(), accountFundingDetail, fieldsForAccount())) {
312
313 orgAccountFundingDetailReportEntry.setTotalAccountPositionCsfAmount(fundingDetailTotalAccountEntry.getTotalAccountPositionCsfAmount());
314 orgAccountFundingDetailReportEntry.setTotalAccountAppointmentRequestedAmount(fundingDetailTotalAccountEntry.getTotalAccountAppointmentRequestedAmount());
315 orgAccountFundingDetailReportEntry.setTotalAccountPositionCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalAccountEntry.getTotalAccountPositionCsfFteQuantity(), 5, true));
316 orgAccountFundingDetailReportEntry.setTotalAccountAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalAccountEntry.getTotalAccountAppointmentRequestedFteQuantity(), 5, true));
317 Integer amountChange = fundingDetailTotalAccountEntry.getTotalAccountAppointmentRequestedAmount() - fundingDetailTotalAccountEntry.getTotalAccountPositionCsfAmount();
318 orgAccountFundingDetailReportEntry.setTotalAccountAmountChange(amountChange);
319 orgAccountFundingDetailReportEntry.setTotalAccountPercentChange(BudgetConstructionReportHelper.calculatePercent(amountChange, fundingDetailTotalAccountEntry.getTotalAccountPositionCsfAmount()));
320 }
321 }
322 }
323
324
325 /**
326 * builds report total
327 *
328 * @param BudgetConstructionObjectDump bcod
329 * @param List reportTotalList
330 */
331 protected Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> calculateObjectTotal(Map appointmentFundingEntireMap, List<BudgetConstructionObjectDump> listForCalculateTotalObject) {
332 Integer totalObjectPositionCsfAmount = new Integer(0);
333 Integer totalObjectAppointmentRequestedAmount = new Integer(0);
334 BigDecimal totalObjectPositionCsfFteQuantity = BigDecimal.ZERO;
335 BigDecimal totalObjectAppointmentRequestedFteQuantity = BigDecimal.ZERO;
336
337 Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> returnCollection = new ArrayList();
338
339 for (BudgetConstructionObjectDump budgetConstructionObjectDump : listForCalculateTotalObject) {
340 Collection<PendingBudgetConstructionAppointmentFunding> accountFundingCollection = new ArrayList();
341 accountFundingCollection = (Collection<PendingBudgetConstructionAppointmentFunding>) appointmentFundingEntireMap.get(budgetConstructionObjectDump);
342 for (PendingBudgetConstructionAppointmentFunding accountFundingEntry : accountFundingCollection) {
343 if (accountFundingEntry.getBcnCalculatedSalaryFoundationTracker().size() > 0) {
344 BudgetConstructionCalculatedSalaryFoundationTracker calculatedSalaryFoundationTracker = accountFundingEntry.getBcnCalculatedSalaryFoundationTracker().get(0);
345 totalObjectPositionCsfAmount = totalObjectPositionCsfAmount + new Integer(calculatedSalaryFoundationTracker.getCsfAmount().intValue());
346 totalObjectPositionCsfFteQuantity = totalObjectPositionCsfFteQuantity.add(calculatedSalaryFoundationTracker.getCsfFullTimeEmploymentQuantity());
347 }
348 totalObjectAppointmentRequestedAmount = totalObjectAppointmentRequestedAmount + new Integer(accountFundingEntry.getAppointmentRequestedAmount().intValue());
349 totalObjectAppointmentRequestedFteQuantity = totalObjectAppointmentRequestedFteQuantity.add(accountFundingEntry.getAppointmentRequestedFteQuantity());
350 }
351
352 BudgetConstructionOrgAccountFundingDetailReportTotal budgetConstructionOrgAccountFundingDetailReportTotal = new BudgetConstructionOrgAccountFundingDetailReportTotal();
353
354 budgetConstructionOrgAccountFundingDetailReportTotal.setBudgetConstructionObjectDump(budgetConstructionObjectDump);
355 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalObjectPositionCsfAmount(totalObjectPositionCsfAmount);
356 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalObjectPositionCsfFteQuantity(totalObjectPositionCsfFteQuantity);
357 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalObjectAppointmentRequestedAmount(totalObjectAppointmentRequestedAmount);
358 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalObjectAppointmentRequestedFteQuantity(totalObjectAppointmentRequestedFteQuantity);
359
360 returnCollection.add(budgetConstructionOrgAccountFundingDetailReportTotal);
361
362 totalObjectPositionCsfAmount = new Integer(0);
363 totalObjectAppointmentRequestedAmount = new Integer(0);
364 totalObjectPositionCsfFteQuantity = BigDecimal.ZERO;
365 totalObjectAppointmentRequestedFteQuantity = BigDecimal.ZERO;
366 }
367
368
369 return returnCollection;
370 }
371
372 protected Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> calculateAccountTotal(Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> fundingDetailTotalObject, List<BudgetConstructionObjectDump> listForCalculateTotalAccount) {
373
374 // private Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> calculateAccountTotal(Map
375 // appointmentFundingEntireMap, Collection<BudgetConstructionObjectDump> accountFundingDetailList,
376 // List<BudgetConstructionObjectDump> listForCalculateTotalAccount) {
377
378 Integer totalAccountPositionCsfAmount = new Integer(0);
379 Integer totalAccountAppointmentRequestedAmount = new Integer(0);
380 BigDecimal totalAccountPositionCsfFteQuantity = BigDecimal.ZERO;
381 BigDecimal totalAccountAppointmentRequestedFteQuantity = BigDecimal.ZERO;
382
383 Collection<BudgetConstructionOrgAccountFundingDetailReportTotal> returnCollection = new ArrayList();
384 for (BudgetConstructionObjectDump budgetConstructionObjectDump : listForCalculateTotalAccount) {
385 for (BudgetConstructionOrgAccountFundingDetailReportTotal fundingDetailTotalObjectEntry : fundingDetailTotalObject) {
386 if (BudgetConstructionReportHelper.isSameEntry(budgetConstructionObjectDump, fundingDetailTotalObjectEntry.getBudgetConstructionObjectDump(), fieldsForAccount())) {
387 totalAccountPositionCsfAmount = totalAccountPositionCsfAmount + fundingDetailTotalObjectEntry.getTotalObjectPositionCsfAmount();
388 totalAccountPositionCsfFteQuantity = totalAccountPositionCsfFteQuantity.add(fundingDetailTotalObjectEntry.getTotalObjectPositionCsfFteQuantity());
389 totalAccountAppointmentRequestedAmount = totalAccountAppointmentRequestedAmount + fundingDetailTotalObjectEntry.getTotalObjectAppointmentRequestedAmount();
390 totalAccountAppointmentRequestedFteQuantity = totalAccountAppointmentRequestedFteQuantity.add(fundingDetailTotalObjectEntry.getTotalObjectAppointmentRequestedFteQuantity());
391 }
392 }
393 BudgetConstructionOrgAccountFundingDetailReportTotal budgetConstructionOrgAccountFundingDetailReportTotal = new BudgetConstructionOrgAccountFundingDetailReportTotal();
394 budgetConstructionOrgAccountFundingDetailReportTotal.setBudgetConstructionObjectDump(budgetConstructionObjectDump);
395 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalAccountPositionCsfAmount(totalAccountPositionCsfAmount);
396 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalAccountPositionCsfFteQuantity(totalAccountPositionCsfFteQuantity);
397 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalAccountAppointmentRequestedAmount(totalAccountAppointmentRequestedAmount);
398 budgetConstructionOrgAccountFundingDetailReportTotal.setTotalAccountAppointmentRequestedFteQuantity(totalAccountAppointmentRequestedFteQuantity);
399
400 returnCollection.add(budgetConstructionOrgAccountFundingDetailReportTotal);
401
402 totalAccountPositionCsfAmount = new Integer(0);
403 totalAccountAppointmentRequestedAmount = new Integer(0);
404 totalAccountPositionCsfFteQuantity = BigDecimal.ZERO;
405 totalAccountAppointmentRequestedFteQuantity = BigDecimal.ZERO;
406 }
407 return returnCollection;
408 }
409
410 protected List<String> fieldsForObject() {
411 List<String> fieldList = new ArrayList();
412 fieldList.addAll(fieldsForAccount());
413 fieldList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
414 return fieldList;
415 }
416
417 protected List<String> fieldsForAccount() {
418 List<String> fieldList = new ArrayList();
419 fieldList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
420 fieldList.add(KFSPropertyConstants.ORGANIZATION_CODE);
421 fieldList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
422 fieldList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
423 fieldList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
424 fieldList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
425 return fieldList;
426 }
427
428 /**
429 * builds orderByList for sort order.
430 *
431 * @return returnList
432 */
433 public List<String> buildOrderByList() {
434 List<String> returnList = new ArrayList();
435 returnList.add(KFSPropertyConstants.ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
436 returnList.add(KFSPropertyConstants.ORGANIZATION_CODE);
437 returnList.add(KFSPropertyConstants.SUB_FUND_GROUP_CODE);
438 returnList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
439 returnList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
440 returnList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
441 returnList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
442 returnList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
443 return returnList;
444 }
445
446 public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) {
447 this.kualiConfigurationService = kualiConfigurationService;
448 }
449
450 public void setBudgetConstructionAccountFundingDetailReportDao(BudgetConstructionAccountFundingDetailReportDao budgetConstructionAccountFundingDetailReportDao) {
451 this.budgetConstructionAccountFundingDetailReportDao = budgetConstructionAccountFundingDetailReportDao;
452 }
453
454 public void setBudgetConstructionReportsServiceHelper(BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper) {
455 this.budgetConstructionReportsServiceHelper = budgetConstructionReportsServiceHelper;
456 }
457
458 }