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.BudgetConstructionAdministrativePost;
026 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionCalculatedSalaryFoundationTracker;
027 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionIntendedIncumbent;
028 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgPositionFundingDetailReport;
029 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionOrgPositionFundingDetailReportTotal;
030 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionPosition;
031 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionPositionFunding;
032 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionReportThresholdSettings;
033 import org.kuali.kfs.module.bc.businessobject.PendingBudgetConstructionAppointmentFunding;
034 import org.kuali.kfs.module.bc.document.dataaccess.BudgetConstructionPositionFundingDetailReportDao;
035 import org.kuali.kfs.module.bc.document.service.BudgetConstructionPositionFundingDetailReportService;
036 import org.kuali.kfs.module.bc.document.service.BudgetConstructionReportsServiceHelper;
037 import org.kuali.kfs.module.bc.document.service.SalarySettingService;
038 import org.kuali.kfs.module.bc.report.BudgetConstructionReportHelper;
039 import org.kuali.kfs.sys.KFSPropertyConstants;
040 import org.kuali.rice.kns.service.KualiConfigurationService;
041 import org.kuali.rice.kns.util.KualiDecimal;
042 import org.springframework.transaction.annotation.Transactional;
043
044 /**
045 * Service implementation of BudgetConstructionPositionFundingDetailReportService.
046 */
047 @Transactional
048 public class BudgetConstructionPositionFundingDetailReportServiceImpl implements BudgetConstructionPositionFundingDetailReportService {
049
050 private BudgetConstructionPositionFundingDetailReportDao budgetConstructionPositionFundingDetailReportDao;
051 private KualiConfigurationService kualiConfigurationService;
052 private BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper;
053 private SalarySettingService salarySettingService;
054
055 /**
056 * @see org.kuali.kfs.module.bc.document.service.BudgetConstructionPositionFundingDetailReportService#updatePositionFundingDetailReport(java.lang.String,
057 * org.kuali.kfs.module.bc.businessobject.BudgetConstructionReportThresholdSettings)
058 */
059 public void updatePositionFundingDetailReport(String principalName, BudgetConstructionReportThresholdSettings budgetConstructionReportThresholdSettings) {
060 boolean applyAThreshold = budgetConstructionReportThresholdSettings.isUseThreshold();
061 boolean selectOnlyGreaterThanOrEqualToThreshold = budgetConstructionReportThresholdSettings.isUseGreaterThanOperator();
062 KualiDecimal thresholdPercent = budgetConstructionReportThresholdSettings.getThresholdPercent();
063 budgetConstructionPositionFundingDetailReportDao.updateReportsPositionFundingDetailTable(principalName, applyAThreshold, selectOnlyGreaterThanOrEqualToThreshold, thresholdPercent);
064 }
065
066 /**
067 * @see org.kuali.kfs.module.bc.document.service.BudgetConstructionPositionFundingDetailReportService#buildReports(java.lang.Integer,
068 * java.lang.String)
069 */
070 public Collection<BudgetConstructionOrgPositionFundingDetailReport> buildReports(Integer universityFiscalYear, String principalName) {
071 Collection<BudgetConstructionOrgPositionFundingDetailReport> reportSet = new ArrayList();
072
073 Collection<BudgetConstructionPositionFunding> positionFundingDetailList = budgetConstructionReportsServiceHelper.getDataForBuildingReports(BudgetConstructionPositionFunding.class, principalName, buildOrderByList());
074
075 List<BudgetConstructionPositionFunding> listForCalculateTotalPerson = BudgetConstructionReportHelper.deleteDuplicated((List) positionFundingDetailList, fieldsForPerson());
076 List<BudgetConstructionPositionFunding> listForCalculateTotalOrg = BudgetConstructionReportHelper.deleteDuplicated((List) positionFundingDetailList, fieldsForOrg());
077
078 // Calculate Total Section
079 Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> fundingDetailTotalPerson = calculatePersonTotal(positionFundingDetailList, listForCalculateTotalPerson);
080 Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> fundingDetailTotalOrg = calculateOrgTotal(positionFundingDetailList, listForCalculateTotalOrg);
081
082 // Get selected objectCodes
083 String objectCodes = budgetConstructionReportsServiceHelper.getSelectedObjectCodes(principalName);
084 for (BudgetConstructionPositionFunding positionFundingDetailEntry : positionFundingDetailList) {
085 BudgetConstructionOrgPositionFundingDetailReport orgPositionFundingDetailReportEntry = new BudgetConstructionOrgPositionFundingDetailReport();
086 buildReportsHeader(universityFiscalYear, objectCodes, orgPositionFundingDetailReportEntry, positionFundingDetailEntry);
087 buildReportsBody(universityFiscalYear, orgPositionFundingDetailReportEntry, positionFundingDetailEntry);
088 buildReportsTotal(orgPositionFundingDetailReportEntry, positionFundingDetailEntry, fundingDetailTotalPerson, fundingDetailTotalOrg);
089 reportSet.add(orgPositionFundingDetailReportEntry);
090 }
091 return reportSet;
092 }
093
094 /**
095 * builds report header
096 *
097 * @param universityFiscalYear
098 * @param objectCodes
099 * @param orgPositionFundingDetailReportEntry
100 * @param positionFundingDetail
101 */
102 public void buildReportsHeader(Integer universityFiscalYear, String objectCodes, BudgetConstructionOrgPositionFundingDetailReport orgPositionFundingDetailReportEntry, BudgetConstructionPositionFunding positionFundingDetail) {
103 String chartDesc = positionFundingDetail.getSelectedOrganizationChartOfAccounts().getFinChartOfAccountDescription();
104 String orgName = positionFundingDetail.getSelectedOrganization().getOrganizationName();
105 Integer prevFiscalyear = universityFiscalYear - 1;
106 orgPositionFundingDetailReportEntry.setFiscalYear(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
107 orgPositionFundingDetailReportEntry.setOrganizationCode(positionFundingDetail.getSelectedOrganizationCode());
108
109 if (orgName == null) {
110 orgPositionFundingDetailReportEntry.setOrganizationName(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_ORGANIZATION_NAME));
111 }
112 else {
113 orgPositionFundingDetailReportEntry.setOrganizationName(orgName);
114 }
115
116 orgPositionFundingDetailReportEntry.setOrgChartOfAccountsCode(positionFundingDetail.getSelectedOrganizationChartOfAccountsCode());
117 if (chartDesc == null) {
118 orgPositionFundingDetailReportEntry.setOrgChartOfAccountDescription(kualiConfigurationService.getPropertyString(BCKeyConstants.ERROR_REPORT_GETTING_CHART_DESCRIPTION));
119 }
120 else {
121 orgPositionFundingDetailReportEntry.setOrgChartOfAccountDescription(chartDesc);
122 }
123 orgPositionFundingDetailReportEntry.setReqFy(prevFiscalyear.toString() + "-" + universityFiscalYear.toString().substring(2, 4));
124 orgPositionFundingDetailReportEntry.setFinancialObjectCode(positionFundingDetail.getFinancialObjectCode());
125 orgPositionFundingDetailReportEntry.setObjectCodes(objectCodes);
126 }
127
128 /**
129 * builds report body
130 *
131 * @param universityFiscalYear
132 * @param orgPositionFundingDetailReportEntry
133 * @param positionFundingDetailEntry
134 */
135 public void buildReportsBody(Integer universityFiscalYear, BudgetConstructionOrgPositionFundingDetailReport detailReportEntry, BudgetConstructionPositionFunding positionFundingDetailEntry) {
136 PendingBudgetConstructionAppointmentFunding appointmentFundingEntry = positionFundingDetailEntry.getPendingAppointmentFunding();
137 // get budgetConstructionIntendedIncumbent, budgetConstructionAdministrativePost, budgetConstructionPosition objects
138 BudgetConstructionIntendedIncumbent budgetConstructionIntendedIncumbent = budgetConstructionReportsServiceHelper.getBudgetConstructionIntendedIncumbent(appointmentFundingEntry);
139 BudgetConstructionAdministrativePost budgetConstructionAdministrativePost = budgetConstructionReportsServiceHelper.getBudgetConstructionAdministrativePost(appointmentFundingEntry);
140 BudgetConstructionPosition budgetConstructionPosition = budgetConstructionReportsServiceHelper.getBudgetConstructionPosition(universityFiscalYear, appointmentFundingEntry);
141
142 // set report body
143 detailReportEntry.setChartOfAccountsCode(positionFundingDetailEntry.getChartOfAccountsCode());
144 detailReportEntry.setAccountNumber(positionFundingDetailEntry.getAccountNumber());
145 detailReportEntry.setSubAccountNumber(positionFundingDetailEntry.getSubAccountNumber());
146 detailReportEntry.setFinancialSubObjectCode(positionFundingDetailEntry.getFinancialSubObjectCode());
147 if (positionFundingDetailEntry.getName() != null) {
148 int nameLength = positionFundingDetailEntry.getName().length();
149 detailReportEntry.setName(positionFundingDetailEntry.getName().substring(0, (nameLength > 35) ? 35 : nameLength));
150 if (budgetConstructionIntendedIncumbent != null) {
151 if (budgetConstructionIntendedIncumbent.getIuClassificationLevel() == null) {
152 detailReportEntry.setCls(BCConstants.Report.UNDF);
153 }
154 else {
155 detailReportEntry.setCls(budgetConstructionIntendedIncumbent.getIuClassificationLevel());
156 }
157 }
158 }
159 else {
160 detailReportEntry.setName(BCConstants.Report.VACANT);
161 detailReportEntry.setCls(BCConstants.Report.BLANK);
162 }
163
164 if (budgetConstructionAdministrativePost != null) {
165 detailReportEntry.setAdministrativePost(budgetConstructionAdministrativePost.getAdministrativePost());
166 }
167 if (budgetConstructionPosition != null) {
168 detailReportEntry.setPositionNumber(budgetConstructionPosition.getPositionNumber());
169 detailReportEntry.setNormalWorkMonthsAndiuPayMonths(budgetConstructionPosition.getIuNormalWorkMonths() + "/" + budgetConstructionPosition.getIuPayMonths());
170 detailReportEntry.setPositionFte(BudgetConstructionReportHelper.setDecimalDigit(budgetConstructionPosition.getPositionFullTimeEquivalency(), 2, false));
171 detailReportEntry.setPositionSalaryPlanDefault(budgetConstructionPosition.getPositionSalaryPlanDefault());
172 detailReportEntry.setPositionGradeDefault(budgetConstructionPosition.getPositionGradeDefault());
173 detailReportEntry.setPositionStandardHoursDefault(budgetConstructionPosition.getPositionStandardHoursDefault());
174 }
175
176 BudgetConstructionCalculatedSalaryFoundationTracker csfTracker = appointmentFundingEntry.getEffectiveCSFTracker();
177 detailReportEntry.setAmountChange(new Integer(0));
178 detailReportEntry.setPercentChange(BigDecimal.ZERO);
179 if (csfTracker != null) {
180 detailReportEntry.setCsfFundingStatusCode(csfTracker.getCsfFundingStatusCode());
181 detailReportEntry.setCsfTimePercent(BudgetConstructionReportHelper.setDecimalDigit(csfTracker.getCsfTimePercent(), 2, false));
182 detailReportEntry.setCsfAmount(new Integer(csfTracker.getCsfAmount().intValue()));
183 detailReportEntry.setCsfFullTimeEmploymentQuantity(BudgetConstructionReportHelper.setDecimalDigit(csfTracker.getCsfFullTimeEmploymentQuantity(), 5, false));
184
185 // calculate amountChange and percentChange
186 Integer amountChange = new Integer(0);
187 BigDecimal percentChange = BigDecimal.ZERO;
188 BigDecimal csfFte = BudgetConstructionReportHelper.setDecimalDigit(csfTracker.getCsfFullTimeEmploymentQuantity(), 5, false);
189 BigDecimal reqFte = BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedFteQuantity(), 5, false);
190 if (reqFte.compareTo(csfFte) == 0) {
191 amountChange = appointmentFundingEntry.getAppointmentRequestedAmount().subtract(csfTracker.getCsfAmount()).intValue();
192 percentChange = BudgetConstructionReportHelper.calculatePercent(new BigDecimal(amountChange.intValue()), csfTracker.getCsfAmount().bigDecimalValue());
193 }
194 detailReportEntry.setAmountChange(amountChange);
195 detailReportEntry.setPercentChange(BudgetConstructionReportHelper.calculatePercent(new BigDecimal(amountChange.intValue()), csfTracker.getCsfAmount().bigDecimalValue()));
196 }
197
198 if (appointmentFundingEntry != null) {
199 detailReportEntry.setFinancialSubObjectCode(appointmentFundingEntry.getFinancialSubObjectCode());
200
201 detailReportEntry.setAppointmentFundingMonth(appointmentFundingEntry.getAppointmentFundingMonth());
202 detailReportEntry.setAppointmentRequestedAmount(new Integer(appointmentFundingEntry.getAppointmentRequestedAmount().intValue()));
203 detailReportEntry.setAppointmentRequestedTimePercent(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedTimePercent(), 2, false));
204 detailReportEntry.setAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedFteQuantity(), 5, false));
205 if (salarySettingService.isHourlyPaidObject(appointmentFundingEntry.getUniversityFiscalYear(), appointmentFundingEntry.getChartOfAccountsCode(), appointmentFundingEntry.getFinancialObjectCode())){
206 detailReportEntry.setAppointmentRequestedPayRate(appointmentFundingEntry.getAppointmentRequestedPayRate());
207 }
208
209 detailReportEntry.setAppointmentFundingDurationCode(appointmentFundingEntry.getAppointmentFundingDurationCode());
210 detailReportEntry.setAppointmentRequestedCsfAmount(BudgetConstructionReportHelper.convertKualiInteger(appointmentFundingEntry.getAppointmentRequestedCsfAmount()));
211 detailReportEntry.setAppointmentRequestedCsfTimePercent(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedCsfTimePercent(), 2, false));
212 detailReportEntry.setAppointmentRequestedCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentRequestedCsfFteQuantity(), 5, false));
213
214 detailReportEntry.setAppointmentTotalIntendedAmount(BudgetConstructionReportHelper.convertKualiInteger(appointmentFundingEntry.getAppointmentTotalIntendedAmount()));
215 detailReportEntry.setAppointmentTotalIntendedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(appointmentFundingEntry.getAppointmentTotalIntendedFteQuantity(), 5, false));
216
217 detailReportEntry.setEmplid(appointmentFundingEntry.getEmplid());
218 }
219
220 if (appointmentFundingEntry.isAppointmentFundingDeleteIndicator()) {
221 detailReportEntry.setDeleteBox(BCConstants.Report.DELETE_MARK);
222 }
223 else {
224 detailReportEntry.setDeleteBox(BCConstants.Report.BLANK);
225 }
226 }
227
228 /**
229 * builds report total
230 *
231 * @param orgPositionFundingDetailReportEntry
232 * @param positionFundingDetail
233 * @param fundingDetailTotalPerson
234 * @param fundingDetailTotalOrg
235 */
236 public void buildReportsTotal(BudgetConstructionOrgPositionFundingDetailReport orgPositionFundingDetailReportEntry, BudgetConstructionPositionFunding positionFundingDetail, Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> fundingDetailTotalPerson, Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> fundingDetailTotalOrg) {
237 // set person part of total
238 for (BudgetConstructionOrgPositionFundingDetailReportTotal fundingDetailTotalPersonEntry : fundingDetailTotalPerson) {
239
240 if (BudgetConstructionReportHelper.isSameEntry(fundingDetailTotalPersonEntry.getBudgetConstructionPositionFunding(), positionFundingDetail, fieldsForPerson())) {
241 orgPositionFundingDetailReportEntry.setTotalPersonPositionCsfAmount(fundingDetailTotalPersonEntry.getTotalPersonPositionCsfAmount());
242 orgPositionFundingDetailReportEntry.setTotalPersonAppointmentRequestedAmount(fundingDetailTotalPersonEntry.getTotalPersonAppointmentRequestedAmount());
243 orgPositionFundingDetailReportEntry.setTotalPersonPositionCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalPersonEntry.getTotalPersonPositionCsfFteQuantity(), 5, false));
244 orgPositionFundingDetailReportEntry.setTotalPersonAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalPersonEntry.getTotalPersonAppointmentRequestedFteQuantity(), 5, false));
245
246 // calculate amountChange and percentChange
247 orgPositionFundingDetailReportEntry.setTotalPersonAmountChange(new Integer(0));
248 orgPositionFundingDetailReportEntry.setTotalPersonPercentChange(BigDecimal.ZERO);
249 BigDecimal csfFte = BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalPersonEntry.getTotalPersonPositionCsfFteQuantity(), 5, false);
250 BigDecimal reqFte = BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalPersonEntry.getTotalPersonAppointmentRequestedFteQuantity(), 5, false);
251 if (csfFte.compareTo(reqFte) == 0) {
252 Integer amountChange = fundingDetailTotalPersonEntry.getTotalPersonAppointmentRequestedAmount() - fundingDetailTotalPersonEntry.getTotalPersonPositionCsfAmount();
253 BigDecimal percentChange = BigDecimal.ZERO;
254 orgPositionFundingDetailReportEntry.setTotalPersonAmountChange(amountChange);
255 if (!fundingDetailTotalPersonEntry.getTotalPersonPositionCsfAmount().equals(new Integer(0))) {
256 percentChange = BudgetConstructionReportHelper.calculatePercent(amountChange, fundingDetailTotalPersonEntry.getTotalPersonPositionCsfAmount().intValue());
257 }
258 orgPositionFundingDetailReportEntry.setTotalPersonPercentChange(percentChange);
259 }
260
261 orgPositionFundingDetailReportEntry.setPersonSortCode(fundingDetailTotalPersonEntry.getPersonSortCode());
262 }
263 }
264 // set org part of total
265 for (BudgetConstructionOrgPositionFundingDetailReportTotal fundingDetailTotalOrgEntry : fundingDetailTotalOrg) {
266 if (BudgetConstructionReportHelper.isSameEntry(fundingDetailTotalOrgEntry.getBudgetConstructionPositionFunding(), positionFundingDetail, fieldsForOrg())) {
267 orgPositionFundingDetailReportEntry.setTotalOrgPositionCsfAmount(fundingDetailTotalOrgEntry.getTotalOrgPositionCsfAmount());
268 orgPositionFundingDetailReportEntry.setTotalOrgAppointmentRequestedAmount(fundingDetailTotalOrgEntry.getTotalOrgAppointmentRequestedAmount());
269 orgPositionFundingDetailReportEntry.setTotalOrgPositionCsfFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalOrgEntry.getTotalOrgPositionCsfFteQuantity(), 5, false));
270 orgPositionFundingDetailReportEntry.setTotalOrgAppointmentRequestedFteQuantity(BudgetConstructionReportHelper.setDecimalDigit(fundingDetailTotalOrgEntry.getTotalOrgAppointmentRequestedFteQuantity(), 5, false));
271 Integer amountChange = fundingDetailTotalOrgEntry.getTotalOrgAppointmentRequestedAmount() - fundingDetailTotalOrgEntry.getTotalOrgPositionCsfAmount();
272 orgPositionFundingDetailReportEntry.setTotalOrgAmountChange(amountChange);
273 orgPositionFundingDetailReportEntry.setTotalOrgPercentChange(BudgetConstructionReportHelper.calculatePercent(new BigDecimal(amountChange.intValue()), new BigDecimal(fundingDetailTotalOrgEntry.getTotalOrgPositionCsfAmount().intValue())));
274 if (orgPositionFundingDetailReportEntry.getPersonSortCode() == null) {
275 orgPositionFundingDetailReportEntry.setPersonSortCode(fundingDetailTotalOrgEntry.getPersonSortCode());
276 }
277 }
278 }
279 }
280
281 /**
282 * calculates total part of person
283 *
284 * @param positionFundingDetailList
285 * @param listForCalculateTotalPerson
286 * @return
287 */
288 protected Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> calculatePersonTotal(Collection<BudgetConstructionPositionFunding> positionFundingDetailList, List<BudgetConstructionPositionFunding> listForCalculateTotalPerson) {
289 Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> returnCollection = new ArrayList();
290 Integer totalPersonPositionCsfAmount = new Integer(0);
291 Integer totalPersonAppointmentRequestedAmount = new Integer(0);
292 BigDecimal totalPersonPositionCsfFteQuantity = BigDecimal.ZERO;
293 BigDecimal totalPersonAppointmentRequestedFteQuantity = BigDecimal.ZERO;
294 Integer personSortCode = new Integer(0);
295 PendingBudgetConstructionAppointmentFunding pendingAppointmentFunding = null;
296 for (BudgetConstructionPositionFunding budgetConstructionPositionFunding : listForCalculateTotalPerson) {
297 for (BudgetConstructionPositionFunding positionFundingEntry : positionFundingDetailList) {
298 if (BudgetConstructionReportHelper.isSameEntry(budgetConstructionPositionFunding, positionFundingEntry, fieldsForPerson())) {
299 pendingAppointmentFunding = positionFundingEntry.getPendingAppointmentFunding();
300 if (pendingAppointmentFunding.getBcnCalculatedSalaryFoundationTracker().size() > 0) {
301 BudgetConstructionCalculatedSalaryFoundationTracker calculatedSalaryFoundationTracker = pendingAppointmentFunding.getBcnCalculatedSalaryFoundationTracker().get(0);
302 totalPersonPositionCsfAmount = totalPersonPositionCsfAmount + new Integer(calculatedSalaryFoundationTracker.getCsfAmount().intValue());
303 totalPersonPositionCsfFteQuantity = totalPersonPositionCsfFteQuantity.add(calculatedSalaryFoundationTracker.getCsfFullTimeEmploymentQuantity());
304 }
305 if (pendingAppointmentFunding != null) {
306 totalPersonAppointmentRequestedAmount = totalPersonAppointmentRequestedAmount + new Integer(pendingAppointmentFunding.getAppointmentRequestedAmount().intValue());
307 totalPersonAppointmentRequestedFteQuantity = totalPersonAppointmentRequestedFteQuantity.add(pendingAppointmentFunding.getAppointmentRequestedFteQuantity());
308 }
309 // sort code for person - display total part of person, when person have more than one info
310 personSortCode += 1;
311 }
312 }
313 BudgetConstructionOrgPositionFundingDetailReportTotal budgetConstructionOrgPositionFundingDetailReportTotal = new BudgetConstructionOrgPositionFundingDetailReportTotal();
314 budgetConstructionOrgPositionFundingDetailReportTotal.setBudgetConstructionPositionFunding(budgetConstructionPositionFunding);
315 budgetConstructionOrgPositionFundingDetailReportTotal.setTotalPersonPositionCsfAmount(totalPersonPositionCsfAmount);
316 budgetConstructionOrgPositionFundingDetailReportTotal.setTotalPersonPositionCsfFteQuantity(totalPersonPositionCsfFteQuantity);
317 budgetConstructionOrgPositionFundingDetailReportTotal.setTotalPersonAppointmentRequestedAmount(totalPersonAppointmentRequestedAmount);
318 budgetConstructionOrgPositionFundingDetailReportTotal.setTotalPersonAppointmentRequestedFteQuantity(totalPersonAppointmentRequestedFteQuantity);
319 if (personSortCode.intValue() > 1) {
320 budgetConstructionOrgPositionFundingDetailReportTotal.setPersonSortCode(new Integer(1));
321 }
322 returnCollection.add(budgetConstructionOrgPositionFundingDetailReportTotal);
323 // set all values to zero, after the entry was added to collection
324 totalPersonPositionCsfAmount = new Integer(0);
325 totalPersonAppointmentRequestedAmount = new Integer(0);
326 totalPersonPositionCsfFteQuantity = BigDecimal.ZERO;
327 totalPersonAppointmentRequestedFteQuantity = BigDecimal.ZERO;
328 personSortCode = new Integer(0);
329 }
330 return returnCollection;
331 }
332
333 /**
334 * calculates total part of org
335 *
336 * @param positionFundingDetailList
337 * @param listForCalculateTotalOrg
338 * @return
339 */
340 protected Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> calculateOrgTotal(Collection<BudgetConstructionPositionFunding> positionFundingDetailList, List<BudgetConstructionPositionFunding> listForCalculateTotalOrg) {
341 Collection<BudgetConstructionOrgPositionFundingDetailReportTotal> returnCollection = new ArrayList();
342 Integer totalOrgPositionCsfAmount = new Integer(0);
343 Integer totalOrgAppointmentRequestedAmount = new Integer(0);
344 BigDecimal totalOrgPositionCsfFteQuantity = BigDecimal.ZERO;
345 BigDecimal totalOrgAppointmentRequestedFteQuantity = BigDecimal.ZERO;
346 PendingBudgetConstructionAppointmentFunding pendingAppointmentFunding = null;
347 for (BudgetConstructionPositionFunding budgetConstructionPositionFunding : listForCalculateTotalOrg) {
348 for (BudgetConstructionPositionFunding positionFundingEntry : positionFundingDetailList) {
349 if (BudgetConstructionReportHelper.isSameEntry(budgetConstructionPositionFunding, positionFundingEntry, fieldsForOrg())) {
350 pendingAppointmentFunding = positionFundingEntry.getPendingAppointmentFunding();
351 if (pendingAppointmentFunding.getBcnCalculatedSalaryFoundationTracker().size() > 0) {
352 BudgetConstructionCalculatedSalaryFoundationTracker calculatedSalaryFoundationTracker = pendingAppointmentFunding.getBcnCalculatedSalaryFoundationTracker().get(0);
353 totalOrgPositionCsfAmount = totalOrgPositionCsfAmount + new Integer(calculatedSalaryFoundationTracker.getCsfAmount().intValue());
354 totalOrgPositionCsfFteQuantity = totalOrgPositionCsfFteQuantity.add(calculatedSalaryFoundationTracker.getCsfFullTimeEmploymentQuantity());
355 }
356 if (pendingAppointmentFunding != null) {
357 totalOrgAppointmentRequestedAmount = totalOrgAppointmentRequestedAmount + new Integer(pendingAppointmentFunding.getAppointmentRequestedAmount().intValue());
358 totalOrgAppointmentRequestedFteQuantity = totalOrgAppointmentRequestedFteQuantity.add(pendingAppointmentFunding.getAppointmentRequestedFteQuantity());
359 }
360 }
361 }
362 BudgetConstructionOrgPositionFundingDetailReportTotal budgetConstructionOrgOrgFundingDetailReportTotal = new BudgetConstructionOrgPositionFundingDetailReportTotal();
363 budgetConstructionOrgOrgFundingDetailReportTotal.setBudgetConstructionPositionFunding(budgetConstructionPositionFunding);
364 budgetConstructionOrgOrgFundingDetailReportTotal.setTotalOrgPositionCsfAmount(totalOrgPositionCsfAmount);
365 budgetConstructionOrgOrgFundingDetailReportTotal.setTotalOrgPositionCsfFteQuantity(totalOrgPositionCsfFteQuantity);
366 budgetConstructionOrgOrgFundingDetailReportTotal.setTotalOrgAppointmentRequestedAmount(totalOrgAppointmentRequestedAmount);
367 budgetConstructionOrgOrgFundingDetailReportTotal.setTotalOrgAppointmentRequestedFteQuantity(totalOrgAppointmentRequestedFteQuantity);
368 returnCollection.add(budgetConstructionOrgOrgFundingDetailReportTotal);
369 // set all values to zero, after the entry was added to collection
370 totalOrgPositionCsfAmount = new Integer(0);
371 totalOrgAppointmentRequestedAmount = new Integer(0);
372 totalOrgPositionCsfFteQuantity = BigDecimal.ZERO;
373 totalOrgAppointmentRequestedFteQuantity = BigDecimal.ZERO;
374 }
375 return returnCollection;
376 }
377
378 /**
379 * builds orderByList for sort order.
380 *
381 * @return List<String> returnList
382 */
383 public List<String> buildOrderByList() {
384 List<String> returnList = new ArrayList();
385 returnList.add(KFSPropertyConstants.SELECTED_ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
386 returnList.add(KFSPropertyConstants.SELECTED_ORGANIZATION_CODE);
387 returnList.add(KFSPropertyConstants.PERSON_NAME);
388 returnList.add(KFSPropertyConstants.EMPLID);
389 returnList.add(KFSPropertyConstants.POSITION_NUMBER);
390 returnList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
391 returnList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
392 returnList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
393 returnList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
394 returnList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
395 returnList.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
396 return returnList;
397 }
398
399 /**
400 * builds list of fields for comparing entry of person total
401 *
402 * @return List<String>
403 */
404 protected List<String> fieldsForPerson() {
405 List<String> fieldList = new ArrayList();
406 fieldList.addAll(fieldsForOrg());
407 fieldList.add(KFSPropertyConstants.EMPLID);
408 return fieldList;
409 }
410
411 /**
412 * builds list of fields for comparing entry of org total
413 *
414 * @return List<String>
415 */
416 protected List<String> fieldsForOrg() {
417 List<String> fieldList = new ArrayList();
418 fieldList.add(KFSPropertyConstants.SELECTED_ORGANIZATION_CHART_OF_ACCOUNTS_CODE);
419 fieldList.add(KFSPropertyConstants.SELECTED_ORGANIZATION_CODE);
420 return fieldList;
421 }
422
423 public void setBudgetConstructionPositionFundingDetailReportDao(BudgetConstructionPositionFundingDetailReportDao budgetConstructionPositionFundingDetailReportDao) {
424 this.budgetConstructionPositionFundingDetailReportDao = budgetConstructionPositionFundingDetailReportDao;
425 }
426
427 public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) {
428 this.kualiConfigurationService = kualiConfigurationService;
429 }
430
431 public void setBudgetConstructionReportsServiceHelper(BudgetConstructionReportsServiceHelper budgetConstructionReportsServiceHelper) {
432 this.budgetConstructionReportsServiceHelper = budgetConstructionReportsServiceHelper;
433 }
434
435 /**
436 * Sets the salarySettingService attribute value.
437 * @param salarySettingService The salarySettingService to set.
438 */
439 public void setSalarySettingService(SalarySettingService salarySettingService) {
440 this.salarySettingService = salarySettingService;
441 }
442 }