X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main_county.pm;h=3c355e823aaaf76aab4da6e94e902906e4fbf7c6;hp=652ff33aeb05e84fe2ac75fae6af79850012baac;hb=674cb2d9d7105f4cc2871539b2e9f7088cdaa750;hpb=95b6042f37f00de9dca4b5654522fc4098a82d04 diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index 652ff33ae..3c355e823 100644 --- a/FS/FS/cust_main_county.pm +++ b/FS/FS/cust_main_county.pm @@ -12,6 +12,7 @@ use FS::cust_pkg; use FS::part_pkg; use FS::cust_tax_exempt; use FS::cust_tax_exempt_pkg; +use FS::upgrade_journal; @EXPORT_OK = qw( regionselector ); @@ -78,6 +79,9 @@ currently supported: =item recurtax - if 'Y', this tax does not apply to recurring fees +=item source - the tax lookup method that created this tax record. For records +created manually, this will be null. + =back =head1 METHODS @@ -132,6 +136,7 @@ sub check { || $self->ut_textn('taxname') || $self->ut_enum('setuptax', [ '', 'Y' ] ) || $self->ut_enum('recurtax', [ '', 'Y' ] ) + || $self->ut_textn('source') || $self->SUPER::check ; @@ -674,6 +679,31 @@ END } +sub _upgrade_data { + my $class = shift; + # assume taxes in Washington with district numbers, and null name, or + # named 'sales tax', are looked up via the wa_sales method. mark them. + my $journal = 'cust_main_county__source_wa_sales'; + if (!FS::upgrade_journal->is_done($journal)) { + my @taxes = qsearch({ + 'table' => 'cust_main_county', + 'extra_sql' => " WHERE tax > 0 AND country = 'US' AND state = 'WA'". + " AND district IS NOT NULL AND ( taxname IS NULL OR ". + " taxname ~* 'sales tax' )", + }); + if ( @taxes ) { + warn "Flagging Washington state sales taxes: ".scalar(@taxes)." records.\n"; + foreach (@taxes) { + $_->set('source', 'wa_sales'); + my $error = $_->replace; + die $error if $error; + } + } + FS::upgrade_journal->set_done($journal); + } + ''; +} + =back =head1 BUGS