001/* 002 * Copyright 2007-2008 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.fp.document.authorization; 017 018import java.util.Iterator; 019import java.util.List; 020 021import org.kuali.ole.fp.businessobject.FiscalYearFunctionControl; 022import org.kuali.ole.fp.service.FiscalYearFunctionControlService; 023import org.kuali.ole.sys.context.SpringContext; 024import org.kuali.ole.sys.service.UniversityDateService; 025 026/** 027 * Document Authorizer for the Year End Budget Adjustment document. 028 */ 029public class YearEndBudgetAdjustmentDocumentPresentationController extends BudgetAdjustmentDocumentPresentationController { 030 031 /** 032 * Checks whether the BA document is active for the year end posting year. 033 * 034 * @see org.kuali.rice.kns.document.authorization.DocumentAuthorizer#canInitiate(java.lang.String, org.kuali.rice.krad.bo.user.KualiUser) 035 */ 036 @Override 037 public boolean canInitiate(String documentTypeName) { 038 List allowedYears = SpringContext.getBean(FiscalYearFunctionControlService.class).getBudgetAdjustmentAllowedYears(); 039 Integer previousPostingYear = new Integer(SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().intValue() - 1); 040 boolean previousActive = false; 041 if (allowedYears != null) { 042 for (Iterator iter = allowedYears.iterator(); iter.hasNext();) { 043 FiscalYearFunctionControl fyControl = (FiscalYearFunctionControl) iter.next(); 044 if (fyControl.getUniversityFiscalYear().equals(previousPostingYear)) { 045 previousActive = true; 046 } 047 } 048 } 049 return super.canInitiate(documentTypeName) && previousActive; 050 } 051} 052