Bug 18936: (follow-up) Make possible to have unlimited value for holds_per_day
authorJoonas Kylmälä <joonas.kylmala@helsinki.fi>
Tue, 28 Jan 2020 15:05:15 +0000 (15:05 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 4 Feb 2020 09:56:29 +0000 (09:56 +0000)
Without this it is not possible to make for a specific patron category
or itemtype a more specific unlimited holds_per_day rule if you have a
catch all rule (categorycode = *, itemtype = *) with limited
holds_per_day value.

Signed-off-by: Minna Kivinen <minna.kivinen@hamk.fi>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Reserves.pm
admin/smart-rules.pl

index 86ff1fa..db910a0 100644 (file)
@@ -393,7 +393,8 @@ sub CanItemBeReserved {
             biblionumber   => $item->biblionumber,
         }
     );
-    if ( $holds->count() >= $holds_per_record ) {
+    if (   defined $holds_per_record && $holds_per_record ne ''
+        && $holds->count() >= $holds_per_record ) {
         return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record };
     }
 
@@ -402,10 +403,9 @@ sub CanItemBeReserved {
         reservedate    => dt_from_string->date
     });
 
-    if ( defined $holds_per_day &&
-          (   ( $holds_per_day > 0 && $today_holds->count() >= $holds_per_day )
-           or ( $holds_per_day == 0 ) )
-        )  {
+    if (   defined $holds_per_day && $holds_per_day ne ''
+        && $today_holds->count() >= $holds_per_day )
+    {
         return { status => 'tooManyReservesToday', limit => $holds_per_day };
     }
 
@@ -436,7 +436,8 @@ sub CanItemBeReserved {
     }
 
     # we check if it's ok or not
-    if ( $reservecount >= $allowedreserves ) {
+    if (   defined  $allowedreserves && $allowedreserves ne ''
+        && $reservecount >= $allowedreserves ) {
         return { status => 'tooManyReserves', limit => $allowedreserves };
     }
 
index ceb4a9b..75ed516 100755 (executable)
@@ -277,7 +277,7 @@ elsif ($op eq 'add') {
     my $holds_per_record = $input->param('holds_per_record');
     my $holds_per_day    = $input->param('holds_per_day');
     $holds_per_day =~ s/\s//g;
-    $holds_per_day = undef if $holds_per_day !~ /^\d+/;
+    $holds_per_day = '' if $holds_per_day !~ /^\d+/;
     my $onshelfholds     = $input->param('onshelfholds') || 0;
     $maxissueqty =~ s/\s//g;
     $maxissueqty = '' if $maxissueqty !~ /^\d+/;