X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Ftax_rate_location.pm;h=ad3618a9835dd347f5012318f724cb420e992082;hp=d9646e4bcb0cd7f957c2e03903567635561034cf;hb=5f7c4a6025b9e3a49bee72dbc06cac37a45e6f10;hpb=7516e3da0f17eeecba27219ef96a8b5f46af2083 diff --git a/FS/FS/tax_rate_location.pm b/FS/FS/tax_rate_location.pm index d9646e4bc..ad3618a98 100644 --- a/FS/FS/tax_rate_location.pm +++ b/FS/FS/tax_rate_location.pm @@ -118,16 +118,12 @@ sub check { ; return $error if $error; - my $t; - $t = qsearchs( 'tax_rate_location', - { disabled => '', - ( map { $_ => $self->$_ } qw( data_vendor geocode ) ), - }, - ) + my $t = ''; + $t = $self->existing_search unless $self->disabled; $t = $self->by_key( $self->taxratelocationnum ) - if ( !$t && $self->taxratelocationnum ); + if !$t && $self->taxratelocationnum; return "geocode ". $self->geocode. " already in use for this vendor" if ( $t && $t->taxratelocationnum != $self->taxratelocationnum ); @@ -153,11 +149,7 @@ record. sub find_or_insert { my $self = shift; - my $existing = qsearchs('tax_rate_location', { - disabled => '', - data_vendor => $self->data_vendor, - geocode => $self->geocode - }); + my $existing = $self->existing_search; if ($existing) { my $update = 0; foreach (qw(city county state country)) { @@ -176,6 +168,20 @@ sub find_or_insert { } } +sub existing_search { + my $self = shift; + + my @unique = qw( data_vendor geocode ); + push @unique, qw( state country ) + if $self->data_vendor eq 'compliance_solutions'; + + qsearchs( 'tax_rate_location', + { disabled => '', + map { $_ => $self->$_ } @unique + } + ); +} + =back =head1 CLASS METHODS @@ -392,6 +398,16 @@ sub batch_import { } +sub _upgrade_data { + my $class = shift; + + my $sql = "UPDATE tax_rate_location SET data_vendor = 'compliance_solutions' WHERE data_vendor = 'compliance solutions'"; + + my $sth = dbh->prepare($sql) or die $DBI::errstr; + $sth->execute() or die $sth->errstr; + +} + =head1 BUGS Currently somewhat specific to CCH supplied data.