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.fp.document.authorization; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.kuali.kfs.fp.document.BudgetAdjustmentDocument; 020 import org.kuali.kfs.fp.service.FiscalYearFunctionControlService; 021 import org.kuali.kfs.sys.businessobject.AccountingLine; 022 import org.kuali.kfs.sys.context.SpringContext; 023 import org.kuali.kfs.sys.document.AccountingDocument; 024 import org.kuali.kfs.sys.document.authorization.AccountingLineAuthorizerBase; 025 import org.kuali.kfs.sys.document.web.AccountingLineViewField; 026 027 /** 028 * The line authorizer for Budget Adjustment documents, which makes the base amount read only if it can't be edited for the given 029 * fiscal year 030 */ 031 public class BudgetAdjustmentAccountingLineAuthorizer extends AccountingLineAuthorizerBase { 032 033 /** 034 * Overridden to make base amount read only if it is not available to be edited for the given fiscal year 035 * 036 * @see org.kuali.kfs.sys.document.authorization.AccountingLineAuthorizerBase#determineFieldModifyability(org.kuali.kfs.sys.document.AccountingDocument, 037 * org.kuali.kfs.sys.businessobject.AccountingLine, org.kuali.kfs.sys.document.web.AccountingLineViewField, java.util.Map) 038 */ 039 @Override 040 public boolean determineEditPermissionOnField(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, String fieldName, boolean editablePage) { 041 final boolean canModify = super.determineEditPermissionOnField(accountingDocument, accountingLine, accountingLineCollectionProperty, fieldName, editablePage); 042 043 if (StringUtils.equals(fieldName, getBaseAmountPropertyName())) { 044 return SpringContext.getBean(FiscalYearFunctionControlService.class).isBaseAmountChangeAllowed(((BudgetAdjustmentDocument) accountingDocument).getPostingYear()); 045 } 046 047 return canModify; 048 } 049 050 /** 051 * @return the property name of the base amount field, which will be set to read only under certain conditions 052 */ 053 protected String getBaseAmountPropertyName() { 054 return "baseBudgetAdjustmentAmount"; 055 } 056 }