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 org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.fp.document.BudgetAdjustmentDocument;
20 import org.kuali.ole.fp.service.FiscalYearFunctionControlService;
21 import org.kuali.ole.sys.businessobject.AccountingLine;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.ole.sys.document.AccountingDocument;
24 import org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase;
25
26 /**
27 * The line authorizer for Budget Adjustment documents, which makes the base amount read only if it can't be edited for the given
28 * fiscal year
29 */
30 public class BudgetAdjustmentAccountingLineAuthorizer extends AccountingLineAuthorizerBase {
31
32 /**
33 * Overridden to make base amount read only if it is not available to be edited for the given fiscal year
34 *
35 * @see org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase#determineFieldModifyability(org.kuali.ole.sys.document.AccountingDocument,
36 * org.kuali.ole.sys.businessobject.AccountingLine, org.kuali.ole.sys.document.web.AccountingLineViewField, java.util.Map)
37 */
38 @Override
39 public boolean determineEditPermissionOnField(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, String fieldName, boolean editablePage) {
40 final boolean canModify = super.determineEditPermissionOnField(accountingDocument, accountingLine, accountingLineCollectionProperty, fieldName, editablePage);
41
42 if (StringUtils.equals(fieldName, getBaseAmountPropertyName())) {
43 return SpringContext.getBean(FiscalYearFunctionControlService.class).isBaseAmountChangeAllowed(((BudgetAdjustmentDocument) accountingDocument).getPostingYear());
44 }
45
46 return canModify;
47 }
48
49 /**
50 * @return the property name of the base amount field, which will be set to read only under certain conditions
51 */
52 protected String getBaseAmountPropertyName() {
53 return "baseBudgetAdjustmentAmount";
54 }
55 }