View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.document.validation.impl;
17  
18  import org.kuali.ole.module.purap.businessobject.PurApItem;
19  import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem;
20  import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
21  import org.kuali.ole.sys.document.validation.BranchingValidation;
22  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23  
24  public class PurchaseOrderAmendmentProcessAccountValidation extends BranchingValidation {
25  
26      protected final String PROCESS_ACCOUNT_VALIDATION = "processAccountValidation";
27      protected PurApItem itemForValidation;
28  
29      /**
30       * Overrides the method in PurchasingProcessAccountValidation to provide additional
31       * validation condition. If the accounts on the item are editable in the amendment document then
32       * we should continue doing the processAccountValidation in the superclass, otherwise
33       * we should just return true so that the account won't be validated, because if
34       * the items contain accounts that aren't editable, it doesn't make sense to give
35       * the user account validation errors.
36       */
37      @Override
38      protected String determineBranch(AttributedDocumentEvent event) {
39          PurchaseOrderDocument document = (PurchaseOrderDocument) event.getDocument();
40          PurchaseOrderItem itemLine = (PurchaseOrderItem) getItemForValidation();
41          if (itemLine.isItemActiveIndicator() && (!(document.getContainsUnpaidPaymentRequestsOrCreditMemos() && itemLine.getItemInvoicedTotalAmount() != null))) {
42              //This means the accounts on the item are editable, so we'll call super's processAccountValidation.
43              return PROCESS_ACCOUNT_VALIDATION;
44          } else {
45              //This means the accounts on the item are not editable, so we'll return true so that it won't do any further validations on the accounts.
46              return null;
47          }
48      }
49  
50      public PurApItem getItemForValidation() {
51          return itemForValidation;
52      }
53  
54      public void setItemForValidation(PurApItem itemForValidation) {
55          this.itemForValidation = itemForValidation;
56      }
57  
58  }