1 package FS::location_Mixin;
4 use FS::Record qw( qsearchs );
9 Returns the location object, if any (see L<FS::cust_location>).
14 my( $self, %opt ) = @_;
16 return '' unless $self->locationnum;
18 return $opt{_cache}->{$self->locationnum}
19 if $opt{_cache} && $opt{_cache}->{$self->locationnum};
22 qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } );
24 $opt{_cache}->{$self->locationnum} = $cust_location
30 =item cust_location_or_main
32 If this package is associated with a location, returns the locaiton (see
33 L<FS::cust_location>), otherwise returns the customer (see L<FS::cust_main>).
37 sub cust_location_or_main {
39 $self->cust_location(@_) || $self->cust_main;
42 =item location_label [ OPTION => VALUE ... ]
44 Returns the label of the location object (see L<FS::cust_location>).
50 my $object = $self->cust_location_or_main or return '';
51 $object->location_label(@_);
56 Returns a hash of values for the location, either from the location object,
57 the cust_main shipping address, or the cust_main address, whichever is present
64 my $object = $self->cust_location_or_main;
65 $object->location_hash(@_);