View Javadoc
1   /*
2    * Copyright 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  
17  package org.kuali.ole.module.purap.businessobject;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.kuali.ole.module.purap.util.PurApObjectUtils;
21  import org.kuali.ole.sys.businessobject.AccountingLineBase;
22  import org.kuali.rice.core.api.util.type.KualiDecimal;
23  
24  import java.math.BigDecimal;
25  
26  /**
27   * Payment Request Account Business Object.
28   */
29  public class InvoiceAccount extends PurApAccountingLineBase {
30  
31      private KualiDecimal disencumberedAmount = KualiDecimal.ZERO;
32      private KualiDecimal existingAmount;
33      private BigDecimal bigDecimalAmount;
34  
35      /**
36       * Default constructor.
37       */
38      public InvoiceAccount() {
39          this.setAmount(null);
40          this.setAccountLinePercent(null);
41          this.setSequenceNumber(0);
42      }
43  
44      /**
45       * Constructor.
46       *
47       * @param item - payment request item
48       * @param poa  - purchase order account
49       */
50      public InvoiceAccount(InvoiceItem item, PurchaseOrderAccount poa) {
51          this();
52          // copy base attributes
53          PurApObjectUtils.populateFromBaseClass(AccountingLineBase.class, poa, this);
54          // copy percent
55          this.setSequenceNumber(poa.getSequenceNumber());
56          this.setAccountLinePercent(poa.getAccountLinePercent());
57          setItemIdentifier(item.getItemIdentifier());
58          setInvoiceItem(item);
59      }
60  
61      public KualiDecimal getDisencumberedAmount() {
62          return disencumberedAmount;
63      }
64  
65      public void setDisencumberedAmount(KualiDecimal disencumberedAmount) {
66          this.disencumberedAmount = disencumberedAmount;
67      }
68  
69      public InvoiceItem getInvoiceItem() {
70          return super.getPurapItem();
71      }
72  
73      public void setInvoiceItem(InvoiceItem invoiceItem) {
74          super.setPurapItem(invoiceItem);
75      }
76  
77      /**
78       * Caller of this method should take care of creating InvoiceItems
79       */
80      public void copyFrom(InvoiceAccount other) {
81          super.copyFrom(other);
82          setDisencumberedAmount(other.getDisencumberedAmount());
83      }
84  
85      @Override
86      public void setFinancialSubObjectCode(String financialSubObjectCode) {
87          super.setFinancialSubObjectCode(StringUtils.trimToNull(financialSubObjectCode));
88      }
89  
90      @Override
91      public void setFinancialObjectCode(String financialObjectCode) {
92          super.setFinancialObjectCode(StringUtils.trimToNull(financialObjectCode));
93      }
94  
95      @Override
96      public void setChartOfAccountsCode(String chartOfAccountsCode) {
97          super.setChartOfAccountsCode(StringUtils.trimToNull(chartOfAccountsCode));
98      }
99  
100     @Override
101     public void setBalanceTypeCode(String balanceTypeCode) {
102         super.setBalanceTypeCode(StringUtils.trimToNull(balanceTypeCode));
103     }
104 
105     @Override
106     public void setAccountNumber(String accountNumber) {
107         super.setAccountNumber(StringUtils.trimToNull(accountNumber));
108     }
109 
110     @Override
111     public void setReferenceTypeCode(String referenceTypeCode) {
112         super.setReferenceTypeCode(StringUtils.trimToNull(referenceTypeCode));
113     }
114 
115     @Override
116     public void setProjectCode(String projectCode) {
117         super.setProjectCode(StringUtils.trimToNull(projectCode));
118     }
119 
120     @Override
121     public void setOverrideCode(String overrideCode) {
122         super.setOverrideCode(StringUtils.trimToNull(overrideCode));
123     }
124 
125     @Override
126     public void setReferenceOriginCode(String originCode) {
127         super.setReferenceOriginCode(StringUtils.trimToNull(originCode));
128     }
129 
130     @Override
131     public void setSubAccountNumber(String subAccountNumber) {
132         super.setSubAccountNumber(StringUtils.trimToNull(subAccountNumber));
133     }
134 
135     @Override
136     public String getSubAccountNumber() {
137         return StringUtils.trimToNull(super.getSubAccountNumber());
138     }
139 
140     @Override
141     public String getFinancialDocumentLineTypeCode() {
142         return StringUtils.trimToNull(super.getFinancialDocumentLineTypeCode());
143     }
144 
145     @Override
146     public String getObjectTypeCode() {
147         return StringUtils.trimToNull(super.getObjectTypeCode());
148     }
149 
150     @Override
151     public void setFinancialDocumentLineTypeCode(String financialDocumentLineTypeCode) {
152         super.setFinancialDocumentLineTypeCode(StringUtils.trimToNull(financialDocumentLineTypeCode));
153     }
154 
155     @Override
156     public String getFinancialSubObjectCode() {
157         return StringUtils.trimToNull(super.getFinancialSubObjectCode());
158     }
159 
160     @Override
161     public String getFinancialObjectCode() {
162         return StringUtils.trimToNull(super.getFinancialObjectCode());
163     }
164 
165     @Override
166     public String getChartOfAccountsCode() {
167         return StringUtils.trimToNull(super.getChartOfAccountsCode());
168     }
169 
170     @Override
171     public String getBalanceTypeCode() {
172         return StringUtils.trimToNull(super.getBalanceTypeCode());
173     }
174 
175     @Override
176     public String getDebitCreditCode() {
177         return StringUtils.trimToNull(super.getDebitCreditCode());
178     }
179 
180     @Override
181     public String getEncumbranceUpdateCode() {
182         return StringUtils.trimToNull(super.getEncumbranceUpdateCode());
183     }
184 
185     @Override
186     public String getProjectCode() {
187         return StringUtils.trimToNull(super.getProjectCode());
188     }
189 
190     @Override
191     public String getReferenceTypeCode() {
192         return StringUtils.trimToNull(super.getReferenceTypeCode());
193     }
194 
195     @Override
196     public String getOverrideCode() {
197         return StringUtils.trimToNull(super.getOverrideCode());
198     }
199 
200     public KualiDecimal getExistingAmount() {
201         return existingAmount;
202     }
203 
204     public void setExistingAmount(KualiDecimal existingAmount) {
205         this.existingAmount = existingAmount;
206     }
207 
208 
209     public BigDecimal getBigDecimalAmount() {
210         if(this.getAmount()!=null){
211             return this.getAmount().bigDecimalValue();
212         }else{
213             return bigDecimalAmount;
214         }
215     }
216 
217     public void setBigDecimalAmount(BigDecimal bigDecimalAmount) {
218         if(bigDecimalAmount!=null){
219             this.setAmount(new KualiDecimal(bigDecimalAmount));
220         }else{
221             this.bigDecimalAmount = bigDecimalAmount;
222         }
223     }
224 }