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.document.PurchaseOrderDocument;
020 import org.kuali.kfs.module.purap.document.service.PurapService;
021 import org.kuali.kfs.module.purap.document.service.PurchaseOrderService;
022 import org.kuali.kfs.sys.KFSConstants;
023 import org.kuali.kfs.sys.context.SpringContext;
024 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
025
026 public class PurchaseOrderAmendmentRequiresAccountValidationBranchingValidation extends PurchaseOrderRequiresAccountValidationBranchingValidation {
027
028 protected PurchaseOrderService purchaseOrderService;
029 protected PurapService purapService;
030
031 @Override
032 protected String determineBranch(AttributedDocumentEvent event) {
033 PurchaseOrderDocument document = (PurchaseOrderDocument)event.getDocument();
034 // If a new unordered item has been added to the purchase order, this is due to Receiving Line document,
035 // and items should not have account validation performed initially, until new unordered items review.
036 if( SpringContext.getBean(PurchaseOrderService.class).hasNewUnorderedItem(document) &&
037 !SpringContext.getBean(PurapService.class).isDocumentStoppedInRouteNode(document, "New Unordered Items") ){
038 return KFSConstants.EMPTY_STRING;
039 }else{
040 return super.determineBranch(event);
041 }
042 }
043
044 public PurchaseOrderService getPurchaseOrderService() {
045 return purchaseOrderService;
046 }
047
048 public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService) {
049 this.purchaseOrderService = purchaseOrderService;
050 }
051
052 public PurapService getPurapService() {
053 return purapService;
054 }
055
056 public void setPurapService(PurapService purapService) {
057 this.purapService = purapService;
058 }
059
060
061 }