1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.validation.impl;
17
18 import org.kuali.ole.module.purap.PurapKeyConstants;
19 import org.kuali.ole.module.purap.businessobject.PurApItem;
20 import org.kuali.ole.module.purap.document.PaymentRequestDocument;
21 import org.kuali.ole.sys.OLEPropertyConstants;
22 import org.kuali.ole.sys.document.validation.GenericValidation;
23 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24 import org.kuali.rice.core.api.util.type.KualiDecimal;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27 import java.util.List;
28
29 public class LineItemQuantityNotZero extends GenericValidation {
30
31 public boolean validate(AttributedDocumentEvent event) {
32 boolean valid = true;
33
34 PaymentRequestDocument document = (PaymentRequestDocument) event.getDocument();
35 GlobalVariables.getMessageMap().clearErrorPath();
36 GlobalVariables.getMessageMap().addToErrorPath(OLEPropertyConstants.DOCUMENT);
37
38 int i = 0;
39 for (PurApItem item : (List<PurApItem>) document.getItems()) {
40 KualiDecimal itemQuantity = item.getItemQuantity();
41 if (itemQuantity != null) {
42 if (!itemQuantity.isNonZero()) {
43 GlobalVariables.getMessageMap().putError("item[" + i + "].itemQuantity", PurapKeyConstants.ERROR_PAYMENT_REQUEST_LINE_ITEM_QUANTITY_ZERO);
44 GlobalVariables.getMessageMap().clearErrorPath();
45
46 valid = false;
47 break;
48 }
49 i++;
50 }
51 }
52
53 return valid;
54 }
55
56 }