001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.module.purap.document.validation.impl; 017 018 import org.kuali.kfs.module.purap.businessobject.PurApItem; 019 import org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem; 020 import org.kuali.kfs.module.purap.document.PurchaseOrderDocument; 021 import org.kuali.kfs.sys.document.validation.BranchingValidation; 022 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent; 023 024 public class PurchaseOrderAmendmentProcessAccountValidation extends BranchingValidation { 025 026 protected final String PROCESS_ACCOUNT_VALIDATION="processAccountValidation"; 027 protected PurApItem itemForValidation; 028 029 /** 030 * Overrides the method in PurchasingProcessAccountValidation to provide additional 031 * validation condition. If the accounts on the item are editable in the amendment document then 032 * we should continue doing the processAccountValidation in the superclass, otherwise 033 * we should just return true so that the account won't be validated, because if 034 * the items contain accounts that aren't editable, it doesn't make sense to give 035 * the user account validation errors. 036 * 037 */ 038 @Override 039 protected String determineBranch(AttributedDocumentEvent event) { 040 PurchaseOrderDocument document = (PurchaseOrderDocument)event.getDocument(); 041 PurchaseOrderItem itemLine = (PurchaseOrderItem) getItemForValidation(); 042 if (itemLine.isItemActiveIndicator() && (! (document.getContainsUnpaidPaymentRequestsOrCreditMemos() && itemLine.getItemInvoicedTotalAmount() != null))) { 043 //This means the accounts on the item are editable, so we'll call super's processAccountValidation. 044 return PROCESS_ACCOUNT_VALIDATION; 045 } 046 else { 047 //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. 048 return null; 049 } 050 } 051 052 public PurApItem getItemForValidation() { 053 return itemForValidation; 054 } 055 056 public void setItemForValidation(PurApItem itemForValidation) { 057 this.itemForValidation = itemForValidation; 058 } 059 060 }