/* * [PrepOklahoma.java] * * Summary: One shot program to process tax data for Oklahoma. Generates code for AmericanTax.java table. * * Copyright: (c) 2010-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-13 initial version */ package com.mindprod.americantax; import com.mindprod.common18.ST; import com.mindprod.csv.CSVReader; import java.io.IOException; /** * One shot program to process tax data for Oklahoma. Generates code for AmericanTax.java table. *

* Generates code for AmericanTax.java table. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2010-12-13 initial version * @since 2010-12-13 */ public final class PrepOklahoma extends PrepStateBase { private final String[] countiesByCountyNumber = new String[ 100 ]; private final double[] lookupCountyTax = new double[ 100 ]; /** * Constructor */ private PrepOklahoma() { super( "OK", "oklahoma", 4.5, true /* counties */, true /* cities */, false /* files include state rate */, true /* convert to book case */, 75 ); } /** * 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 int countyNumber = Integer.parseInt( c.get().substring( 0, 2 ) ); final String city = ST.toBookTitleCase( c.get() ); final double percent = c.getDouble(); c.skipToNextLine(); String county = countiesByCountyNumber[ countyNumber ]; assert county != null : "Undefined county:" + countyNumber + " for city: " + city; final double countyPercent = lookupCountyTax[ countyNumber ]; // city rate does not include county tax, we have to add it in. salesTaxItems.add( new SalesTaxItem( county, city, 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 { final int countyNumber = Integer.parseInt( c.get().substring( 0, 2 ) ); final String county = ST.toBookTitleCase( c.get() ); final double percent = c.getDouble(); c.skipToNextLine(); countiesByCountyNumber[ countyNumber ] = county; lookupCountyTax[ countyNumber ] = percent; salesTaxItems.add( new SalesTaxItem( county, "", percent ) ); } /* * home: http://www.tax.ok.gov/ratechts.html * download http://www.tax.ok.gov/publicat/copos/copo1Q11.pdf oklahomaraw.pdf * Contains both county and state info, linked by a 4-digit COPA (county) number. * COPO: 2digit county + 2 digit city. COPO for county of form XX88. * The list of counties contains only thos ewith sales tax, It is missing tho copa number for the other such as * 0703= Bryan, 6201= Pontotoc, 4903=Mayes, 3403=Jefferson *

* Copy paste the html file then tidy it to this format, * Plus other minor tidies. * #oklahoma counties * #COPO county rate (excluding state) * 5588, OKLAHOMA, 0 <-- add manually. Missing from PDF. * 0188, ADAIR, 0.75 * 0288, ALFALFA, 2 * 0388, ATOKA, 2 * 0488, BEAVER, 2 * 0588, BECKHAM, 0.30 *

* #Okalahoma cities NOTE: city tax does not include county tax. * #copa city rate * # some cities appear twice, in two different counties, we list both. * 0703, ACHILLE, 3 * 6201, ADA, 4 * 4903, ADAIR, 4 * 3403, ADDINGTON, 2 * and save as E:\com\mindprod\americantax\oklahomacounties.csv and E:\com\mindprod\americantax\oklahomacities.csv */ public static void main( String[] args ) throws IOException { new PrepOklahoma().prepare(); } }