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