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.PurapConstants;
19 import org.kuali.ole.module.purap.document.ElectronicInvoiceRejectDocument;
20 import org.kuali.ole.module.purap.service.ElectronicInvoiceHelperService;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.rice.core.api.util.type.KualiDecimal;
24 import org.kuali.rice.kns.rules.DocumentRuleBase;
25 import org.kuali.rice.krad.document.Document;
26 import org.kuali.rice.krad.util.GlobalVariables;
27
28 import java.math.BigDecimal;
29
30
31
32
33 public class ElectronicInvoiceRejectDocumentRule extends DocumentRuleBase {
34
35 protected static KualiDecimal zero = KualiDecimal.ZERO;
36 protected static BigDecimal ONE_HUNDRED = BigDecimal.valueOf(100);
37
38
39
40
41 @Override
42 protected boolean processCustomRouteDocumentBusinessRules(Document document) {
43 return processBusinessRules(document);
44 }
45
46 protected boolean processBusinessRules(Document document) {
47 boolean isValid = true;
48
49 ElectronicInvoiceRejectDocument eirDocument = (ElectronicInvoiceRejectDocument) document;
50
51
52 if (eirDocument.isInvoiceResearchIndicator()) {
53 GlobalVariables.getMessageMap().putError(OLEConstants.DOCUMENT_ERRORS, PurapConstants.REJECT_DOCUMENT_RESEARCH_INCOMPETE);
54 isValid = false;
55 }
56
57 if (!eirDocument.isDocumentCreationInProgress()) {
58 isValid = isValid && SpringContext.getBean(ElectronicInvoiceHelperService.class).doMatchingProcess(eirDocument);
59 if (isValid) {
60 SpringContext.getBean(ElectronicInvoiceHelperService.class).createPaymentRequest(eirDocument);
61 }
62 }
63
64 return isValid;
65 }
66
67 }