View Javadoc
1   /*
2    * Copyright 2007 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.fp.businessobject;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.coa.businessobject.ObjectType;
20  import org.kuali.ole.sys.OLEConstants;
21  import org.kuali.ole.sys.businessobject.SourceAccountingLine;
22  import org.kuali.rice.krad.util.ObjectUtils;
23  
24  
25  /**
26   * Special case <code>{@link SourceAccountingLine}</code> type for <code>{@link org.kuali.ole.fp.document.VoucherDocument}</code>
27   */
28  public class VoucherSourceAccountingLine extends SourceAccountingLine {
29      private String objectTypeCode;
30      private ObjectType objectType;
31  
32      /**
33       * Constructs a VoucherSourceAccountingLine.java.
34       */
35      public VoucherSourceAccountingLine() {
36          super();
37  
38          // default is debit. This is important for single sided accounting lines (example: JV w/BB) so that
39          // totals get calculated correctly
40          this.setDebitCreditCode(OLEConstants.GL_DEBIT_CODE);
41      }
42  
43      /**
44       * Gets the objectType attribute.
45       * 
46       * @return Returns the objectType.
47       */
48      
49      public ObjectType getObjectType() {
50          return objectType;
51      }
52  
53      /**
54       * Sets the objectType attribute value.
55       * 
56       * @param objectType The objectType to set.
57       */
58      public void setObjectType(ObjectType objectType) {
59          this.objectType = objectType;
60      }
61  
62      /**
63       * Gets the objectTypeCode attribute.
64       * 
65       * @return Returns the objectTypeCode.
66       */
67      @Override
68      public String getObjectTypeCode() {
69          return objectTypeCode;
70      }
71  
72      /**
73       * Sets the objectTypeCode attribute value.
74       * 
75       * @param objectTypeCode The objectTypeCode to set.
76       */
77      public void setObjectTypeCode(String objectTypeCode) {
78          this.objectTypeCode = objectTypeCode;
79      }
80  
81      /**
82       * Overridden to automatically set the object type code on the setting of the object code - if the object type code is blank
83       * 
84       * @see org.kuali.ole.sys.businessobject.AccountingLineBase#setFinancialObjectCode(java.lang.String)
85       */
86      @Override
87      public void setFinancialObjectCode(String financialObjectCode) {
88          super.setFinancialObjectCode(financialObjectCode);
89          if (StringUtils.isBlank(getObjectTypeCode()) && !StringUtils.isBlank(getFinancialObjectCode())) {
90              refreshReferenceObject("objectCode");
91              if (!ObjectUtils.isNull(getObjectCode())) {
92                  setObjectTypeCode(getObjectCode().getFinancialObjectTypeCode());
93              }
94          }
95      }
96  
97  }