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.apache.commons.lang.StringUtils;
19  import org.kuali.ole.module.purap.PurapKeyConstants;
20  import org.kuali.ole.module.purap.businessobject.NegativeInvoiceApprovalLimit;
21  import org.kuali.ole.sys.OLEPropertyConstants;
22  import org.kuali.rice.kns.document.MaintenanceDocument;
23  import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
24  
25  
26  
27  
28  public class NegativeInvoiceApprovalLimitRule extends MaintenanceDocumentRuleBase {
29  
30      
31  
32  
33      @Override
34      protected boolean processCustomApproveDocumentBusinessRules(MaintenanceDocument document) {
35          boolean result = super.processCustomApproveDocumentBusinessRules(document);
36          final NegativeInvoiceApprovalLimit limit = (NegativeInvoiceApprovalLimit) getNewBo();
37          result &= checkExclusiveOrganizationCodeAndAccountNumber(limit);
38          return result;
39      }
40  
41      
42  
43  
44      @Override
45      protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
46          boolean result = super.processCustomRouteDocumentBusinessRules(document);
47          final NegativeInvoiceApprovalLimit limit = (NegativeInvoiceApprovalLimit) getNewBo();
48          result &= checkExclusiveOrganizationCodeAndAccountNumber(limit);
49          return result;
50      }
51  
52      
53  
54  
55  
56  
57  
58      protected boolean checkExclusiveOrganizationCodeAndAccountNumber(NegativeInvoiceApprovalLimit limit) {
59          if (!StringUtils.isBlank(limit.getOrganizationCode()) && !StringUtils.isBlank(limit.getAccountNumber())) {
60              putFieldError(OLEPropertyConstants.ORGANIZATION_CODE, PurapKeyConstants.ERROR_NEGATIVE_PAYMENT_REQUEST_APPROVAL_LIMIT_ORG_AND_ACCOUNT_EXCLUSIVE, new String[]{});
61              putFieldError(OLEPropertyConstants.ACCOUNT_NUMBER, PurapKeyConstants.ERROR_NEGATIVE_PAYMENT_REQUEST_APPROVAL_LIMIT_ORG_AND_ACCOUNT_EXCLUSIVE, new String[]{});
62              return false;
63          }
64          return true;
65      }
66  
67  }