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.endow.businessobject;
017
018 import java.util.LinkedHashMap;
019
020 import org.apache.log4j.Logger;
021 import org.kuali.kfs.coa.businessobject.Account;
022 import org.kuali.kfs.coa.businessobject.Chart;
023 import org.kuali.kfs.coa.businessobject.ObjectCodeCurrent;
024 import org.kuali.kfs.coa.businessobject.ProjectCode;
025 import org.kuali.kfs.coa.businessobject.SubAccount;
026 import org.kuali.kfs.coa.businessobject.SubObjectCodeCurrent;
027 import org.kuali.kfs.sys.KFSPropertyConstants;
028 import org.kuali.kfs.sys.businessobject.AccountingLineBase;
029 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
030 import org.kuali.rice.kns.util.KualiDecimal;
031
032 /**
033 * Provides basic implementation for the accounting lines used in the Transfer of Funds documents in the Endowment module.
034 */
035 public class EndowmentAccountingLineBase extends PersistableBusinessObjectBase implements EndowmentAccountingLine {
036 private static Logger LOG = Logger.getLogger(AccountingLineBase.class);
037
038 private String documentNumber;
039 private Integer accountingLineNumber; // relative to the grouping of acctng lines
040 private KualiDecimal amount;
041 private String organizationReferenceId;
042 protected String financialDocumentLineTypeCode;
043
044 private String chartOfAccountsCode;
045 private String accountNumber;
046 private String financialObjectCode;
047 private String subAccountNumber;
048 private String financialSubObjectCode;
049 private String projectCode;
050
051 // bo references
052 private Chart chart;
053 private Account account;
054 private ObjectCodeCurrent objectCode;
055 private SubAccount subAccount;
056 private SubObjectCodeCurrent subObjectCode;
057 private ProjectCode project;
058
059 /**
060 * This constructor sets up empty instances for the dependent objects.
061 */
062 public EndowmentAccountingLineBase() {
063 setAmount(KualiDecimal.ZERO);
064 chart = new Chart();
065 account = new Account();
066 objectCode = new ObjectCodeCurrent();
067 subAccount = new SubAccount();
068 subObjectCode = new SubObjectCodeCurrent();
069 project = new ProjectCode();
070 }
071
072
073 /**
074 * @return Returns the account.
075 */
076 public Account getAccount() {
077 return account;
078 }
079
080 /**
081 * @param account The account to set.
082 * @deprecated
083 */
084 public void setAccount(Account account) {
085 this.account = account;
086 }
087
088 /**
089 * @return Returns the chartOfAccountsCode.
090 */
091 public Chart getChart() {
092 return chart;
093 }
094
095 /**
096 * @param chart The chartOfAccountsCode to set.
097 * @deprecated
098 */
099 public void setChart(Chart chart) {
100 this.chart = chart;
101 }
102
103 /**
104 * @return Returns the documentNumber.
105 */
106 public String getDocumentNumber() {
107 return documentNumber;
108 }
109
110 /**
111 * @return Returns the amount.
112 */
113 public KualiDecimal getAmount() {
114 return amount;
115 }
116
117 /**
118 * @param amount The amount to set.
119 */
120 public void setAmount(KualiDecimal amount) {
121 this.amount = amount;
122 }
123
124 /**
125 * @return Returns the objectCode.
126 */
127 public ObjectCodeCurrent getObjectCode() {
128 return objectCode;
129 }
130
131 /**
132 * @param objectCode The objectCode to set.
133 * @deprecated
134 */
135 public void setObjectCode(ObjectCodeCurrent objectCode) {
136 this.objectCode = objectCode;
137 }
138
139 /**
140 * @return Returns the organizationReferenceId.
141 */
142 public String getOrganizationReferenceId() {
143 return organizationReferenceId;
144 }
145
146 /**
147 * @param organizationReferenceId The organizationReferenceId to set.
148 */
149 public void setOrganizationReferenceId(String organizationReferenceId) {
150 this.organizationReferenceId = organizationReferenceId;
151 }
152
153 /**
154 * Gets the accountingLineNumber.
155 *
156 * @return accountingLineNumber
157 */
158 public Integer getAccountingLineNumber() {
159 return accountingLineNumber;
160 }
161
162
163 /**
164 * Sets the accountingLineNumber.
165 *
166 * @param accountingLineNumber
167 */
168 public void setAccountingLineNumber(Integer accountingLineNumber) {
169 this.accountingLineNumber = accountingLineNumber;
170 }
171
172 /**
173 * @return Returns the projectCode.
174 */
175 public String getProjectCode() {
176 return projectCode;
177 }
178
179 /**
180 * @param projectCode The projectCode to set.
181 */
182 public void setProjectCode(String projectCode) {
183 this.projectCode = projectCode;
184 }
185
186 /**
187 * @return Returns the subAccount.
188 */
189 public SubAccount getSubAccount() {
190 return subAccount;
191 }
192
193 /**
194 * @param subAccount The subAccount to set.
195 * @deprecated
196 */
197 public void setSubAccount(SubAccount subAccount) {
198 this.subAccount = subAccount;
199 }
200
201 /**
202 * @return Returns the subObjectCode.
203 */
204 public SubObjectCodeCurrent getSubObjectCode() {
205 return subObjectCode;
206 }
207
208 /**
209 * @param subObjectCode The subObjectCode to set.
210 * @deprecated
211 */
212 public void setSubObjectCode(SubObjectCodeCurrent subObjectCode) {
213 this.subObjectCode = subObjectCode;
214 }
215
216 /**
217 * @param documentNumber The documentNumber to set.
218 */
219 public void setDocumentNumber(String documentNumber) {
220 this.documentNumber = documentNumber;
221 }
222
223 /**
224 * @return Returns the accountNumber.
225 */
226 public String getAccountNumber() {
227 return accountNumber;
228 }
229
230 /**
231 * @param accountNumber The accountNumber to set.
232 */
233 public void setAccountNumber(String accountNumber) {
234 this.accountNumber = accountNumber;
235 // if accounts can't cross charts, set chart code whenever account number is set
236 // SpringContext.getBean(AccountService.class).populateAccountingLineChartIfNeeded(this);
237 }
238
239 /**
240 * @return Returns the chartOfAccountsCode.
241 */
242 public String getChartOfAccountsCode() {
243 return chartOfAccountsCode;
244 }
245
246 /**
247 * @param chartOfAccountsCode The chartOfAccountsCode to set.
248 */
249 public void setChartOfAccountsCode(String chartOfAccountsCode) {
250 this.chartOfAccountsCode = chartOfAccountsCode;
251 }
252
253 /**
254 * @return Returns the financialObjectCode.
255 */
256 public String getFinancialObjectCode() {
257 return financialObjectCode;
258 }
259
260 /**
261 * @param financialObjectCode The financialObjectCode to set.
262 */
263 public void setFinancialObjectCode(String financialObjectCode) {
264 this.financialObjectCode = financialObjectCode;
265 }
266
267 /**
268 * @return Returns the financialSubObjectCode.
269 */
270 public String getFinancialSubObjectCode() {
271 return financialSubObjectCode;
272 }
273
274 /**
275 * @param financialSubObjectCode The financialSubObjectCode to set.
276 */
277 public void setFinancialSubObjectCode(String financialSubObjectCode) {
278 this.financialSubObjectCode = financialSubObjectCode;
279 }
280
281 /**
282 * @return Returns the financialDocumentLineTypeCode.
283 */
284 public String getFinancialDocumentLineTypeCode() {
285 return financialDocumentLineTypeCode;
286 }
287
288 /**
289 * @param financialDocumentLineTypeCode The financialDocumentLineTypeCode to set.
290 */
291 public void setFinancialDocumentLineTypeCode(String financialDocumentLineTypeCode) {
292 this.financialDocumentLineTypeCode = financialDocumentLineTypeCode;
293 }
294
295 /**
296 * @return Returns the project.
297 */
298 public ProjectCode getProject() {
299 return project;
300 }
301
302 /**
303 * @param project The project to set.
304 * @deprecated
305 */
306 public void setProject(ProjectCode project) {
307 this.project = project;
308 }
309
310 /**
311 * @return Returns the subAccountNumber.
312 */
313 public String getSubAccountNumber() {
314 return subAccountNumber;
315 }
316
317 /**
318 * @param subAccountNumber The subAccountNumber to set.
319 */
320 public void setSubAccountNumber(String subAccountNumber) {
321 this.subAccountNumber = subAccountNumber;
322 }
323
324 /**
325 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
326 */
327 protected LinkedHashMap toStringMapper() {
328 LinkedHashMap m = new LinkedHashMap();
329
330 m.put(KFSPropertyConstants.DOCUMENT_NUMBER, documentNumber);
331
332 m.put("accountingLineNumber", accountingLineNumber);
333 m.put("amount", amount);
334 m.put("chartOfAccountsCode", getChartOfAccountsCode());
335 m.put("accountNumber", getAccountNumber());
336 m.put("objectCode", getFinancialObjectCode());
337 m.put("subAccountNumber", getSubAccountNumber());
338 m.put("financialSubObjectCode", getFinancialSubObjectCode());
339 m.put("projectCode", getProjectCode());
340 m.put("organizationReferenceId", getOrganizationReferenceId());
341
342 return m;
343 }
344
345 /**
346 * @see org.kuali.kfs.module.endow.businessobject.EndowmentAccountingLine#isSourceAccountingLine()
347 */
348 public boolean isSourceAccountingLine() {
349 return (this instanceof SourceEndowmentAccountingLine);
350 }
351
352 /**
353 * @see org.kuali.kfs.module.endow.businessobject.EndowmentAccountingLine#isTargetAccountingLine()
354 */
355 public boolean isTargetAccountingLine() {
356 return (this instanceof TargetEndowmentAccountingLine);
357 }
358
359 }