View Javadoc
1   /*
2    * Copyright 2007-2008 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.fp.document.authorization;
17  
18  import java.util.Iterator;
19  import java.util.List;
20  
21  import org.kuali.ole.fp.businessobject.FiscalYearFunctionControl;
22  import org.kuali.ole.fp.service.FiscalYearFunctionControlService;
23  import org.kuali.ole.sys.context.SpringContext;
24  import org.kuali.ole.sys.service.UniversityDateService;
25  
26  /**
27   * Document Authorizer for the Year End Budget Adjustment document.
28   */
29  public class YearEndBudgetAdjustmentDocumentPresentationController extends BudgetAdjustmentDocumentPresentationController {
30  
31      /**
32       * Checks whether the BA document is active for the year end posting year.
33       * 
34       * @see org.kuali.rice.kns.document.authorization.DocumentAuthorizer#canInitiate(java.lang.String, org.kuali.rice.krad.bo.user.KualiUser)
35       */
36      @Override
37      public boolean canInitiate(String documentTypeName) {
38          List allowedYears = SpringContext.getBean(FiscalYearFunctionControlService.class).getBudgetAdjustmentAllowedYears();
39          Integer previousPostingYear = new Integer(SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().intValue() - 1);
40          boolean previousActive = false;
41  		if (allowedYears != null) {
42              for (Iterator iter = allowedYears.iterator(); iter.hasNext();) {
43                  FiscalYearFunctionControl fyControl = (FiscalYearFunctionControl) iter.next();
44                  if (fyControl.getUniversityFiscalYear().equals(previousPostingYear)) {
45                      previousActive = true;
46                  }
47              }
48          }
49          return super.canInitiate(documentTypeName) && previousActive;
50      }
51  }
52