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.validation.impl;
17  
18  import org.kuali.ole.fp.businessobject.BudgetAdjustmentAccountingLine;
19  import org.kuali.ole.fp.document.BudgetAdjustmentDocument;
20  import org.kuali.ole.fp.service.FiscalYearFunctionControlService;
21  import org.kuali.ole.sys.OLEKeyConstants;
22  import org.kuali.ole.sys.OLEPropertyConstants;
23  import org.kuali.ole.sys.document.validation.GenericValidation;
24  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25  import org.kuali.rice.krad.util.GlobalVariables;
26  
27  /**
28   * Validates an accounting line on a budget adjustment document whether the base amount on the line can be changed or not
29   */
30  public class BudgetAdjustmentAccountingLineBaseAmountValidation extends GenericValidation {
31      private BudgetAdjustmentDocument accountingDocumentForValidation;
32      private BudgetAdjustmentAccountingLine accountingLineForValidation;
33      private FiscalYearFunctionControlService fiscalYearFunctionControlService;
34  
35      /**
36       * Validate that, if a base amount is entered for a line, that it can be adjusted for the posting year
37       * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
38       */
39      public boolean validate(AttributedDocumentEvent event) {
40          boolean allow = true;
41          if (getAccountingLineForValidation().getBaseBudgetAdjustmentAmount().isNonZero() && !fiscalYearFunctionControlService.isBaseAmountChangeAllowed(getAccountingDocumentForValidation().getPostingYear())) {
42              GlobalVariables.getMessageMap().putError(OLEPropertyConstants.BASE_BUDGET_ADJUSTMENT_AMOUNT, OLEKeyConstants.ERROR_DOCUMENT_BA_BASE_AMOUNT_CHANGE_NOT_ALLOWED);
43              allow = false;
44          }
45          return allow;
46      }
47  
48      /**
49       * Gets the accountingLineForValidation attribute. 
50       * @return Returns the accountingLineForValidation.
51       */
52      public BudgetAdjustmentAccountingLine getAccountingLineForValidation() {
53          return accountingLineForValidation;
54      }
55  
56      /**
57       * Sets the accountingLineForValidation attribute value.
58       * @param accountingLineForValidation The accountingLineForValidation to set.
59       */
60      public void setAccountingLineForValidation(BudgetAdjustmentAccountingLine accountingLineForValidation) {
61          this.accountingLineForValidation = accountingLineForValidation;
62      }
63  
64      /**
65       * Gets the fiscalYearFunctionControlService attribute. 
66       * @return Returns the fiscalYearFunctionControlService.
67       */
68      public FiscalYearFunctionControlService getFiscalYearFunctionControlService() {
69          return fiscalYearFunctionControlService;
70      }
71  
72      /**
73       * Sets the fiscalYearFunctionControlService attribute value.
74       * @param fiscalYearFunctionControlService The fiscalYearFunctionControlService to set.
75       */
76      public void setFiscalYearFunctionControlService(FiscalYearFunctionControlService fiscalYearFunctionControlService) {
77          this.fiscalYearFunctionControlService = fiscalYearFunctionControlService;
78      }
79  
80      /**
81       * Gets the accountingDocumentForValidation attribute. 
82       * @return Returns the accountingDocumentForValidation.
83       */
84      public BudgetAdjustmentDocument getAccountingDocumentForValidation() {
85          return accountingDocumentForValidation;
86      }
87  
88      /**
89       * Sets the accountingDocumentForValidation attribute value.
90       * @param accountingDocumentForValidation The accountingDocumentForValidation to set.
91       */
92      public void setAccountingDocumentForValidation(BudgetAdjustmentDocument accountingDocumentForValidation) {
93          this.accountingDocumentForValidation = accountingDocumentForValidation;
94      }
95  }