Bug 33159: Simplify ES handling and fix zebra handling
[srvgit] / Koha / Holds.pm
index 4ff90e6..d4e0b5c 100644 (file)
@@ -34,8 +34,21 @@ Koha::Holds - Koha Hold object set class
 
 =head2 Class methods
 
+=head3 filter_by_found
+
+    my $found_holds = $holds->filter_by_found;
+
+Returns a filtered resultset without holds that are considered I<found>.
+i.e. 'P', 'T' and 'W'.
+
 =cut
 
+sub filter_by_found {
+    my ($self) = @_;
+
+    return $self->search( { found => [ 'P', 'T', 'W' ] } );
+}
+
 =head3 waiting
 
 returns a set of holds that are waiting from an existing set
@@ -48,6 +61,18 @@ sub waiting {
     return $self->search( { found => 'W' } );
 }
 
+=head3 processing
+
+returns a set of holds that are processing from an existing set
+
+=cut
+
+sub processing {
+    my ( $self ) = @_;
+
+    return $self->search( { found => 'P' } );
+}
+
 =head3 unfilled
 
 returns a set of holds that are unfilled from an existing set
@@ -85,6 +110,9 @@ sub forced_hold_level {
     my $item_level_count = $self->search( { itemnumber => { '!=' => undef } } )->count();
     return 'item' if $item_level_count > 0;
 
+    my $item_group_level_count = $self->search( { item_group_id => { '!=' => undef } } )->count();
+    return 'item_group' if $item_group_level_count > 0;
+
     my $record_level_count = $self->search( { itemnumber => undef } )->count();
     return 'record' if $record_level_count > 0;
 
@@ -120,12 +148,7 @@ sub get_items_that_can_fill {
     push @bibs_or_items, 'me.itemnumber' => { in => \@itemnumbers } if @itemnumbers;
     push @bibs_or_items, 'me.biblionumber' => { in => \@biblionumbers } if @biblionumbers;
 
-    my @branchtransfers = Koha::Item::Transfers->search(
-        {
-            datearrived => undef,
-            datecancelled => undef,
-        },
-        {
+    my @branchtransfers = Koha::Item::Transfers->filter_by_current->search({}, {
             columns  => ['itemnumber'],
             collapse => 1,
         }