View Javadoc
1   package org.kuali.ole.module.purap.document;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.ole.coa.businessobject.Account;
5   import org.kuali.ole.coa.businessobject.Chart;
6   import org.kuali.ole.coa.businessobject.Organization;
7   import org.kuali.ole.integration.purap.CapitalAssetLocation;
8   import org.kuali.ole.integration.purap.CapitalAssetSystem;
9   import org.kuali.ole.integration.purap.ItemCapitalAsset;
10  import org.kuali.ole.module.purap.PurapConstants;
11  import org.kuali.ole.module.purap.PurapParameterConstants;
12  import org.kuali.ole.module.purap.PurapPropertyConstants;
13  import org.kuali.ole.module.purap.businessobject.*;
14  import org.kuali.ole.module.purap.document.service.PurapService;
15  import org.kuali.ole.module.purap.document.service.PurchasingDocumentSpecificService;
16  import org.kuali.ole.module.purap.document.service.PurchasingService;
17  import org.kuali.ole.module.purap.document.service.ReceivingAddressService;
18  import org.kuali.ole.module.purap.util.ItemParser;
19  import org.kuali.ole.module.purap.util.ItemParserBase;
20  import org.kuali.ole.sys.context.SpringContext;
21  import org.kuali.ole.sys.service.impl.OleParameterConstants;
22  import org.kuali.ole.vnd.VendorPropertyConstants;
23  import org.kuali.ole.vnd.businessobject.*;
24  import org.kuali.ole.vnd.document.service.VendorService;
25  import org.kuali.rice.core.api.datetime.DateTimeService;
26  import org.kuali.rice.core.api.util.type.KualiDecimal;
27  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
28  import org.kuali.rice.krad.rules.rule.event.ApproveDocumentEvent;
29  import org.kuali.rice.krad.rules.rule.event.DocumentEvent;
30  import org.kuali.rice.krad.rules.rule.event.RouteDocumentEvent;
31  import org.kuali.rice.krad.util.GlobalVariables;
32  import org.kuali.rice.krad.util.ObjectUtils;
33  import org.kuali.rice.location.api.country.Country;
34  import org.kuali.rice.location.api.country.CountryService;
35  
36  import java.sql.Date;
37  import java.util.ArrayList;
38  import java.util.Iterator;
39  import java.util.List;
40  
41  /**
42   * Created by premkumarv on 10/9/14.
43   */
44  public abstract class OlePurchasingDocumentBase extends OlePurchasingAccountsPayableDocumentBase implements OlePurchasingDocument {
45      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePurchasingDocumentBase.class);
46  
47      // SHARED FIELDS BETWEEN REQUISITION AND PURCHASE ORDER
48      protected String documentFundingSourceCode;
49      protected String requisitionSourceCode;
50      protected String purchaseOrderTransmissionMethodCode;
51      protected String purchaseOrderCostSourceCode;
52      protected String deliveryRequiredDateReasonCode;
53      protected String recurringPaymentTypeCode;
54      protected String chartOfAccountsCode;
55      protected String organizationCode;
56      protected String deliveryCampusCode;
57      protected KualiDecimal purchaseOrderTotalLimit;
58      protected Boolean vendorRestrictedIndicator;
59      protected String vendorPhoneNumber;
60      protected String vendorFaxNumber;
61      protected Integer vendorContractGeneratedIdentifier;
62      protected String vendorNoteText;
63      protected String requestorPersonName;
64      protected String requestorPersonEmailAddress;
65      protected String requestorPersonPhoneNumber;
66      protected String nonInstitutionFundOrgChartOfAccountsCode;
67      protected String nonInstitutionFundOrganizationCode;
68      protected String nonInstitutionFundChartOfAccountsCode;
69      protected String nonInstitutionFundAccountNumber;
70      protected boolean deliveryBuildingOtherIndicator;
71      protected String deliveryBuildingCode;
72      protected String deliveryBuildingName;
73      protected String deliveryBuildingRoomNumber;
74      protected String deliveryBuildingLine1Address;
75      protected String deliveryBuildingLine2Address;
76      protected String deliveryCityName;
77      protected String deliveryStateCode;
78      protected String deliveryPostalCode;
79      protected String deliveryCountryCode;
80      protected String deliveryToName;
81      protected String deliveryToEmailAddress;
82      protected String deliveryToPhoneNumber;
83      protected Date deliveryRequiredDate;
84      protected String deliveryInstructionText;
85      protected Date purchaseOrderBeginDate;
86      protected Date purchaseOrderEndDate;
87      protected String institutionContactName;
88      protected String institutionContactPhoneNumber;
89      protected String institutionContactEmailAddress;
90      protected String billingName;
91      protected String billingLine1Address;
92      protected String billingLine2Address;
93      protected String billingCityName;
94      protected String billingStateCode;
95      protected String billingPostalCode;
96      protected String billingCountryCode;
97      protected String billingPhoneNumber;
98      protected String billingEmailAddress;
99      protected String receivingName;
100     protected String receivingLine1Address;
101     protected String receivingLine2Address;
102     protected String receivingCityName;
103     protected String receivingStateCode;
104     protected String receivingPostalCode;
105     protected String receivingCountryCode;
106     protected boolean addressToVendorIndicator; // if true, use receiving address
107     protected String externalOrganizationB2bSupplierIdentifier;
108     protected boolean purchaseOrderAutomaticIndicator;
109     protected String vendorPaymentTermsCode;
110     protected String vendorShippingTitleCode;
111     protected String vendorShippingPaymentTermsCode;
112     protected String capitalAssetSystemTypeCode;
113     protected String capitalAssetSystemStateCode;
114     protected String justification;
115 
116     // NOT PERSISTED IN DB
117     protected String supplierDiversityLabel;
118     protected String vendorContactsLabel;
119 
120     // REFERENCE OBJECTS
121     protected FundingSource fundingSource;
122     protected RequisitionSource requisitionSource;
123     protected PurchaseOrderTransmissionMethod purchaseOrderTransmissionMethod;
124     protected PurchaseOrderCostSource purchaseOrderCostSource;
125     protected DeliveryRequiredDateReason deliveryRequiredDateReason;
126     protected RecurringPaymentType recurringPaymentType;
127     protected Organization organization;
128     protected Chart chartOfAccounts;
129     protected CampusParameter deliveryCampus;
130     protected Chart nonInstitutionFundOrgChartOfAccounts;
131     protected Organization nonInstitutionFundOrganization;
132     protected Account nonInstitutionFundAccount;
133     protected Chart nonInstitutionFundChartOfAccounts;
134     protected VendorContract vendorContract;
135     protected CapitalAssetSystemType capitalAssetSystemType;
136     protected CapitalAssetSystemState capitalAssetSystemState;
137     protected List<CapitalAssetSystem> purchasingCapitalAssetSystems;
138     protected List<PurchasingCapitalAssetItem> purchasingCapitalAssetItems;
139 
140     protected boolean receivingDocumentRequiredIndicator;
141     protected boolean paymentRequestPositiveApprovalIndicator;
142 
143     protected List<CommodityCode> commodityCodesForRouting;
144 
145     /**
146      * Default Constructor.
147      */
148     public OlePurchasingDocumentBase() {
149         super();
150 
151         purchasingCapitalAssetItems = new ArrayList();
152         purchasingCapitalAssetSystems = new ArrayList();
153     }
154 
155     @Override
156     public abstract PurchasingDocumentSpecificService getDocumentSpecificService();
157 
158     /**
159      * @see org.kuali.ole.module.purap.document.PurchasingDocument#templateVendorDetail(org.kuali.ole.vnd.businessobject.VendorDetail)
160      */
161     @Override
162     public void templateVendorDetail(VendorDetail vendorDetail) {
163         if (ObjectUtils.isNotNull(vendorDetail)) {
164             this.setVendorDetail(vendorDetail);
165             this.setVendorName(vendorDetail.getVendorName());
166             this.setVendorShippingTitleCode(vendorDetail.getVendorShippingTitleCode());
167             this.setVendorPaymentTermsCode(vendorDetail.getVendorPaymentTermsCode());
168             this.setVendorShippingPaymentTermsCode(vendorDetail.getVendorShippingPaymentTermsCode());
169             this.setVendorCustomerNumber("");
170         }
171     }
172 
173     /**
174      * @see org.kuali.ole.module.purap.document.PurchasingDocument#templateVendorContract(org.kuali.ole.vnd.businessobject.VendorContract)
175      */
176     @Override
177     public void templateVendorContract(VendorContract vendorContract) {
178         if (ObjectUtils.isNotNull(vendorContract)) {
179             this.setVendorContract(vendorContract);
180             this.setVendorContractGeneratedIdentifier(vendorContract.getVendorContractGeneratedIdentifier());
181             this.setVendorShippingTitleCode(vendorContract.getVendorShippingTitleCode());
182             this.setVendorPaymentTermsCode(vendorContract.getVendorPaymentTermsCode());
183             this.setVendorShippingPaymentTermsCode(vendorContract.getVendorShippingPaymentTermsCode());
184             this.setPurchaseOrderCostSourceCode(vendorContract.getPurchaseOrderCostSourceCode());
185         }
186     }
187 
188     /**
189      * @see org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase#templateVendorAddress(org.kuali.ole.vnd.businessobject.VendorAddress)
190      */
191     @Override
192     public void templateVendorAddress(VendorAddress vendorAddress) {
193         super.templateVendorAddress(vendorAddress);
194         if (vendorAddress != null) {
195             this.setVendorFaxNumber(vendorAddress.getVendorFaxNumber());
196             this.setVendorAttentionName(vendorAddress.getVendorAttentionName());
197         }
198     }
199 
200     /**
201      * @see org.kuali.ole.module.purap.document.PurchasingDocumentBase#templateBillingAddress(org.kuali.ole.module.purap.businessobject.BillingAddress).
202      */
203     @Override
204     public void templateBillingAddress(BillingAddress billingAddress) {
205         if (ObjectUtils.isNotNull(billingAddress)) {
206             this.setBillingName(billingAddress.getBillingName());
207             this.setBillingLine1Address(billingAddress.getBillingLine1Address());
208             this.setBillingLine2Address(billingAddress.getBillingLine2Address());
209             this.setBillingCityName(billingAddress.getBillingCityName());
210             this.setBillingStateCode(billingAddress.getBillingStateCode());
211             this.setBillingPostalCode(billingAddress.getBillingPostalCode());
212             this.setBillingCountryCode(billingAddress.getBillingCountryCode());
213             this.setBillingPhoneNumber(billingAddress.getBillingPhoneNumber());
214             this.setBillingEmailAddress(billingAddress.getBillingEmailAddress());
215         }
216     }
217 
218     /**
219      * @see org.kuali.ole.module.purap.document.PurchasingDocumentBase#templateReceivingAddress(org.kuali.ole.module.purap.businessobject.ReceivingAddress).
220      */
221     @Override
222     public void templateReceivingAddress(ReceivingAddress receivingAddress) {
223         if (receivingAddress != null) {
224             this.setReceivingName(receivingAddress.getReceivingName());
225             this.setReceivingLine1Address(receivingAddress.getReceivingLine1Address());
226             this.setReceivingLine2Address(receivingAddress.getReceivingLine2Address());
227             this.setReceivingCityName(receivingAddress.getReceivingCityName());
228             this.setReceivingStateCode(receivingAddress.getReceivingStateCode());
229             this.setReceivingPostalCode(receivingAddress.getReceivingPostalCode());
230             this.setReceivingCountryCode(receivingAddress.getReceivingCountryCode());
231             this.setAddressToVendorIndicator(receivingAddress.isUseReceivingIndicator());
232         } else {
233             this.setReceivingName(null);
234             this.setReceivingLine1Address(null);
235             this.setReceivingLine2Address(null);
236             this.setReceivingCityName(null);
237             this.setReceivingStateCode(null);
238             this.setReceivingPostalCode(null);
239             this.setReceivingCountryCode(null);
240             this.setAddressToVendorIndicator(false);
241         }
242     }
243 
244     /**
245      * Loads the default receiving address from database corresponding to the chart/org of this document.
246      */
247     @Override
248     public void loadReceivingAddress() {
249         /*
250         Map criteria = new HashMap();
251         criteria.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, this.getChartOfAccountsCode());
252         criteria.put(OLEPropertyConstants.ORGANIZATION_CODE, this.getOrganizationCode());
253         criteria.put(PurapPropertyConstants.RCVNG_ADDR_DFLT_IND, true);
254         criteria.put(PurapPropertyConstants.RCVNG_ADDR_ACTIVE, true);
255         List<ReceivingAddress> addresses = (List)KRADServiceLocatorWeb.getLegacyDataAdapter().findMatching(ReceivingAddress.class, criteria);
256         if (addresses != null && addresses.size()>0 )
257             this.templateReceivingAddress(addresses.get(0));
258         else // if no address is found, fill with null
259             this.templateReceivingAddress(null);
260         */
261         String chartCode = getChartOfAccountsCode();
262         String orgCode = getOrganizationCode();
263         ReceivingAddress address = SpringContext.getBean(ReceivingAddressService.class).findUniqueDefaultByChartOrg(chartCode, orgCode);
264         // if default address for chart/org not found, look for chart default
265         if (address == null && orgCode != null) {
266             address = SpringContext.getBean(ReceivingAddressService.class).findUniqueDefaultByChartOrg(chartCode, null);
267         }
268         this.templateReceivingAddress(address);
269     }
270 
271     /**
272      * Iterates through the purchasingCapitalAssetItems of the document and returns the purchasingCapitalAssetItem with the item id equal to the number given, or null if a
273      * match is not found.
274      *
275      * @param itemIdentifier item id to match on.
276      * @return the PurchasingCapitalAssetItem if a match is found, else null.
277      */
278     public PurchasingCapitalAssetItem getPurchasingCapitalAssetItemByItemIdentifier(int itemIdentifier) {
279         for (Iterator iter = purchasingCapitalAssetItems.iterator(); iter.hasNext(); ) {
280             PurchasingCapitalAssetItem camsItem = (PurchasingCapitalAssetItem) iter.next();
281             if (camsItem.getItemIdentifier().intValue() == itemIdentifier) {
282                 return camsItem;
283             }
284         }
285         return null;
286     }
287 
288 
289     /**
290      * @see org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase#addItem(org.kuali.ole.module.purap.businessobject.PurApItem)
291      */
292     @Override
293     public void addItem(PurApItem item) {
294         item.refreshReferenceObject(PurapPropertyConstants.COMMODITY_CODE);
295         super.addItem(item);
296     }
297 
298     /**
299      * @see org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase#populateDocumentForRouting()
300      */
301     @Override
302     public void populateDocumentForRouting() {
303         commodityCodesForRouting = new ArrayList<CommodityCode>();
304         for (PurchasingItemBase item : (List<PurchasingItemBase>) this.getItems()) {
305             if (item.getCommodityCode() != null && !commodityCodesForRouting.contains(item.getCommodityCode())) {
306                 commodityCodesForRouting.add(item.getCommodityCode());
307             }
308         }
309         super.populateDocumentForRouting();
310     }
311 
312     @Override
313     public ItemParser getItemParser() {
314         return new ItemParserBase();
315     }
316 
317     /**
318      * Decides whether receivingDocumentRequiredIndicator functionality shall be enabled according to the controlling parameter.
319      */
320     public boolean isEnableReceivingDocumentRequiredIndicator() {
321         return SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.RECEIVING_DOCUMENT_REQUIRED_IND);
322     }
323 
324     /**
325      * Decides whether paymentRequestPositiveApprovalIndicator functionality shall be enabled according to the controlling parameter.
326      */
327     public boolean isEnablePaymentRequestPositiveApprovalIndicator() {
328         return SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.PAYMENT_REQUEST_POSITIVE_APPROVAL_IND);
329     }
330 
331     @Override
332     public String getBillingCityName() {
333         return billingCityName;
334     }
335 
336     @Override
337     public void setBillingCityName(String billingCityName) {
338         this.billingCityName = billingCityName;
339     }
340 
341     @Override
342     public String getBillingCountryCode() {
343         return billingCountryCode;
344     }
345 
346     @Override
347     public void setBillingCountryCode(String billingCountryCode) {
348         this.billingCountryCode = billingCountryCode;
349     }
350 
351     @Override
352     public String getBillingCountryName() {
353         if (StringUtils.isNotBlank(getBillingCountryCode())) {
354             Country country = SpringContext.getBean(CountryService.class).getCountry(getBillingCountryCode());
355             if (country != null) {
356                 return country.getName();
357             }
358         }
359         return null;
360     }
361 
362     @Override
363     public String getBillingLine1Address() {
364         return billingLine1Address;
365     }
366 
367     @Override
368     public void setBillingLine1Address(String billingLine1Address) {
369         this.billingLine1Address = billingLine1Address;
370     }
371 
372     @Override
373     public String getBillingLine2Address() {
374         return billingLine2Address;
375     }
376 
377     @Override
378     public void setBillingLine2Address(String billingLine2Address) {
379         this.billingLine2Address = billingLine2Address;
380     }
381 
382     @Override
383     public String getBillingName() {
384         return billingName;
385     }
386 
387     @Override
388     public void setBillingName(String billingName) {
389         this.billingName = billingName;
390     }
391 
392     @Override
393     public String getBillingPhoneNumber() {
394         return billingPhoneNumber;
395     }
396 
397     @Override
398     public void setBillingPhoneNumber(String billingPhoneNumber) {
399         this.billingPhoneNumber = billingPhoneNumber;
400     }
401 
402     public String getBillingEmailAddress() {
403         return billingEmailAddress;
404     }
405 
406     public void setBillingEmailAddress(String billingEmailAddress) {
407         this.billingEmailAddress = billingEmailAddress;
408     }
409 
410     @Override
411     public String getBillingPostalCode() {
412         return billingPostalCode;
413     }
414 
415     @Override
416     public void setBillingPostalCode(String billingPostalCode) {
417         this.billingPostalCode = billingPostalCode;
418     }
419 
420     @Override
421     public String getBillingStateCode() {
422         return billingStateCode;
423     }
424 
425     @Override
426     public void setBillingStateCode(String billingStateCode) {
427         this.billingStateCode = billingStateCode;
428     }
429 
430     @Override
431     public String getReceivingCityName() {
432         return receivingCityName;
433     }
434 
435     @Override
436     public void setReceivingCityName(String receivingCityName) {
437         this.receivingCityName = receivingCityName;
438     }
439 
440     @Override
441     public String getReceivingCountryCode() {
442         return receivingCountryCode;
443     }
444 
445     @Override
446     public void setReceivingCountryCode(String receivingCountryCode) {
447         this.receivingCountryCode = receivingCountryCode;
448     }
449 
450     @Override
451     public String getReceivingCountryName() {
452         if (StringUtils.isNotBlank(getReceivingCountryCode())) {
453             Country country = SpringContext.getBean(CountryService.class).getCountry(getReceivingCountryCode());
454             if (country != null) {
455                 return country.getName();
456             }
457         }
458         return null;
459     }
460 
461     @Override
462     public String getReceivingLine1Address() {
463         return receivingLine1Address;
464     }
465 
466     @Override
467     public void setReceivingLine1Address(String receivingLine1Address) {
468         this.receivingLine1Address = receivingLine1Address;
469     }
470 
471     @Override
472     public String getReceivingLine2Address() {
473         return receivingLine2Address;
474     }
475 
476     @Override
477     public void setReceivingLine2Address(String receivingLine2Address) {
478         this.receivingLine2Address = receivingLine2Address;
479     }
480 
481     @Override
482     public String getReceivingName() {
483         return receivingName;
484     }
485 
486     @Override
487     public void setReceivingName(String receivingName) {
488         this.receivingName = receivingName;
489     }
490 
491     @Override
492     public String getReceivingPostalCode() {
493         return receivingPostalCode;
494     }
495 
496     @Override
497     public void setReceivingPostalCode(String receivingPostalCode) {
498         this.receivingPostalCode = receivingPostalCode;
499     }
500 
501     @Override
502     public String getReceivingStateCode() {
503         return receivingStateCode;
504     }
505 
506     @Override
507     public void setReceivingStateCode(String receivingStateCode) {
508         this.receivingStateCode = receivingStateCode;
509     }
510 
511     @Override
512     public boolean getAddressToVendorIndicator() {
513         return addressToVendorIndicator;
514     }
515 
516     @Override
517     public void setAddressToVendorIndicator(boolean addressToVendor) {
518         this.addressToVendorIndicator = addressToVendor;
519     }
520 
521     @Override
522     public String getChartOfAccountsCode() {
523         return chartOfAccountsCode;
524     }
525 
526     @Override
527     public void setChartOfAccountsCode(String chartOfAccountsCode) {
528         this.chartOfAccountsCode = chartOfAccountsCode;
529     }
530 
531     @Override
532     public String getDeliveryBuildingCode() {
533         return deliveryBuildingCode;
534     }
535 
536     @Override
537     public void setDeliveryBuildingCode(String deliveryBuildingCode) {
538         this.deliveryBuildingCode = deliveryBuildingCode;
539     }
540 
541     @Override
542     public String getDeliveryBuildingLine1Address() {
543         return deliveryBuildingLine1Address;
544     }
545 
546     @Override
547     public void setDeliveryBuildingLine1Address(String deliveryBuildingLine1Address) {
548         this.deliveryBuildingLine1Address = deliveryBuildingLine1Address;
549     }
550 
551     @Override
552     public String getDeliveryBuildingLine2Address() {
553         return deliveryBuildingLine2Address;
554     }
555 
556     @Override
557     public void setDeliveryBuildingLine2Address(String deliveryBuildingLine2Address) {
558         this.deliveryBuildingLine2Address = deliveryBuildingLine2Address;
559     }
560 
561     @Override
562     public String getDeliveryBuildingName() {
563         return deliveryBuildingName;
564     }
565 
566     @Override
567     public void setDeliveryBuildingName(String deliveryBuildingName) {
568         this.deliveryBuildingName = deliveryBuildingName;
569     }
570 
571     @Override
572     public boolean isDeliveryBuildingOtherIndicator() {
573         return deliveryBuildingOtherIndicator;
574     }
575 
576     @Override
577     public void setDeliveryBuildingOtherIndicator(boolean deliveryBuildingOtherIndicator) {
578         this.deliveryBuildingOtherIndicator = deliveryBuildingOtherIndicator;
579     }
580 
581     @Override
582     public String getDeliveryBuildingRoomNumber() {
583         return deliveryBuildingRoomNumber;
584     }
585 
586     @Override
587     public void setDeliveryBuildingRoomNumber(String deliveryBuildingRoomNumber) {
588         this.deliveryBuildingRoomNumber = deliveryBuildingRoomNumber;
589     }
590 
591     @Override
592     public String getDeliveryCampusCode() {
593         return deliveryCampusCode;
594     }
595 
596     @Override
597     public void setDeliveryCampusCode(String deliveryCampusCode) {
598         this.deliveryCampusCode = deliveryCampusCode;
599     }
600 
601     @Override
602     public String getDeliveryCityName() {
603         return deliveryCityName;
604     }
605 
606     @Override
607     public void setDeliveryCityName(String deliveryCityName) {
608         this.deliveryCityName = deliveryCityName;
609     }
610 
611     @Override
612     public String getDeliveryCountryCode() {
613         return deliveryCountryCode;
614     }
615 
616     @Override
617     public String getDeliveryCountryName() {
618         if (StringUtils.isNotBlank(getDeliveryCountryCode())) {
619             Country country = SpringContext.getBean(CountryService.class).getCountry(getDeliveryCountryCode());
620             if (country != null) {
621                 return country.getName();
622             }
623         }
624         return null;
625     }
626 
627     @Override
628     public void setDeliveryCountryCode(String deliveryCountryCode) {
629         this.deliveryCountryCode = deliveryCountryCode;
630     }
631 
632 
633     @Override
634     public String getDeliveryInstructionText() {
635         return deliveryInstructionText;
636     }
637 
638     @Override
639     public void setDeliveryInstructionText(String deliveryInstructionText) {
640         this.deliveryInstructionText = deliveryInstructionText;
641     }
642 
643     @Override
644     public String getDeliveryPostalCode() {
645         return deliveryPostalCode;
646     }
647 
648     @Override
649     public void setDeliveryPostalCode(String deliveryPostalCode) {
650         this.deliveryPostalCode = deliveryPostalCode;
651     }
652 
653     @Override
654     public Date getDeliveryRequiredDate() {
655         return deliveryRequiredDate;
656     }
657 
658     @Override
659     public void setDeliveryRequiredDate(Date deliveryRequiredDate) {
660         this.deliveryRequiredDate = deliveryRequiredDate;
661     }
662 
663     @Override
664     public String getDeliveryRequiredDateReasonCode() {
665         return deliveryRequiredDateReasonCode;
666     }
667 
668     @Override
669     public void setDeliveryRequiredDateReasonCode(String deliveryRequiredDateReasonCode) {
670         this.deliveryRequiredDateReasonCode = deliveryRequiredDateReasonCode;
671     }
672 
673     @Override
674     public String getDeliveryStateCode() {
675         return deliveryStateCode;
676     }
677 
678     @Override
679     public void setDeliveryStateCode(String deliveryStateCode) {
680         this.deliveryStateCode = deliveryStateCode;
681     }
682 
683     @Override
684     public String getDeliveryToEmailAddress() {
685         return deliveryToEmailAddress;
686     }
687 
688     @Override
689     public void setDeliveryToEmailAddress(String deliveryToEmailAddress) {
690         this.deliveryToEmailAddress = deliveryToEmailAddress;
691     }
692 
693     @Override
694     public String getDeliveryToName() {
695         return deliveryToName;
696     }
697 
698     @Override
699     public void setDeliveryToName(String deliveryToName) {
700         this.deliveryToName = deliveryToName;
701     }
702 
703     @Override
704     public String getDeliveryToPhoneNumber() {
705         return deliveryToPhoneNumber;
706     }
707 
708     @Override
709     public void setDeliveryToPhoneNumber(String deliveryToPhoneNumber) {
710         this.deliveryToPhoneNumber = deliveryToPhoneNumber;
711     }
712 
713     @Override
714     public String getExternalOrganizationB2bSupplierIdentifier() {
715         return externalOrganizationB2bSupplierIdentifier;
716     }
717 
718     @Override
719     public void setExternalOrganizationB2bSupplierIdentifier(String externalOrganizationB2bSupplierIdentifier) {
720         this.externalOrganizationB2bSupplierIdentifier = externalOrganizationB2bSupplierIdentifier;
721     }
722 
723     @Override
724     public String getDocumentFundingSourceCode() {
725         return documentFundingSourceCode;
726     }
727 
728     @Override
729     public void setDocumentFundingSourceCode(String documentFundingSourceCode) {
730         this.documentFundingSourceCode = documentFundingSourceCode;
731     }
732 
733     @Override
734     public String getInstitutionContactEmailAddress() {
735         return institutionContactEmailAddress;
736     }
737 
738     @Override
739     public void setInstitutionContactEmailAddress(String institutionContactEmailAddress) {
740         this.institutionContactEmailAddress = institutionContactEmailAddress;
741     }
742 
743     @Override
744     public String getInstitutionContactName() {
745         return institutionContactName;
746     }
747 
748     @Override
749     public void setInstitutionContactName(String institutionContactName) {
750         this.institutionContactName = institutionContactName;
751     }
752 
753     @Override
754     public String getInstitutionContactPhoneNumber() {
755         return institutionContactPhoneNumber;
756     }
757 
758     @Override
759     public void setInstitutionContactPhoneNumber(String institutionContactPhoneNumber) {
760         this.institutionContactPhoneNumber = institutionContactPhoneNumber;
761     }
762 
763     @Override
764     public String getNonInstitutionFundAccountNumber() {
765         return nonInstitutionFundAccountNumber;
766     }
767 
768     @Override
769     public void setNonInstitutionFundAccountNumber(String nonInstitutionFundAccountNumber) {
770         this.nonInstitutionFundAccountNumber = nonInstitutionFundAccountNumber;
771     }
772 
773     @Override
774     public String getNonInstitutionFundChartOfAccountsCode() {
775         return nonInstitutionFundChartOfAccountsCode;
776     }
777 
778     @Override
779     public void setNonInstitutionFundChartOfAccountsCode(String nonInstitutionFundChartOfAccountsCode) {
780         this.nonInstitutionFundChartOfAccountsCode = nonInstitutionFundChartOfAccountsCode;
781     }
782 
783     @Override
784     public String getNonInstitutionFundOrganizationCode() {
785         return nonInstitutionFundOrganizationCode;
786     }
787 
788     @Override
789     public void setNonInstitutionFundOrganizationCode(String nonInstitutionFundOrganizationCode) {
790         this.nonInstitutionFundOrganizationCode = nonInstitutionFundOrganizationCode;
791     }
792 
793     @Override
794     public String getNonInstitutionFundOrgChartOfAccountsCode() {
795         return nonInstitutionFundOrgChartOfAccountsCode;
796     }
797 
798     @Override
799     public void setNonInstitutionFundOrgChartOfAccountsCode(String nonInstitutionFundOrgChartOfAccountsCode) {
800         this.nonInstitutionFundOrgChartOfAccountsCode = nonInstitutionFundOrgChartOfAccountsCode;
801     }
802 
803     @Override
804     public String getOrganizationCode() {
805         return organizationCode;
806     }
807 
808     @Override
809     public void setOrganizationCode(String organizationCode) {
810         this.organizationCode = organizationCode;
811     }
812 
813     @Override
814     public boolean getPurchaseOrderAutomaticIndicator() {
815         return purchaseOrderAutomaticIndicator;
816     }
817 
818     @Override
819     public void setPurchaseOrderAutomaticIndicator(boolean purchaseOrderAutomaticIndicator) {
820         this.purchaseOrderAutomaticIndicator = purchaseOrderAutomaticIndicator;
821     }
822 
823     @Override
824     public Date getPurchaseOrderBeginDate() {
825         return purchaseOrderBeginDate;
826     }
827 
828     @Override
829     public void setPurchaseOrderBeginDate(Date purchaseOrderBeginDate) {
830         this.purchaseOrderBeginDate = purchaseOrderBeginDate;
831     }
832 
833     @Override
834     public String getPurchaseOrderCostSourceCode() {
835         return purchaseOrderCostSourceCode;
836     }
837 
838     @Override
839     public void setPurchaseOrderCostSourceCode(String purchaseOrderCostSourceCode) {
840         this.purchaseOrderCostSourceCode = purchaseOrderCostSourceCode;
841     }
842 
843     @Override
844     public Date getPurchaseOrderEndDate() {
845         return purchaseOrderEndDate;
846     }
847 
848     @Override
849     public void setPurchaseOrderEndDate(Date purchaseOrderEndDate) {
850         this.purchaseOrderEndDate = purchaseOrderEndDate;
851     }
852 
853     @Override
854     public KualiDecimal getPurchaseOrderTotalLimit() {
855         return purchaseOrderTotalLimit;
856     }
857 
858     @Override
859     public void setPurchaseOrderTotalLimit(KualiDecimal purchaseOrderTotalLimit) {
860         this.purchaseOrderTotalLimit = purchaseOrderTotalLimit;
861     }
862 
863     @Override
864     public String getPurchaseOrderTransmissionMethodCode() {
865         return purchaseOrderTransmissionMethodCode;
866     }
867 
868     @Override
869     public void setPurchaseOrderTransmissionMethodCode(String purchaseOrderTransmissionMethodCode) {
870         this.purchaseOrderTransmissionMethodCode = purchaseOrderTransmissionMethodCode;
871     }
872 
873     @Override
874     public String getRecurringPaymentTypeCode() {
875         return recurringPaymentTypeCode;
876     }
877 
878     @Override
879     public void setRecurringPaymentTypeCode(String recurringPaymentTypeCode) {
880         this.recurringPaymentTypeCode = recurringPaymentTypeCode;
881     }
882 
883     @Override
884     public String getRequestorPersonEmailAddress() {
885         return requestorPersonEmailAddress;
886     }
887 
888     @Override
889     public void setRequestorPersonEmailAddress(String requestorPersonEmailAddress) {
890         this.requestorPersonEmailAddress = requestorPersonEmailAddress;
891     }
892 
893     @Override
894     public String getRequestorPersonName() {
895         return requestorPersonName;
896     }
897 
898     @Override
899     public void setRequestorPersonName(String requestorPersonName) {
900         this.requestorPersonName = requestorPersonName;
901     }
902 
903     @Override
904     public String getRequestorPersonPhoneNumber() {
905         return requestorPersonPhoneNumber;
906     }
907 
908     @Override
909     public void setRequestorPersonPhoneNumber(String requestorPersonPhoneNumber) {
910         this.requestorPersonPhoneNumber = requestorPersonPhoneNumber;
911     }
912 
913     @Override
914     public String getRequisitionSourceCode() {
915         return requisitionSourceCode;
916     }
917 
918     @Override
919     public void setRequisitionSourceCode(String requisitionSourceCode) {
920         this.requisitionSourceCode = requisitionSourceCode;
921     }
922 
923     public String getVendorContactsLabel() {
924         return vendorContactsLabel;
925     }
926 
927     public void setVendorContactsLabel(String vendorContactsLabel) {
928         this.vendorContactsLabel = vendorContactsLabel;
929     }
930 
931     public VendorContract getVendorContract() {
932         if (ObjectUtils.isNull(vendorContract)) {
933             refreshReferenceObject(PurapPropertyConstants.VENDOR_CONTRACT);
934         }
935         return vendorContract;
936     }
937 
938     public void setVendorContract(VendorContract vendorContract) {
939         this.vendorContract = vendorContract;
940     }
941 
942     @Override
943     public Integer getVendorContractGeneratedIdentifier() {
944         return vendorContractGeneratedIdentifier;
945     }
946 
947     @Override
948     public void setVendorContractGeneratedIdentifier(Integer vendorContractGeneratedIdentifier) {
949         this.vendorContractGeneratedIdentifier = vendorContractGeneratedIdentifier;
950     }
951 
952     public String getVendorContractName() {
953         getVendorContract();
954         if (ObjectUtils.isNull(vendorContract)) {
955             return "";
956         } else {
957             return vendorContract.getVendorContractName();
958         }
959     }
960 
961     @Override
962     public String getVendorFaxNumber() {
963         return vendorFaxNumber;
964     }
965 
966     @Override
967     public void setVendorFaxNumber(String vendorFaxNumber) {
968         this.vendorFaxNumber = vendorFaxNumber;
969     }
970 
971     @Override
972     public String getVendorNoteText() {
973         return vendorNoteText;
974     }
975 
976     @Override
977     public void setVendorNoteText(String vendorNoteText) {
978         this.vendorNoteText = vendorNoteText;
979     }
980 
981     @Override
982     public String getVendorPaymentTermsCode() {
983         return vendorPaymentTermsCode;
984     }
985 
986     @Override
987     public void setVendorPaymentTermsCode(String vendorPaymentTermsCode) {
988         this.vendorPaymentTermsCode = vendorPaymentTermsCode;
989     }
990 
991     @Override
992     public String getVendorPhoneNumber() {
993         return vendorPhoneNumber;
994     }
995 
996     @Override
997     public void setVendorPhoneNumber(String vendorPhoneNumber) {
998         this.vendorPhoneNumber = vendorPhoneNumber;
999     }
1000 
1001     @Override
1002     public Boolean getVendorRestrictedIndicator() {
1003         return vendorRestrictedIndicator;
1004     }
1005 
1006     @Override
1007     public void setVendorRestrictedIndicator(Boolean vendorRestrictedIndicator) {
1008         this.vendorRestrictedIndicator = vendorRestrictedIndicator;
1009     }
1010 
1011     @Override
1012     public String getVendorShippingPaymentTermsCode() {
1013         return vendorShippingPaymentTermsCode;
1014     }
1015 
1016     @Override
1017     public void setVendorShippingPaymentTermsCode(String vendorShippingPaymentTermsCode) {
1018         this.vendorShippingPaymentTermsCode = vendorShippingPaymentTermsCode;
1019     }
1020 
1021     @Override
1022     public String getVendorShippingTitleCode() {
1023         return vendorShippingTitleCode;
1024     }
1025 
1026     @Override
1027     public void setVendorShippingTitleCode(String vendorShippingTitleCode) {
1028         this.vendorShippingTitleCode = vendorShippingTitleCode;
1029     }
1030 
1031     @Override
1032     public Chart getChartOfAccounts() {
1033         return chartOfAccounts;
1034     }
1035 
1036     @Override
1037     public CampusParameter getDeliveryCampus() {
1038         return deliveryCampus;
1039     }
1040 
1041     @Override
1042     public DeliveryRequiredDateReason getDeliveryRequiredDateReason() {
1043         return deliveryRequiredDateReason;
1044     }
1045 
1046     @Override
1047     public FundingSource getFundingSource() {
1048         return fundingSource;
1049     }
1050 
1051     @Override
1052     public Account getNonInstitutionFundAccount() {
1053         return nonInstitutionFundAccount;
1054     }
1055 
1056     @Override
1057     public Chart getNonInstitutionFundChartOfAccounts() {
1058         return nonInstitutionFundChartOfAccounts;
1059     }
1060 
1061     @Override
1062     public Organization getNonInstitutionFundOrganization() {
1063         return nonInstitutionFundOrganization;
1064     }
1065 
1066     @Override
1067     public Chart getNonInstitutionFundOrgChartOfAccounts() {
1068         return nonInstitutionFundOrgChartOfAccounts;
1069     }
1070 
1071     @Override
1072     public Organization getOrganization() {
1073         return organization;
1074     }
1075 
1076     @Override
1077     public PurchaseOrderTransmissionMethod getPurchaseOrderTransmissionMethod() {
1078         return purchaseOrderTransmissionMethod;
1079     }
1080 
1081     @Override
1082     public RecurringPaymentType getRecurringPaymentType() {
1083         return recurringPaymentType;
1084     }
1085 
1086     @Override
1087     public RequisitionSource getRequisitionSource() {
1088         return requisitionSource;
1089     }
1090 
1091     public String getSupplierDiversityLabel() {
1092         return supplierDiversityLabel;
1093     }
1094 
1095     @Override
1096     public PurchaseOrderCostSource getPurchaseOrderCostSource() {
1097         if (ObjectUtils.isNull(purchaseOrderCostSource)) {
1098             refreshReferenceObject(PurapPropertyConstants.PURCHASE_ORDER_COST_SOURCE);
1099         }
1100         return purchaseOrderCostSource;
1101     }
1102 
1103     /**
1104      * @deprecated
1105      */
1106     @Deprecated
1107     @Override
1108     public void setChartOfAccounts(Chart chartOfAccounts) {
1109         this.chartOfAccounts = chartOfAccounts;
1110     }
1111 
1112     /**
1113      * @deprecated
1114      */
1115     @Deprecated
1116     @Override
1117     public void setDeliveryCampus(CampusParameter deliveryCampus) {
1118         this.deliveryCampus = deliveryCampus;
1119     }
1120 
1121     /**
1122      * @deprecated
1123      */
1124     @Deprecated
1125     @Override
1126     public void setDeliveryRequiredDateReason(DeliveryRequiredDateReason deliveryRequiredDateReason) {
1127         this.deliveryRequiredDateReason = deliveryRequiredDateReason;
1128     }
1129 
1130     /**
1131      * @deprecated
1132      */
1133     @Deprecated
1134     @Override
1135     public void setFundingSource(FundingSource fundingSource) {
1136         this.fundingSource = fundingSource;
1137     }
1138 
1139     /**
1140      * @deprecated
1141      */
1142     @Deprecated
1143     @Override
1144     public void setNonInstitutionFundAccount(Account nonInstitutionFundAccount) {
1145         this.nonInstitutionFundAccount = nonInstitutionFundAccount;
1146     }
1147 
1148     /**
1149      * @deprecated
1150      */
1151     @Deprecated
1152     @Override
1153     public void setNonInstitutionFundChartOfAccounts(Chart nonInstitutionFundChartOfAccounts) {
1154         this.nonInstitutionFundChartOfAccounts = nonInstitutionFundChartOfAccounts;
1155     }
1156 
1157     /**
1158      * @deprecated
1159      */
1160     @Deprecated
1161     @Override
1162     public void setNonInstitutionFundOrganization(Organization nonInstitutionFundOrganization) {
1163         this.nonInstitutionFundOrganization = nonInstitutionFundOrganization;
1164     }
1165 
1166     /**
1167      * @deprecated
1168      */
1169     @Deprecated
1170     @Override
1171     public void setNonInstitutionFundOrgChartOfAccounts(Chart nonInstitutionFundOrgChartOfAccounts) {
1172         this.nonInstitutionFundOrgChartOfAccounts = nonInstitutionFundOrgChartOfAccounts;
1173     }
1174 
1175     /**
1176      * @deprecated
1177      */
1178     @Deprecated
1179     @Override
1180     public void setOrganization(Organization organization) {
1181         this.organization = organization;
1182     }
1183 
1184     /**
1185      * @deprecated
1186      */
1187     @Deprecated
1188     @Override
1189     public void setPurchaseOrderCostSource(PurchaseOrderCostSource purchaseOrderCostSource) {
1190         this.purchaseOrderCostSource = purchaseOrderCostSource;
1191     }
1192 
1193     /**
1194      * @deprecated
1195      */
1196     @Deprecated
1197     @Override
1198     public void setPurchaseOrderTransmissionMethod(PurchaseOrderTransmissionMethod purchaseOrderTransmissionMethod) {
1199         this.purchaseOrderTransmissionMethod = purchaseOrderTransmissionMethod;
1200     }
1201 
1202     /**
1203      * @deprecated
1204      */
1205     @Deprecated
1206     @Override
1207     public void setRecurringPaymentType(RecurringPaymentType recurringPaymentType) {
1208         this.recurringPaymentType = recurringPaymentType;
1209     }
1210 
1211     /**
1212      * @deprecated
1213      */
1214     @Deprecated
1215     @Override
1216     public void setRequisitionSource(RequisitionSource requisitionSource) {
1217         this.requisitionSource = requisitionSource;
1218     }
1219 
1220     /**
1221      * Gets the receivingDocumentRequiredIndicator attribute.
1222      *
1223      * @return Returns the receivingDocumentRequiredIndicator.
1224      */
1225     @Override
1226     public boolean isReceivingDocumentRequiredIndicator() {
1227         return receivingDocumentRequiredIndicator;
1228     }
1229 
1230     /**
1231      * Sets the receivingDocumentRequiredIndicator attribute value.
1232      *
1233      * @param receivingDocumentRequiredIndicator
1234      *         The receivingDocumentRequiredIndicator to set.
1235      */
1236     @Override
1237     public void setReceivingDocumentRequiredIndicator(boolean receivingDocumentRequiredIndicator) {
1238         // if receivingDocumentRequiredIndicator functionality is disabled, always set it to false, overriding the passed-in value
1239         if (!isEnableReceivingDocumentRequiredIndicator()) {
1240             receivingDocumentRequiredIndicator = false;
1241         } else {
1242             this.receivingDocumentRequiredIndicator = receivingDocumentRequiredIndicator;
1243         }
1244     }
1245 
1246     @Override
1247     public boolean isPaymentRequestPositiveApprovalIndicator() {
1248         return paymentRequestPositiveApprovalIndicator;
1249     }
1250 
1251     @Override
1252     public void setPaymentRequestPositiveApprovalIndicator(boolean paymentRequestPositiveApprovalIndicator) {
1253         // if paymentRequestPositiveApprovalIndicator functionality is disabled, always set it to false, overriding the passed-in value
1254         if (!isEnablePaymentRequestPositiveApprovalIndicator()) {
1255             paymentRequestPositiveApprovalIndicator = false;
1256         } else {
1257             this.paymentRequestPositiveApprovalIndicator = paymentRequestPositiveApprovalIndicator;
1258         }
1259     }
1260 
1261     public List<CommodityCode> getCommodityCodesForRouting() {
1262         return commodityCodesForRouting;
1263     }
1264 
1265     public void setCommodityCodesForRouting(List<CommodityCode> commodityCodesForRouting) {
1266         this.commodityCodesForRouting = commodityCodesForRouting;
1267     }
1268 
1269     @Override
1270     public String getCapitalAssetSystemTypeCode() {
1271         return capitalAssetSystemTypeCode;
1272     }
1273 
1274     @Override
1275     public void setCapitalAssetSystemTypeCode(String capitalAssetSystemTypeCode) {
1276         this.capitalAssetSystemTypeCode = capitalAssetSystemTypeCode;
1277     }
1278 
1279     @Override
1280     public String getCapitalAssetSystemStateCode() {
1281         return capitalAssetSystemStateCode;
1282     }
1283 
1284     @Override
1285     public void setCapitalAssetSystemStateCode(String capitalAssetSystemStateCode) {
1286         this.capitalAssetSystemStateCode = capitalAssetSystemStateCode;
1287     }
1288 
1289     /**
1290      * Gets the justification attribute.
1291      *
1292      * @return Returns the justification.
1293      */
1294     public String getJustification() {
1295         return justification;
1296     }
1297 
1298     /**
1299      * Sets the justification attribute value.
1300      *
1301      * @param justification The justification to set.
1302      */
1303     public void setJustification(String justification) {
1304         this.justification = justification;
1305     }
1306 
1307     @Override
1308     public CapitalAssetSystemType getCapitalAssetSystemType() {
1309         if (ObjectUtils.isNull(capitalAssetSystemType)) {
1310             this.refreshReferenceObject("capitalAssetSystemType");
1311         }
1312         return capitalAssetSystemType;
1313     }
1314 
1315     @Override
1316     public void setCapitalAssetSystemType(CapitalAssetSystemType capitalAssetSystemType) {
1317         this.capitalAssetSystemType = capitalAssetSystemType;
1318     }
1319 
1320     @Override
1321     public CapitalAssetSystemState getCapitalAssetSystemState() {
1322         if (ObjectUtils.isNull(capitalAssetSystemState)) {
1323             this.refreshReferenceObject("capitalAssetSystemState");
1324         }
1325         return capitalAssetSystemState;
1326     }
1327 
1328     @Override
1329     public void setCapitalAssetSystemState(CapitalAssetSystemState capitalAssetSystemState) {
1330         this.capitalAssetSystemState = capitalAssetSystemState;
1331     }
1332 
1333     @Override
1334     public List<CapitalAssetSystem> getPurchasingCapitalAssetSystems() {
1335         return purchasingCapitalAssetSystems;
1336     }
1337 
1338     @Override
1339     public void setPurchasingCapitalAssetSystems(List<CapitalAssetSystem> purchasingCapitalAssetSystems) {
1340         this.purchasingCapitalAssetSystems = purchasingCapitalAssetSystems;
1341     }
1342 
1343     @Override
1344     public List<PurchasingCapitalAssetItem> getPurchasingCapitalAssetItems() {
1345         return purchasingCapitalAssetItems;
1346     }
1347 
1348     @Override
1349     public void setPurchasingCapitalAssetItems(List<PurchasingCapitalAssetItem> purchasingCapitalAssetItems) {
1350         this.purchasingCapitalAssetItems = purchasingCapitalAssetItems;
1351     }
1352 
1353     @Override
1354     public abstract Class getPurchasingCapitalAssetItemClass();
1355 
1356     @Override
1357     public abstract Class getPurchasingCapitalAssetSystemClass();
1358 
1359     @Override
1360     public PurchasingItem getPurchasingItem(Integer itemIdentifier) {
1361 
1362         if (ObjectUtils.isNull(itemIdentifier)) {
1363             return null;
1364         }
1365 
1366         PurchasingItem item = null;
1367 
1368         for (PurchasingItem pi : (List<PurchasingItem>) this.getItems()) {
1369             if (itemIdentifier.equals(pi.getItemIdentifier())) {
1370                 item = pi;
1371                 break;
1372             }
1373         }
1374 
1375         return item;
1376     }
1377 
1378     @Override
1379     public PurchasingCapitalAssetItem getPurchasingCapitalAssetItem(Integer itemIdentifier) {
1380 
1381         if (ObjectUtils.isNull(itemIdentifier)) {
1382             return null;
1383         }
1384 
1385         PurchasingCapitalAssetItem item = null;
1386 
1387         for (PurchasingCapitalAssetItem pcai : this.getPurchasingCapitalAssetItems()) {
1388             if (itemIdentifier.equals(pcai.getItemIdentifier())) {
1389                 item = pcai;
1390                 break;
1391             }
1392         }
1393 
1394         return item;
1395     }
1396 
1397     /**
1398      * @see org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase#buildListOfDeletionAwareLists()
1399      */
1400     @Override
1401     public List buildListOfDeletionAwareLists() {
1402         List managedLists = super.buildListOfDeletionAwareLists();
1403         if (allowDeleteAwareCollection) {
1404             List<ItemCapitalAsset> assetLists = new ArrayList<ItemCapitalAsset>();
1405             List<CapitalAssetLocation> capitalAssetLocationLists = new ArrayList<CapitalAssetLocation>();
1406             if (StringUtils.equals(this.getCapitalAssetSystemTypeCode(), PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
1407                 for (PurchasingCapitalAssetItem capitalAssetItem : this.getPurchasingCapitalAssetItems()) {
1408                     //We only need to add the itemCapitalAssets to assetLists if the system is not null, otherwise
1409                     //just let the assetLists be empty ArrayList.
1410                     if (capitalAssetItem.getPurchasingCapitalAssetSystem() != null) {
1411                         assetLists.addAll(capitalAssetItem.getPurchasingCapitalAssetSystem().getItemCapitalAssets());
1412                         capitalAssetLocationLists.addAll(capitalAssetItem.getPurchasingCapitalAssetSystem().getCapitalAssetLocations());
1413                     }
1414                 }
1415             } else {
1416                 for (CapitalAssetSystem system : this.getPurchasingCapitalAssetSystems()) {
1417                     assetLists.addAll(system.getItemCapitalAssets());
1418                     capitalAssetLocationLists.addAll(system.getCapitalAssetLocations());
1419                 }
1420             }
1421             managedLists.add(assetLists);
1422             managedLists.add(capitalAssetLocationLists);
1423             managedLists.add(this.getPurchasingCapitalAssetSystems());
1424             //managedLists.add(this.getPurchasingCapitalAssetItems());
1425         }
1426         return managedLists;
1427     }
1428 
1429     /**
1430      * Overrides the method in PurchasingAccountsPayableDocumentBase to remove the
1431      * purchasingCapitalAssetSystem when the system type is either ONE or MULT.
1432      *
1433      *
1434      */
1435     @Override
1436     public void prepareForSave(DocumentEvent event) {
1437         super.prepareForSave(event);
1438         if (StringUtils.isNotBlank(this.getCapitalAssetSystemTypeCode())) {
1439             if (this.getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.ONE_SYSTEM) || this.getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.MULTIPLE)) {
1440                 //If the system state is ONE or MULT, we have to remove all the systems on the items because it's not applicable.
1441                 for (PurchasingCapitalAssetItem camsItem : this.getPurchasingCapitalAssetItems()) {
1442                     camsItem.setPurchasingCapitalAssetSystem(null);
1443                 }
1444             }
1445         }
1446         if (event instanceof RouteDocumentEvent || event instanceof ApproveDocumentEvent) {
1447 
1448             boolean defaultUseTaxIndicatorValue = SpringContext.getBean(PurchasingService.class).getDefaultUseTaxIndicatorValue(this);
1449             SpringContext.getBean(PurapService.class).updateUseTaxIndicator(this, defaultUseTaxIndicatorValue);
1450         }
1451     }
1452 
1453     @Override
1454     public Date getTransactionTaxDate() {
1455         return SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
1456     }
1457 
1458     @Override
1459     public void clearCapitalAssetFields() {
1460         this.getPurchasingCapitalAssetItems().clear();
1461         this.getPurchasingCapitalAssetSystems().clear();
1462         this.setCapitalAssetSystemStateCode(null);
1463         this.setCapitalAssetSystemTypeCode(null);
1464         this.setCapitalAssetSystemState(null);
1465         this.setCapitalAssetSystemType(null);
1466 
1467     }
1468 
1469     /**
1470      * @return the payment request positive approval indicator
1471      */
1472     public boolean getPaymentRequestPositiveApprovalIndicatorForSearching() {
1473         return paymentRequestPositiveApprovalIndicator;
1474     }
1475 
1476     /**
1477      * @return the receiving document required indicator
1478      */
1479     public boolean getReceivingDocumentRequiredIndicatorForSearching() {
1480         return receivingDocumentRequiredIndicator;
1481     }
1482 
1483     public String getDocumentChartOfAccountsCodeForSearching() {
1484         return chartOfAccountsCode;
1485     }
1486 
1487     public String getDocumentOrganizationCodeForSearching() {
1488         return organizationCode;
1489     }
1490 
1491     @Override
1492     public boolean shouldGiveErrorForEmptyAccountsProration() {
1493         return true;
1494     }
1495 
1496     public String getChartAndOrgCodeForResult() {
1497         return getChartOfAccountsCode() + "-" + getOrganizationCode();
1498     }
1499 
1500     public String getDeliveryCampusCodeForSearch() {
1501         return getDeliveryCampusCode();
1502     }
1503 
1504     public boolean getHasB2BVendor() {
1505         if (getVendorHeaderGeneratedIdentifier() != null) {
1506             refreshReferenceObject(VendorPropertyConstants.VENDOR_DETAIL);
1507             String campusCode = GlobalVariables.getUserSession().getPerson().getCampusCode();
1508             VendorDetail vendorDetail = getVendorDetail();
1509             if (vendorDetail == null || StringUtils.isEmpty(campusCode)) {
1510                 return false; // this should never happen
1511             }
1512             return SpringContext.getBean(VendorService.class).getVendorB2BContract(vendorDetail, campusCode) != null;
1513         }
1514         return false;
1515     }
1516 }