Bug 23185: Realistic POD for Koha::Objects->search
[srvgit] / Koha / Holds.pm
index bde63c9..604953d 100644 (file)
@@ -4,18 +4,18 @@ package Koha::Holds;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
 
@@ -39,7 +39,7 @@ Koha::Holds - Koha Hold object set class
 
 =head3 waiting
 
-Returns a set of holds that are waiting from an existing set
+returns a set of holds that are waiting from an existing set
 
 =cut
 
@@ -49,6 +49,18 @@ sub waiting {
     return $self->search( { found => 'W' } );
 }
 
+=head3 unfilled
+
+returns a set of holds that are unfilled from an existing set
+
+=cut
+
+sub unfilled {
+    my ( $self ) = @_;
+
+    return $self->search( { found => undef } );
+}
+
 =head3 forced_hold_level
 
 If a patron has multiple holds for a single record,
@@ -62,7 +74,7 @@ This method will return 'item' if the patron has
 at least one item level hold. It will return 'record'
 if the patron has holds but none are item level,
 Finally, if the patron has no holds, it will return
-undef which indicateds the patron may select either
+undef which indicates the patron may select either
 record or item level holds, barring any other rules
 that would prevent one or the other.
 
@@ -71,9 +83,13 @@ that would prevent one or the other.
 sub forced_hold_level {
     my ($self) = @_;
 
-    return $self->search( { itemnumber => { '!=' => undef } } )->count()
-      ? 'item'
-      : 'record';
+    my $item_level_count = $self->search( { itemnumber => { '!=' => undef } } )->count();
+    return 'item' if $item_level_count > 0;
+
+    my $record_level_count = $self->search( { itemnumber => undef } )->count();
+    return 'record' if $record_level_count > 0;
+
+    return;
 }
 
 =head3 type