View Javadoc

1   /*
2    * Copyright 2008 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.sys.businessobject;
17  
18  import java.sql.Date;
19  import java.util.ArrayList;
20  import java.util.LinkedHashMap;
21  import java.util.List;
22  
23  import org.kuali.ole.coa.businessobject.Account;
24  import org.kuali.ole.coa.businessobject.Chart;
25  import org.kuali.ole.coa.businessobject.ObjectCodeCurrent;
26  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
27  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
28  
29  public class TaxRegion extends PersistableBusinessObjectBase implements MutableInactivatable {
30  
31      protected String taxRegionCode; // (e.g., state code or district code)
32      protected String taxRegionName; // (e.g., state name or tax district name)
33      protected String taxRegionTypeCode;
34      protected String chartOfAccountsCode;
35      protected String accountNumber;
36      protected String financialObjectCode;
37      protected boolean active;
38      protected boolean taxRegionUseTaxIndicator;
39  
40      protected Chart chartOfAccounts;
41      protected Account account;
42      protected ObjectCodeCurrent objectCode;
43      protected TaxRegionType taxRegionType;
44  
45      protected List<TaxRegionRate> taxRegionRates = new ArrayList<TaxRegionRate>();
46      protected List<TaxRegionState> taxRegionStates = new ArrayList<TaxRegionState>();
47      protected List<TaxRegionCounty> taxRegionCounties = new ArrayList<TaxRegionCounty>();
48      protected List<TaxRegionPostalCode> taxRegionPostalCodes = new ArrayList<TaxRegionPostalCode>();
49  
50      public List<TaxRegionRate> getTaxRegionRates() {
51          return taxRegionRates;
52      }
53  
54      public void setTaxRegionRates(List<TaxRegionRate> taxRegionRates) {
55          this.taxRegionRates = taxRegionRates;
56      }
57  
58      public List<TaxRegionState> getTaxRegionStates() {
59          return taxRegionStates;
60      }
61  
62      public void setTaxRegionStates(List<TaxRegionState> taxRegionStates) {
63          this.taxRegionStates = taxRegionStates;
64      }
65  
66      public List<TaxRegionCounty> getTaxRegionCounties() {
67          return taxRegionCounties;
68      }
69  
70      public void setTaxRegionCounties(List<TaxRegionCounty> taxRegionCounties) {
71          this.taxRegionCounties = taxRegionCounties;
72      }
73  
74      public List<TaxRegionPostalCode> getTaxRegionPostalCodes() {
75          return taxRegionPostalCodes;
76      }
77  
78      public void setTaxRegionPostalCodes(List<TaxRegionPostalCode> taxRegionPostalCodes) {
79          this.taxRegionPostalCodes = taxRegionPostalCodes;
80      }
81  
82      public TaxRegionType getTaxRegionType() {
83          return taxRegionType;
84      }
85  
86      public void setTaxRegionType(TaxRegionType taxRegionType) {
87          this.taxRegionType = taxRegionType;
88      }
89  
90      public String getAccountNumber() {
91          return accountNumber;
92      }
93  
94      public void setAccountNumber(String accountNumber) {
95          this.accountNumber = accountNumber;
96      }
97  
98      @Override
99      public boolean isActive() {
100         return active;
101     }
102 
103     @Override
104     public void setActive(boolean active) {
105         this.active = active;
106     }
107 
108     public String getChartOfAccountsCode() {
109         return chartOfAccountsCode;
110     }
111 
112     public void setChartOfAccountsCode(String chartOfAccountsCode) {
113         this.chartOfAccountsCode = chartOfAccountsCode;
114     }
115 
116     public String getFinancialObjectCode() {
117         return financialObjectCode;
118     }
119 
120     public void setFinancialObjectCode(String financialObjectCode) {
121         this.financialObjectCode = financialObjectCode;
122     }
123 
124     public String getTaxRegionCode() {
125         return taxRegionCode;
126     }
127 
128     public void setTaxRegionCode(String taxDistrictCode) {
129         this.taxRegionCode = taxDistrictCode;
130     }
131 
132     public String getTaxRegionName() {
133         return taxRegionName;
134     }
135 
136     public void setTaxRegionName(String taxDistrictName) {
137         this.taxRegionName = taxDistrictName;
138     }
139 
140 
141     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
142         // TODO Auto-generated method stub
143         return null;
144     }
145 
146     @Override
147     public String toString() {
148         return taxRegionTypeCode + "-" + taxRegionCode + "-" + taxRegionName;
149     }
150     
151     public Account getAccount() {
152         return account;
153     }
154 
155     public void setAccount(Account account) {
156         this.account = account;
157     }
158 
159     public Chart getChartOfAccounts() {
160         return chartOfAccounts;
161     }
162 
163     public void setChartOfAccounts(Chart chartOfAccounts) {
164         this.chartOfAccounts = chartOfAccounts;
165     }
166 
167     public ObjectCodeCurrent getObjectCode() {
168         return objectCode;
169     }
170 
171     public void setObjectCode(ObjectCodeCurrent objectCode) {
172         this.objectCode = objectCode;
173     }
174 
175     public String getTaxRegionTypeCode() {
176         return taxRegionTypeCode;
177     }
178 
179     public void setTaxRegionTypeCode(String taxRegionTypeCode) {
180         this.taxRegionTypeCode = taxRegionTypeCode;
181     }
182 
183     public boolean isTaxRegionUseTaxIndicator() {
184         return taxRegionUseTaxIndicator;
185     }
186 
187     public void setTaxRegionUseTaxIndicator(boolean taxRegionUseTaxIndicator) {
188         this.taxRegionUseTaxIndicator = taxRegionUseTaxIndicator;
189     }
190 
191     /**
192      * This method returns the effective tax region rate based off the date of transaction passed in
193      * @param dateOfTransaction
194      * @return
195      */
196     public TaxRegionRate getEffectiveTaxRegionRate(Date dateOfTransaction) {
197         TaxRegionRate selectedTaxRegionRate = null;
198 
199         for (TaxRegionRate taxRegionRate : taxRegionRates) {
200             if (taxRegionRate.getEffectiveDate().getTime() <= dateOfTransaction.getTime() ) {
201                 selectedTaxRegionRate = taxRegionRate;
202             }
203         }
204         
205         return selectedTaxRegionRate;
206     }
207 }