View Javadoc
1   /*
2    * Copyright 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.List;
19  
20  import org.kuali.ole.fp.service.FiscalYearFunctionControlService;
21  import org.kuali.ole.sys.context.SpringContext;
22  import org.kuali.ole.sys.document.Correctable;
23  import org.kuali.ole.sys.document.FinancialSystemTransactionalDocument;
24  import org.kuali.ole.sys.document.authorization.AccountingDocumentPresentationControllerBase;
25  import org.kuali.ole.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry;
26  import org.kuali.rice.kew.api.WorkflowDocument;
27  import org.kuali.rice.kns.service.DataDictionaryService;
28  
29  /**
30   * Presentation Controller for Budget Adjustment documents
31   */
32  public class BudgetAdjustmentDocumentPresentationController extends AccountingDocumentPresentationControllerBase {
33      /**
34       * @see org.kuali.rice.krad.document.authorization.DocumentPresentationControllerBase#canInitiate(java.lang.String)
35       */
36      @Override
37      public boolean canInitiate(String documentTypeName) {
38          List<Integer> allowedYears = SpringContext.getBean(FiscalYearFunctionControlService.class).getBudgetAdjustmentAllowedYears();
39  
40          // if no allowed years found, BA document is not allowed to be initiated
41          if (allowedYears == null || allowedYears.isEmpty()) {
42              return false;
43          }
44  
45          return super.canInitiate(documentTypeName);
46      }
47  
48      // TODO is there really anything specific to the BA in this logic?
49      /**
50       * @see org.kuali.ole.sys.document.authorization.LedgerPostingDocumentPresentationControllerBase#canErrorCorrect(org.kuali.ole.sys.document.FinancialSystemTransactionalDocument)
51       */
52      @Override
53      public boolean canErrorCorrect(FinancialSystemTransactionalDocument document) {
54          final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
55  
56          if (!(document instanceof Correctable)) return false;
57          if (!((FinancialSystemTransactionalDocumentEntry)SpringContext.getBean(DataDictionaryService.class).getDataDictionary().getDocumentEntry(document.getClass().getName())).getAllowsErrorCorrection()) return false;
58          if (document.getFinancialSystemDocumentHeader().getCorrectedByDocumentId() != null) return false;
59          return (workflowDocument.isApproved() || workflowDocument.isProcessed() || workflowDocument.isFinal());
60      }
61  
62  }