1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.businessobject;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.module.purap.PurapPropertyConstants;
20 import org.kuali.ole.module.purap.document.PurchasingDocument;
21 import org.kuali.ole.sys.businessobject.UnitOfMeasure;
22 import org.kuali.ole.vnd.businessobject.CommodityCode;
23 import org.kuali.rice.krad.util.ObjectUtils;
24
25 import java.math.BigDecimal;
26
27
28
29
30 public abstract class PurchasingItemBase extends PurApItemBase implements PurchasingItem {
31
32 private String purchasingCommodityCode;
33
34 private CommodityCode commodityCode;
35
36 private UnitOfMeasure itemUnitOfMeasure;
37
38
39
40
41 public boolean isConsideredEntered() {
42 if (this instanceof PurchaseOrderItem) {
43
44 PurchaseOrderItem poi = (PurchaseOrderItem) this;
45 if (!poi.isItemActiveIndicator()) {
46 return false;
47 }
48 }
49 if (getItemType().isAdditionalChargeIndicator()) {
50 if ((ObjectUtils.isNull(getItemUnitPrice())) && (StringUtils.isBlank(getItemDescription())) && (getSourceAccountingLines().isEmpty())) {
51 return false;
52 }
53 }
54 return true;
55 }
56
57
58
59
60
61
62 public boolean isEmpty() {
63 return !(StringUtils.isNotEmpty(getItemUnitOfMeasureCode()) || StringUtils.isNotEmpty(getItemCatalogNumber()) || StringUtils.isNotEmpty(getItemDescription()) || StringUtils.isNotEmpty(getItemAuxiliaryPartIdentifier()) || ObjectUtils.isNotNull(getItemQuantity()) || (ObjectUtils.isNotNull(getItemUnitPrice()) && (getItemUnitPrice().compareTo(BigDecimal.ZERO) != 0)) || (!this.isAccountListEmpty()));
64 }
65
66
67
68
69
70
71 public boolean isItemDetailEmpty() {
72 boolean empty = true;
73 empty &= ObjectUtils.isNull(getItemQuantity()) || StringUtils.isEmpty(getItemQuantity().toString());
74 empty &= StringUtils.isEmpty(getItemUnitOfMeasureCode());
75 empty &= StringUtils.isEmpty(getItemCatalogNumber());
76 empty &= StringUtils.isEmpty(getItemDescription());
77 empty &= ObjectUtils.isNull(getItemUnitPrice()) || (getItemUnitPrice().compareTo(BigDecimal.ZERO) == 0);
78 return empty;
79 }
80
81 public CommodityCode getCommodityCode() {
82 if (ObjectUtils.isNull(commodityCode) || !StringUtils.equalsIgnoreCase(commodityCode.getPurchasingCommodityCode(), getPurchasingCommodityCode())) {
83 refreshReferenceObject(PurapPropertyConstants.COMMODITY_CODE);
84 }
85 return commodityCode;
86 }
87
88 public void setCommodityCode(CommodityCode commodityCode) {
89 this.commodityCode = commodityCode;
90 }
91
92 public String getPurchasingCommodityCode() {
93 return purchasingCommodityCode;
94 }
95
96 public void setPurchasingCommodityCode(String purchasingCommodityCode) {
97 this.purchasingCommodityCode = (StringUtils.isNotBlank(purchasingCommodityCode) ? purchasingCommodityCode.toUpperCase() : purchasingCommodityCode);
98 }
99
100 public PurchasingCapitalAssetItem getPurchasingCapitalAssetItem() {
101 PurchasingDocument pd = (PurchasingDocument) this.getPurapDocument();
102 if (this.getItemIdentifier() != null) {
103 return pd.getPurchasingCapitalAssetItem(this.getItemIdentifier());
104 } else {
105 return null;
106 }
107 }
108
109 public UnitOfMeasure getItemUnitOfMeasure() {
110 if (ObjectUtils.isNull(itemUnitOfMeasure) || !StringUtils.equalsIgnoreCase(itemUnitOfMeasure.getItemUnitOfMeasureCode(), getItemUnitOfMeasureCode())) {
111 refreshReferenceObject(PurapPropertyConstants.ITEM_UNIT_OF_MEASURE);
112 }
113 return itemUnitOfMeasure;
114 }
115
116 public void setItemUnitOfMeasure(UnitOfMeasure itemUnitOfMeasure) {
117 this.itemUnitOfMeasure = itemUnitOfMeasure;
118 }
119
120 public boolean isNewItemForAmendment() {
121 return false;
122 }
123 }