[freeside-commits] branch master updated. befa6ce8570f6493d9a77d6522c97bc5f8d501a8
Mark Wells
mark at 420.am
Tue Jun 4 19:03:39 PDT 2013
The branch, master has been updated
via befa6ce8570f6493d9a77d6522c97bc5f8d501a8 (commit)
from be03a0f16d1476522950d93869d17d067375804e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit befa6ce8570f6493d9a77d6522c97bc5f8d501a8
Author: Mark Wells <mark at freeside.biz>
Date: Tue Jun 4 19:03:08 2013 -0700
handle census tract properly in location upgrade, #23422
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index bd0af53..22feaf9 100644
--- a/FS/FS/cust_main/Location.pm
+++ b/FS/FS/cust_main/Location.pm
@@ -157,19 +157,15 @@ sub _upgrade_data {
my $bill_location = FS::cust_location->new(
{
custnum => $custnum,
- map { $_ => $cust_main->get($_) } location_fields()
+ map { $_ => $cust_main->get($_) } location_fields(),
}
);
- $error = $bill_location->insert;
- die "error migrating billing address for customer $custnum: $error"
- if $error;
-
- $cust_main->set(bill_locationnum => $bill_location->locationnum);
+ $bill_location->set('censustract', ''); # properly goes with ship_location
+ my $ship_location = $bill_location; # until proven otherwise
if ( $cust_main->get('ship_address1') ) {
# detect duplicates
my $same = 1;
- my $ship_location;
foreach (location_fields()) {
if ( length($cust_main->get("ship_$_")) and
$cust_main->get($_) ne $cust_main->get("ship_$_") ) {
@@ -177,21 +173,16 @@ sub _upgrade_data {
}
}
- if ( $same ) {
- $ship_location = $bill_location;
- } else {
+ if ( !$same ) {
$ship_location = FS::cust_location->new(
{
custnum => $custnum,
map { $_ => $cust_main->get("ship_$_") } location_fields()
}
);
- $error = $ship_location->insert;
- die "error migrating service address for customer $custnum: $error"
- if $error;
- }
+ } # else it stays equal to $bill_location
- $cust_main->set(ship_locationnum => $ship_location->locationnum);
+ $ship_location->set('censustract', $cust_main->get('censustract'));
# Step 2: Extract shipping address contact fields into contact
my %unlike = map { $_ => 1 }
@@ -233,10 +224,20 @@ sub _upgrade_data {
$cust_main->set("ship_$_" => '') foreach qw(last first company);
} #if %unlike
} #if ship_address1
- else {
- $cust_main->set(ship_locationnum => $bill_location->locationnum);
+ $error = $bill_location->insert;
+ die "error migrating billing address for customer $custnum: $error"
+ if $error;
+
+ $cust_main->set(bill_locationnum => $bill_location->locationnum);
+
+ if (!$ship_location->locationnum) {
+ $error = $ship_location->insert;
+ die "error migrating service address for customer $custnum: $error"
+ if $error;
}
+ $cust_main->set(ship_locationnum => $ship_location->locationnum);
+
# Step 3: Wipe the migrated fields and update the cust_main
$cust_main->set("ship_$_" => '') foreach location_fields();
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main/Location.pm | 35 ++++++++++++++++++-----------------
1 files changed, 18 insertions(+), 17 deletions(-)
More information about the freeside-commits
mailing list