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.PurapPropertyConstants;
20 import org.kuali.ole.module.purap.document.InvoiceDocument;
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 public class InvoiceGrandTotalOverZeroValidation extends GenericValidation {
28
29 public boolean validate(AttributedDocumentEvent event) {
30 boolean valid = true;
31 InvoiceDocument document = (InvoiceDocument) event.getDocument();
32 GlobalVariables.getMessageMap().clearErrorPath();
33 GlobalVariables.getMessageMap().addToErrorPath(OLEPropertyConstants.DOCUMENT);
34
35
36 if (document.getGrandTotal().compareTo(KualiDecimal.ZERO) <= 0) {
37 GlobalVariables.getMessageMap().putError(PurapPropertyConstants.GRAND_TOTAL, PurapKeyConstants.ERROR_PAYMENT_REQUEST_GRAND_TOTAL_NOT_POSITIVE);
38 valid &= false;
39 }
40
41 GlobalVariables.getMessageMap().clearErrorPath();
42
43
44 return valid;
45 }
46
47 }