From: Terran McCanna Date: Wed, 23 Nov 2022 18:56:49 +0000 (-0500) Subject: Online Renewal - Progress on updating addresses X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0332fcdbde9bfc5a46431ee2d55552a50c6f3347;p=evergreen%2Fpines.git Online Renewal - Progress on updating addresses (still issues with checkmarks when changing from 1 to 2 addresses or from 2 to 1 address) Signed-off-by: Terran McCanna --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm index a0484a3518..02a4329a65 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm @@ -573,7 +573,7 @@ sub update_addresses { $physical_addr->id($user->billing_address->id); $physical_addr->usr($user->id); $physical_addr->address_type('PHYSICAL'); - $physical_addr->within_city_limits('f'); + $physical_addr->within_city_limits($user->billing_address->within_city_limits); $physical_addr->valid('t'); $physical_addr->pending('f'); @@ -581,7 +581,7 @@ sub update_addresses { $mailing_addr->id($user->mailing_address->id); $mailing_addr->usr($user->id); $mailing_addr->address_type('MAILING'); - $mailing_addr->within_city_limits('f'); + $mailing_addr->within_city_limits($user->mailing_address->within_city_limits); $mailing_addr->valid('t'); $mailing_addr->pending('f'); @@ -594,18 +594,32 @@ sub update_addresses { my $val = $cgi->param($field); - # if the addr ids are the same, but the streets don't match, create second address - if ($physical_addr->id eq $mailing_addr->id && $physical_addr->street1 ne $mailing_addr->street1) { - $physical_addr->isnew(0); - $physical_addr->ischanged(1); - $mailing_addr->isnew(1); - $mailing_addr->ischanged(0); - } else { - $physical_addr->isnew(0); - $physical_addr->ischanged(1); - $mailing_addr->isnew(0); - $mailing_addr->ischanged(1); - } + if ($physical_addr->id eq $mailing_addr->id && $physical_addr->street1 eq $mailing_addr->street1) { + # if one address & stays at one address, just update it + $physical_addr->isnew(0); + $physical_addr->ischanged(1); + $mailing_addr->isnew(0); + $mailing_addr->ischanged(1); + } elsif ($physical_addr->id eq $mailing_addr->id && $physical_addr->street1 ne $mailing_addr->street1) { + # if the addr ids are the same, but the streets don't match, create a separate address entry for mailing + $physical_addr->isnew(0); + $physical_addr->ischanged(1); + $mailing_addr->isnew(1); + $mailing_addr->ischanged(0); + } elsif ($physical_addr->id ne $mailing_addr->id && $physical_addr->street1 eq $mailing_addr->street1) { + # if there were previously 2 addresses, but there is only one address now, delete excess entry + $physical_addr->isnew(0); + $physical_addr->ischanged(1); + $mailing_addr->isnew(0); + $mailing_addr->ischanged(0); + $mailing_addr->isdeleted(1); + } else { + # otherwise, update existing entries + $physical_addr->isnew(0); + $physical_addr->ischanged(1); + $mailing_addr->isnew(0); + $mailing_addr->ischanged(1); + } if ($field_info->{required} && !$val) { my $msg = "Value required for field: '$field'"; @@ -621,7 +635,6 @@ sub update_addresses { (my $col_field = $field) =~ s/mailing_//g; $mailing_addr->$col_field($val) if $val; } - } # exit if there were any errors above.