View Javadoc
1   /*
2    * Copyright 2005-2006 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.gl.businessobject;
17  
18  import java.sql.Date;
19  import java.sql.Timestamp;
20  import java.util.LinkedHashMap;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.kuali.ole.coa.businessobject.Account;
24  import org.kuali.ole.coa.businessobject.BalanceType;
25  import org.kuali.ole.coa.businessobject.Chart;
26  import org.kuali.ole.coa.businessobject.ObjectCode;
27  import org.kuali.ole.coa.businessobject.SubAccount;
28  import org.kuali.ole.coa.businessobject.SubObjectCode;
29  import org.kuali.ole.sys.OLEPropertyConstants;
30  import org.kuali.ole.sys.businessobject.OriginationCode;
31  import org.kuali.ole.sys.businessobject.SystemOptions;
32  import org.kuali.ole.sys.context.SpringContext;
33  import org.kuali.rice.core.api.util.type.KualiDecimal;
34  import org.kuali.rice.kew.api.doctype.DocumentTypeService;
35  import org.kuali.rice.kew.doctype.bo.DocumentType;
36  import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO;
37  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
38  
39  /**
40   * Represents the encumbrance amount for a specific university fiscal year, 
41   * chart of accounts code, account number, sub account number, object code,
42   * sub object code, balance type code, document type code, origin code, and document number.
43   * This encumbrance object contains amounts for actual enumbrance amount, closed amount,
44   * outstanding amount 
45   * 
46  */
47  public class Encumbrance extends PersistableBusinessObjectBase {
48      static final long serialVersionUID = -7494473472438516396L;
49  
50      private Integer universityFiscalYear;
51      private String chartOfAccountsCode;
52      private String accountNumber;
53      private String subAccountNumber;
54      private String objectCode;
55      private String subObjectCode;
56      private String balanceTypeCode;
57      private String documentTypeCode;
58      private String originCode;
59      private String documentNumber;
60      private String transactionEncumbranceDescription;
61      private Date transactionEncumbranceDate;
62      private KualiDecimal accountLineEncumbranceAmount;
63      private KualiDecimal accountLineEncumbranceClosedAmount;
64      private KualiDecimal accountLineEncumbranceOutstandingAmount;
65      private String accountLineEncumbrancePurgeCode;
66      private Timestamp timestamp;
67  
68      private SubAccount subAccount;
69      private Chart chart;
70      private Account account;
71      private SubObjectCode financialSubObject;
72      private DocumentTypeEBO financialSystemDocumentTypeCode;
73  
74      private ObjectCode financialObject;
75      private BalanceType balanceType;
76      private OriginationCode originationCode;
77      private SystemOptions option;
78  
79      private TransientBalanceInquiryAttributes dummyBusinessObject;
80  
81      public Encumbrance() {
82      }
83  
84      public Encumbrance(Transaction t) {
85          universityFiscalYear = t.getUniversityFiscalYear();
86          chartOfAccountsCode = t.getChartOfAccountsCode();
87          accountNumber = t.getAccountNumber();
88          subAccountNumber = t.getSubAccountNumber();
89          objectCode = t.getFinancialObjectCode();
90          subObjectCode = t.getFinancialSubObjectCode();
91          balanceTypeCode = t.getFinancialBalanceTypeCode();
92          documentTypeCode = t.getFinancialDocumentTypeCode();
93          originCode = t.getFinancialSystemOriginationCode();
94          documentNumber = t.getDocumentNumber();
95          transactionEncumbranceDescription = t.getTransactionLedgerEntryDescription();
96          transactionEncumbranceDate = t.getTransactionDate();
97          accountLineEncumbranceAmount = KualiDecimal.ZERO;
98          accountLineEncumbranceClosedAmount = KualiDecimal.ZERO;
99          accountLineEncumbrancePurgeCode = " ";
100         this.dummyBusinessObject = new TransientBalanceInquiryAttributes();
101     }
102 
103     /**
104      * Constructs a AccountBalance.java per the primary keys only of the passed in accountBalanceHistory
105      * @param accountBalanceHistory
106      */
107     public Encumbrance(EncumbranceHistory encumbranceHistory) {
108         universityFiscalYear = encumbranceHistory.getUniversityFiscalYear();
109         chartOfAccountsCode = encumbranceHistory.getChartOfAccountsCode();
110         accountNumber = encumbranceHistory.getAccountNumber();
111         subAccountNumber = encumbranceHistory.getSubAccountNumber();
112         objectCode = encumbranceHistory.getObjectCode();
113         subObjectCode = encumbranceHistory.getSubObjectCode();
114         balanceTypeCode = encumbranceHistory.getBalanceTypeCode();
115         documentTypeCode = encumbranceHistory.getDocumentTypeCode();
116         originCode = encumbranceHistory.getOriginCode();
117         documentNumber = encumbranceHistory.getDocumentNumber();
118     }
119 
120     
121     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
122         LinkedHashMap map = new LinkedHashMap();
123         map.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, getUniversityFiscalYear());
124         map.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, getChartOfAccountsCode());
125         map.put(OLEPropertyConstants.ACCOUNT_NUMBER, getAccountNumber());
126         map.put(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, getSubAccountNumber());
127         map.put(OLEPropertyConstants.OBJECT_CODE, getObjectCode());
128         map.put(OLEPropertyConstants.SUB_OBJECT_CODE, getSubObjectCode());
129         map.put(OLEPropertyConstants.BALANCE_TYPE_CODE, getBalanceTypeCode());
130         map.put(OLEPropertyConstants.ENCUMBRANCE_DOCUMENT_TYPE_CODE, getDocumentTypeCode());
131         map.put(OLEPropertyConstants.ORIGIN_CODE, getOriginCode());
132         map.put(OLEPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
133         map.put(OLEPropertyConstants.ACCOUNT_LINE_ENCUMBRANCE_AMOUNT, getAccountLineEncumbranceAmount());
134         map.put(OLEPropertyConstants.ACCOUNT_LINE_ENCUMBRANCE_CLOSED_AMOUNT, getAccountLineEncumbranceClosedAmount());
135         return map;
136     }
137 
138     public OriginationCode getOriginationCode() {
139         return originationCode;
140     }
141 
142     public void setOriginationCode(OriginationCode originationCode) {
143         this.originationCode = originationCode;
144     }
145 
146     /**
147      * @return Returns the accountLineEncumbranceAmount.
148      */
149     public KualiDecimal getAccountLineEncumbranceAmount() {
150         return accountLineEncumbranceAmount;
151     }
152 
153     /**
154      * @param accountLineEncumbranceAmount The accountLineEncumbranceAmount to set.
155      */
156     public void setAccountLineEncumbranceAmount(KualiDecimal accountLineEncumbranceAmount) {
157         this.accountLineEncumbranceAmount = accountLineEncumbranceAmount;
158     }
159 
160     /**
161      * @return Returns the accountLineEncumbranceClearedAmount.
162      */
163     public KualiDecimal getAccountLineEncumbranceClosedAmount() {
164         return accountLineEncumbranceClosedAmount;
165     }
166 
167     public void setAccountLineEncumbranceOutstandingAmount() {
168     }
169 
170     public KualiDecimal getAccountLineEncumbranceOutstandingAmount() {
171         return accountLineEncumbranceAmount.subtract(accountLineEncumbranceClosedAmount);
172     }
173 
174     /**
175      * @param accountLineEncumbranceClearedAmount The accountLineEncumbranceClearedAmount to set.
176      */
177     public void setAccountLineEncumbranceClosedAmount(KualiDecimal accountLineEncumbranceClosedAmount) {
178         this.accountLineEncumbranceClosedAmount = accountLineEncumbranceClosedAmount;
179     }
180 
181     /**
182      * @return Returns the accountLineEncumbrancePrg.
183      */
184     public String getAccountLineEncumbrancePurgeCode() {
185         return accountLineEncumbrancePurgeCode;
186     }
187 
188     /**
189      * @param accountLineEncumbrancePrg The accountLineEncumbrancePrg to set.
190      */
191     public void setAccountLineEncumbrancePurgeCode(String accountLineEncumbrancePurgeCode) {
192         this.accountLineEncumbrancePurgeCode = accountLineEncumbrancePurgeCode;
193     }
194 
195     /**
196      * @return Returns the accountNumber.
197      */
198     public String getAccountNumber() {
199         return accountNumber;
200     }
201 
202     /**
203      * @param accountNumber The accountNumber to set.
204      */
205     public void setAccountNumber(String accountNumber) {
206         this.accountNumber = accountNumber;
207     }
208 
209     /**
210      * @return Returns the balanceTypeCode.
211      */
212     public String getBalanceTypeCode() {
213         return balanceTypeCode;
214     }
215 
216     /**
217      * @param balanceTypeCode The balanceTypeCode to set.
218      */
219     public void setBalanceTypeCode(String balanceTypeCode) {
220         this.balanceTypeCode = balanceTypeCode;
221     }
222 
223     /**
224      * @return Returns the chartOfAccountsCode.
225      */
226     public String getChartOfAccountsCode() {
227         return chartOfAccountsCode;
228     }
229 
230     /**
231      * @param chartOfAccountsCode The chartOfAccountsCode to set.
232      */
233     public void setChartOfAccountsCode(String chartOfAccountsCode) {
234         this.chartOfAccountsCode = chartOfAccountsCode;
235     }
236 
237     /**
238      * @return Returns the documentNumber.
239      */
240     public String getDocumentNumber() {
241         return documentNumber;
242     }
243 
244     /**
245      * @param documentNumber The documentNumber to set.
246      */
247     public void setDocumentNumber(String documentNumber) {
248         this.documentNumber = documentNumber;
249     }
250 
251     /**
252      * @return Returns the documentTypeCode.
253      */
254     public String getDocumentTypeCode() {
255         return documentTypeCode;
256     }
257 
258     /**
259      * @param documentTypeCode The documentTypeCode to set.
260      */
261     public void setDocumentTypeCode(String documentTypeCode) {
262         this.documentTypeCode = documentTypeCode;
263     }
264 
265     /**
266      * @return Returns the objectCode.
267      */
268     public String getObjectCode() {
269         return objectCode;
270     }
271 
272     /**
273      * @param objectCode The objectCode to set.
274      */
275     public void setObjectCode(String objectCode) {
276         this.objectCode = objectCode;
277     }
278 
279     /**
280      * @return Returns the originCode.
281      */
282     public String getOriginCode() {
283         return originCode;
284     }
285 
286     /**
287      * @param originCode The originCode to set.
288      */
289     public void setOriginCode(String originCode) {
290         this.originCode = originCode;
291     }
292 
293     /**
294      * @return Returns the subAccountNumber.
295      */
296     public String getSubAccountNumber() {
297         return subAccountNumber;
298     }
299 
300     /**
301      * @param subAccountNumber The subAccountNumber to set.
302      */
303     public void setSubAccountNumber(String subAccountNumber) {
304         this.subAccountNumber = subAccountNumber;
305     }
306 
307     /**
308      * @return Returns the subObjectCode.
309      */
310     public String getSubObjectCode() {
311         return subObjectCode;
312     }
313 
314     /**
315      * @param subObjectCode The subObjectCode to set.
316      */
317     public void setSubObjectCode(String subObjectCode) {
318         this.subObjectCode = subObjectCode;
319     }
320 
321     /**
322      * @return Returns the timestamp.
323      */
324     public Timestamp getTimestamp() {
325         return timestamp;
326     }
327 
328     /**
329      * @param timestamp The timestamp to set.
330      */
331     public void setTimestamp(Timestamp timestamp) {
332         this.timestamp = timestamp;
333     }
334 
335     /**
336      * @return Returns the transactionEncumbranceDate.
337      */
338     public Date getTransactionEncumbranceDate() {
339         return transactionEncumbranceDate;
340     }
341 
342     /**
343      * @param transactionEncumbranceDate The transactionEncumbranceDate to set.
344      */
345     public void setTransactionEncumbranceDate(Date transactionEncumbranceDate) {
346         this.transactionEncumbranceDate = transactionEncumbranceDate;
347     }
348 
349     /**
350      * @return Returns the transactionEncumbranceDescription.
351      */
352     public String getTransactionEncumbranceDescription() {
353         return transactionEncumbranceDescription;
354     }
355 
356     /**
357      * @param transactionEncumbranceDescription The transactionEncumbranceDescription to set.
358      */
359     public void setTransactionEncumbranceDescription(String transactionEncumbranceDescription) {
360         this.transactionEncumbranceDescription = transactionEncumbranceDescription;
361     }
362 
363     /**
364      * @return Returns the universityFiscalYear.
365      */
366     public Integer getUniversityFiscalYear() {
367         return universityFiscalYear;
368     }
369 
370     /**
371      * @param universityFiscalYear The universityFiscalYear to set.
372      */
373     public void setUniversityFiscalYear(Integer universityFiscalYear) {
374         this.universityFiscalYear = universityFiscalYear;
375     }
376 
377     /**
378      * Gets the account attribute.
379      * 
380      * @return Returns the account.
381      */
382     public Account getAccount() {
383         return account;
384     }
385 
386     /**
387      * Sets the account attribute value.
388      * 
389      * @param account The account to set.
390      */
391     public void setAccount(Account account) {
392         this.account = account;
393     }
394 
395     /**
396      * Gets the chart attribute.
397      * 
398      * @return Returns the chart.
399      */
400     public Chart getChart() {
401         return chart;
402     }
403 
404     /**
405      * Sets the chart attribute value.
406      * 
407      * @param chart The chart to set.
408      */
409     public void setChart(Chart chart) {
410         this.chart = chart;
411     }
412 
413     /**
414      * Gets the financialObject attribute.
415      * 
416      * @return Returns the financialObject.
417      */
418     public ObjectCode getFinancialObject() {
419         return financialObject;
420     }
421 
422     /**
423      * Sets the financialObject attribute value.
424      * 
425      * @param financialObject The financialObject to set.
426      */
427     public void setFinancialObject(ObjectCode financialObject) {
428         this.financialObject = financialObject;
429     }
430 
431     /**
432      * Gets the balanceType attribute.
433      * 
434      * @return Returns the balanceType.
435      */
436     public BalanceType getBalanceType() {
437         return balanceType;
438     }
439 
440     /**
441      * Sets the balanceType attribute value.
442      * 
443      * @param balanceType The balanceType to set.
444      */
445     public void setBalanceType(BalanceType balanceType) {
446         this.balanceType = balanceType;
447     }
448 
449     /**
450      * Gets the dummyBusinessObject attribute.
451      * 
452      * @return Returns the dummyBusinessObject.
453      */
454     public TransientBalanceInquiryAttributes getDummyBusinessObject() {
455         return dummyBusinessObject;
456     }
457 
458     /**
459      * Sets the dummyBusinessObject attribute value.
460      * 
461      * @param dummyBusinessObject The dummyBusinessObject to set.
462      */
463     public void setDummyBusinessObject(TransientBalanceInquiryAttributes dummyBusinessObject) {
464         this.dummyBusinessObject = dummyBusinessObject;
465     }
466 
467     /**
468      * Gets the option attribute.
469      * 
470      * @return Returns the option.
471      */
472     public SystemOptions getOption() {
473         return option;
474     }
475 
476     /**
477      * Sets the option attribute value.
478      * 
479      * @param option The option to set.
480      */
481     public void setOption(SystemOptions option) {
482         this.option = option;
483     }
484 
485     /**
486      * Gets the subAccount attribute.
487      * 
488      * @return Returns the subAccount.
489      */
490     public SubAccount getSubAccount() {
491         return subAccount;
492     }
493 
494     /**
495      * Sets the subAccount attribute value.
496      * 
497      * @param subAccount The subAccount to set.
498      */
499     public void setSubAccount(SubAccount subAccount) {
500         this.subAccount = subAccount;
501     }
502 
503     /**
504      * Gets the financialSystemDocumentTypeCode attribute. 
505      * @return Returns the financialSystemDocumentTypeCode.
506      */
507     public DocumentTypeEBO getFinancialSystemDocumentTypeCode() {
508         if ( StringUtils.isBlank( documentTypeCode ) ) {
509             financialSystemDocumentTypeCode = null;
510         } else {
511             if ( financialSystemDocumentTypeCode == null || !StringUtils.equals(documentTypeCode, financialSystemDocumentTypeCode.getName() ) ) {
512                 org.kuali.rice.kew.api.doctype.DocumentType temp = SpringContext.getBean(DocumentTypeService.class).getDocumentTypeByName(documentTypeCode);
513                 if ( temp != null ) {
514                     financialSystemDocumentTypeCode = DocumentType.from( temp );
515                 } else {
516                     financialSystemDocumentTypeCode = null;
517                 }
518             }
519         }
520         return financialSystemDocumentTypeCode;
521     }
522 
523     /**
524      * Gets the financialSubObject attribute.
525      * 
526      * @return Returns the financialSubObject.
527      */
528     public SubObjectCode getFinancialSubObject() {
529         return financialSubObject;
530     }
531 
532     /**
533      * Sets the financialSubObject attribute value.
534      * 
535      * @param financialSubObject The financialSubObject to set.
536      */
537     public void setFinancialSubObject(SubObjectCode financialSubObject) {
538         this.financialSubObject = financialSubObject;
539     }
540 }