/* * [PrepTexas.java] * * Summary: One shot program to process tax data for Texas. Generates data for AmericanTax.java table. * * Copyright: (c) 1999-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2008-06-01 initial * 1.1 2010-12-06 new format of screen scraped file. * 1.2 2010-12-10 update to produce CSV file without state tax included. */ package com.mindprod.americantax; import com.mindprod.csv.CSVReader; import java.io.IOException; /** * One shot program to process tax data for Texas. Generates data for AmericanTax.java table. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2010-12-10 produce CSV file without state tax included. * @since 2010-12-10 */ public final class PrepTexas extends PrepStateBase { /* Texas sales tax home http://www.window.state.tx.us/taxinfo/local/ download http://www.window.state.tx.us/taxinfo/local/cityrate.csv texasraw.csv CityName,CityNo,CityTax,CountyName,CountyNo,CountyTax,... extract 4 columns of useful data with: csvsort texasraw.csv 2s+ 0s+ save that as texascities.csv # city, citytax, county, countytax. Bethel, 0, Anderson, 0.005 Blackfoot, 0, Anderson, 0.005 <-- tax is a fraction not a percent Bradford, 0, Anderson, 0.005 Cayuga, 0, Anderson, 0.005 then extract off the last two columns, and dedup, remove junk manually, leaving texascounties.csv # county, tax Anderson, 0.005 Andrews, 0 Angelina, 0.005 <-- tax is a fraction not a percent Aransas, 0.005 Archer, 0.005 */ /** * Constructor */ private PrepTexas() { super( "TX", "texas", 6.250, true /* counties */, true /* cities */, false /* files include state rate */, false /* convert to book case */, 2000 ); } /** * Default method to read and prepare one county record. * You must read, and add SalesTaxItem to salesTaxItems, and skipToNewLine * * @param c open CSV reader. * * @throws IOException if cannot read file */ void prepareCity( final CSVReader c ) throws IOException { // # city, citytax, county, countytax. // Bethel, 0, Anderson, 0.005 final String city = c.get(); final double cityTax = c.getDouble() * 100.; // state tax not included, county tax not included final String county = c.get(); final double countyTax = c.getDouble() * 100.; // state tax not included, county tax included c.skipToNextLine(); salesTaxItems.add( new SalesTaxItem( county, city, countyTax + cityTax ) ); } /** * Default method to read and prepare one county record. * You must read, and add SalesTaxItem to salesTaxItems, and skipToNewLine * * @param c open CSV reader. * * @throws IOException if cannot read file */ void prepareCounty( final CSVReader c ) throws IOException { // # county, tax // Anderson, 0.005 final String county = c.get(); final double percent = c.getDouble() * 100.; // state tax not included, county tax included c.skipToNextLine(); salesTaxItems.add( new SalesTaxItem( county, "", percent ) ); } public static void main( String[] args ) throws IOException { new PrepTexas().prepare(); } }