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.cam.businessobject;
017    
018    import java.sql.Date;
019    import java.sql.Timestamp;
020    import java.util.ArrayList;
021    import java.util.LinkedHashMap;
022    import java.util.List;
023    
024    import org.apache.commons.lang.StringUtils;
025    import org.kuali.kfs.coa.businessobject.Account;
026    import org.kuali.kfs.coa.businessobject.Chart;
027    import org.kuali.kfs.module.cam.CamsConstants;
028    import org.kuali.kfs.module.cam.CamsPropertyConstants;
029    import org.kuali.kfs.module.cam.document.service.AssetPaymentService;
030    import org.kuali.kfs.module.cam.document.service.AssetRetirementService;
031    import org.kuali.kfs.module.cam.document.service.PaymentSummaryService;
032    import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
033    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
034    import org.kuali.kfs.sys.businessobject.UniversityDate;
035    import org.kuali.kfs.sys.context.SpringContext;
036    import org.kuali.kfs.sys.service.UniversityDateService;
037    import org.kuali.rice.kns.bo.Country;
038    import org.kuali.rice.kns.bo.DocumentHeader;
039    import org.kuali.rice.kns.bo.GlobalBusinessObject;
040    import org.kuali.rice.kns.bo.GlobalBusinessObjectDetail;
041    import org.kuali.rice.kns.bo.PersistableBusinessObject;
042    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
043    import org.kuali.rice.kns.bo.PostalCode;
044    import org.kuali.rice.kns.bo.State;
045    import org.kuali.rice.kns.service.BusinessObjectService;
046    import org.kuali.rice.kns.service.CountryService;
047    import org.kuali.rice.kns.service.DateTimeService;
048    import org.kuali.rice.kns.service.PostalCodeService;
049    import org.kuali.rice.kns.service.StateService;
050    import org.kuali.rice.kns.util.KualiDecimal;
051    import org.kuali.rice.kns.util.ObjectUtils;
052    import org.kuali.rice.kns.util.TypedArrayList;
053    
054    /**
055     * @author Kuali Nervous System Team (kualidev@oncourse.iu.edu)
056     */
057    
058    public class AssetRetirementGlobal extends PersistableBusinessObjectBase implements GlobalBusinessObject {
059    
060        private String documentNumber;
061        private Long mergedTargetCapitalAssetNumber;
062        private String mergedTargetCapitalAssetDescription;
063        private String retirementReasonCode;
064        private String retirementChartOfAccountsCode;
065        private String retirementAccountNumber;
066        private String retirementContactName;
067        private String retirementInstitutionName;
068        private String retirementStreetAddress;
069        private String retirementCityName;
070        private String retirementStateCode;
071        private String retirementZipCode;
072        private String retirementCountryCode;
073        private String retirementPhoneNumber;
074        private KualiDecimal estimatedSellingPrice;
075        private KualiDecimal salePrice;
076        private String cashReceiptFinancialDocumentNumber;
077        private KualiDecimal handlingFeeAmount;
078        private KualiDecimal preventiveMaintenanceAmount;
079        private String buyerDescription;
080        private String paidCaseNumber;
081        // persistent relationship
082        private Date retirementDate;
083        private Asset mergedTargetCapitalAsset;
084        private AssetRetirementReason retirementReason;
085        private FinancialSystemDocumentHeader documentHeader;
086        private List<AssetRetirementGlobalDetail> assetRetirementGlobalDetails;
087        private Account retirementAccount;
088        private Chart retirementChartOfAccounts;
089        private DocumentHeader cashReceiptFinancialDocument;
090        private State retirementState;
091        private Country retirementCountry;
092        private PostalCode postalZipCode;
093    
094        private List<GeneralLedgerPendingEntry> generalLedgerPendingEntries;
095    
096        // Non-persistent
097        private KualiDecimal calculatedTotal;
098    
099        /**
100         * Default constructor.
101         */
102        public AssetRetirementGlobal() {
103            this.assetRetirementGlobalDetails = new TypedArrayList(AssetRetirementGlobalDetail.class);
104            this.generalLedgerPendingEntries = new TypedArrayList(GeneralLedgerPendingEntry.class);
105        }
106    
107    
108        public List<PersistableBusinessObject> generateDeactivationsToPersist() {
109            return null;
110        }
111    
112        /**
113         * @see org.kuali.rice.kns.bo.GlobalBusinessObject#generateGlobalChangesToPersist()
114         */
115        public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
116            AssetRetirementService retirementService = SpringContext.getBean(AssetRetirementService.class);
117    
118            List<PersistableBusinessObject> persistables = new ArrayList<PersistableBusinessObject>();
119    
120            if (retirementService.isAssetRetiredByMerged(this) && mergedTargetCapitalAsset != null) {
121                setMergeObjectsForPersist(persistables, retirementService);
122            }
123    
124            for (AssetRetirementGlobalDetail detail : assetRetirementGlobalDetails) {
125                setAssetForPersist(detail.getAsset(), persistables, retirementService);
126            }
127    
128            return persistables;
129        }
130    
131        @Override
132        public List buildListOfDeletionAwareLists() {
133            List<List> managedList = super.buildListOfDeletionAwareLists();
134    
135            managedList.add(getAssetRetirementGlobalDetails());
136    
137            return managedList;
138        }
139    
140        /**
141         * This method set asset fields for update
142         * 
143         * @param detail
144         * @param persistables
145         */
146        private void setAssetForPersist(Asset asset, List<PersistableBusinessObject> persistables, AssetRetirementService retirementService) {
147            UniversityDateService universityDateService = SpringContext.getBean(UniversityDateService.class);
148    
149            // load the object by key
150            asset.setInventoryStatusCode(CamsConstants.InventoryStatusCode.CAPITAL_ASSET_RETIRED);
151            asset.setRetirementReasonCode(retirementReasonCode);
152    
153            // set retirement fiscal year and period code into asset
154            UniversityDate currentUniversityDate = universityDateService.getCurrentUniversityDate();
155            if (ObjectUtils.isNotNull(currentUniversityDate)) {
156                asset.setRetirementFiscalYear(universityDateService.getCurrentUniversityDate().getUniversityFiscalYear());
157                asset.setRetirementPeriodCode(universityDateService.getCurrentUniversityDate().getUniversityFiscalAccountingPeriod());
158            }
159    
160    
161            if (retirementService.isAssetRetiredByTheft(this) && StringUtils.isNotBlank(this.getPaidCaseNumber())) {
162                asset.setCampusPoliceDepartmentCaseNumber(this.getPaidCaseNumber());
163            }
164            else if (retirementService.isAssetRetiredBySold(this) || retirementService.isAssetRetiredByAuction(this)) {
165                asset.setRetirementChartOfAccountsCode(this.getRetirementChartOfAccountsCode());
166                asset.setRetirementAccountNumber(this.getRetirementAccountNumber());
167                asset.setCashReceiptFinancialDocumentNumber(this.getCashReceiptFinancialDocumentNumber());
168                asset.setSalePrice(this.getSalePrice());
169                asset.setEstimatedSellingPrice(this.getEstimatedSellingPrice());
170            }
171            else if (retirementService.isAssetRetiredByMerged(this)) {
172                asset.setTotalCostAmount(KualiDecimal.ZERO);
173                asset.setSalvageAmount(KualiDecimal.ZERO);
174            }
175            else if (retirementService.isAssetRetiredByExternalTransferOrGift(this)) {
176                persistables.add(setOffCampusLocationObjectsForPersist(asset));
177            }
178            asset.setLastInventoryDate(new Timestamp(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate().getTime()));
179            persistables.add(asset);
180        }
181    
182        /**
183         * This method set off campus location for persist
184         * 
185         * @param AssetGlobalDetail and Asset to populate AssetLocation
186         * @return Returns the AssetLocation.
187         */
188        private AssetLocation setOffCampusLocationObjectsForPersist(Asset asset) {
189            AssetLocation offCampusLocation = new AssetLocation();
190            offCampusLocation.setCapitalAssetNumber(asset.getCapitalAssetNumber());
191            offCampusLocation.setAssetLocationTypeCode(CamsConstants.AssetLocationTypeCode.RETIREMENT);
192            offCampusLocation = (AssetLocation) SpringContext.getBean(BusinessObjectService.class).retrieve(offCampusLocation);
193            if (offCampusLocation == null) {
194                offCampusLocation = new AssetLocation();
195                offCampusLocation.setCapitalAssetNumber(asset.getCapitalAssetNumber());
196                offCampusLocation.setAssetLocationTypeCode(CamsConstants.AssetLocationTypeCode.RETIREMENT);
197                asset.getAssetLocations().add(offCampusLocation);
198            }
199    
200            offCampusLocation.setAssetLocationContactName(this.getRetirementContactName());
201            offCampusLocation.setAssetLocationInstitutionName(this.getRetirementInstitutionName());
202            offCampusLocation.setAssetLocationPhoneNumber(this.getRetirementPhoneNumber());
203            offCampusLocation.setAssetLocationStreetAddress(this.getRetirementStreetAddress());
204            offCampusLocation.setAssetLocationCityName(this.getRetirementCityName());
205            offCampusLocation.setAssetLocationStateCode(this.getRetirementStateCode());
206            offCampusLocation.setAssetLocationCountryCode(this.getRetirementCountryCode());
207            offCampusLocation.setAssetLocationZipCode(this.getRetirementZipCode());
208    
209            return offCampusLocation;
210        }
211    
212        /**
213         * This method set target payment and source payment; set target/source asset salvageAmount/totalCostAmount
214         * 
215         * @param persistables
216         */
217        private void setMergeObjectsForPersist(List<PersistableBusinessObject> persistables, AssetRetirementService retirementService) {
218            PaymentSummaryService paymentSummaryService = SpringContext.getBean(PaymentSummaryService.class);
219            AssetPaymentService assetPaymentService = SpringContext.getBean(AssetPaymentService.class);
220    
221            Integer maxTargetSequenceNo = assetPaymentService.getMaxSequenceNumber(mergedTargetCapitalAssetNumber);
222    
223            KualiDecimal salvageAmount = KualiDecimal.ZERO;
224            KualiDecimal totalCostAmount = KualiDecimal.ZERO;
225            Asset sourceAsset;
226    
227            // update for each merge source asset
228            for (AssetRetirementGlobalDetail detail : getAssetRetirementGlobalDetails()) {
229                detail.refreshReferenceObject(CamsPropertyConstants.AssetRetirementGlobalDetail.ASSET);
230                sourceAsset = detail.getAsset();
231    
232                totalCostAmount = totalCostAmount.add(paymentSummaryService.calculatePaymentTotalCost(sourceAsset));
233                salvageAmount = salvageAmount.add(sourceAsset.getSalvageAmount());
234    
235                retirementService.generateOffsetPaymentsForEachSource(sourceAsset, persistables, detail.getDocumentNumber());
236                maxTargetSequenceNo = retirementService.generateNewPaymentForTarget(mergedTargetCapitalAsset, sourceAsset, persistables, maxTargetSequenceNo, detail.getDocumentNumber());
237    
238            }
239            KualiDecimal mergedTargetSalvageAmount = (mergedTargetCapitalAsset.getSalvageAmount() != null ? mergedTargetCapitalAsset.getSalvageAmount() : KualiDecimal.ZERO);
240    
241            // update merget target asset
242            mergedTargetCapitalAsset.setTotalCostAmount(totalCostAmount.add(paymentSummaryService.calculatePaymentTotalCost(mergedTargetCapitalAsset)));
243            mergedTargetCapitalAsset.setSalvageAmount(salvageAmount.add(mergedTargetSalvageAmount));
244            mergedTargetCapitalAsset.setLastInventoryDate(new Timestamp(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate().getTime()));
245            mergedTargetCapitalAsset.setCapitalAssetDescription(this.getMergedTargetCapitalAssetDescription());
246            persistables.add(mergedTargetCapitalAsset);
247        }
248    
249    
250        public List<? extends GlobalBusinessObjectDetail> getAllDetailObjects() {
251            return getAssetRetirementGlobalDetails();
252        }
253    
254        public boolean isPersistable() {
255            return true;
256        }
257    
258        /**
259         * Gets the documentNumber attribute.
260         * 
261         * @return Returns the documentNumber
262         */
263        public String getDocumentNumber() {
264            return documentNumber;
265        }
266    
267        /**
268         * Sets the documentNumber attribute.
269         * 
270         * @param documentNumber The documentNumber to set.
271         */
272        public void setDocumentNumber(String documentNumber) {
273            this.documentNumber = documentNumber;
274        }
275    
276    
277        /**
278         * Gets the mergedTargetCapitalAssetNumber attribute.
279         * 
280         * @return Returns the mergedTargetCapitalAssetNumber
281         */
282        public Long getMergedTargetCapitalAssetNumber() {
283            return mergedTargetCapitalAssetNumber;
284        }
285    
286        /**
287         * Sets the mergedTargetCapitalAssetNumber attribute.
288         * 
289         * @param mergedTargetCapitalAssetNumber The mergedTargetCapitalAssetNumber to set.
290         */
291        public void setMergedTargetCapitalAssetNumber(Long mergedTargetCapitalAssetNumber) {
292            this.mergedTargetCapitalAssetNumber = mergedTargetCapitalAssetNumber;
293        }
294    
295    
296        /**
297         * Gets the retirementReasonCode attribute.
298         * 
299         * @return Returns the retirementReasonCode
300         */
301        public String getRetirementReasonCode() {
302            return retirementReasonCode;
303        }
304    
305        /**
306         * Sets the retirementReasonCode attribute.
307         * 
308         * @param retirementReasonCode The retirementReasonCode to set.
309         */
310        public void setRetirementReasonCode(String retirementReasonCode) {
311            this.retirementReasonCode = retirementReasonCode;
312        }
313    
314    
315        /**
316         * Gets the retirementDate attribute.
317         * 
318         * @return Returns the retirementDate
319         */
320        public Date getRetirementDate() {
321            return retirementDate;
322        }
323    
324        /**
325         * Sets the retirementDate attribute.
326         * 
327         * @param retirementDate The retirementDate to set.
328         */
329        public void setRetirementDate(Date remeretirementDatentDate) {
330            this.retirementDate = remeretirementDatentDate;
331        }
332    
333        /**
334         * Gets the mergedTargetCapitalAsset attribute.
335         * 
336         * @return Returns the mergedTargetCapitalAsset.
337         */
338        public Asset getMergedTargetCapitalAsset() {
339            return mergedTargetCapitalAsset;
340        }
341    
342        /**
343         * Sets the mergedTargetCapitalAsset attribute value.
344         * 
345         * @param mergedTargetCapitalAsset The mergedTargetCapitalAsset to set.
346         * @deprecated
347         */
348        public void setMergedTargetCapitalAsset(Asset mergedTargetCapitalAsset) {
349            this.mergedTargetCapitalAsset = mergedTargetCapitalAsset;
350        }
351    
352        /**
353         * Gets the retirementReason attribute.
354         * 
355         * @return Returns the retirementReason.
356         */
357        public AssetRetirementReason getRetirementReason() {
358            return retirementReason;
359        }
360    
361        /**
362         * Sets the retirementReason attribute value.
363         * 
364         * @param retirementReason The retirementReason to set.
365         * @deprecated
366         */
367        public void setRetirementReason(AssetRetirementReason retirementReason) {
368            this.retirementReason = retirementReason;
369        }
370    
371    
372        public FinancialSystemDocumentHeader getDocumentHeader() {
373            return documentHeader;
374        }
375    
376        public void setDocumentHeader(FinancialSystemDocumentHeader documentHeader) {
377            this.documentHeader = documentHeader;
378        }
379    
380        public List<AssetRetirementGlobalDetail> getAssetRetirementGlobalDetails() {
381            return assetRetirementGlobalDetails;
382        }
383    
384        public void setAssetRetirementGlobalDetails(List<AssetRetirementGlobalDetail> assetRetirementGlobalDetails) {
385            this.assetRetirementGlobalDetails = assetRetirementGlobalDetails;
386        }
387    
388    
389        public List<GeneralLedgerPendingEntry> getGeneralLedgerPendingEntries() {
390            return generalLedgerPendingEntries;
391        }
392    
393    
394        public void setGeneralLedgerPendingEntries(List<GeneralLedgerPendingEntry> glPendingEntries) {
395            this.generalLedgerPendingEntries = glPendingEntries;
396        }
397    
398    
399        /**
400         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
401         */
402        protected LinkedHashMap toStringMapper() {
403            LinkedHashMap m = new LinkedHashMap();
404            m.put("documentNumber", this.documentNumber);
405            return m;
406        }
407    
408    
409        public String getMergedTargetCapitalAssetDescription() {
410            return mergedTargetCapitalAssetDescription;
411        }
412    
413    
414        public void setMergedTargetCapitalAssetDescription(String mergedTargetCapitalAssetDescription) {
415            this.mergedTargetCapitalAssetDescription = mergedTargetCapitalAssetDescription;
416        }
417    
418        /**
419         * Gets the retirementChartOfAccountsCode attribute.
420         * 
421         * @return Returns the retirementChartOfAccountsCode
422         */
423        public String getRetirementChartOfAccountsCode() {
424            return retirementChartOfAccountsCode;
425        }
426    
427        /**
428         * Sets the retirementChartOfAccountsCode attribute.
429         * 
430         * @param retirementChartOfAccountsCode The retirementChartOfAccountsCode to set.
431         */
432        public void setRetirementChartOfAccountsCode(String retirementChartOfAccountsCode) {
433            this.retirementChartOfAccountsCode = retirementChartOfAccountsCode;
434        }
435    
436    
437        /**
438         * Gets the retirementAccountNumber attribute.
439         * 
440         * @return Returns the retirementAccountNumber
441         */
442        public String getRetirementAccountNumber() {
443            return retirementAccountNumber;
444        }
445    
446        /**
447         * Sets the retirementAccountNumber attribute.
448         * 
449         * @param retirementAccountNumber The retirementAccountNumber to set.
450         */
451        public void setRetirementAccountNumber(String retirementAccountNumber) {
452            this.retirementAccountNumber = retirementAccountNumber;
453        }
454    
455    
456        /**
457         * Gets the retirementContactName attribute.
458         * 
459         * @return Returns the retirementContactName
460         */
461        public String getRetirementContactName() {
462            return retirementContactName;
463        }
464    
465        /**
466         * Sets the retirementContactName attribute.
467         * 
468         * @param retirementContactName The retirementContactName to set.
469         */
470        public void setRetirementContactName(String retirementContactName) {
471            this.retirementContactName = retirementContactName;
472        }
473    
474    
475        /**
476         * Gets the retirementInstitutionName attribute.
477         * 
478         * @return Returns the retirementInstitutionName
479         */
480        public String getRetirementInstitutionName() {
481            return retirementInstitutionName;
482        }
483    
484        /**
485         * Sets the retirementInstitutionName attribute.
486         * 
487         * @param retirementInstitutionName The retirementInstitutionName to set.
488         */
489        public void setRetirementInstitutionName(String retirementInstitutionName) {
490            this.retirementInstitutionName = retirementInstitutionName;
491        }
492    
493    
494        /**
495         * Gets the retirementStreetAddress attribute.
496         * 
497         * @return Returns the retirementStreetAddress
498         */
499        public String getRetirementStreetAddress() {
500            return retirementStreetAddress;
501        }
502    
503        /**
504         * Sets the retirementStreetAddress attribute.
505         * 
506         * @param retirementStreetAddress The retirementStreetAddress to set.
507         */
508        public void setRetirementStreetAddress(String retirementStreetAddress) {
509            this.retirementStreetAddress = retirementStreetAddress;
510        }
511    
512    
513        /**
514         * Gets the retirementCityName attribute.
515         * 
516         * @return Returns the retirementCityName
517         */
518        public String getRetirementCityName() {
519            return retirementCityName;
520        }
521    
522        /**
523         * Sets the retirementCityName attribute.
524         * 
525         * @param retirementCityName The retirementCityName to set.
526         */
527        public void setRetirementCityName(String retirementCityName) {
528            this.retirementCityName = retirementCityName;
529        }
530    
531    
532        /**
533         * Gets the retirementStateCode attribute.
534         * 
535         * @return Returns the retirementStateCode
536         */
537        public String getRetirementStateCode() {
538            return retirementStateCode;
539        }
540    
541        /**
542         * Sets the retirementStateCode attribute.
543         * 
544         * @param retirementStateCode The retirementStateCode to set.
545         */
546        public void setRetirementStateCode(String retirementStateCode) {
547            this.retirementStateCode = retirementStateCode;
548        }
549    
550    
551        /**
552         * Gets the retirementZipCode attribute.
553         * 
554         * @return Returns the retirementZipCode
555         */
556        public String getRetirementZipCode() {
557            return retirementZipCode;
558        }
559    
560        /**
561         * Sets the retirementZipCode attribute.
562         * 
563         * @param retirementZipCode The retirementZipCode to set.
564         */
565        public void setRetirementZipCode(String retirementZipCode) {
566            this.retirementZipCode = retirementZipCode;
567        }
568    
569    
570        /**
571         * Gets the postalZipCode attribute.
572         * 
573         * @return Returns the postalZipCode
574         */
575        public PostalCode getPostalZipCode() {
576            postalZipCode = SpringContext.getBean(PostalCodeService.class).getByPrimaryIdIfNecessary(retirementCountryCode, retirementZipCode, postalZipCode);
577            return postalZipCode;
578        }
579    
580        /**
581         * Sets the postalZipCode attribute.
582         * 
583         * @param postalZipCode The postalZipCode to set.
584         */
585        public void setPostalZipCode(PostalCode postalZipCode) {
586            this.postalZipCode = postalZipCode;
587        }
588    
589        /**
590         * Gets the retirementCountryCode attribute.
591         * 
592         * @return Returns the retirementCountryCode
593         */
594        public String getRetirementCountryCode() {
595            return retirementCountryCode;
596        }
597    
598        /**
599         * Sets the retirementCountryCode attribute.
600         * 
601         * @param retirementCountryCode The retirementCountryCode to set.
602         */
603        public void setRetirementCountryCode(String retirementCountryCode) {
604            this.retirementCountryCode = retirementCountryCode;
605        }
606    
607    
608        /**
609         * Gets the retirementPhoneNumber attribute.
610         * 
611         * @return Returns the retirementPhoneNumber
612         */
613        public String getRetirementPhoneNumber() {
614            return retirementPhoneNumber;
615        }
616    
617        /**
618         * Sets the retirementPhoneNumber attribute.
619         * 
620         * @param retirementPhoneNumber The retirementPhoneNumber to set.
621         */
622        public void setRetirementPhoneNumber(String retirementPhoneNumber) {
623            this.retirementPhoneNumber = retirementPhoneNumber;
624        }
625    
626    
627        /**
628         * Gets the estimatedSellingPrice attribute.
629         * 
630         * @return Returns the estimatedSellingPrice
631         */
632        public KualiDecimal getEstimatedSellingPrice() {
633            return estimatedSellingPrice;
634        }
635    
636        /**
637         * Sets the estimatedSellingPrice attribute.
638         * 
639         * @param estimatedSellingPrice The estimatedSellingPrice to set.
640         */
641        public void setEstimatedSellingPrice(KualiDecimal estimatedSellingPrice) {
642            this.estimatedSellingPrice = estimatedSellingPrice;
643        }
644    
645    
646        /**
647         * Gets the salePrice attribute.
648         * 
649         * @return Returns the salePrice
650         */
651        public KualiDecimal getSalePrice() {
652            return salePrice;
653        }
654    
655        /**
656         * Sets the salePrice attribute.
657         * 
658         * @param salePrice The salePrice to set.
659         */
660        public void setSalePrice(KualiDecimal salePrice) {
661            this.salePrice = salePrice;
662        }
663    
664    
665        /**
666         * Gets the cashReceiptFinancialDocumentNumber attribute.
667         * 
668         * @return Returns the cashReceiptFinancialDocumentNumber
669         */
670        public String getCashReceiptFinancialDocumentNumber() {
671            return cashReceiptFinancialDocumentNumber;
672        }
673    
674        /**
675         * Sets the cashReceiptFinancialDocumentNumber attribute.
676         * 
677         * @param cashReceiptFinancialDocumentNumber The cashReceiptFinancialDocumentNumber to set.
678         */
679        public void setCashReceiptFinancialDocumentNumber(String cashReceiptFinancialDocumentNumber) {
680            this.cashReceiptFinancialDocumentNumber = cashReceiptFinancialDocumentNumber;
681        }
682    
683    
684        /**
685         * Gets the handlingFeeAmount attribute.
686         * 
687         * @return Returns the handlingFeeAmount
688         */
689        public KualiDecimal getHandlingFeeAmount() {
690            return handlingFeeAmount;
691        }
692    
693        /**
694         * Sets the handlingFeeAmount attribute.
695         * 
696         * @param handlingFeeAmount The handlingFeeAmount to set.
697         */
698        public void setHandlingFeeAmount(KualiDecimal handlingFeeAmount) {
699            this.handlingFeeAmount = handlingFeeAmount;
700        }
701    
702    
703        /**
704         * Gets the preventiveMaintenanceAmount attribute.
705         * 
706         * @return Returns the preventiveMaintenanceAmount
707         */
708        public KualiDecimal getPreventiveMaintenanceAmount() {
709            return preventiveMaintenanceAmount;
710        }
711    
712        /**
713         * Sets the preventiveMaintenanceAmount attribute.
714         * 
715         * @param preventiveMaintenanceAmount The preventiveMaintenanceAmount to set.
716         */
717        public void setPreventiveMaintenanceAmount(KualiDecimal preventiveMaintenanceAmount) {
718            this.preventiveMaintenanceAmount = preventiveMaintenanceAmount;
719        }
720    
721    
722        /**
723         * Gets the buyerDescription attribute.
724         * 
725         * @return Returns the buyerDescription
726         */
727        public String getBuyerDescription() {
728            return buyerDescription;
729        }
730    
731        /**
732         * Sets the buyerDescription attribute.
733         * 
734         * @param buyerDescription The buyerDescription to set.
735         */
736        public void setBuyerDescription(String buyerDescription) {
737            this.buyerDescription = buyerDescription;
738        }
739    
740    
741        /**
742         * Gets the paidCaseNumber attribute.
743         * 
744         * @return Returns the paidCaseNumber
745         */
746        public String getPaidCaseNumber() {
747            return paidCaseNumber;
748        }
749    
750        /**
751         * Sets the paidCaseNumber attribute.
752         * 
753         * @param paidCaseNumber The paidCaseNumber to set.
754         */
755        public void setPaidCaseNumber(String paidCaseNumber) {
756            this.paidCaseNumber = paidCaseNumber;
757        }
758    
759        /**
760         * Gets the retirementChartOfAccounts attribute.
761         * 
762         * @return Returns the retirementChartOfAccounts
763         */
764        public Chart getRetirementChartOfAccounts() {
765            return retirementChartOfAccounts;
766        }
767    
768        /**
769         * Sets the retirementChartOfAccounts attribute.
770         * 
771         * @param retirementChartOfAccounts The retirementChartOfAccounts to set.
772         * @deprecated
773         */
774        public void setRetirementChartOfAccounts(Chart retirementChartOfAccounts) {
775            this.retirementChartOfAccounts = retirementChartOfAccounts;
776        }
777    
778        /**
779         * Gets the retirementAccount attribute.
780         * 
781         * @return Returns the retirementAccount
782         */
783        public Account getRetirementAccount() {
784            return retirementAccount;
785        }
786    
787        /**
788         * Sets the retirementAccount attribute.
789         * 
790         * @param retirementAccount The retirementAccount to set.
791         * @deprecated
792         */
793        public void setRetirementAccount(Account retirementAccount) {
794            this.retirementAccount = retirementAccount;
795        }
796    
797    
798        /**
799         * Gets the cashReceiptFinancialDocument attribute.
800         * 
801         * @return Returns the cashReceiptFinancialDocument.
802         */
803        public DocumentHeader getCashReceiptFinancialDocument() {
804            return cashReceiptFinancialDocument;
805        }
806    
807        /**
808         * Sets the cashReceiptFinancialDocument attribute value.
809         * 
810         * @param cashReceiptFinancialDocument The cashReceiptFinancialDocument to set.
811         * @deprecated
812         */
813        public void setCashReceiptFinancialDocument(DocumentHeader cashReceiptFinancialDocument) {
814            this.cashReceiptFinancialDocument = cashReceiptFinancialDocument;
815        }
816    
817    
818        /**
819         * Gets the retirementCountry attribute.
820         * 
821         * @return Returns the retirementCountry.
822         */
823        public Country getRetirementCountry() {
824            retirementCountry = SpringContext.getBean(CountryService.class).getByPrimaryIdIfNecessary(retirementCountryCode, retirementCountry);
825            return retirementCountry;
826        }
827    
828        /**
829         * Sets the retirementCountry attribute value.
830         * 
831         * @param retirementCountry The retirementCountry to set.
832         * @deprecated
833         */
834        public void setRetirementCountry(Country retirementCountry) {
835            this.retirementCountry = retirementCountry;
836        }
837    
838        /**
839         * Gets the retirementState attribute.
840         * 
841         * @return Returns the retirementState.
842         */
843        public State getRetirementState() {
844            retirementState = SpringContext.getBean(StateService.class).getByPrimaryIdIfNecessary(retirementCountryCode, retirementStateCode, retirementState);
845            return retirementState;
846        }
847    
848        /**
849         * Sets the retirementState attribute value.
850         * 
851         * @param retirementState The retirementState to set.
852         * @deprecated
853         */
854        public void setRetirementState(State retirementState) {
855            this.retirementState = retirementState;
856        }
857    
858    
859        /**
860         * Gets the calculatedTotal attribute.
861         * 
862         * @return Returns the calculatedTotal.
863         */
864        public KualiDecimal getCalculatedTotal() {
865            this.calculatedTotal = KualiDecimal.ZERO;
866            if (this.handlingFeeAmount != null) {
867                this.calculatedTotal = calculatedTotal.add(this.handlingFeeAmount);
868            }
869            if (this.preventiveMaintenanceAmount != null) {
870                this.calculatedTotal = calculatedTotal.add(this.preventiveMaintenanceAmount);
871            }
872            if (this.salePrice != null) {
873                this.calculatedTotal = calculatedTotal.add(this.salePrice);
874            }
875            return calculatedTotal;
876        }
877    }