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.businessobject;
018    
019    import java.util.LinkedHashMap;
020    import java.util.List;
021    
022    import org.apache.commons.lang.StringUtils;
023    import org.kuali.kfs.coa.businessobject.Account;
024    import org.kuali.kfs.coa.businessobject.Chart;
025    import org.kuali.kfs.coa.businessobject.ObjectCode;
026    import org.kuali.kfs.coa.businessobject.SubAccount;
027    import org.kuali.kfs.integration.cg.ContractsAndGrantsModuleService;
028    import org.kuali.kfs.integration.ld.LaborModuleService;
029    import org.kuali.kfs.module.ec.EffortPropertyConstants;
030    import org.kuali.kfs.module.ec.document.EffortCertificationDocument;
031    import org.kuali.kfs.module.ec.util.EffortCertificationParameterFinder;
032    import org.kuali.kfs.module.ec.util.PayrollAmountHolder;
033    import org.kuali.kfs.module.ld.LaborPropertyConstants;
034    import org.kuali.kfs.module.ld.businessobject.PositionData;
035    import org.kuali.kfs.sys.KFSConstants;
036    import org.kuali.kfs.sys.KFSPropertyConstants;
037    import org.kuali.kfs.sys.businessobject.AccountingLineOverride;
038    import org.kuali.kfs.sys.businessobject.SystemOptions;
039    import org.kuali.kfs.sys.context.SpringContext;
040    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
041    import org.kuali.rice.kns.util.KualiDecimal;
042    
043    /**
044     * Business Object for the Effort Certification Detail Table.
045     */
046    public class EffortCertificationDetail extends PersistableBusinessObjectBase {
047        private String documentNumber;
048        private String chartOfAccountsCode;
049        private String accountNumber;
050        private String subAccountNumber;
051        private String positionNumber;
052        private String financialObjectCode;
053        private String sourceChartOfAccountsCode;
054        private String sourceAccountNumber;
055    
056        private KualiDecimal effortCertificationPayrollAmount;
057        private KualiDecimal effortCertificationOriginalPayrollAmount;
058        private Integer effortCertificationCalculatedOverallPercent;
059        private Integer effortCertificationUpdatedOverallPercent;
060        private String costShareSourceSubAccountNumber;
061    
062        private Integer universityFiscalYear;
063    
064        private KualiDecimal originalFringeBenefitAmount;
065    
066        private boolean accountExpiredOverride;
067        private boolean accountExpiredOverrideNeeded;
068        private String overrideCode = AccountingLineOverride.CODE.NONE;
069    
070        private boolean newLineIndicator; // to indicate if this detail line has been persisted or not
071        
072        // holds last saved updated payroll amount so business rule can check if it has been updated at the route level
073        private KualiDecimal persistedPayrollAmount;
074        private Integer persistedEffortPercent;
075        private String groupId;
076    
077        private EffortCertificationDocument effortCertificationDocument;
078        private ObjectCode financialObject;
079        private Chart chartOfAccounts;
080        private Account account;
081        private Chart sourceChartOfAccounts;
082        private Account sourceAccount;
083        private SubAccount subAccount;
084        private SystemOptions options;
085    
086        protected PositionData positionData;
087        protected String effectiveDate; 
088        /**
089         * Default constructor.
090         */
091        public EffortCertificationDetail() {
092            super();
093    
094            try {
095                subAccountNumber = KFSConstants.getDashSubAccountNumber();
096            } catch ( RuntimeException ex ) {
097                // skip errors caused by calling this prior to spring startup
098            }
099    
100            effortCertificationPayrollAmount = KualiDecimal.ZERO;
101            effortCertificationOriginalPayrollAmount = KualiDecimal.ZERO;
102            effortCertificationCalculatedOverallPercent = new Integer(0);
103            effortCertificationUpdatedOverallPercent = new Integer(0);
104            originalFringeBenefitAmount = KualiDecimal.ZERO;
105            effectiveDate = KFSConstants.EMPTY_STRING;
106        }
107    
108        public EffortCertificationDetail(EffortCertificationDetail effortCertificationDetail) {
109            super();
110            if (effortCertificationDetail != null) {
111                this.chartOfAccountsCode = effortCertificationDetail.getChartOfAccountsCode();
112                this.accountNumber = effortCertificationDetail.getAccountNumber();
113                this.subAccountNumber = effortCertificationDetail.getSubAccountNumber();
114                this.positionNumber = effortCertificationDetail.getPositionNumber();
115                this.financialObjectCode = effortCertificationDetail.getFinancialObjectCode();
116                this.sourceChartOfAccountsCode = effortCertificationDetail.getSourceChartOfAccountsCode();
117                this.sourceAccountNumber = effortCertificationDetail.getSourceAccountNumber();
118                this.effortCertificationPayrollAmount = effortCertificationDetail.getEffortCertificationPayrollAmount();
119                this.effortCertificationCalculatedOverallPercent = effortCertificationDetail.getEffortCertificationCalculatedOverallPercent();
120                this.effortCertificationUpdatedOverallPercent = effortCertificationDetail.getEffortCertificationUpdatedOverallPercent();
121                this.universityFiscalYear = effortCertificationDetail.getUniversityFiscalYear();
122                this.costShareSourceSubAccountNumber = effortCertificationDetail.getCostShareSourceSubAccountNumber();
123                this.effortCertificationOriginalPayrollAmount = effortCertificationDetail.getEffortCertificationOriginalPayrollAmount();
124                this.originalFringeBenefitAmount = effortCertificationDetail.getOriginalFringeBenefitAmount();
125                this.effectiveDate = effortCertificationDetail.getEffectiveDate();
126            }
127        }
128    
129        /**
130         * Gets the documentNumber attribute.
131         * 
132         * @return Returns the documentNumber.
133         */
134        public String getDocumentNumber() {
135            return documentNumber;
136        }
137    
138        /**
139         * Sets the documentNumber attribute value.
140         * 
141         * @param documentNumber The documentNumber to set.
142         */
143        public void setDocumentNumber(String documentNumber) {
144            this.documentNumber = documentNumber;
145        }
146    
147        /**
148         * Gets the chartOfAccountsCode attribute.
149         * 
150         * @return Returns the chartOfAccountsCode.
151         */
152        public String getChartOfAccountsCode() {
153            return chartOfAccountsCode;
154        }
155    
156        /**
157         * Sets the chartOfAccountsCode attribute value.
158         * 
159         * @param chartOfAccountsCode The chartOfAccountsCode to set.
160         */
161        public void setChartOfAccountsCode(String chartOfAccountsCode) {
162            this.chartOfAccountsCode = chartOfAccountsCode;
163        }
164    
165        /**
166         * Gets the accountNumber attribute.
167         * 
168         * @return Returns the accountNumber.
169         */
170        public String getAccountNumber() {
171            return accountNumber;
172        }
173    
174        /**
175         * Sets the accountNumber attribute value.
176         * 
177         * @param accountNumber The accountNumber to set.
178         */
179        public void setAccountNumber(String accountNumber) {
180            this.accountNumber = accountNumber;
181        }
182    
183        /**
184         * Gets the subAccountNumber attribute.
185         * 
186         * @return Returns the subAccountNumber.
187         */
188        public String getSubAccountNumber() {
189            return subAccountNumber;
190        }
191    
192        /**
193         * Sets the subAccountNumber attribute value.
194         * 
195         * @param subAccountNumber The subAccountNumber to set.
196         */
197        public void setSubAccountNumber(String subAccountNumber) {
198            this.subAccountNumber = subAccountNumber;
199        }
200    
201        /**
202         * Gets the positionNumber attribute.
203         * 
204         * @return Returns the positionNumber.
205         */
206        public String getPositionNumber() {
207            return positionNumber;
208        }
209    
210        /**
211         * Sets the positionNumber attribute value.
212         * 
213         * @param positionNumber The positionNumber to set.
214         */
215        public void setPositionNumber(String positionNumber) {
216            this.positionNumber = positionNumber;
217        }
218    
219        /**
220         * Gets the effectiveDate attribute.
221         * 
222         * @return Returns the effectiveDate.
223         */
224        public String getEffectiveDate() {
225            return effectiveDate;
226        }
227    
228        /**
229         * Sets the effectiveDate attribute value.
230         * 
231         * @param effectiveDate The effectiveDate to set.
232         */
233        public void setEffectiveDate(String effectiveDate) {
234            this.effectiveDate = effectiveDate;
235        }    
236        
237        /**
238         * Gets the financialObjectCode attribute.
239         * 
240         * @return Returns the financialObjectCode.
241         */
242        public String getFinancialObjectCode() {
243            return financialObjectCode;
244        }
245    
246        /**
247         * Sets the financialObjectCode attribute value.
248         * 
249         * @param financialObjectCode The financialObjectCode to set.
250         */
251        public void setFinancialObjectCode(String financialObjectCode) {
252            this.financialObjectCode = financialObjectCode;
253        }
254    
255        /**
256         * Gets the sourceChartOfAccountsCode attribute.
257         * 
258         * @return Returns the sourceChartOfAccountsCode.
259         */
260        public String getSourceChartOfAccountsCode() {
261            return sourceChartOfAccountsCode;
262        }
263    
264        /**
265         * Sets the sourceChartOfAccountsCode attribute value.
266         * 
267         * @param sourceChartOfAccountsCode The sourceChartOfAccountsCode to set.
268         */
269        public void setSourceChartOfAccountsCode(String sourceChartOfAccountsCode) {
270            this.sourceChartOfAccountsCode = sourceChartOfAccountsCode;
271        }
272    
273        /**
274         * Gets the sourceAccountNumber attribute.
275         * 
276         * @return Returns the sourceAccountNumber.
277         */
278        public String getSourceAccountNumber() {
279            return sourceAccountNumber;
280        }
281    
282        /**
283         * Sets the sourceAccountNumber attribute value.
284         * 
285         * @param sourceAccountNumber The sourceAccountNumber to set.
286         */
287        public void setSourceAccountNumber(String sourceAccountNumber) {
288            this.sourceAccountNumber = sourceAccountNumber;
289        }
290    
291        /**
292         * Gets the effortCertificationPayrollAmount attribute.
293         * 
294         * @return Returns the effortCertificationPayrollAmount.
295         */
296        public KualiDecimal getEffortCertificationPayrollAmount() {
297            return effortCertificationPayrollAmount;
298        }
299    
300        /**
301         * Sets the effortCertificationPayrollAmount attribute value.
302         * 
303         * @param effortCertificationPayrollAmount The effortCertificationPayrollAmount to set.
304         */
305        public void setEffortCertificationPayrollAmount(KualiDecimal effortCertificationPayrollAmount) {
306            this.effortCertificationPayrollAmount = effortCertificationPayrollAmount;
307        }
308    
309        /**
310         * Gets the effortCertificationCalculatedOverallPercent attribute.
311         * 
312         * @return Returns the effortCertificationCalculatedOverallPercent.
313         */
314        public Integer getEffortCertificationCalculatedOverallPercent() {
315            return effortCertificationCalculatedOverallPercent;
316        }
317    
318        /**
319         * Sets the effortCertificationCalculatedOverallPercent attribute value.
320         * 
321         * @param effortCertificationCalculatedOverallPercent The effortCertificationCalculatedOverallPercent to set.
322         */
323        public void setEffortCertificationCalculatedOverallPercent(Integer effortCertificationCalculatedOverallPercent) {
324            this.effortCertificationCalculatedOverallPercent = effortCertificationCalculatedOverallPercent;
325        }
326    
327        /**
328         * Gets the effortCertificationUpdatedOverallPercent attribute.
329         * 
330         * @return Returns the effortCertificationUpdatedOverallPercent.
331         */
332        public Integer getEffortCertificationUpdatedOverallPercent() {
333            return effortCertificationUpdatedOverallPercent;
334        }
335    
336        /**
337         * Sets the effortCertificationUpdatedOverallPercent attribute value.
338         * 
339         * @param effortCertificationUpdatedOverallPercent The effortCertificationUpdatedOverallPercent to set.
340         */
341        public void setEffortCertificationUpdatedOverallPercent(Integer effortCertificationUpdatedOverallPercent) {
342            this.effortCertificationUpdatedOverallPercent = effortCertificationUpdatedOverallPercent;
343        }
344    
345        /**
346         * Gets the costShareSourceSubAccountNumber attribute.
347         * 
348         * @return Returns the costShareSourceSubAccountNumber.
349         */
350        public String getCostShareSourceSubAccountNumber() {
351            return costShareSourceSubAccountNumber;
352        }
353    
354        /**
355         * Sets the costShareSourceSubAccountNumber attribute value.
356         * 
357         * @param costShareSourceSubAccountNumber The costShareSourceSubAccountNumber to set.
358         */
359        public void setCostShareSourceSubAccountNumber(String costShareSourceSubAccountNumber) {
360            this.costShareSourceSubAccountNumber = costShareSourceSubAccountNumber;
361        }
362    
363        /**
364         * Gets the effortCertificationOriginalPayrollAmount attribute.
365         * 
366         * @return Returns the effortCertificationOriginalPayrollAmount.
367         */
368        public KualiDecimal getEffortCertificationOriginalPayrollAmount() {
369            return effortCertificationOriginalPayrollAmount;
370        }
371    
372        /**
373         * Sets the effortCertificationOriginalPayrollAmount attribute value.
374         * 
375         * @param effortCertificationOriginalPayrollAmount The effortCertificationOriginalPayrollAmount to set.
376         */
377        public void setEffortCertificationOriginalPayrollAmount(KualiDecimal effortCertificationOriginalPayrollAmount) {
378            this.effortCertificationOriginalPayrollAmount = effortCertificationOriginalPayrollAmount;
379        }
380    
381    
382        /**
383         * Gets the financialObject attribute.
384         * 
385         * @return Returns the financialObject.
386         */
387        public ObjectCode getFinancialObject() {
388            return financialObject;
389        }
390    
391        /**
392         * Sets the financialObject attribute value.
393         * 
394         * @param financialObject The financialObject to set.
395         */
396        @Deprecated
397        public void setFinancialObject(ObjectCode financialObject) {
398            this.financialObject = financialObject;
399        }
400    
401        /**
402         * Gets the chartOfAccounts attribute.
403         * 
404         * @return Returns the chartOfAccounts.
405         */
406        public Chart getChartOfAccounts() {
407            return chartOfAccounts;
408        }
409    
410        /**
411         * Sets the chartOfAccounts attribute value.
412         * 
413         * @param chartOfAccounts The chartOfAccounts to set.
414         */
415        @Deprecated
416        public void setChartOfAccounts(Chart chartOfAccounts) {
417            this.chartOfAccounts = chartOfAccounts;
418        }
419    
420        /**
421         * Gets the effortCertificationDocument attribute.
422         * 
423         * @return Returns the effortCertificationDocument.
424         */
425        public EffortCertificationDocument getEffortCertificationDocument() {
426            return effortCertificationDocument;
427        }
428    
429        /**
430         * Sets the effortCertificationDocument attribute value.
431         * 
432         * @param effortCertificationDocument The effortCertificationDocument to set.
433         */
434        @Deprecated
435        public void setEffortCertificationDocument(EffortCertificationDocument effortCertificationDocument) {
436            this.effortCertificationDocument = effortCertificationDocument;
437        }
438    
439        /**
440         * Gets the account attribute.
441         * 
442         * @return Returns the account.
443         */
444        public Account getAccount() {
445            if (account == null && StringUtils.isNotBlank(this.getChartOfAccountsCode()) && StringUtils.isNotBlank(this.getAccountNumber())) {
446                this.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
447            }
448    
449            return account;
450        }
451    
452        /**
453         * Sets the account attribute value.
454         * 
455         * @param account The account to set.
456         */
457        @Deprecated
458        public void setAccount(Account account) {
459            this.account = account;
460        }
461    
462        /**
463         * Gets the sourceChartOfAccounts attribute.
464         * 
465         * @return Returns the sourceChartOfAccounts.
466         */
467        public Chart getSourceChartOfAccounts() {
468            return sourceChartOfAccounts;
469        }
470    
471        /**
472         * Sets the sourceChartOfAccounts attribute value.
473         * 
474         * @param sourceChartOfAccounts The sourceChartOfAccounts to set.
475         */
476        @Deprecated
477        public void setSourceChartOfAccounts(Chart sourceChartOfAccounts) {
478            this.sourceChartOfAccounts = sourceChartOfAccounts;
479        }
480    
481        /**
482         * Gets the sourceAccount attribute.
483         * 
484         * @return Returns the sourceAccount.
485         */
486        public Account getSourceAccount() {
487            return sourceAccount;
488        }
489    
490        /**
491         * Sets the sourceAccount attribute value.
492         * 
493         * @param sourceAccount The sourceAccount to set.
494         */
495        @Deprecated
496        public void setSourceAccount(Account sourceAccount) {
497            this.sourceAccount = sourceAccount;
498        }
499    
500        /**
501         * Gets the subAccount attribute.
502         * 
503         * @return Returns the subAccount.
504         */
505        public SubAccount getSubAccount() {
506            return subAccount;
507        }
508    
509        /**
510         * Sets the subAccount attribute value.
511         * 
512         * @param subAccount The subAccount to set.
513         */
514        @Deprecated
515        public void setSubAccount(SubAccount subAccount) {
516            this.subAccount = subAccount;
517        }
518    
519        /**
520         * Gets the options attribute.
521         * 
522         * @return Returns the options.
523         */
524        public SystemOptions getOptions() {
525            return options;
526        }
527    
528        /**
529         * Sets the options attribute value.
530         * 
531         * @param options The options to set.
532         */
533        @Deprecated
534        public void setOptions(SystemOptions options) {
535            this.options = options;
536        }
537    
538        /**
539         * Gets the positionData attribute.
540         * 
541         * @return Returns the positionData.
542         */
543        public PositionData getPositionData() {
544            return positionData;
545        }
546    
547        /**
548         * Sets the positionData attribute value.
549         * 
550         * @param positionData The positionData to set.
551         */
552        public void setPositionData(PositionData positionData) {
553            this.positionData = positionData;
554        }    
555        
556        /**
557         * Gets the newLineIndicator attribute.
558         * 
559         * @return Returns the newLineIndicator.
560         */
561        public boolean isNewLineIndicator() {
562            return newLineIndicator;
563        }
564    
565        /**
566         * Sets the newLineIndicator attribute value.
567         * 
568         * @param newLineIndicator The newLineIndicator to set.
569         */
570        public void setNewLineIndicator(boolean newLineIndicator) {
571            this.newLineIndicator = newLineIndicator;
572        }
573    
574        /**
575         * If the account of this detail line is closed, the line cannot be edited.
576         * 
577         * @return Returns true if line can be edited, false otherwise
578         */
579        public boolean isEditable() {
580            if (this.getAccount() != null && !this.getAccount().isActive()) {
581                return false;
582            }
583            
584            return true;
585        }
586    
587        /**
588         * Gets the federalOrFederalPassThroughIndicator attribute. If this line is associated with a valid account, the indicator will
589         * be retrieved and updated.
590         * 
591         * @return Returns the federalOrFederalPassThroughIndicator.
592         */
593        public boolean isFederalOrFederalPassThroughIndicator() {
594            if (this.getAccount() != null) {
595                List<String> federalAgencyTypeCodes = EffortCertificationParameterFinder.getFederalAgencyTypeCodes();
596                return SpringContext.getBean(ContractsAndGrantsModuleService.class).isAwardedByFederalAgency(getAccount().getChartOfAccountsCode(), getAccount().getAccountNumber(), federalAgencyTypeCodes);
597            }
598    
599            return false;
600        }
601    
602        /**
603         * This is a marker method, which does nothing.
604         */
605        public void setFederalOrFederalPassThroughIndicator(boolean federalOrFederalPassThroughIndicator) {
606            return;
607        }
608    
609        /**
610         * Gets the overrideCode attribute.
611         * 
612         * @return Returns the overrideCode.
613         */
614        public String getOverrideCode() {
615            return overrideCode;
616        }
617    
618        /**
619         * Sets the overrideCode attribute value.
620         * 
621         * @param overrideCode The overrideCode to set.
622         */
623        public void setOverrideCode(String overrideCode) {
624            this.overrideCode = overrideCode;
625        }
626    
627        /**
628         * Gets the fringeBenefitAmount attribute.
629         * 
630         * @return Returns the fringeBenefitAmount.
631         */
632        public KualiDecimal getFringeBenefitAmount() {
633            KualiDecimal payrollAmount = this.getEffortCertificationPayrollAmount();
634    
635            return EffortCertificationDetail.calculateFringeBenefit(this, payrollAmount);
636        }
637    
638        /**
639         * This is a marker method, which does nothing.
640         */
641        public void setFringeBenefitAmount(KualiDecimal fringeBenefitAmount) {
642            return;
643        }
644    
645        /**
646         * Gets the originalFringeBenefitAmount attribute.
647         * 
648         * @return Returns the originalFringeBenefitAmount.
649         */
650        public KualiDecimal getOriginalFringeBenefitAmount() {
651            if (this.originalFringeBenefitAmount == null || originalFringeBenefitAmount.isZero()) {
652                this.recalculateOriginalFringeBenefit();
653            }
654            return originalFringeBenefitAmount;
655        }
656    
657        /**
658         * Sets the originalFringeBenefitAmount attribute value.
659         * 
660         * @param originalFringeBenefitAmount The originalFringeBenefitAmount to set.
661         */
662        public void setOriginalFringeBenefitAmount(KualiDecimal originalFringeBenefitAmount) {
663            this.originalFringeBenefitAmount = originalFringeBenefitAmount;
664        }
665    
666        /**
667         * Gets the universityFiscalYear attribute.
668         * 
669         * @return Returns the universityFiscalYear.
670         */
671        public Integer getUniversityFiscalYear() {
672            return this.universityFiscalYear;
673        }
674    
675        /**
676         * Sets the universityFiscalYear attribute value.
677         * 
678         * @param universityFiscalYear The universityFiscalYear to set.
679         */
680        public void setUniversityFiscalYear(Integer universityFiscalYear) {
681            this.universityFiscalYear = universityFiscalYear;
682        }
683    
684        /**
685         * Gets the persistedPayrollAmount attribute.
686         * 
687         * @return Returns the persistedPayrollAmount.
688         */
689        public KualiDecimal getPersistedPayrollAmount() {
690            return persistedPayrollAmount;
691        }
692    
693        /**
694         * Sets the persistedPayrollAmount attribute value.
695         * 
696         * @param persistedPayrollAmount The persistedPayrollAmount to set.
697         */
698        public void setPersistedPayrollAmount(KualiDecimal persistedPayrollAmount) {
699            this.persistedPayrollAmount = persistedPayrollAmount;
700        }
701    
702        /**
703         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
704         */
705        @SuppressWarnings("unchecked")
706        protected LinkedHashMap toStringMapper() {
707            LinkedHashMap map = new LinkedHashMap();
708            map.put(KFSPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
709            map.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, this.chartOfAccountsCode);
710            map.put(KFSPropertyConstants.ACCOUNT_NUMBER, this.accountNumber);
711            map.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, this.subAccountNumber);
712            map.put(KFSPropertyConstants.POSITION_NUMBER, this.positionNumber);
713            map.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, this.financialObjectCode);
714            map.put(EffortPropertyConstants.SOURCE_CHART_OF_ACCOUNTS_CODE, this.sourceChartOfAccountsCode);
715            map.put(EffortPropertyConstants.SOURCE_ACCOUNT_NUMBER, this.sourceAccountNumber);
716            map.put(EffortPropertyConstants.EFFORT_CERTIFICATION_PAYROLL_AMOUNT, this.effortCertificationPayrollAmount);
717            map.put(EffortPropertyConstants.EFFORT_CERTIFICATION_ORIGINAL_PAYROLL_AMOUNT, this.effortCertificationOriginalPayrollAmount);
718            map.put(LaborPropertyConstants.EFFECTIVE_DATE, this.effectiveDate);        
719    
720            return map;
721        }
722    
723        /**
724         * Gets the accountExpiredOverride attribute.
725         * 
726         * @return Returns the accountExpiredOverride.
727         */
728        public boolean isAccountExpiredOverride() {
729            return accountExpiredOverride;
730        }
731    
732        /**
733         * Sets the accountExpiredOverride attribute value.
734         * 
735         * @param accountExpiredOverride The accountExpiredOverride to set.
736         */
737        public void setAccountExpiredOverride(boolean accountExpiredOverride) {
738            this.accountExpiredOverride = accountExpiredOverride;
739        }
740    
741        /**
742         * Gets the accountExpiredOverrideNeeded attribute.
743         * 
744         * @return Returns the accountExpiredOverrideNeeded.
745         */
746        public boolean isAccountExpiredOverrideNeeded() {
747            return accountExpiredOverrideNeeded;
748        }
749    
750        /**
751         * Sets the accountExpiredOverrideNeeded attribute value.
752         * 
753         * @param accountExpiredOverrideNeeded The accountExpiredOverrideNeeded to set.
754         */
755        public void setAccountExpiredOverrideNeeded(boolean accountExpiredOverrideNeeded) {
756            this.accountExpiredOverrideNeeded = accountExpiredOverrideNeeded;
757        }
758    
759        /**
760         * calculate the total effort percent of the given detail lines
761         * 
762         * @param the given detail lines
763         * @return Returns the total effort percent
764         */
765        public static Integer getTotalEffortPercent(List<EffortCertificationDetail> effortCertificationDetailLines) {
766            Integer totalEffortPercent = 0;
767    
768            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
769                totalEffortPercent += detailLine.getEffortCertificationUpdatedOverallPercent();
770            }
771    
772            return totalEffortPercent;
773        }
774        
775        /**
776         * calculate the total persised effort percent of the given detail lines
777         * 
778         * @param the given detail lines
779         * @return Returns the total persisted effort percent
780         */
781        public static Integer getTotalPersistedEffortPercent(List<EffortCertificationDetail> effortCertificationDetailLines) {
782            Integer totalEffortPercent = 0;
783    
784            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
785                totalEffortPercent += detailLine.getPersistedEffortPercent();
786            }
787    
788            return totalEffortPercent;
789        }
790    
791        /**
792         * calculate the total original effort percent of the given detail lines
793         * 
794         * @param the given detail lines
795         * @return Returns the total original effort percent
796         */
797        public static Integer getTotalOriginalEffortPercent(List<EffortCertificationDetail> effortCertificationDetailLines) {
798            Integer totalOriginalEffortPercent = 0;
799    
800            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
801                totalOriginalEffortPercent += detailLine.getEffortCertificationCalculatedOverallPercent();
802            }
803    
804            return totalOriginalEffortPercent;
805        }
806    
807        /**
808         * calculate the total payroll amount of the given detail lines
809         * 
810         * @param the given detail lines
811         * @return Returns the total original payroll amount
812         */
813        public static KualiDecimal getTotalPayrollAmount(List<EffortCertificationDetail> effortCertificationDetailLines) {
814            KualiDecimal totalPayrollAmount = KualiDecimal.ZERO;
815    
816            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
817                totalPayrollAmount = totalPayrollAmount.add(detailLine.getEffortCertificationPayrollAmount());
818            }
819    
820            return totalPayrollAmount;
821        }
822        
823        /**
824         * calculate the total payroll amount of the given detail lines
825         * 
826         * @param the given detail lines
827         * @return Returns the total original payroll amount
828         */
829        public static KualiDecimal getTotalPersistedPayrollAmount(List<EffortCertificationDetail> effortCertificationDetailLines) {
830            KualiDecimal totalPayrollAmount = KualiDecimal.ZERO;
831    
832            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
833                totalPayrollAmount = totalPayrollAmount.add(detailLine.getPersistedPayrollAmount());
834            }
835    
836            return totalPayrollAmount;
837        }
838    
839        /**
840         * calculate the total original payroll amount of the given detail lines
841         * 
842         * @param the given detail lines
843         * @return Returns the total original payroll amount
844         */
845        public static KualiDecimal getTotalOriginalPayrollAmount(List<EffortCertificationDetail> effortCertificationDetailLines) {
846            KualiDecimal totalOriginalPayrollAmount = KualiDecimal.ZERO;
847    
848            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
849                totalOriginalPayrollAmount = totalOriginalPayrollAmount.add(detailLine.getEffortCertificationOriginalPayrollAmount());
850            }
851    
852            return totalOriginalPayrollAmount;
853        }
854    
855        /**
856         * Gets the totalFringeBenefit attribute.
857         * 
858         * @return Returns the totalFringeBenefit.
859         */
860        public static KualiDecimal getTotalFringeBenefit(List<EffortCertificationDetail> effortCertificationDetailLines) {
861            KualiDecimal totalFringeBenefit = KualiDecimal.ZERO;
862    
863            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
864                totalFringeBenefit = totalFringeBenefit.add(detailLine.getFringeBenefitAmount());
865            }
866    
867            return totalFringeBenefit;
868        }
869    
870        /**
871         * Gets the totalOriginalFringeBenefit attribute.
872         * 
873         * @return Returns the totalOriginalFringeBenefit.
874         */
875        public static KualiDecimal getTotalOriginalFringeBenefit(List<EffortCertificationDetail> effortCertificationDetailLines) {
876            KualiDecimal totalOriginalFringeBenefit = KualiDecimal.ZERO;
877    
878            for (EffortCertificationDetail detailLine : effortCertificationDetailLines) {
879                totalOriginalFringeBenefit = totalOriginalFringeBenefit.add(detailLine.getOriginalFringeBenefitAmount());
880            }
881    
882            return totalOriginalFringeBenefit;
883        }
884    
885        /**
886         * recalculate the payroll amount of the current detail line
887         * 
888         * @param totalPayrollAmount the total payroll amount of the hosting document
889         */
890        public void recalculatePayrollAmount(KualiDecimal totalPayrollAmount) {
891            Integer effortPercent = this.getEffortCertificationUpdatedOverallPercent();
892            KualiDecimal payrollAmount = PayrollAmountHolder.recalculatePayrollAmount(totalPayrollAmount, effortPercent);
893            this.setEffortCertificationPayrollAmount(payrollAmount);
894        }
895    
896        /**
897         * recalculate the original fringe benefit of the current detail line
898         */
899        public void recalculateOriginalFringeBenefit() {
900            KualiDecimal originalPayrollAmount = this.getEffortCertificationOriginalPayrollAmount();
901            KualiDecimal fringeBenefit = EffortCertificationDetail.calculateFringeBenefit(this, originalPayrollAmount);
902            this.setOriginalFringeBenefitAmount(fringeBenefit);
903        }
904    
905        /**
906         * recalculate the original fringe benefit of the current detail line
907         */
908        public static KualiDecimal calculateFringeBenefit(EffortCertificationDetail detailLine, KualiDecimal payrollAmount) {
909            LaborModuleService laborModuleService = SpringContext.getBean(LaborModuleService.class);
910            Integer fiscalYear = detailLine.getUniversityFiscalYear();
911            String chartOfAccountsCode = detailLine.getChartOfAccountsCode();
912            String objectCode = detailLine.getFinancialObjectCode();
913    
914            return laborModuleService.calculateFringeBenefit(fiscalYear, chartOfAccountsCode, objectCode, payrollAmount);
915        }
916    
917        /**
918         * Gets the persistedEffortPercent attribute. 
919         * @return Returns the persistedEffortPercent.
920         */
921        public Integer getPersistedEffortPercent() {
922            return persistedEffortPercent;
923        }
924    
925        /**
926         * Sets the persistedEffortPercent attribute value.
927         * @param persistedEffortPercent The persistedEffortPercent to set.
928         */
929        public void setPersistedEffortPercent(Integer persistedEffortPercent) {
930            this.persistedEffortPercent = persistedEffortPercent;
931        }
932    
933        /**
934         * Gets the groupId attribute. 
935         * @return Returns the groupId.
936         */
937        public String getGroupId() {
938            return groupId;
939        }
940    
941        /**
942         * Sets the groupId attribute value.
943         * @param groupId The groupId to set.
944         */
945        public void setGroupId(String groupId) {
946            this.groupId = groupId;
947        }
948    }