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.module.purap.document.service.InvoiceService;
22 import org.kuali.ole.sys.OLEPropertyConstants;
23 import org.kuali.ole.sys.document.validation.GenericValidation;
24 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25 import org.kuali.rice.krad.util.GlobalVariables;
26 import org.kuali.rice.krad.util.ObjectUtils;
27
28 public class InvoiceDateForContinueValidation extends GenericValidation {
29
30 private InvoiceService invoiceService;
31
32 public boolean validate(AttributedDocumentEvent event) {
33 boolean valid = true;
34 InvoiceDocument document = (InvoiceDocument) event.getDocument();
35 GlobalVariables.getMessageMap().clearErrorPath();
36 GlobalVariables.getMessageMap().addToErrorPath(OLEPropertyConstants.DOCUMENT);
37
38
39 java.sql.Date invoiceDate = document.getInvoiceDate();
40 if (ObjectUtils.isNotNull(invoiceDate) && invoiceService.isInvoiceDateAfterToday(invoiceDate)) {
41 GlobalVariables.getMessageMap().putError(PurapPropertyConstants.INVOICE_DATE, PurapKeyConstants.ERROR_INVALID_INVOICE_DATE);
42 valid &= false;
43 }
44
45 GlobalVariables.getMessageMap().clearErrorPath();
46
47 return valid;
48 }
49
50 public InvoiceService getInvoiceService() {
51 return invoiceService;
52 }
53
54 public void setInvoiceService(InvoiceService invoiceService) {
55 this.invoiceService = invoiceService;
56 }
57
58 }