fix A/R report
[freeside.git] / httemplate / misc / xmlhttp-address_standardize.html
index 9880571..be58618 100644 (file)
@@ -1,4 +1,4 @@
-<% encode_json($return) %>
+<% encode_json($return) %>\
 <%init>
 
 local $SIG{__DIE__}; #disable Mason error trap
@@ -16,15 +16,14 @@ my %old = %{ decode_json($cgi->param('arg')) }
 
 my %new;
 
-my @prefixes;
-if ($old{onlyship}) {
-  @prefixes = ('ship_');
-} elsif ( $old{same} ) {
+my @prefixes = ('');
+if ( $old{same} ) {
   @prefixes = ('bill_');
-} else {
+} elsif ( $old{billship} ) {
   @prefixes = ('bill_', 'ship_');
 }
 my $all_same = 1;
+my $all_clean = 1;
 foreach my $pre ( @prefixes ) {
 
   my $location = {
@@ -44,8 +43,19 @@ foreach my $pre ( @prefixes ) {
     $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, all_same => $all_same };
+my $return = { old => \%old,
+               new => \%new,
+               all_same => $all_same,
+               all_clean => $all_clean };
 warn "result:\n".encode_json($return) if $DEBUG;
 </%init>