use Modern::Perl;
-use Carp;
use Koha::Database;
=head1 API
-=head2 Class Methods
+=head2 Class methods
=cut
return $self->search( $params, $attributes );
}
+=head3 filter_by_current
+
+ my $current_article_requests = $article_requests->filter_by_current;
+
+Returns a new resultset, filtering out finished article requests.
+
+=cut
+
+sub filter_by_current {
+ my ($self) = @_;
+
+ return $self->search(
+ {
+ status => [
+ Koha::ArticleRequest::Status::Requested,
+ Koha::ArticleRequest::Status::Pending,
+ Koha::ArticleRequest::Status::Processing,
+ ]
+ }
+ );
+}
+
+=head3 filter_by_finished
+
+ my $finished_article_requests = $article_requests->filter_by_finished;
+
+Returns a new resultset, filtering out current article requests.
+
+=cut
+
+sub filter_by_finished {
+ my ($self) = @_;
+
+ return $self->search(
+ {
+ status => [
+ Koha::ArticleRequest::Status::Completed,
+ Koha::ArticleRequest::Status::Canceled,
+ ]
+ }
+ );
+}
+
+=head3 requested
+
+=cut
+
+sub requested {
+ my ( $self, $branchcode ) = @_;
+ my $params = { status => Koha::ArticleRequest::Status::Requested };
+ $params->{'me.branchcode'} = $branchcode if $branchcode;
+ return Koha::ArticleRequests->search_limited($params);
+}
+
=head3 pending
=cut