9 Tool to update city/district sales tax rates in I<cust_main_county> from
10 the Washington State Department of Revenue website.
12 Creates, or updates, a L<FS::cust_main_county> row for every tax district
13 in Washington state. Some cities have different tax rates based on the
14 address, within the city. Because of this, some cities have
17 If tax classes are enabled, a row is created in every tax class for
20 Customer addresses aren't classified into districts here. Instead,
21 when a Washington state address is inserted or changed in L<FS::cust_location>,
22 a job is queued for FS::geocode_Mixin::process_district_update, to ask the
23 Washington state API which tax district to use for this address.
27 -f <filename>: Skip downloading, and process the given excel file
29 -t <taxname>: Updated or created records will be set to the given tax name.
30 If not specified, conf value 'tax_district_taxname' will be used
32 -y <year>: Specify year for tax table - defaults to current year
34 -q <quarter>: Specify quarter for tax table - defaults to current quarter
36 -l <lookup>: Attempt to look up the tax district classification for
37 unclassified cust_location records in Washington. Will
38 notify of records that cannot be classified
40 =head1 Washington State Department of Revenue Resources
42 The state of Washington makes data files available via their public website.
43 It's possible the availability or format of these files may change. As of now,
44 the only data file that contains both city and county names is published in
47 =item WA Dept of Revenue
51 =item Data file downloads
53 https://dor.wa.gov/find-taxes-rates/sales-and-use-tax-rates/downloadable-database
55 =item XLSX file example
57 https://dor.wa.gov/sites/default/files/legacy/Docs/forms/ExcsTx/LocSalUseTx/ExcelLocalSlsUserates_19_Q1.xlsx
59 =item CSV file example
61 https://dor.wa.gov/sites/default/files/legacy/downloads/Add_DataRates2018Q4.zip
63 =item Other district tax rows
65 When this tool updates the tax tables, any additional tax table rows with
66 a district set, where the 'source' column is not 'wa_sales', will have the
67 country, state, county, and city values kept updated to match the data
68 provided in the state tax tables
70 =item Address lookup API tool
72 http://webgis.dor.wa.gov/webapi/AddressRates.aspx?output=xml&addr=410 Terry Ave. North&city=&zip=98100
79 our $VERSION = '0.02'; # Make Getopt:Std happy
83 use FS::Cron::tax_rate_update qw(
84 wa_sales_update_tax_table
85 wa_sales_log_customer_without_tax_district
88 use FS::UID qw(adminsuidsetup);
91 getopts( 't:y:q:f:l', \%opts );
94 or die HELP_MESSAGE();
96 adminsuidsetup( $user )
97 or die "bad username '$user'\n";
99 my $log = FS::Log->new('wa_tax_rate_update');
101 $log->info('Begin wa_tax_rate_update');
106 wa_sales_update_tax_table({
107 $opts{f} ? ( filename => $opts{f} ) : (),
108 $opts{t} ? ( taxname => $opts{t} ) : (),
109 $opts{y} ? ( year => $opts{y} ) : (),
110 $opts{q} ? ( quarter => $opts{q} ) : (),
116 $log->error( "Error: $@" );
118 $log->info( 'Finished wa_tax_rate_update' );
119 warn "Finished wa_tax_rate_update\n";
125 $log->info( 'Begin wa_sales_log_customer_without_tax_district' );
127 wa_sales_log_customer_without_tax_district();
129 $log->info( 'Finished wa_sales_log_customer_without_tax_district' );
130 warn "Finished wa_sales_log_customer_without_tax_district\n";
137 Tool to update city/district sales tax rates in I<cust_main_county> from
138 the Washington State Department of Revenue website.
140 Usage: wa_tax_rate_update [-f filename] [-t taxname] [-y year] [-q quarter] [-l] freeside_username
143 -f filename Skip download, and process the specified filename
144 -t taxname Apply tax name value to created or updated records
145 defaults as conf value 'tax_district_taxname'
146 -y year Year for data file download
147 -q quarter Quarter of data file to download
148 -l lookup Try to fix cust_location records without a district