X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fwa_tax_rate_update;h=d4a4b52e48ff49bff2b0e0669d39915b3480757b;hp=27d152775044a0e3bdbba7797270dd4e727c073a;hb=3fa5501cf8f3344360cb2a795ab58711d96540f5;hpb=f9bb139d807c80de32ce7d7f98f5b74712f03a99 diff --git a/bin/wa_tax_rate_update b/bin/wa_tax_rate_update index 27d152775..d4a4b52e4 100644 --- a/bin/wa_tax_rate_update +++ b/bin/wa_tax_rate_update @@ -15,9 +15,13 @@ and relies on a heinous screen-scraping of the interactive search tool. This script just updates the cust_main_county records that already exist with the latest quarterly tax rates. -The only option it accepts is "-c" to operate on a specific tax class -(named after the -c). If this isn't included it will operate on records -with null tax class. +Options: + +-c : operate only on records with the named tax class. If not +specified, this operates on records with null tax class. + +-t : operate only on records with that tax name. If not specified, +it operates on records where the tax name is either null or 'Tax'. =cut @@ -31,7 +35,7 @@ use File::Slurp qw(read_file write_file); use Text::CSV; use Getopt::Std; -getopts('c:'); +getopts('c:t:'); my $user = shift or die usage(); # download the update file @@ -68,11 +72,13 @@ adminsuidsetup($user) or die "bad username '$user'\n"; $FS::UID::AutoCommit = 0; $opt_c ||= ''; # taxclass +$opt_t ||= ''; # taxname my $total_changed = 0; my $total_skipped = 0; while ( !$csv->eof ) { my $line = $csv->getline_hr($fh); my $district = $line->{Code} or next; + $district = sprintf('%04d', $district); my $tax = sprintf('%.1f', $line->{Rate} * 100); my $changed = 0; my $skipped = 0; @@ -82,7 +88,19 @@ while ( !$csv->eof ) { state => 'WA', # this is specific to WA district => $district, taxclass => $opt_c, + taxname => $opt_t, + tax => { op => '>', value => '0' }, }); + if ($opt_t eq '') { + push @rates, qsearch('cust_main_county', { + country => 'US', + state => 'WA', # this is specific to WA + district => $district, + taxclass => $opt_c, + taxname => 'Tax', + tax => { op => '>', value => '0' }, + }); + } foreach my $rate (@rates) { if ( $rate->tax == $tax ) { $skipped++; @@ -103,6 +121,6 @@ dbh->commit; sub usage { "usage: - wa_tax_rate_update [ -c taxclass ] user + wa_tax_rate_update [ -c taxclass ] [ -t taxname ] user "; }