/* * [PrepColorado.java] * * Summary: One shot program to process tax data for Colorado. Generates code 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 2007-06-08 * 1.1 2010-12-10 update to produce CSV file without state tax included. */ package com.mindprod.americantax; import com.mindprod.common18.ST; import com.mindprod.csv.CSVReader; import java.io.IOException; /* download "http://www.colorado.gov/cms/forms/dor-tax/dr1002.pdf" coloradoraw.pdf use OCR to extract spreadsheet data. Pull out list of counties, counties with tax, and cities with city tax (excluding county tax) Create a complete list of counties like this by merging. Prune out word "county" coloradocounties.csv #county number tax Denver, 01, 0 Pueblo, 02, 1 Create a complete list of cities like this. Ignore use or service fee. Collect both state-collected and home-rule cities. coloradocities.csv no state or county tax. #city county rate Aguilar, 05, 3 Akron, 27, 2.5 Alma, 54, 3 state sales tax is 2.9%, not included in these figures. Denver collects its own 3.62% sales tax. Must manually add to tables. Ditto Broomfield which has 8.25 - 2.9 = 5.35% */ /** * One shot program to process tax data for Colorado. Generates code for AmericanTax.java table. * * @author Roedy Green, Canadian Mind Products * @version 1.1 2010-12-10 update to produce CSV file without state tax included. * @since 2007-06-08 */ public final class PrepColorado extends PrepStateBase { private final String[] lookupCounty = new String[ 100 ]; // 0..99 private final double[] lookupCountyTax = new double[ 100 ]; /** * Constructor */ private PrepColorado() { super( "CO", "colorado", 2.9 /* state tax */, true /* counties in coloradocounties.csv*/, true /* cities in colorandocitives.csv */, false /* files do not include state rate */, true /* convert to book case */, 300 /* est # cities */ ); } /** * 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, county #, percent */ final String location = ST.toBookTitleCase( c.get() ); final int countyNumber = c.getInt(); // city tax only. does not include county or state tax final double percent = c.getDouble(); c.skipToNextLine(); final String countyName = lookupCounty[ countyNumber ]; final double countyPercent = lookupCountyTax[ countyNumber ]; assert countyName != null : "unknown county: " + countyNumber; salesTaxItems.add( new SalesTaxItem( countyName, location, countyPercent + percent ) ); } /** * 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 { /* country name, county#, percent */ final String countyName = ST.toBookTitleCase( c.get() ); final int countyNumber = c.getInt(); final double percent = c.getDouble(); c.skipToNextLine(); lookupCounty[ countyNumber ] = countyName; lookupCountyTax[ countyNumber ] = percent; salesTaxItems.add( new SalesTaxItem( countyName, "", percent ) ); } @SuppressWarnings( { "InfiniteLoopStatement" } ) public static void main( String[] args ) throws IOException { new PrepColorado().prepare(); } }