Expects output of location_hash() as parameter
-Dies on error, or if tax rate cannot be found using given address
+Returns undef on error, or if tax rate cannot be found using given address
Query the WA State Dept of Revenue API with an address, and return
tax district information for that address.
This API does not return consistent usable county names, as the county
name may include appreviations or labels referring to PTBA (public transport
benefit area) or CEZ (community empowerment zone). It's recommended to use
-the tool wa_tax_rate_update to fully populate the city/county/districts for
-WA state every financial quarter.
+the tool freeside-wa-tax-table-update to fully populate the
+city/county/districts for WA state every financial quarter.
Returns a hashref with the following keys:
- country US
- exempt_amount 0
+If api returns no district for address, generates system log error
+and returns undef
+
=cut
sub wa_sales {
+
+ #
+ # no die():
+ # freeside-queued will issue dbh->rollback on die() ... this will
+ # also roll back system log messages about errors :/ freeside-queued
+ # doesn't propgate die messages into the system log.
+ #
+
my $location_hash = shift;
- # Return without die() when called with pointless context
+ # Return when called with pointless context
return
unless $location_hash
&& ref $location_hash
my $error =
sprintf "Problem parsing XML from API URL(%s): %s",
$prepared_url, $@;
+
$log->error( $error );
- die $error;
+ warn $error;
+ return;
}
my ($res_root) = $dom->findnodes('/response');
$res_code ? $api_response_codes[$res_code] : 'n/a',
$location_hash->{address1},
$prepared_url;
+
$log->error( $error );
- die "$error\n";
+ warn "$error\n";
+ return;
}
my %response = (