@@ -, +, @@ methods to use relationships $ kshell k$ prove t/db_dependent/Koha/Biblio.t \ t/db_dependent/ArticleRequests.t --- Koha/Biblio.pm | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -342,67 +342,44 @@ sub article_request_type_for_items { =head3 article_requests -my @requests = $biblio->article_requests + my $article_requests = $biblio->article_requests -Returns the article requests associated with this Biblio +Returns the article requests associated with this biblio =cut sub article_requests { - my ( $self, $borrower ) = @_; - - $self->{_article_requests} ||= Koha::ArticleRequests->search( { biblionumber => $self->biblionumber() } ); + my ( $self ) = @_; - return wantarray ? $self->{_article_requests}->as_list : $self->{_article_requests}; + return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests ); } =head3 article_requests_current -my @requests = $biblio->article_requests_current + my $current_article_requests = $biblio->article_requests_current -Returns the article requests associated with this Biblio that are incomplete +Returns the article requests associated with this biblio that are incomplete =cut sub article_requests_current { - my ( $self, $borrower ) = @_; - - $self->{_article_requests_current} ||= Koha::ArticleRequests->search( - { - biblionumber => $self->biblionumber(), - -or => [ - { status => Koha::ArticleRequest::Status::Requested }, - { status => Koha::ArticleRequest::Status::Pending }, - { status => Koha::ArticleRequest::Status::Processing } - ] - } - ); + my ( $self ) = @_; - return wantarray ? $self->{_article_requests_current}->as_list : $self->{_article_requests_current}; + return $self->article_requests->filter_by_current; } =head3 article_requests_finished -my @requests = $biblio->article_requests_finished + my $finished_article_requests = $biblio->article_requests_finished -Returns the article requests associated with this Biblio that are completed +Returns the article requests associated with this biblio that are completed =cut sub article_requests_finished { my ( $self, $borrower ) = @_; - $self->{_article_requests_finished} ||= Koha::ArticleRequests->search( - { - biblionumber => $self->biblionumber(), - -or => [ - { status => Koha::ArticleRequest::Status::Completed }, - { status => Koha::ArticleRequest::Status::Canceled } - ] - } - ); - - return wantarray ? $self->{_article_requests_finished}->as_list : $self->{_article_requests_finished}; + return $self->article_requests->filter_by_finished; } =head3 items --