RT# 83122 Move wa_tax_rate_update for dist
authorMitch Jackson <mitch@freeside.biz>
Sun, 5 May 2019 01:53:28 +0000 (21:53 -0400)
committerMitch Jackson <mitch@freeside.biz>
Sun, 5 May 2019 01:56:23 +0000 (21:56 -0400)
FS/FS/Misc/Geo.pm
FS/bin/freeside-wa-tax-table-update [new file with mode: 0755]
bin/wa_tax_rate_update [deleted file]

index 2e44364..bc020a2 100644 (file)
@@ -159,8 +159,8 @@ L<https://dor.wa.gov/find-taxes-rates/retail-sales-tax/destination-based-sales-t
 This API does not return consistent usable county names, as the county
 name may include appreviations or labels referring to PTBA (public transport
 benefit area) or CEZ (community empowerment zone).  It's recommended to use
-the tool wa_tax_rate_update to fully populate the city/county/districts for
-WA state every financial quarter.
+the tool freeside-wa-tax-table-update to fully populate the
+city/county/districts for WA state every financial quarter.
 
 Returns a hashref with the following keys:
 
diff --git a/FS/bin/freeside-wa-tax-table-update b/FS/bin/freeside-wa-tax-table-update
new file mode 100755 (executable)
index 0000000..ad14687
--- /dev/null
@@ -0,0 +1,147 @@
+#!/usr/bin/env perl
+
+=head1 NAME
+
+wa_tax_rate_update
+
+=head1 DESCRIPTION
+
+Tool to update city/district sales tax rates in I<cust_main_county> from 
+the Washington State Department of Revenue website.
+
+Creates, or updates, a L<FS::cust_main_county> row for every tax district
+in Washington state. Some cities have different tax rates based on the
+address, within the city.  Because of this, some cities have
+district.
+
+If tax classes are enabled, a row is created in every tax class for
+every district.
+
+Customer addresses aren't classified into districts here.  Instead,
+when a Washington state address is inserted or changed in L<FS::cust_location>,
+a job is queued for FS::geocode_Mixin::process_district_update, to ask the
+Washington state API which tax district to use for this address.
+
+Options:
+
+  -f <filename>: Skip downloading, and process the given excel file
+
+  -t <taxname>:  Updated or created records will be set to the given tax name.
+                 If not specified, conf value 'tax_district_taxname' will be used
+
+  -y <year>:     Specify year for tax table - defaults to current year
+
+  -q <quarter>:  Specify quarter for tax table - defaults to current quarter
+
+  -l <lookup>:   Attempt to look up the tax district classification for
+                 unclassified cust_location records in Washington.  Will
+                 notify of records that cannot be classified
+
+=head1 Washington State Department of Revenue Resources
+
+The state of Washington makes data files available via their public website.
+It's possible the availability or format of these files may change.  As of now,
+the only data file that contains both city and county names is published in
+XLSX format.
+
+=item WA Dept of Revenue
+
+https://dor.wa.gov
+
+=item Data file downloads
+
+https://dor.wa.gov/find-taxes-rates/sales-and-use-tax-rates/downloadable-database
+
+=item XLSX file example
+
+https://dor.wa.gov/sites/default/files/legacy/Docs/forms/ExcsTx/LocSalUseTx/ExcelLocalSlsUserates_19_Q1.xlsx
+
+=item CSV file example
+
+https://dor.wa.gov/sites/default/files/legacy/downloads/Add_DataRates2018Q4.zip
+
+
+=item Address lookup API tool
+
+http://webgis.dor.wa.gov/webapi/AddressRates.aspx?output=xml&addr=410 Terry Ave. North&city=&zip=98100
+
+=cut
+
+use strict;
+use warnings;
+
+our $VERSION = '0.02'; # Make Getopt:Std happy
+
+use Getopt::Std;
+
+use FS::Cron::tax_rate_update qw(
+  wa_sales_update_tax_table
+  wa_sales_log_customer_without_tax_district
+);
+use FS::Log;
+use FS::UID qw(adminsuidsetup);
+
+my %opts;
+getopts( 't:y:q:f:l', \%opts );
+
+my $user = shift
+  or die HELP_MESSAGE();
+
+adminsuidsetup( $user )
+  or die "bad username '$user'\n";
+
+my $log = FS::Log->new('wa_tax_rate_update');
+
+$log->info('Begin wa_tax_rate_update');
+
+{
+  local $@;
+  eval {
+    wa_sales_update_tax_table({
+      $opts{f} ? ( filename => $opts{f} ) : (),
+      $opts{t} ? ( taxname  => $opts{t} ) : (),
+      $opts{y} ? ( year     => $opts{y} ) : (),
+      $opts{q} ? ( quarter  => $opts{q} ) : (),
+    });
+  };
+
+  if ( $@ ) {
+    $log->error( "Error: $@" );
+    warn "Error: $@\n";
+  } else {
+    $log->info( 'Finished wa_tax_rate_update' );
+    warn "Finished wa_tax_rate_update\n";
+  }
+}
+
+
+if ( $opts{l} ) {
+  $log->info( 'Begin wa_sales_log_customer_without_tax_district' );
+
+  wa_sales_log_customer_without_tax_district();
+
+  $log->info( 'Finished wa_sales_log_customer_without_tax_district' );
+  warn "Finished wa_sales_log_customer_without_tax_district\n";
+}
+
+exit;
+
+sub HELP_MESSAGE {
+  print "
+    Tool to update city/district sales tax rates in I<cust_main_county> from
+    the Washington State Department of Revenue website.
+
+    Usage: wa_tax_rate_update [-f filename] [-t taxname] [-y year] [-q quarter] [-l] freeside_username
+
+    Optional Options:
+      -f filename   Skip download, and process the specified filename
+      -t taxname    Apply tax name value to created or updated records
+                    defaults as conf value 'tax_district_taxname'
+      -y year       Year for data file download
+      -q quarter    Quarter of data file to download
+      -l lookup     Try to fix cust_location records without a district
+
+  ";
+  exit;
+}
+
diff --git a/bin/wa_tax_rate_update b/bin/wa_tax_rate_update
deleted file mode 100755 (executable)
index ad14687..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env perl
-
-=head1 NAME
-
-wa_tax_rate_update
-
-=head1 DESCRIPTION
-
-Tool to update city/district sales tax rates in I<cust_main_county> from 
-the Washington State Department of Revenue website.
-
-Creates, or updates, a L<FS::cust_main_county> row for every tax district
-in Washington state. Some cities have different tax rates based on the
-address, within the city.  Because of this, some cities have
-district.
-
-If tax classes are enabled, a row is created in every tax class for
-every district.
-
-Customer addresses aren't classified into districts here.  Instead,
-when a Washington state address is inserted or changed in L<FS::cust_location>,
-a job is queued for FS::geocode_Mixin::process_district_update, to ask the
-Washington state API which tax district to use for this address.
-
-Options:
-
-  -f <filename>: Skip downloading, and process the given excel file
-
-  -t <taxname>:  Updated or created records will be set to the given tax name.
-                 If not specified, conf value 'tax_district_taxname' will be used
-
-  -y <year>:     Specify year for tax table - defaults to current year
-
-  -q <quarter>:  Specify quarter for tax table - defaults to current quarter
-
-  -l <lookup>:   Attempt to look up the tax district classification for
-                 unclassified cust_location records in Washington.  Will
-                 notify of records that cannot be classified
-
-=head1 Washington State Department of Revenue Resources
-
-The state of Washington makes data files available via their public website.
-It's possible the availability or format of these files may change.  As of now,
-the only data file that contains both city and county names is published in
-XLSX format.
-
-=item WA Dept of Revenue
-
-https://dor.wa.gov
-
-=item Data file downloads
-
-https://dor.wa.gov/find-taxes-rates/sales-and-use-tax-rates/downloadable-database
-
-=item XLSX file example
-
-https://dor.wa.gov/sites/default/files/legacy/Docs/forms/ExcsTx/LocSalUseTx/ExcelLocalSlsUserates_19_Q1.xlsx
-
-=item CSV file example
-
-https://dor.wa.gov/sites/default/files/legacy/downloads/Add_DataRates2018Q4.zip
-
-
-=item Address lookup API tool
-
-http://webgis.dor.wa.gov/webapi/AddressRates.aspx?output=xml&addr=410 Terry Ave. North&city=&zip=98100
-
-=cut
-
-use strict;
-use warnings;
-
-our $VERSION = '0.02'; # Make Getopt:Std happy
-
-use Getopt::Std;
-
-use FS::Cron::tax_rate_update qw(
-  wa_sales_update_tax_table
-  wa_sales_log_customer_without_tax_district
-);
-use FS::Log;
-use FS::UID qw(adminsuidsetup);
-
-my %opts;
-getopts( 't:y:q:f:l', \%opts );
-
-my $user = shift
-  or die HELP_MESSAGE();
-
-adminsuidsetup( $user )
-  or die "bad username '$user'\n";
-
-my $log = FS::Log->new('wa_tax_rate_update');
-
-$log->info('Begin wa_tax_rate_update');
-
-{
-  local $@;
-  eval {
-    wa_sales_update_tax_table({
-      $opts{f} ? ( filename => $opts{f} ) : (),
-      $opts{t} ? ( taxname  => $opts{t} ) : (),
-      $opts{y} ? ( year     => $opts{y} ) : (),
-      $opts{q} ? ( quarter  => $opts{q} ) : (),
-    });
-  };
-
-  if ( $@ ) {
-    $log->error( "Error: $@" );
-    warn "Error: $@\n";
-  } else {
-    $log->info( 'Finished wa_tax_rate_update' );
-    warn "Finished wa_tax_rate_update\n";
-  }
-}
-
-
-if ( $opts{l} ) {
-  $log->info( 'Begin wa_sales_log_customer_without_tax_district' );
-
-  wa_sales_log_customer_without_tax_district();
-
-  $log->info( 'Finished wa_sales_log_customer_without_tax_district' );
-  warn "Finished wa_sales_log_customer_without_tax_district\n";
-}
-
-exit;
-
-sub HELP_MESSAGE {
-  print "
-    Tool to update city/district sales tax rates in I<cust_main_county> from
-    the Washington State Department of Revenue website.
-
-    Usage: wa_tax_rate_update [-f filename] [-t taxname] [-y year] [-q quarter] [-l] freeside_username
-
-    Optional Options:
-      -f filename   Skip download, and process the specified filename
-      -t taxname    Apply tax name value to created or updated records
-                    defaults as conf value 'tax_district_taxname'
-      -y year       Year for data file download
-      -q quarter    Quarter of data file to download
-      -l lookup     Try to fix cust_location records without a district
-
-  ";
-  exit;
-}
-