001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.businessobject; 017 018 import java.sql.Date; 019 import java.util.LinkedHashMap; 020 import java.util.List; 021 022 import org.kuali.kfs.coa.businessobject.Account; 023 import org.kuali.kfs.coa.businessobject.Chart; 024 import org.kuali.kfs.coa.businessobject.ObjectCodeCurrent; 025 import org.kuali.rice.kns.bo.Inactivateable; 026 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 027 import org.kuali.rice.kns.util.TypedArrayList; 028 029 public class TaxRegion extends PersistableBusinessObjectBase implements Inactivateable { 030 031 private String taxRegionCode; // (e.g., state code or district code) 032 private String taxRegionName; // (e.g., state name or tax district name) 033 private String taxRegionTypeCode; 034 private String chartOfAccountsCode; 035 private String accountNumber; 036 private String financialObjectCode; 037 private boolean active; 038 private boolean taxRegionUseTaxIndicator; 039 040 private Chart chartOfAccounts; 041 private Account account; 042 private ObjectCodeCurrent objectCode; 043 private TaxRegionType taxRegionType; 044 045 private List<TaxRegionRate> taxRegionRates = new TypedArrayList(TaxRegionRate.class); 046 private List<TaxRegionState> taxRegionStates = new TypedArrayList(TaxRegionState.class); 047 private List<TaxRegionCounty> taxRegionCounties = new TypedArrayList(TaxRegionCounty.class); 048 private List<TaxRegionPostalCode> taxRegionPostalCodes = new TypedArrayList(TaxRegionPostalCode.class); 049 050 public List<TaxRegionRate> getTaxRegionRates() { 051 return taxRegionRates; 052 } 053 054 public void setTaxRegionRates(List<TaxRegionRate> taxRegionRates) { 055 this.taxRegionRates = taxRegionRates; 056 } 057 058 public List<TaxRegionState> getTaxRegionStates() { 059 return taxRegionStates; 060 } 061 062 public void setTaxRegionStates(List<TaxRegionState> taxRegionStates) { 063 this.taxRegionStates = taxRegionStates; 064 } 065 066 public List<TaxRegionCounty> getTaxRegionCounties() { 067 return taxRegionCounties; 068 } 069 070 public void setTaxRegionCounties(List<TaxRegionCounty> taxRegionCounties) { 071 this.taxRegionCounties = taxRegionCounties; 072 } 073 074 public List<TaxRegionPostalCode> getTaxRegionPostalCodes() { 075 return taxRegionPostalCodes; 076 } 077 078 public void setTaxRegionPostalCodes(List<TaxRegionPostalCode> taxRegionPostalCodes) { 079 this.taxRegionPostalCodes = taxRegionPostalCodes; 080 } 081 082 public TaxRegionType getTaxRegionType() { 083 return taxRegionType; 084 } 085 086 public void setTaxRegionType(TaxRegionType taxRegionType) { 087 this.taxRegionType = taxRegionType; 088 } 089 090 public String getAccountNumber() { 091 return accountNumber; 092 } 093 094 public void setAccountNumber(String accountNumber) { 095 this.accountNumber = accountNumber; 096 } 097 098 public boolean isActive() { 099 return active; 100 } 101 102 public void setActive(boolean active) { 103 this.active = active; 104 } 105 106 public String getChartOfAccountsCode() { 107 return chartOfAccountsCode; 108 } 109 110 public void setChartOfAccountsCode(String chartOfAccountsCode) { 111 this.chartOfAccountsCode = chartOfAccountsCode; 112 } 113 114 public String getFinancialObjectCode() { 115 return financialObjectCode; 116 } 117 118 public void setFinancialObjectCode(String financialObjectCode) { 119 this.financialObjectCode = financialObjectCode; 120 } 121 122 public String getTaxRegionCode() { 123 return taxRegionCode; 124 } 125 126 public void setTaxRegionCode(String taxDistrictCode) { 127 this.taxRegionCode = taxDistrictCode; 128 } 129 130 public String getTaxRegionName() { 131 return taxRegionName; 132 } 133 134 public void setTaxRegionName(String taxDistrictName) { 135 this.taxRegionName = taxDistrictName; 136 } 137 138 @Override 139 protected LinkedHashMap toStringMapper() { 140 // TODO Auto-generated method stub 141 return null; 142 } 143 144 public String toString() { 145 return taxRegionTypeCode + "-" + taxRegionCode + "-" + taxRegionName; 146 } 147 148 public Account getAccount() { 149 return account; 150 } 151 152 public void setAccount(Account account) { 153 this.account = account; 154 } 155 156 public Chart getChartOfAccounts() { 157 return chartOfAccounts; 158 } 159 160 public void setChartOfAccounts(Chart chartOfAccounts) { 161 this.chartOfAccounts = chartOfAccounts; 162 } 163 164 public ObjectCodeCurrent getObjectCode() { 165 return objectCode; 166 } 167 168 public void setObjectCode(ObjectCodeCurrent objectCode) { 169 this.objectCode = objectCode; 170 } 171 172 public String getTaxRegionTypeCode() { 173 return taxRegionTypeCode; 174 } 175 176 public void setTaxRegionTypeCode(String taxRegionTypeCode) { 177 this.taxRegionTypeCode = taxRegionTypeCode; 178 } 179 180 public boolean isTaxRegionUseTaxIndicator() { 181 return taxRegionUseTaxIndicator; 182 } 183 184 public void setTaxRegionUseTaxIndicator(boolean taxRegionUseTaxIndicator) { 185 this.taxRegionUseTaxIndicator = taxRegionUseTaxIndicator; 186 } 187 188 /** 189 * This method returns the effective tax region rate based off the date of transaction passed in 190 * @param dateOfTransaction 191 * @return 192 */ 193 public TaxRegionRate getEffectiveTaxRegionRate(Date dateOfTransaction) { 194 TaxRegionRate selectedTaxRegionRate = null; 195 196 for (TaxRegionRate taxRegionRate : taxRegionRates) { 197 if (taxRegionRate.getEffectiveDate().before(dateOfTransaction)) { 198 selectedTaxRegionRate = taxRegionRate; 199 } 200 } 201 202 return selectedTaxRegionRate; 203 } 204 }