01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.purap.bo;
17:
18: import java.math.BigDecimal;
19:
20: import org.apache.commons.lang.StringUtils;
21: import org.kuali.core.util.ObjectUtils;
22:
23: /**
24: * Purchasing Item Base Business Object.
25: */
26: public abstract class PurchasingItemBase extends PurApItemBase
27: implements PurchasingItem {
28:
29: /**
30: * @see org.kuali.module.purap.bo.PurApItem#isConsideredEntered()
31: */
32: public boolean isConsideredEntered() {
33: if (this instanceof PurchaseOrderItem) {
34: // if item is PO item... only validate active items
35: PurchaseOrderItem poi = (PurchaseOrderItem) this ;
36: if (!poi.isItemActiveIndicator()) {
37: return false;
38: }
39: }
40: if (!getItemType().isItemTypeAboveTheLineIndicator()) {
41: if ((ObjectUtils.isNull(getItemUnitPrice()))
42: && (StringUtils.isBlank(getItemDescription()))
43: && (getSourceAccountingLines().isEmpty())) {
44: return false;
45: }
46: }
47: return true;
48: }
49:
50: /**
51: * Determines if the Purchasing Item is empty.
52: *
53: * @return boolean - true if item is empty, false if conditions show its not empty.
54: */
55: public boolean isEmpty() {
56: return !(StringUtils.isNotEmpty(getItemUnitOfMeasureCode())
57: || StringUtils.isNotEmpty(getItemCatalogNumber())
58: || StringUtils.isNotEmpty(getItemDescription())
59: || StringUtils
60: .isNotEmpty(getItemCapitalAssetNoteText())
61: || StringUtils
62: .isNotEmpty(getItemAuxiliaryPartIdentifier())
63: || ObjectUtils.isNotNull(getItemQuantity())
64: || (ObjectUtils.isNotNull(getItemUnitPrice()) && (getItemUnitPrice()
65: .compareTo(BigDecimal.ZERO) != 0))
66: || ObjectUtils
67: .isNotNull(getCapitalAssetTransactionType()) || (!this
68: .isAccountListEmpty()));
69: }
70:
71: /**
72: * Determines if the Purchasing Item Detail is empty.
73: *
74: * @return boolean - true if item is empty, false if conditions show its not empty.
75: */
76: public boolean isItemDetailEmpty() {
77: boolean empty = true;
78: empty &= ObjectUtils.isNull(getItemQuantity())
79: || StringUtils.isEmpty(getItemQuantity().toString());
80: empty &= StringUtils.isEmpty(getItemUnitOfMeasureCode());
81: empty &= StringUtils.isEmpty(getItemCatalogNumber());
82: empty &= StringUtils.isEmpty(getItemDescription());
83: empty &= ObjectUtils.isNull(getItemUnitPrice())
84: || (getItemUnitPrice().compareTo(BigDecimal.ZERO) == 0);
85: return empty;
86: }
87:
88: }
|