/* * [PrepUtah.java] * * Summary: One shot program to process tax data for Utah. 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 2010-12-14 initial version */ package com.mindprod.americantax; import com.mindprod.common18.ST; import com.mindprod.csv.CSVReader; import java.io.IOException; /* home: http://www.tax.utah.gov/sales/rates.html download http://www.tax.utah.gov/sales/rates/11q1simple.xls utah.xls contains interleaved counties and cities, with code of form cc-nnn cc=county# nnn=city# Can tell which city a county belong in by county ahead of it. Also could use codes, but we don't. Reshape to look like this: #county/city rate included state tax Beaver county, 5.95 Beaver City, 6.95 Milford, 5.95 Minersville, 5.95 Box Elder county, 5.95 */ /** * One shot program to process tax data for Utah. 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 PrepUtah extends PrepStateBase { private String enclosingCounty; /** * Constructor */ private PrepUtah() { super( "UT", "utah", 4.7, false /* counties */, true /* cities */, true /* files include state rate */, false /* convert to book case */, /* guess country rates */ 400 ); } /** * 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 java.io.IOException if cannot read file */ void prepareCity( final CSVReader c ) throws IOException { final String item = c.get(); if ( item.endsWith( " county" ) ) { // was a country record enclosingCounty = ST.chopTrailingString( item, " county" ); final double percent = c.getDouble() - stateTax; // strip state tax salesTaxItems.add( new SalesTaxItem( enclosingCounty, "", percent ) ); } else { // was a city record String city = item; final double percent = c.getDouble() - stateTax; // strip state tax, includes county tax salesTaxItems.add( new SalesTaxItem( enclosingCounty, city, percent ) ); } c.skipToNextLine(); } // default count and city processors are fine. @SuppressWarnings( { "InfiniteLoopStatement" } ) public static void main( String[] args ) throws IOException { new PrepUtah().prepare(); } }