creating address-less free customers, RT#24968
[freeside.git] / FS / FS / cust_main / Location.pm
index 6b707b1..4bcffab 100644 (file)
@@ -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++;
@@ -301,6 +303,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({