11 Also accepts all the above keys with the prefixes bill_ and ship_
13 Returns json with a key for each given address, e.g., whose value is
14 the tax district number. e.g.
24 error: district not found
30 <% encode_json($return) %>
35 http_header('Content-Type' => 'application/json');
38 my %param = ( $cgi->Vars );
41 warn '$param: '.Dumper( \%param )."\n"
45 for my $prefix ( '', 'bill', 'ship' ) {
46 my $addr_key = $prefix || 'address';
47 $address{$addr_key} = {};
48 $address{$addr_key}->{$_} = $param{ $prefix ? "${prefix}_${_}" : $_ }
49 for qw/ address1 address2 city state zip country /;
50 delete $address{$addr_key}
51 unless $address{$addr_key}->{address1}
52 && $address{$addr_key}->{city};
54 warn Dumper( \%address )
57 for my $k ( keys %address ) {
58 next unless lc $address{$k}->{state} eq 'wa';
59 my $response = FS::Misc::Geo::wa_sales( $address{$k} );
60 warn Dumper( $response )
63 if ( ref $response ) {
64 $return->{$k} = $response;
66 $return->{$k} = { error => 'Lookup Failed' };
70 unless ( keys %$return ) {
71 $return->{error} = 'No WA addresses passed for lookup - nothing to do';
74 warn '$return: '.Dumper( $return )."\n"