X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-address_standardize.html;h=d0255a02a7b484e35ce235732c8f47a9970db166;hb=e4a02dc995c0db1994ff26504c28557d1cb617b4;hp=f53c35fca3e7c3bfdba9de28721c2202338ca2a7;hpb=468c9e660eb0edb2033f0f8dbb4458f20280082c;p=freeside.git diff --git a/httemplate/misc/xmlhttp-address_standardize.html b/httemplate/misc/xmlhttp-address_standardize.html index f53c35fca..d0255a02a 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,8 +16,14 @@ my %old = %{ decode_json($cgi->param('arg')) } my %new; -foreach my $pre ( '', 'ship_' ) { - next unless ($pre || !$old{onlyship}); +my @prefixes = (''); +if ( $old{same} ) { + @prefixes = ('bill_'); +} elsif ( $old{billship} ) { + @prefixes = ('bill_', 'ship_'); +} +my $all_same = 1; +foreach my $pre ( @prefixes ) { my $location = { map { $_ => $old{$pre.$_} } @@ -31,8 +37,19 @@ foreach my $pre ( '', 'ship_' ) { 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'}; } -my $return = { old => \%old, new => \%new }; +my $return = { old => \%old, new => \%new, all_same => $all_same }; warn "result:\n".encode_json($return) if $DEBUG;