X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-address_standardize.html;h=be58618d091c13271f5b70dd778126815ad5ff17;hp=e28c06f3a8228d5fa217d96d4cbf67e86631c5ac;hb=79c8be3bd0c5db42794b36bf5b5dd25addba67cb;hpb=84fa358b56b89205fff99927080d5c28c01d57ff diff --git a/httemplate/misc/xmlhttp-address_standardize.html b/httemplate/misc/xmlhttp-address_standardize.html index e28c06f3a..be58618d0 100644 --- a/httemplate/misc/xmlhttp-address_standardize.html +++ b/httemplate/misc/xmlhttp-address_standardize.html @@ -1,4 +1,4 @@ -<% encode_json($return) %> +<% encode_json($return) %>\ <%init> local $SIG{__DIE__}; #disable Mason error trap @@ -16,14 +16,14 @@ my %old = %{ decode_json($cgi->param('arg')) } my %new; -my @prefixes; -if ($old{onlyship}) { - @prefixes = ('ship_'); -} elsif ( $old{same} ) { - @prefixes = (''); -} else { - @prefixes = ('', 'ship_'); +my @prefixes = (''); +if ( $old{same} ) { + @prefixes = ('bill_'); +} elsif ( $old{billship} ) { + @prefixes = ('bill_', 'ship_'); } +my $all_same = 1; +my $all_clean = 1; foreach my $pre ( @prefixes ) { my $location = { @@ -38,8 +38,24 @@ foreach my $pre ( @prefixes ) { foreach ( keys(%$cache) ) { $new{$pre.$_} = $cache->get($_); } + + foreach ( qw(address1 address2 city state zip country) ) { + $all_same = 0 if ( $new{$pre.$_} ne $old{$pre.$_} ); + last if !$all_same; + } + + $all_same = 0 if ( length( $old{$pre.'censustract'} ) > 0 && + length( $new{$pre.'censustract'} ) > 0 && + $old{$pre.'censustract'} ne $new{$pre.'censustract'} ); + + $all_same = 0 if $new{$pre.'error'}; + + $all_clean = 0 if !$new{$pre.'addr_clean'}; } -my $return = { old => \%old, new => \%new }; +my $return = { old => \%old, + new => \%new, + all_same => $all_same, + all_clean => $all_clean }; warn "result:\n".encode_json($return) if $DEBUG;