X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FLocation.pm;h=4f382af433325943339738bb08e1da74f17d99ad;hb=e18442a0b77e7ef55d51f369eabba19848d19a08;hp=6b707b1eb87bce54e340dd6165867ca4c24f0545;hpb=b1d823bed5c9d953a62f2b6245b71cbbab191bda;p=freeside.git diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm index 6b707b1eb..4f382af43 100644 --- a/FS/FS/cust_main/Location.pm +++ b/FS/FS/cust_main/Location.pm @@ -24,11 +24,13 @@ BEGIN { foreach my $f (@location_fields) { *{"FS::cust_main::Location::$f"} = sub { carp "WARNING: tried to set cust_main.$f with accessor" if (@_ > 1); - shift->bill_location->$f + my $l = shift->bill_location; + $l ? $l->$f : ''; }; *{"FS::cust_main::Location::ship_$f"} = sub { carp "WARNING: tried to set cust_main.ship_$f with accessor" if (@_ > 1); - shift->ship_location->$f + my $l = shift->ship_location; + $l ? $l->$f : ''; }; } $init++; @@ -156,7 +158,11 @@ sub _upgrade_data { } } - foreach my $cust_main (qsearch('cust_main', { bill_locationnum => '' })) { + foreach my $cust_main (qsearch('cust_main', { + bill_locationnum => '', + address1 => { op=>'!=', value=>'' }, + })) + { # Step 1: extract billing and service addresses into cust_location my $custnum = $cust_main->custnum; my $bill_location = FS::cust_location->new( @@ -301,6 +307,7 @@ sub _upgrade_data { qsearch('cust_location', { 'censustract' => '' }) ) { my $custnum = $cust_location->custnum; + next if !$custnum; # avoid doing this for prospect locations my $address1 = $cust_location->address1; # find the last history record that had that address my $last_h = qsearchs({