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
017 package org.kuali.kfs.module.ec.document;
018
019 import java.util.ArrayList;
020 import java.util.LinkedHashMap;
021 import java.util.List;
022
023 import org.apache.commons.lang.StringUtils;
024 import org.kuali.kfs.coa.businessobject.Organization;
025 import org.kuali.kfs.module.ec.businessobject.EffortCertificationDetail;
026 import org.kuali.kfs.module.ec.businessobject.EffortCertificationReportDefinition;
027 import org.kuali.kfs.module.ec.service.EffortCertificationDocumentService;
028 import org.kuali.kfs.module.ec.util.EffortCertificationParameterFinder;
029 import org.kuali.kfs.sys.KFSConstants;
030 import org.kuali.kfs.sys.KFSPropertyConstants;
031 import org.kuali.kfs.sys.businessobject.SystemOptions;
032 import org.kuali.kfs.sys.context.SpringContext;
033 import org.kuali.kfs.sys.document.FinancialSystemTransactionalDocumentBase;
034 import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO;
035 import org.kuali.rice.kim.bo.Person;
036 import org.kuali.rice.kim.service.PersonService;
037 import org.kuali.rice.kns.UserSession;
038 import org.kuali.rice.kns.service.ParameterConstants.COMPONENT;
039 import org.kuali.rice.kns.util.GlobalVariables;
040 import org.kuali.rice.kns.util.KualiDecimal;
041 import org.kuali.rice.kns.util.ObjectUtils;
042 import org.kuali.rice.kns.util.TypedArrayList;
043 import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument;
044
045 /**
046 * Effort Certification Document Class.
047 */
048 @COMPONENT(component="EffortCertification")
049 public class EffortCertificationDocument extends FinancialSystemTransactionalDocumentBase {
050 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(EffortCertificationDocument.class);
051
052 protected static final String DO_AWARD_SPLIT = "DoAwardSplit";
053 protected static final String DO_RECREATE_SPLIT = "DoRecreateSplit";
054
055 protected String effortCertificationReportNumber;
056 protected boolean effortCertificationDocumentCode;
057 protected Integer universityFiscalYear;
058 protected String emplid;
059 protected String organizationCode;
060 protected KualiDecimal financialDocumentTotalAmount;
061
062 protected Integer totalEffortPercent;
063 protected Integer totalOriginalEffortPercent;
064 protected KualiDecimal totalPayrollAmount;
065 protected KualiDecimal totalOriginalPayrollAmount;
066
067 protected EffortCertificationReportDefinition effortCertificationReportDefinition;
068 protected Person employee;
069 protected Organization organization;
070 protected SystemOptions options;
071
072 protected List<EffortCertificationDetail> effortCertificationDetailLines;
073 protected List<EffortCertificationDetail> summarizedDetailLines;
074
075 protected Person ledgerPerson;
076
077 /**
078 * Default constructor.
079 */
080 public EffortCertificationDocument() {
081 super();
082
083 effortCertificationDetailLines = new TypedArrayList(EffortCertificationDetail.class);
084 summarizedDetailLines = new TypedArrayList(EffortCertificationDetail.class);
085 }
086
087 /**
088 * Gets the effortCertificationReportNumber attribute.
089 *
090 * @return Returns the effortCertificationReportNumber.
091 */
092 public String getEffortCertificationReportNumber() {
093 return effortCertificationReportNumber;
094 }
095
096 /**
097 * Sets the effortCertificationReportNumber attribute value.
098 *
099 * @param effortCertificationReportNumber The effortCertificationReportNumber to set.
100 */
101 public void setEffortCertificationReportNumber(String effortCertificationReportNumber) {
102 this.effortCertificationReportNumber = effortCertificationReportNumber;
103 }
104
105 /**
106 * Gets the effortCertificationDocumentCode attribute.
107 *
108 * @return Returns the effortCertificationDocumentCode.
109 */
110 public boolean getEffortCertificationDocumentCode() {
111 return effortCertificationDocumentCode;
112 }
113
114 /**
115 * Sets the effortCertificationDocumentCode attribute value.
116 *
117 * @param effortCertificationDocumentCode The effortCertificationDocumentCode to set.
118 */
119 public void setEffortCertificationDocumentCode(boolean effortCertificationDocumentCode) {
120 this.effortCertificationDocumentCode = effortCertificationDocumentCode;
121 }
122
123 /**
124 * Gets the universityFiscalYear attribute.
125 *
126 * @return Returns the universityFiscalYear.
127 */
128 public Integer getUniversityFiscalYear() {
129 return universityFiscalYear;
130 }
131
132 /**
133 * Sets the universityFiscalYear attribute value.
134 *
135 * @param universityFiscalYear The universityFiscalYear to set.
136 */
137 public void setUniversityFiscalYear(Integer universityFiscalYear) {
138 this.universityFiscalYear = universityFiscalYear;
139 }
140
141 /**
142 * Gets the organizationCode attribute.
143 *
144 * @return Returns the organizationCode.
145 */
146 public String getOrganizationCode() {
147 return organizationCode;
148 }
149
150 /**
151 * Sets the organizationCode attribute value.
152 *
153 * @param organizationCode The organizationCode to set.
154 */
155 public void setOrganizationCode(String organizationCode) {
156 this.organizationCode = organizationCode;
157 }
158
159 /**
160 * Gets the organization attribute.
161 *
162 * @return Returns the organization.
163 */
164 public Organization getOrganization() {
165 return organization;
166 }
167
168 /**
169 * Sets the organization attribute value.
170 *
171 * @param organization The organization to set.
172 */
173 public void setOrganization(Organization organization) {
174 this.organization = organization;
175 }
176
177 /**
178 * Gets the emplid attribute.
179 *
180 * @return Returns the emplid.
181 */
182 public String getEmplid() {
183 return emplid;
184 }
185
186 /**
187 * Sets the emplid attribute value.
188 *
189 * @param emplid The emplid to set.
190 */
191 public void setEmplid(String emplid) {
192 this.emplid = emplid;
193 }
194
195 /**
196 * Gets the effortCertificationReportDefinition attribute.
197 *
198 * @return Returns the effortCertificationReportDefinition.
199 */
200 public EffortCertificationReportDefinition getEffortCertificationReportDefinition() {
201 return effortCertificationReportDefinition;
202 }
203
204 /**
205 * Sets the effortCertificationReportDefinition attribute value.
206 *
207 * @param effortCertificationReportDefinition The effortCertificationReportDefinition to set.
208 */
209 @Deprecated
210 public void setEffortCertificationReportDefinition(EffortCertificationReportDefinition effortCertificationReportDefinition) {
211 this.effortCertificationReportDefinition = effortCertificationReportDefinition;
212 }
213
214 /**
215 * Gets the employee attribute.
216 *
217 * @return Returns the employee.
218 */
219 public Person getEmployee() {
220 return (Person) SpringContext.getBean(PersonService.class).getPersonByEmployeeId(getEmplid());
221 }
222
223 /**
224 * Sets the employee attribute value.
225 *
226 * @param employee The employee to set.
227 */
228 public void setEmployee(Person employee) {
229 this.employee = employee;
230 }
231
232 /**
233 * Gets the Person
234 *
235 * @return Returns the Person
236 */
237 public Person getLedgerPerson() {
238 if(ledgerPerson == null || !StringUtils.equals(ledgerPerson.getEmployeeId(), emplid)) {
239 ledgerPerson = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(emplid);
240 }
241
242 return ledgerPerson;
243 }
244
245 /**
246 * Sets the ledgerPerson
247 *
248 * @param ledgerPerson The ledgerPerson to set.
249 */
250 public void setLedgerPerson(Person ledgerPerson) {
251 this.ledgerPerson = ledgerPerson;
252 }
253
254 /**
255 * Gets the options attribute.
256 *
257 * @return Returns the options.
258 */
259 public SystemOptions getOptions() {
260 return options;
261 }
262
263 /**
264 * Sets the options attribute value.
265 *
266 * @param options The options to set.
267 */
268 public void setOptions(SystemOptions options) {
269 this.options = options;
270 }
271
272 /**
273 * Gets the effortCertificationDetailLines attribute.
274 *
275 * @return Returns the effortCertificationDetailLines.
276 */
277 public List<EffortCertificationDetail> getEffortCertificationDetailLines() {
278 return effortCertificationDetailLines;
279 }
280
281 /**
282 * Sets the effortCertificationDetailLines attribute value.
283 *
284 * @param effortCertificationDetailLines The effortCertificationDetailLines to set.
285 */
286 @Deprecated
287 public void setEffortCertificationDetailLines(List<EffortCertificationDetail> effortCertificationDetailLines) {
288 this.effortCertificationDetailLines = effortCertificationDetailLines;
289 }
290
291
292 /**
293 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
294 */
295 @SuppressWarnings("unchecked")
296 protected LinkedHashMap toStringMapper() {
297 LinkedHashMap m = new LinkedHashMap();
298 m.put(KFSPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
299 return m;
300 }
301
302 /**
303 * get the total amount of the given effort certification document
304 *
305 * @param effortCertificationDocument the given effort certification document
306 * @return the total amount of the given effort certification document
307 */
308 public static KualiDecimal getDocumentTotalAmount(EffortCertificationDocument effortCertificationDocument) {
309 List<EffortCertificationDetail> detailLines = effortCertificationDocument.getEffortCertificationDetailLines();
310 return EffortCertificationDetail.getTotalPayrollAmount(detailLines);
311 }
312
313 /**
314 * @see org.kuali.rice.kns.document.DocumentBase#doRouteStatusChange()
315 */
316 @Override
317 public void doRouteStatusChange(DocumentRouteStatusChangeDTO statusChangeEvent) {
318 LOG.debug("doRouteStatusChange() start...");
319
320 super.doRouteStatusChange(statusChangeEvent);
321 KualiWorkflowDocument workflowDocument = this.getDocumentHeader().getWorkflowDocument();
322 if (workflowDocument.stateIsFinal()) {
323 GlobalVariables.setUserSession(new UserSession(KFSConstants.SYSTEM_USER));
324 SpringContext.getBean(EffortCertificationDocumentService.class).generateSalaryExpenseTransferDocument(this);
325 }
326 // SpringContext.getBean(EffortCertificationDocumentService.class).processApprovedEffortCertificationDocument(this);
327 }
328
329 /**
330 * Gets the totalEffortPercent attribute.
331 *
332 * @return Returns the totalEffortPercent.
333 */
334 public Integer getTotalEffortPercent() {
335 return EffortCertificationDetail.getTotalEffortPercent(this.getEffortCertificationDetailLines());
336 }
337
338 /**
339 * Gets the totalOriginalEffortPercent attribute.
340 *
341 * @return Returns the totalOriginalEffortPercent.
342 */
343 public Integer getTotalOriginalEffortPercent() {
344 return EffortCertificationDetail.getTotalOriginalEffortPercent(this.getEffortCertificationDetailLines());
345 }
346
347 /**
348 * Gets the totalPayrollAmount attribute.
349 *
350 * @return Returns the totalPayrollAmount.
351 */
352 public KualiDecimal getTotalPayrollAmount() {
353 return EffortCertificationDetail.getTotalPayrollAmount(this.getEffortCertificationDetailLines());
354 }
355
356 /**
357 * Gets the totalOriginalPayrollAmount attribute.
358 *
359 * @return Returns the totalOriginalPayrollAmount.
360 */
361 public KualiDecimal getTotalOriginalPayrollAmount() {
362 return EffortCertificationDetail.getTotalOriginalPayrollAmount(this.getEffortCertificationDetailLines());
363 }
364
365 /**
366 * find the detail lines that have max payroll amount
367 *
368 * @return the detail lines that have max payroll amount
369 */
370 public List<EffortCertificationDetail> getEffortCertificationDetailWithMaxPayrollAmount() {
371 List<EffortCertificationDetail> detailLines = new ArrayList<EffortCertificationDetail>();
372
373 KualiDecimal maxAmount = null;
374 for (EffortCertificationDetail line : this.getEffortCertificationDetailLines()) {
375 KualiDecimal currentAmount = line.getEffortCertificationPayrollAmount();
376
377 if (maxAmount == null) {
378 maxAmount = currentAmount;
379 detailLines.add(line);
380 continue;
381 }
382
383 if (maxAmount.isLessThan(currentAmount)) {
384 detailLines.removeAll(detailLines);
385 maxAmount = currentAmount;
386 detailLines.add(line);
387 }
388 else if (maxAmount.equals(currentAmount)) {
389 detailLines.add(line);
390 }
391 }
392
393 return detailLines;
394 }
395
396 /**
397 * Calculates the total updated effort for all federal detail lines
398 *
399 * @return effortFederalTotal
400 */
401 public Integer getFederalTotalEffortPercent() {
402 Integer effortFederalTotal = 0;
403 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
404
405 for (EffortCertificationDetail detailLine : detailLineList) {
406 if (detailLine.isFederalOrFederalPassThroughIndicator()) {
407 effortFederalTotal += detailLine.getEffortCertificationUpdatedOverallPercent();
408 }
409 }
410
411 return effortFederalTotal;
412 }
413
414 /**
415 * Calculates the total original effort for all federal detail lines
416 *
417 * @return original federal total
418 */
419 public Integer getFederalTotalOriginalEffortPercent() {
420 Integer effortOrigFederalTotal = 0;
421 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
422
423 for (EffortCertificationDetail detailLine : detailLineList) {
424 if (detailLine.isFederalOrFederalPassThroughIndicator()) {
425 effortOrigFederalTotal += detailLine.getEffortCertificationCalculatedOverallPercent();
426 }
427 }
428
429 return effortOrigFederalTotal;
430 }
431
432 /**
433 * Calculates the total original fringe benefit amount for federal pass through detail lines
434 *
435 * @return total federal benefit amount
436 */
437 public KualiDecimal getFederalTotalOriginalFringeBenefit() {
438 KualiDecimal totalBenAmount = KualiDecimal.ZERO;
439 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
440
441 for (EffortCertificationDetail detailLine : detailLineList) {
442 if (detailLine.isFederalOrFederalPassThroughIndicator()) {
443 totalBenAmount = totalBenAmount.add(detailLine.getOriginalFringeBenefitAmount());
444 }
445 }
446
447 return totalBenAmount;
448 }
449
450 /**
451 * Calculates total original fringe benenfit amount for non federal pass through detail lines
452 *
453 * @return total non federal benefit amount
454 */
455 public KualiDecimal getOtherTotalOriginalFringeBenefit() {
456 KualiDecimal totalBenAmount = KualiDecimal.ZERO;
457 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
458
459 for (EffortCertificationDetail detailLine : detailLineList) {
460 if (!detailLine.isFederalOrFederalPassThroughIndicator()) {
461 totalBenAmount = totalBenAmount.add(detailLine.getOriginalFringeBenefitAmount());
462 }
463 }
464
465 return totalBenAmount;
466 }
467
468 /**
469 * Calculates the total fringe benefit amount for federal pass through detail lines
470 *
471 * @return total federal benefit amount
472 */
473 public KualiDecimal getFederalTotalFringeBenefit() {
474 KualiDecimal totalBenAmount = KualiDecimal.ZERO;
475 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
476
477 for (EffortCertificationDetail detailLine : detailLineList) {
478 if (detailLine.isFederalOrFederalPassThroughIndicator()) {
479 totalBenAmount = totalBenAmount.add(detailLine.getFringeBenefitAmount());
480 }
481 }
482
483 return totalBenAmount;
484 }
485
486 /**
487 * Calculates total fringe benenfit amount for non federal pass through detail lines
488 *
489 * @return total non federal benefit amount
490 */
491 public KualiDecimal getOtherTotalFringeBenefit() {
492 KualiDecimal totalBenAmount = KualiDecimal.ZERO;
493 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
494
495 for (EffortCertificationDetail detailLine : detailLineList) {
496 if (!detailLine.isFederalOrFederalPassThroughIndicator()) {
497 totalBenAmount = totalBenAmount.add(detailLine.getFringeBenefitAmount());
498 }
499 }
500
501 return totalBenAmount;
502 }
503
504 /**
505 * Calculates the total original effor for non federal pass through detail lines
506 *
507 * @return original other total
508 */
509 public Integer getOtherTotalOriginalEffortPercent() {
510 Integer effortOrigOtherTotal = 0;
511 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
512
513 for (EffortCertificationDetail detailLine : detailLineList) {
514 if (!detailLine.isFederalOrFederalPassThroughIndicator()) {
515 effortOrigOtherTotal += detailLine.getEffortCertificationCalculatedOverallPercent();
516 }
517 }
518
519 return effortOrigOtherTotal;
520 }
521
522 /**
523 * Calculates the total updated effort for non federal pass through detail lines
524 *
525 * @return effort total for non federal pass through accounts
526 */
527 public Integer getOtherTotalEffortPercent() {
528 Integer effortOtherTotal = 0;
529 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
530
531 for (EffortCertificationDetail detailLine : detailLineList) {
532 if (!detailLine.isFederalOrFederalPassThroughIndicator()) {
533 effortOtherTotal += detailLine.getEffortCertificationUpdatedOverallPercent();
534 }
535 }
536
537 return effortOtherTotal;
538 }
539
540 /**
541 * Calculates the total salary for federal detail lines
542 *
543 * @return total salary
544 */
545 public KualiDecimal getFederalTotalPayrollAmount() {
546 KualiDecimal salaryFederalTotal = KualiDecimal.ZERO;
547 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
548
549 for (EffortCertificationDetail detailLine : detailLineList) {
550 if (detailLine.isFederalOrFederalPassThroughIndicator()) {
551 salaryFederalTotal = salaryFederalTotal.add(detailLine.getEffortCertificationPayrollAmount());
552 }
553 }
554
555 return salaryFederalTotal;
556 }
557
558 /**
559 * Calculates the total original salary for federal pass through detail lines
560 *
561 * @return total salary
562 */
563 public KualiDecimal getFederalTotalOriginalPayrollAmount() {
564 KualiDecimal salaryOrigFederalTotal = KualiDecimal.ZERO;
565 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
566
567 for (EffortCertificationDetail detailLine : detailLineList) {
568 if (detailLine.isFederalOrFederalPassThroughIndicator()) {
569 salaryOrigFederalTotal = salaryOrigFederalTotal.add(detailLine.getEffortCertificationOriginalPayrollAmount());
570 }
571 }
572
573 return salaryOrigFederalTotal;
574 }
575
576 /**
577 * Calculates the total original salary for non federal pass through detail lines
578 *
579 * @return total original salary
580 */
581 public KualiDecimal getOtherTotalOriginalPayrollAmount() {
582 KualiDecimal salaryOrigOtherTotal = KualiDecimal.ZERO;
583 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
584
585 for (EffortCertificationDetail detailLine : detailLineList) {
586 if (!detailLine.isFederalOrFederalPassThroughIndicator()) {
587 salaryOrigOtherTotal = salaryOrigOtherTotal.add(detailLine.getEffortCertificationOriginalPayrollAmount());
588 }
589 }
590
591 return salaryOrigOtherTotal;
592 }
593
594 /**
595 * Calculates total updated salary for non federal pass through detail lines
596 *
597 * @return total salary
598 */
599 public KualiDecimal getOtherTotalPayrollAmount() {
600 KualiDecimal salaryOtherTotal = KualiDecimal.ZERO;
601 List<EffortCertificationDetail> detailLineList = this.getEffortCertificationDetailLines();
602
603 for (EffortCertificationDetail detailLine : detailLineList) {
604 if (!detailLine.isFederalOrFederalPassThroughIndicator()) {
605 salaryOtherTotal = salaryOtherTotal.add(detailLine.getEffortCertificationPayrollAmount());
606 }
607 }
608
609 return salaryOtherTotal;
610 }
611
612 /**
613 * Gets the totalFringeBenefit attribute.
614 *
615 * @return Returns the totalFringeBenefit.
616 */
617 public KualiDecimal getTotalFringeBenefit() {
618 return EffortCertificationDetail.getTotalFringeBenefit(effortCertificationDetailLines);
619 }
620
621 /**
622 * Gets the totalOriginalFringeBenefit attribute.
623 *
624 * @return Returns the totalOriginalFringeBenefit.
625 */
626 public KualiDecimal getTotalOriginalFringeBenefit() {
627 return EffortCertificationDetail.getTotalOriginalFringeBenefit(effortCertificationDetailLines);
628 }
629
630 /**
631 * @see org.kuali.rice.kns.document.DocumentBase#processAfterRetrieve()
632 */
633 @Override
634 public void processAfterRetrieve() {
635 super.processAfterRetrieve();
636
637 // capture each line's salary amount before route level modification for later rule validation
638 for (EffortCertificationDetail detailLine : this.getEffortCertificationDetailLines()) {
639 detailLine.setPersistedPayrollAmount(new KualiDecimal(detailLine.getEffortCertificationPayrollAmount().bigDecimalValue()));
640
641 int effortPercent = detailLine.getEffortCertificationUpdatedOverallPercent();
642 detailLine.setPersistedEffortPercent(new Integer(effortPercent));
643 }
644
645 // calculate original fringe benefits for each line
646 for (EffortCertificationDetail detailLine : this.getEffortCertificationDetailLines()) {
647 detailLine.recalculateOriginalFringeBenefit();
648 }
649 }
650
651 /**
652 * Checks if the effort has changed for any of the detail lines.
653 *
654 * @return true if effort has changed, false otherwise
655 */
656 public boolean isEffortDistributionChanged() {
657 for (EffortCertificationDetail detail : this.getEffortCertificationDetailLines()) {
658 if (!detail.getEffortCertificationCalculatedOverallPercent().equals(detail.getEffortCertificationUpdatedOverallPercent())) {
659 return true;
660 }
661 }
662
663 return false;
664 }
665
666 /**
667 * Finds the default position number for display based on the detail line with the maximum effort
668 *
669 * @return default position number
670 */
671 public String getDefaultPositionNumber() {
672 return this.getMaxEffortLine().getPositionNumber();
673 }
674
675 /**
676 * Finds the default object code for display based on the value for the detail line with the maximum effort
677 *
678 * @return default object code
679 */
680 public String getDefaultObjectCode() {
681 return this.getMaxEffortLine().getFinancialObjectCode();
682 }
683
684 /**
685 * Finds the detail line with the maximum effort
686 *
687 * @return max effort line
688 */
689 protected EffortCertificationDetail getMaxEffortLine() {
690 Integer maxEffort = 0;
691 EffortCertificationDetail maxLine = null;
692 List<EffortCertificationDetail> detailLines = this.getEffortCertificationDetailLines();
693 for (EffortCertificationDetail detailLine : detailLines) {
694 if (detailLine.getEffortCertificationUpdatedOverallPercent() > maxEffort) {
695 maxEffort = detailLine.getEffortCertificationUpdatedOverallPercent();
696 maxLine = detailLine;
697 }
698 }
699 return maxLine;
700 }
701
702 /**
703 * @see org.kuali.rice.kns.document.DocumentBase#populateDocumentForRouting()
704 */
705 @Override
706 public void populateDocumentForRouting() {
707 if (ObjectUtils.isNotNull(getTotalPayrollAmount())) {
708 getDocumentHeader().setFinancialDocumentTotalAmount(getTotalPayrollAmount());
709 }
710 else {
711 getDocumentHeader().setFinancialDocumentTotalAmount(new KualiDecimal(0));
712 }
713 super.populateDocumentForRouting();
714 }
715
716
717 /**
718 * Finds the list of unique object codes contained in this document
719 *
720 * @return list of unique object codes
721 */
722 public List<String> getObjectCodeList() {
723 List<String> uniqueObjectCodeList = new ArrayList<String>();
724 List<EffortCertificationDetail> allObjectCodesList = this.getEffortCertificationDetailLines();
725 for (EffortCertificationDetail detail : allObjectCodesList) {
726 if (!uniqueObjectCodeList.contains(detail.getFinancialObjectCode())) {
727 uniqueObjectCodeList.add(detail.getFinancialObjectCode());
728 }
729 }
730
731 return uniqueObjectCodeList;
732 }
733
734 /**
735 * Finds the list of unique position numbers for this document
736 *
737 * @return list of unique position numbers
738 */
739 public List<String> getPositionList() {
740 List<String> uniquePositionList = new ArrayList<String>();
741 List<EffortCertificationDetail> allPositionsList = this.getEffortCertificationDetailLines();
742 for (EffortCertificationDetail detail : allPositionsList) {
743 if (!uniquePositionList.contains(detail.getPositionNumber())) {
744 uniquePositionList.add(detail.getPositionNumber());
745 }
746 }
747
748 return uniquePositionList;
749 }
750
751 /**
752 * This is a marker setter method and does nothing.
753 */
754 public void setTotalOriginalPayrollAmount(KualiDecimal totalOriginalPayrollAmount) {
755 return;
756 }
757
758 /**
759 * Gets the summarizedDetailLines attribute.
760 *
761 * @return Returns the summarizedDetailLines.
762 */
763 public List<EffortCertificationDetail> getSummarizedDetailLines() {
764 return summarizedDetailLines;
765 }
766
767 /**
768 * Sets the summarizedDetailLines attribute value.
769 *
770 * @param summarizedDetailLines The summarizedDetailLines to set.
771 */
772 public void setSummarizedDetailLines(List<EffortCertificationDetail> summarizedDetailLines) {
773 this.summarizedDetailLines = summarizedDetailLines;
774 }
775
776 /**
777 * Provides answers to the following splits:
778 * Do Award Split
779 * Do Recreate Split
780 * @see org.kuali.kfs.sys.document.FinancialSystemTransactionalDocumentBase#answerSplitNodeQuestion(java.lang.String)
781 */
782 @Override
783 public boolean answerSplitNodeQuestion(String nodeName) throws UnsupportedOperationException {
784 if (nodeName.equals(EffortCertificationDocument.DO_AWARD_SPLIT)) return isDoAwardSplit();
785 if (nodeName.equals(EffortCertificationDocument.DO_RECREATE_SPLIT)) return isDoRecreateSplit();
786 throw new UnsupportedOperationException("Cannot answer split question for this node you call \""+nodeName+"\"");
787 }
788
789 /**
790 * Checks system parameter that indicates whether routing to project directors should occur only on
791 * lines with federal accounts or all lines.
792 *
793 * @return detail lines with federal accounts if parameter is true, otherwise all detail lines
794 */
795 public List<EffortCertificationDetail> getDetailLinesForPDRouting() {
796 boolean federalOnlyRouting = EffortCertificationParameterFinder.getFederalOnlyRouteIndicator();
797 if (!federalOnlyRouting) {
798 return this.effortCertificationDetailLines;
799 }
800
801 List<EffortCertificationDetail> federalDetailLines = new ArrayList<EffortCertificationDetail>();
802 for (EffortCertificationDetail detail : this.effortCertificationDetailLines) {
803 if (detail.isFederalOrFederalPassThroughIndicator()) {
804 federalDetailLines.add(detail);
805 }
806 }
807
808 return federalDetailLines;
809 }
810
811 /**
812 * @return boolean value
813 */
814 protected boolean isDoAwardSplit() {
815 return this.isEffortDistributionChanged();
816 }
817
818 /**
819 * @return boolean value
820 */
821 protected boolean isDoRecreateSplit() {
822 return this.getEffortCertificationDocumentCode();
823 }
824 }
825