View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.ld.document.web.struts;
20  
21  import java.util.List;
22  import java.util.Map;
23  
24  import javax.servlet.http.HttpServletRequest;
25  
26  import org.apache.commons.logging.Log;
27  import org.apache.commons.logging.LogFactory;
28  import org.kuali.kfs.module.ld.businessobject.ExpenseTransferAccountingLine;
29  import org.kuali.kfs.module.ld.businessobject.LedgerBalance;
30  import org.kuali.kfs.module.ld.document.SalaryExpenseTransferDocument;
31  import org.kuali.kfs.sys.KFSConstants;
32  import org.kuali.kfs.sys.KFSPropertyConstants;
33  import org.kuali.rice.core.web.format.CurrencyFormatter;
34  
35  /**
36   * Struts Action Form for the Salary Expense Transfer document. This method extends the parent ExpenseTransferDocumentFormBase class
37   * which contains all of the common form methods and form attributes needed by the Salary Expense Transfer document. It adds a new
38   * method which is a convenience method for getting at the Salary Expense Transfer document easier.
39   */
40  public class SalaryExpenseTransferForm extends ExpenseTransferDocumentFormBase {
41      protected static Log LOG = LogFactory.getLog(SalaryExpenseTransferForm.class);
42  
43      protected String balanceTypeCode;
44  
45      /**
46       * Constructs a SalaryExpenseTransferForm instance and sets up the appropriately casted document.
47       */
48      public SalaryExpenseTransferForm() {
49          super();
50  
51          setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
52          setLookupResultsBOClassName(LedgerBalance.class.getName());
53          setFormatterType(KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.APPROVAL_OBJECT_CODE_BALANCES, CurrencyFormatter.class);
54      }
55  
56      @Override
57      protected String getDefaultDocumentTypeName() {
58          return "ST";
59      }
60      
61      /**
62       * Gets the balanceTypeCode attribute.
63       * 
64       * @return Returns the balanceTypeCode.
65       */
66      public String getFinancialBalanceTypeCode() {
67          return balanceTypeCode;
68      }
69  
70      /**
71       * Sets the balanceTypeCode attribute value.
72       * 
73       * @param balanceTypeCode The balanceTypeCode to set.
74       */
75      public void setFinancialBalanceTypeCode(String balanceTypeCode) {
76          this.balanceTypeCode = balanceTypeCode;
77      }
78  
79      /**
80       * @see org.kuali.rice.kns.web.struts.pojo.PojoForm#populate(javax.servlet.http.HttpServletRequest)
81       */
82      @Override
83      public void populate(HttpServletRequest request) {
84          super.populate(request);
85      }
86  
87      /**
88       * This method returns a reference to the Salary Expense Transfer Document
89       * 
90       * @return Returns the SalaryExpenseTransferDocument.
91       */
92      public SalaryExpenseTransferDocument getSalaryExpenseTransferDocument() {
93          return (SalaryExpenseTransferDocument) getDocument();
94      }
95  
96      /**
97       * Removes fields from map if users is allowed to edit.
98       * 
99       * @see org.kuali.kfs.module.ld.document.web.struts.ExpenseTransferDocumentFormBase#getForcedReadOnlyTargetFields()
100      */
101     @Override
102     public Map getForcedReadOnlyTargetFields() {
103         Map map = this.getForcedReadOnlySourceFields();
104         map.remove(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
105         map.remove(KFSPropertyConstants.ACCOUNT_NUMBER);
106         map.remove(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
107         map.remove(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
108         map.remove(KFSPropertyConstants.PROJECT_CODE);
109         map.remove(KFSPropertyConstants.ORGANIZATION_REFERENCE_ID);
110         map.remove(KFSPropertyConstants.AMOUNT);
111 
112         return map;
113     }
114 
115     /**
116      * Populate serach fields (i.e. universal fiscal year and employee ID)
117      * 
118      * @see org.kuali.kfs.module.ld.document.web.struts.ExpenseTransferDocumentFormBase#populateSearchFields()
119      */
120     @Override
121     public void populateSearchFields() {
122         List<ExpenseTransferAccountingLine> sourceAccoutingLines = this.getSalaryExpenseTransferDocument().getSourceAccountingLines();
123         if (sourceAccoutingLines != null && !sourceAccoutingLines.isEmpty()) {
124             ExpenseTransferAccountingLine sourceAccountingLine = sourceAccoutingLines.get(0);
125             this.setUniversityFiscalYear(sourceAccountingLine.getPostingYear());
126         }
127     }
128 }
129