diff options
author | Mitch Jackson <mitch@freeside.biz> | 2019-05-26 15:29:16 -0400 |
---|---|---|
committer | Mitch Jackson <mitch@freeside.biz> | 2019-05-27 17:48:46 -0400 |
commit | 1b832fbb0757e4f694528a0685a6875ab2abc50a (patch) | |
tree | f345a76afb05a8c274910148c4da80e1aeeaf12d /FS/FS/cust_main_county.pm | |
parent | 3bfedb7199c3de10c0f2d9a0c7de675fed63c4d9 (diff) |
RT# 83402 CLI tool to repair wa state tax tables
Diffstat (limited to 'FS/FS/cust_main_county.pm')
-rw-r--r-- | FS/FS/cust_main_county.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index 2bd7342..9582334 100644 --- a/FS/FS/cust_main_county.pm +++ b/FS/FS/cust_main_county.pm @@ -562,6 +562,40 @@ sub taxline { return $tax_item; } +=head1 find_wa_tax_dupes + +Return a list of cust_main_county Record objects that are detected +as duplicate washington state sales tax rows (source=wa_state) +within their respective tax classes + +=cut + +sub find_wa_tax_dupes { + my %cust_main_county; + my @dupes; + + for my $row ( qsearch( cust_main_county => { source => 'wa_sales' } ) ) { + my $taxclass = $row->taxclass || 'none'; + $cust_main_county{$taxclass} ||= {}; + + my $district = $row->district || 'none'; + $cust_main_county{$taxclass}->{$district} ||= []; + + push @{ $cust_main_county{$taxclass}->{$district} }, $row; + } + + for my $taxclass ( keys %cust_main_county ) { + for my $district ( keys %{ $cust_main_county{$taxclass} } ) { + my $tax_rows = $cust_main_county{$taxclass}->{$district}; + if ( scalar @$tax_rows > 1 ) { + push @dupes, @$tax_rows; + } + } + } + + @dupes; +} + =back =head1 SUBROUTINES |