1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document.validation.impl;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.module.purap.PurapConstants;
20 import org.kuali.ole.module.purap.PurapConstants.ItemFields;
21 import org.kuali.ole.module.purap.PurapKeyConstants;
22 import org.kuali.ole.module.purap.businessobject.PaymentRequestItem;
23 import org.kuali.ole.module.purap.document.validation.impl.PaymentRequestProcessItemValidation;
24 import org.kuali.rice.krad.util.GlobalVariables;
25 import org.kuali.rice.krad.util.ObjectUtils;
26
27 public class OlePaymentRequestProcessItemValidation extends PaymentRequestProcessItemValidation {
28
29
30
31
32
33
34
35
36 @Override
37 protected boolean validateAboveTheLineItems(PaymentRequestItem item, String identifierString, boolean isReceivingDocumentRequiredIndicator) {
38 boolean valid = true;
39
40
41 if (ObjectUtils.isNotNull(item.getItemQuantity())) {
42 if (item.getItemQuantity().isNegative()) {
43
44 valid = false;
45 GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_AMOUNT_BELOW_ZERO, ItemFields.INVOICE_QUANTITY, identifierString);
46 }
47 if (!isReceivingDocumentRequiredIndicator) {
48 if (!StringUtils.equalsIgnoreCase(item.getItemTypeCode(), PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE)) {
49 if (item.getPoOutstandingQuantity().isLessThan(item.getItemQuantity())) {
50 valid = false;
51 GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_QUANTITY_TOO_MANY, ItemFields.INVOICE_QUANTITY, identifierString, ItemFields.OPEN_QUANTITY);
52 }
53 }
54 }
55
56 }
57 if (ObjectUtils.isNotNull(item.getExtendedPrice()) && item.getExtendedPrice().isPositive() && ObjectUtils.isNotNull(item.getPoOutstandingQuantity()) && item.getPoOutstandingQuantity().isPositive()) {
58
59
60 if (ObjectUtils.isNull(item.getItemQuantity()) || item.getItemQuantity().isZero()) {
61
62
63 valid = false;
64 GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_QUANTITY_REQUIRED, ItemFields.INVOICE_QUANTITY, identifierString, ItemFields.OPEN_QUANTITY);
65 }
66 }
67
68
69 if ((ObjectUtils.isNull(item.getPaymentRequest().getPurapDocumentIdentifier())) || (PurapConstants.PaymentRequestStatuses.APPDOC_IN_PROCESS.equals(item.getPaymentRequest().getApplicationDocumentStatus()))) {
70 if ((item.getItemType().isAmountBasedGeneralLedgerIndicator()) && ((item.getExtendedPrice() != null) && item.getExtendedPrice().isNonZero())) {
71 if (item.getPoOutstandingAmount() == null || item.getPoOutstandingAmount().isZero()) {
72 valid = false;
73 GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_AMOUNT_ALREADY_PAID, identifierString);
74 }
75 }
76 }
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 return valid;
97 }
98
99
100 }