# create a tax rate location if there isn't one yet
my $taxname = $tax_data->{descript};
my $tax_rate = FS::tax_rate->new({
- data_vendor => 'compliance solutions',
+ data_vendor => 'compliance_solutions',
taxname => $taxname,
taxclassnum => '',
taxauth => $tax_data->{'taxauthtype'}, # federal / state / city / district
$tax_rate = $tax_rate->replace_old;
my $tax_rate_location = FS::tax_rate_location->new({
- data_vendor => 'compliance solutions',
+ data_vendor => 'compliance_solutions',
+ geocode => $tax_data->{'geocode'},
state => $tax_data->{'state'},
country => $tax_data->{'country'},
- geocode => $tax_data->{'geocode'},
});
$error = $tax_rate_location->find_or_insert;
- die "error inserting tax_rate_location record: $error\n"
+ die 'error inserting tax_rate_location record for '. $tax_data->{state}.
+ '/'. $tax_data->{country}. ' ('. $tax_data->{'geocode'}. "): $error\n"
if $error;
$tax_rate_location = $tax_rate_location->replace_old;
#mark certain taxes as system-maintained,
# and fix whitespace
'cust_main_county' => [],
+
+ #'compliance solutions' -> 'compliance_solutions'
+ 'tax_rate' => [],
+ 'tax_rate_location' => [],
;
\%hash;
}
+sub _upgrade_data {
+ my $class = shift;
+ my $sql = "UPDATE tax_rate 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;
+
+}
=back
;
return $error if $error;
+ my @unique = qw( data_vendor geocode );
+ push @unique, qw( state country )
+ if $self->data_vendor eq 'compliance_solutions';
+
my $t;
$t = qsearchs( 'tax_rate_location',
{ disabled => '',
- ( map { $_ => $self->$_ } qw( data_vendor geocode ) ),
+ ( map { $_ => $self->$_ } @unique ),
},
)
unless $self->disabled;
}
+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.