# set up accessors for location fields
if (!$init) {
no strict 'refs';
- @location_fields =
- qw( address1 address2 city county state zip country district
- latitude longitude coord_auto censustract censusyear geocode
- addr_clean );
+ @location_fields = qw(
+ locationname
+ address1 address2 city county state zip country
+ district latitude longitude coord_auto censustract censusyear geocode
+ addr_clean
+ );
foreach my $f (@location_fields) {
*{"FS::cust_main::Location::$f"} = sub {
$self->hashref->{bill_location}
||= FS::cust_location->by_key($self->bill_locationnum)
# degraded mode--let the system keep running during upgrades
- || FS::cust_location->new({
- map { $_ => $self->get($_) } @location_fields
- })
+ || ( $self->get('address1')
+ && FS::cust_location->new({
+ map { $_ => $self->get($_) } @location_fields
+ })
+ );
}
=item ship_location
my $self = shift;
$self->hashref->{ship_location}
||= FS::cust_location->by_key($self->ship_locationnum)
- || FS::cust_location->new({
- map { $_ => $self->get('ship_'.$_) || $self->get($_) } @location_fields
- })
+ # degraded mode--let the system keep running during upgrades
+ || ( $self->get('ship_address1')
+ ? FS::cust_location->new({
+ map { $_ => $self->get('ship_'.$_) } @location_fields
+ })
+ : $self->get('address1')
+ ? FS::cust_location->new({
+ map { $_ => $self->get($_) } @location_fields
+ })
+ : ''
+ );
}