X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Flocation_Mixin.pm;h=b010374a9e51264900c09f6ed7111a8a10be4381;hp=d32b4a37ca06eb940d866ce140496f9b4c9dc5d8;hb=389b6f1116c3309c2ee57a6c295ed1a793503095;hpb=ba638765b1c8a27e8d1da8074b285a93f4a8241e diff --git a/FS/FS/location_Mixin.pm b/FS/FS/location_Mixin.pm index d32b4a37c..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 ... ]