-<% encode_json($return) %>
+<% encode_json($return) %>\
<%init>
local $SIG{__DIE__}; #disable Mason error trap
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;
foreach my $pre ( @prefixes ) {
my $location = {
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;
</%init>