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.module.ld.document.web.struts;
017
018 import java.util.List;
019 import java.util.Map;
020
021 import org.kuali.kfs.module.ld.document.BenefitExpenseTransferDocument;
022 import org.kuali.kfs.sys.KFSPropertyConstants;
023 import org.kuali.kfs.sys.KFSConstants;
024 import org.kuali.kfs.sys.businessobject.SourceAccountingLine;
025
026 /**
027 * Struts Action Form for the Benefit Expense Transfer Document.
028 */
029 public class BenefitExpenseTransferForm extends ExpenseTransferDocumentFormBase {
030
031 protected String chartOfAccountsCode;
032 protected String accountNumber;
033 protected String subAccountNumber;
034
035 /**
036 * Constructs a BenefitExpenseTransferForm instance and sets up the appropriately casted document.
037 */
038 public BenefitExpenseTransferForm() {
039 super();
040 }
041
042 @Override
043 protected String getDefaultDocumentTypeName() {
044 return "BT";
045 }
046
047 /**
048 * Gets the BenefitExpenseTransferDocument attribute.
049 *
050 * @return Returns the BenefitExpenseTransferDocument
051 */
052 public BenefitExpenseTransferDocument getBenefitExpenseTransferDocument() {
053 return (BenefitExpenseTransferDocument) getDocument();
054 }
055
056 /**
057 * Gets the accountNumber attribute.
058 *
059 * @return Returns the accountNumber.
060 */
061 public String getAccountNumber() {
062 return accountNumber;
063 }
064
065 /**
066 * Sets the accountNumber attribute value.
067 *
068 * @param accountNumber The accountNumber to set.
069 */
070 public void setAccountNumber(String accountNumber) {
071 this.accountNumber = accountNumber;
072 }
073
074 /**
075 * Gets the subAccountNumber attribute.
076 *
077 * @return Return the subAccountNumber.
078 */
079 public String getSubAccountNumber() {
080 return subAccountNumber;
081 }
082
083 /**
084 * Sets the subAccountNumber attribute value.
085 *
086 * @param subAccountNumber The subAccountNumber to set.
087 */
088 public void setSubAccountNumber(String subAccountNumber) {
089 this.subAccountNumber = subAccountNumber;
090 }
091
092 /**
093 * Gets the chartOfAccountsCode attribute.
094 *
095 * @return Return the chartOfAccountsCode.
096 */
097 public String getChartOfAccountsCode() {
098 return chartOfAccountsCode;
099 }
100
101 /**
102 * Sets the chartOfAccountsCode attribute value.
103 *
104 * @param chartOfAccountsCode The chartOfAccountsCode to set.
105 */
106 public void setChartOfAccountsCode(String chartOfAccountsCode) {
107 this.chartOfAccountsCode = chartOfAccountsCode;
108 }
109
110 /**
111 * Returns forced read only target fields (i.e only source target fields without chart of accounts code,
112 * account number, sub-account number, financial sub object code, project code, organization reference id, and amount)
113 *
114 * @see org.kuali.kfs.module.ld.document.web.struts.ExpenseTransferDocumentFormBase#getForcedReadOnlyTargetFields()
115 */
116 @Override
117 public Map getForcedReadOnlyTargetFields() {
118 Map map = this.getForcedReadOnlySourceFields();
119 map.remove(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
120 map.remove(KFSPropertyConstants.ACCOUNT_NUMBER);
121 map.remove(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
122 map.remove(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
123 map.remove(KFSPropertyConstants.PROJECT_CODE);
124 map.remove(KFSPropertyConstants.ORGANIZATION_REFERENCE_ID);
125 map.remove(KFSPropertyConstants.AMOUNT);
126
127 return map;
128 }
129
130 /**
131 * Sets university fiscal year, chart of accounts code, account number, sub-account number from first source accounting line
132 *
133 * @see org.kuali.kfs.module.ld.document.web.struts.ExpenseTransferDocumentFormBase#populateSearchFields()
134 */
135 @Override
136 public void populateSearchFields() {
137 List<SourceAccountingLine> sourceAccoutingLines = this.getBenefitExpenseTransferDocument().getSourceAccountingLines();
138 if (sourceAccoutingLines != null && !sourceAccoutingLines.isEmpty()) {
139 SourceAccountingLine sourceAccountingLine = sourceAccoutingLines.get(0);
140 this.setUniversityFiscalYear(sourceAccountingLine.getPostingYear());
141 this.setChartOfAccountsCode(sourceAccountingLine.getChartOfAccountsCode());
142 this.setAccountNumber(sourceAccountingLine.getAccountNumber());
143 this.setSubAccountNumber(sourceAccountingLine.getSubAccountNumber());
144 if (sourceAccountingLine.getSubAccountNumber() == null) {
145 this.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
146 }
147 }
148 }
149 }