/* * [PrepCalifornia.java] * * Summary: One shot program to process tax data for California. 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-07 * 1.1 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 California. Generates code for AmericanTax.java table. *

* general info: http://www.boe.ca.gov/sutax/pam71.htm * Do last minute edits before use. * download http://www.boe.ca.gov/sutax/files/city_rates.csv E:/com/mindprod/americantax/californiacities.csv * convert first line to comment * Remove % and blank links from CSV file before use. * Also remove title line and *s. () * Note order: includes state tax * City,Tax,County * Acampo,7.750%,San Joaquin * Acton,8.250%,Los Angeles * update states sales tax in two places. * * @author Roedy Green, Canadian Mind Products * @version 1.1 2010-12-10 update to produce CSV file without state tax included. * @since 2007-06-07 */ public final class PrepCalifornia extends PrepStateBase { /** * Constructor */ private PrepCalifornia() { super( "CA", "california", 7.5, false /* counties, no californiacounties.csv file */, true /* cities, raw data in californiacities.csv */, true /* files include state rate */, false /* no convert to book case */, 1900 /* est itmems */ ); } /** * 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 { final String city = c.get(); final double percent = c.getDouble() - stateTax; // rates in table include state tax. final String county = c.get(); c.skipToNextLine(); final int place = city.indexOf( '(' ); if ( place > 0 ) { // split entry in two String city1 = city.substring( 0, place ); salesTaxItems.add( new SalesTaxItem( county, city1, percent ) ); int place2 = city.lastIndexOf( ')' ); String city2 = city.substring( place + 1, place2 ); salesTaxItems.add( new SalesTaxItem( county, city2, percent ) ); } else { // normal entry salesTaxItems.add( new SalesTaxItem( county, city, percent ) ); } } @SuppressWarnings( { "InfiniteLoopStatement" } ) public static void main( String[] args ) throws IOException { new PrepCalifornia().prepare(); } }