/* * [PrepNewMexico.java] * * Summary: One shot program to process tax data for New Mexico. 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-17 initial version */ package com.mindprod.americantax; import com.mindprod.csv.CSVReader; import java.io.IOException; /** * One shot program to process tax data for New Mexico. 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 PrepNewMexico extends PrepStateBase { private final String[] countiesByCountyNumber = new String[ 100 ]; /** * Constructor */ private PrepNewMexico() { super( "NM", "newmexico", 5.000, true /* counties */, true /* cities */, true /* files include state rate */, false /* convert to book case */, 300 ); } /** * 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(); final int countyNumber = c.getInt(); final double percent = c.getDouble() - stateTax; c.skipToNextLine(); String county = countiesByCountyNumber[ countyNumber ]; assert county != null : "Undefined county:" + countyNumber + " for item: " + item; final String city; if ( item.equals( "Remainder of County" ) || item.equals( "City and County" ) ) { // county item. city = ""; } else { city = item; } salesTaxItems.add( new SalesTaxItem( county, city, 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 java.io.IOException if cannot read file */ void prepareCounty( final CSVReader c ) throws IOException { final String county = c.get(); final int countyNumber = c.getInt(); c.skipToNextLine(); countiesByCountyNumber[ countyNumber ] = county; } /** * they call the tax the GRC, gross receipts tax. * home: http://www.tax.newmexico.gov/Forms-and-Publications/Forms/Gross-Receipts/Pages/Home.aspx#Rates.aspx * download "http://www.tax.newmexico.gov/SiteCollectionDocuments/Tax-Library/Tax-Policy-and-Revenue-Program * -History/Current-and-Historic-Tax-Rates/Gross-Receipts-Tax-Rates/GRT_rates_Jan_2011.pdf" newmexicocities.pdf * Contains both county and state info interleaved. * Save as CSV, strip out all info but cities, two-digit county code and rate. * CSVSort newmexicocities.csv 1n+ 0s+ 2n+ * Looks like this: * Edgewood, 01, 7.8750 * Espanola, 01, 8.4375 * Espanola/Santa Clara Grant, 01, 8.4375 * Kewa Pueblo, 01, 6.6250 * Nambe Pueblo, 01, 6.6250 * Manually create table of county to county number like this: * # county, number * Sante Fe, 01 * Bernallo, 02 * Eddy, 03 * Chaves, 04 */ public static void main( String[] args ) throws IOException { new PrepNewMexico().prepare(); } }