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