X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-cust_main-address_standardize.html;h=d0627cd59835350ed3c230e74964c889a20a83d5;hb=98779ec47370ad67c716154f67f6a726b83e09ed;hp=e290301c9f3b395894a973ab2a9f6eb61225f4ef;hpb=9dc88f6c738f30ce1eb6339ba4b739b45555dea4;p=freeside.git diff --git a/httemplate/misc/xmlhttp-cust_main-address_standardize.html b/httemplate/misc/xmlhttp-cust_main-address_standardize.html index e290301c9..d0627cd59 100644 --- a/httemplate/misc/xmlhttp-cust_main-address_standardize.html +++ b/httemplate/misc/xmlhttp-cust_main-address_standardize.html @@ -1,7 +1,7 @@ -<% to_json($return) %> +<% objToJson($return) %> <%init> -my $DEBUG = 1; +my $DEBUG = 0; my $conf = new FS::Conf; @@ -28,6 +28,7 @@ if ( $sub eq 'address_standardize' ) { } ); foreach my $pre ( '', 'ship_' ) { + next unless ($pre || !$arg{onlyship}); my($zip5, $zip4) = split('-',$arg{$pre.'zip'}); @@ -50,6 +51,9 @@ if ( $sub eq 'address_standardize' ) { unless ( $verifier->is_error ) { + my $zip = $hash->{Zip5}; + $zip .= '-'. $hash->{Zip4} if $hash->{Zip4} =~ /\d/; + $return = { %$return, "new_$pre".'company' => $hash->{FirmName}, @@ -57,7 +61,7 @@ if ( $sub eq 'address_standardize' ) { "new_$pre".'address2' => $hash->{Address1}, "new_$pre".'city' => $hash->{City}, "new_$pre".'state' => $hash->{State}, - "new_$pre".'zip' => $hash->{Zip5}. '-'. $hash->{Zip4}, + "new_$pre".'zip' => $zip, }; my @fields = (qw( company address1 address2 city state zip )); #hmm @@ -72,7 +76,9 @@ if ( $sub eq 'address_standardize' ) { } else { - warn "USPS WebTools error: ". $verifier->response. "\n"; + $return->{$pre.'error'} = "USPS WebTools error: ". + $verifier->{error}{description}; + }