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.integration.cab.CapitalAssetBuilderAssetTransactionType;
20 import org.kuali.ole.module.purap.PurapPropertyConstants;
21 import org.kuali.ole.module.purap.util.PurApItemUtils;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.rice.core.api.util.type.KualiDecimal;
24 import org.kuali.rice.krad.service.KualiModuleService;
25 import org.kuali.rice.krad.util.ObjectUtils;
26
27 import java.math.BigDecimal;
28
29
30
31
32 public abstract class AccountsPayableItemBase extends PurApItemBase implements AccountsPayableItem {
33 private KualiDecimal extendedPrice;
34 private String capitalAssetTransactionTypeCode;
35 private CapitalAssetBuilderAssetTransactionType capitalAssetTransactionType;
36
37
38
39
40
41
42 public boolean isConsideredEntered() {
43 return isConsideredEnteredWithZero();
44 }
45
46 public boolean isEligibleDisplay() {
47 return isConsideredEnteredWithZero();
48 }
49
50 public boolean isConsideredEnteredWithZero() {
51 return isConsideredEntered(true);
52 }
53
54 public boolean isConsideredEnteredWithoutZero() {
55 return isConsideredEntered(false);
56 }
57
58
59
60
61
62
63
64
65
66
67 private boolean isConsideredEntered(boolean allowsZero) {
68 if (getItemType().isLineItemIndicator()) {
69 if ((getItemType().isQuantityBasedGeneralLedgerIndicator())) {
70 if ((ObjectUtils.isNull(getItemQuantity())) && (ObjectUtils.isNull(getExtendedPrice()) || (allowsZero && getExtendedPrice().isZero()))) {
71 return false;
72 }
73 } else {
74 if (ObjectUtils.isNull(getExtendedPrice()) || (allowsZero && getExtendedPrice().isZero())) {
75 return false;
76 }
77 }
78 } else {
79 if ((ObjectUtils.isNull(getItemUnitPrice()) || (allowsZero && this.getItemUnitPrice().compareTo(new BigDecimal(0)) == 0)) && (StringUtils.isBlank(getItemDescription()))) {
80 return false;
81 }
82 }
83
84 return true;
85 }
86
87 public boolean isNonZeroAmount() {
88 return PurApItemUtils.isNonZeroExtended(this);
89 }
90
91
92
93
94
95
96
97 @Override
98 public KualiDecimal getExtendedPrice() {
99 if (ObjectUtils.isNotNull(this.getItemUnitPrice()) && this.getItemType().isAmountBasedGeneralLedgerIndicator()) {
100 if (ObjectUtils.isNotNull(this.getItemUnitPrice())) {
101 extendedPrice = new KualiDecimal(this.getItemUnitPrice().toString());
102 } else {
103 extendedPrice = null;
104 }
105 } else if (ObjectUtils.isNull(this.getItemUnitPrice()) &&
106 this.getItemType().isAmountBasedGeneralLedgerIndicator() &&
107 this.getItemType().isAdditionalChargeIndicator()) {
108
109 extendedPrice = null;
110 }
111 return extendedPrice;
112 }
113
114 public void setExtendedPrice(KualiDecimal extendedPrice) {
115 this.extendedPrice = extendedPrice;
116 }
117
118
119
120
121
122
123
124
125
126
127 @Override
128 public PurApSummaryItem getSummaryItem() {
129 if (extendedPrice == null || extendedPrice.compareTo(KualiDecimal.ZERO)==0) {
130 return null;
131 } else {
132 return super.getSummaryItem();
133 }
134 }
135
136 public String getCapitalAssetTransactionTypeCode() {
137 return capitalAssetTransactionTypeCode;
138 }
139
140 public void setCapitalAssetTransactionTypeCode(String capitalAssetTransactionTypeCode) {
141 this.capitalAssetTransactionTypeCode = capitalAssetTransactionTypeCode;
142 }
143
144 public CapitalAssetBuilderAssetTransactionType getCapitalAssetTransactionType() {
145 return capitalAssetTransactionType = (CapitalAssetBuilderAssetTransactionType) SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CapitalAssetBuilderAssetTransactionType.class).retrieveExternalizableBusinessObjectIfNecessary(this, capitalAssetTransactionType, PurapPropertyConstants.ITEM_CAPITAL_ASSET_TRANSACTION_TYPE);
146 }
147
148 public void setItemDescription(String itemDescription) {
149 if ((itemDescription != null) && (itemDescription.length() > 100)) {
150 super.setItemDescription(itemDescription.substring(0, 100));
151 } else {
152 super.setItemDescription(itemDescription);
153 }
154
155 }
156
157 }