001/* 002 * Copyright 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.List; 019 020import org.kuali.ole.fp.service.FiscalYearFunctionControlService; 021import org.kuali.ole.sys.context.SpringContext; 022import org.kuali.ole.sys.document.Correctable; 023import org.kuali.ole.sys.document.FinancialSystemTransactionalDocument; 024import org.kuali.ole.sys.document.authorization.AccountingDocumentPresentationControllerBase; 025import org.kuali.ole.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry; 026import org.kuali.rice.kew.api.WorkflowDocument; 027import org.kuali.rice.kns.service.DataDictionaryService; 028 029/** 030 * Presentation Controller for Budget Adjustment documents 031 */ 032public class BudgetAdjustmentDocumentPresentationController extends AccountingDocumentPresentationControllerBase { 033 /** 034 * @see org.kuali.rice.krad.document.authorization.DocumentPresentationControllerBase#canInitiate(java.lang.String) 035 */ 036 @Override 037 public boolean canInitiate(String documentTypeName) { 038 List<Integer> allowedYears = SpringContext.getBean(FiscalYearFunctionControlService.class).getBudgetAdjustmentAllowedYears(); 039 040 // if no allowed years found, BA document is not allowed to be initiated 041 if (allowedYears == null || allowedYears.isEmpty()) { 042 return false; 043 } 044 045 return super.canInitiate(documentTypeName); 046 } 047 048 // TODO is there really anything specific to the BA in this logic? 049 /** 050 * @see org.kuali.ole.sys.document.authorization.LedgerPostingDocumentPresentationControllerBase#canErrorCorrect(org.kuali.ole.sys.document.FinancialSystemTransactionalDocument) 051 */ 052 @Override 053 public boolean canErrorCorrect(FinancialSystemTransactionalDocument document) { 054 final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); 055 056 if (!(document instanceof Correctable)) return false; 057 if (!((FinancialSystemTransactionalDocumentEntry)SpringContext.getBean(DataDictionaryService.class).getDataDictionary().getDocumentEntry(document.getClass().getName())).getAllowsErrorCorrection()) return false; 058 if (document.getFinancialSystemDocumentHeader().getCorrectedByDocumentId() != null) return false; 059 return (workflowDocument.isApproved() || workflowDocument.isProcessed() || workflowDocument.isFinal()); 060 } 061 062}