1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.util;
17
18 import org.kuali.ole.module.purap.businessobject.PurApItem;
19 import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem;
20 import org.kuali.rice.krad.util.ObjectUtils;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25
26
27
28
29 public class PurApItemUtils {
30
31
32
33
34
35
36
37
38 public static boolean checkItemActive(PurApItem item) {
39 boolean active = true;
40 if (item instanceof PurchaseOrderItem) {
41 PurchaseOrderItem poi = (PurchaseOrderItem) item;
42 active = poi.isItemActiveIndicator();
43 }
44 return active;
45 }
46
47 public static boolean isNonZeroExtended(PurApItem item) {
48 return (ObjectUtils.isNotNull(item) && ObjectUtils.isNotNull(item.getExtendedPrice()) && !item.getExtendedPrice().isZero());
49 }
50
51
52
53
54
55
56
57 public static List<PurApItem> getAboveTheLineOnly(List<PurApItem> items) {
58 List<PurApItem> returnItems = new ArrayList<PurApItem>();
59 for (PurApItem item : items) {
60 if (item.getItemType().isLineItemIndicator()) {
61 returnItems.add((PurApItem) ObjectUtils.deepCopy(item));
62 }
63 }
64 return returnItems;
65 }
66
67
68
69
70
71
72 public static int countBelowTheLineItems(List<PurApItem> items) {
73 int count = 0;
74 for (int i = items.size() - 1; i > 0; i--) {
75 PurApItem item = items.get(i);
76
77 if (item.getItemType().isLineItemIndicator()) {
78 break;
79 } else {
80 count++;
81 }
82 }
83 return count;
84 }
85
86 }