Bug 25232: Add ability to specify multiple notforloan values to skip
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 7 May 2020 13:16:37 +0000 (09:16 -0400)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 25 Jun 2020 08:50:02 +0000 (10:50 +0200)
Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Reserves.pm
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
t/db_dependent/Holds.t

index fb7aba2..2c17d53 100644 (file)
@@ -794,8 +794,8 @@ sub CheckReserves {
     # if item is not for loan it cannot be reserved either.....
     # except where items.notforloan < 0 :  This indicates the item is holdable.
 
-    my $SkipHoldTrapOnNotForLoanValue = C4::Context->preference('SkipHoldTrapOnNotForLoanValue');
-    return if $SkipHoldTrapOnNotForLoanValue && $notforloan_per_item eq $SkipHoldTrapOnNotForLoanValue;
+    my @SkipHoldTrapOnNotForLoanValue = split( '|', C4::Context->preference('SkipHoldTrapOnNotForLoanValue') );
+    return if @SkipHoldTrapOnNotForLoanValue && grep( $notforloan_per_item, @SkipHoldTrapOnNotForLoanValue );
 
     my $dont_trap = C4::Context->preference('TrapHoldsOnOrder') ? ($notforloan_per_item > 0) : ($notforloan_per_item && 1 );
     return if $dont_trap or $notforloan_per_itemtype;
index 0fd5438..f2379e7 100644 (file)
@@ -527,10 +527,11 @@ Circulation:
                   no: "Don't trap"
             - items that are not for loan but holdable ( notforloan < 0 ) to fill holds.
         -
-            - Never trap items with a 'not for loan' value of
+            - Never trap items with 'not for loan' values of
             - pref: SkipHoldTrapOnNotForLoanValue
               class: integer
             - to fill holds.
+            - "(list of not for loan values separated with a pipe '|')"
         -
             - pref: HoldsAutoFill
               choices:
index a82fa53..bf95405 100755 (executable)
@@ -7,7 +7,7 @@ use t::lib::TestBuilder;
 
 use C4::Context;
 
-use Test::More tests => 65;
+use Test::More tests => 66;
 use MARC::Record;
 
 use C4::Biblio;
@@ -365,6 +365,8 @@ t::lib::Mocks::mock_preference( 'TrapHoldsOnOrder', 1 );
 ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold is trapped for item that is not for loan but holdable ( notforloan < 0 )" );
 t::lib::Mocks::mock_preference( 'SkipHoldTrapOnNotForLoanValue', '-1' );
 ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for item with notforloan value matching SkipHoldTrapOnNotForLoanValue" );
+t::lib::Mocks::mock_preference( 'SkipHoldTrapOnNotForLoanValue', '-1|1' );
+ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for item with notforloan value matching SkipHoldTrapOnNotForLoanValue" );
 $hold->delete();
 
 # Regression test for bug 9532