X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Flocation_Mixin.pm;h=b010374a9e51264900c09f6ed7111a8a10be4381;hp=d45738682e2c9016af3cfb1d03e6688e2f1a8c15;hb=389b6f1116c3309c2ee57a6c295ed1a793503095;hpb=624b2d44625f69d71175c3348cae635d580c890b diff --git a/FS/FS/location_Mixin.pm b/FS/FS/location_Mixin.pm index d45738682..b010374a9 100644 --- a/FS/FS/location_Mixin.pm +++ b/FS/FS/location_Mixin.pm @@ -11,9 +11,20 @@ Returns the location object, if any (see L). =cut sub cust_location { - my $self = shift; + my( $self, %opt ) = @_; + return '' unless $self->locationnum; - qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } ); + + return $opt{_cache}->{$self->locationnum} + if $opt{_cache} && $opt{_cache}->{$self->locationnum}; + + my $cust_location = + qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } ); + + $opt{_cache}->{$self->locationnum} = $cust_location + if $opt{_cache}; + + $cust_location; } =item cust_location_or_main @@ -25,7 +36,7 @@ L), otherwise returns the customer (see L). sub cust_location_or_main { my $self = shift; - $self->cust_location || $self->cust_main; + $self->cust_location(@_) || $self->cust_main; } =item location_label [ OPTION => VALUE ... ] @@ -36,7 +47,7 @@ Returns the label of the location object (see L). sub location_label { my $self = shift; - my $object = $self->cust_location_or_main; + my $object = $self->cust_location_or_main or return ''; $object->location_label(@_); }