001/* 002 * Copyright 2008-2009 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 */ 016package org.kuali.ole.module.purap.document.validation.impl; 017 018import org.kuali.ole.module.purap.businessobject.PurApItem; 019import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem; 020import org.kuali.ole.module.purap.document.PurchaseOrderDocument; 021import org.kuali.ole.sys.document.validation.BranchingValidation; 022import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent; 023 024public 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 @Override 038 protected String determineBranch(AttributedDocumentEvent event) { 039 PurchaseOrderDocument document = (PurchaseOrderDocument) event.getDocument(); 040 PurchaseOrderItem itemLine = (PurchaseOrderItem) getItemForValidation(); 041 if (itemLine.isItemActiveIndicator() && (!(document.getContainsUnpaidPaymentRequestsOrCreditMemos() && itemLine.getItemInvoicedTotalAmount() != null))) { 042 //This means the accounts on the item are editable, so we'll call super's processAccountValidation. 043 return PROCESS_ACCOUNT_VALIDATION; 044 } else { 045 //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. 046 return null; 047 } 048 } 049 050 public PurApItem getItemForValidation() { 051 return itemForValidation; 052 } 053 054 public void setItemForValidation(PurApItem itemForValidation) { 055 this.itemForValidation = itemForValidation; 056 } 057 058}