Bug 4319: (QA follow-up) Consistency in IsAvailableForItemLevelRequest
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 15 Dec 2017 09:09:29 +0000 (10:09 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 13 Feb 2018 16:02:23 +0000 (13:02 -0300)
[1] For consistency going back to IsItemOnHoldAndFound in this sub.
    This call is used in the on_shelf_holds == 2 case too.
    The routine will be refactored quite soon.
    Adding the else branch for on_shelf_holds == 0 for more clarity.
[2] Removing the test for found==F in reserves. In Koha F is only used
    when the hold is filled and moved to oldreserves.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Reserves.pm
t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t

index f39dc3b..31fc97e 100644 (file)
@@ -1141,18 +1141,9 @@ sub IsAvailableForItemLevelRequest {
         }
 
         return $any_available ? 0 : 1;
+    } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
+        return $item->{onloan} || IsItemOnHoldAndFound( $item->{itemnumber} );
     }
-
-    if ($item->{onloan}) {
-        return 1;
-    }
-
-    if ( Koha::Holds->search({itemnumber => $item->{itemnumber},
-                              found => ['W', 'T']})->count ) {
-        return 1;
-    }
-
-    return 0;
 }
 
 =head2 OnShelfHoldsAllowed
index 3abba34..1a9edd8 100755 (executable)
@@ -7,7 +7,7 @@ use C4::Items;
 use C4::Circulation;
 use Koha::IssuingRule;
 
-use Test::More tests => 7;
+use Test::More tests => 6;
 
 use t::lib::TestBuilder;
 use t::lib::Mocks;
@@ -255,10 +255,5 @@ $rule->store();
 $is = IsAvailableForItemLevelRequest( $item3, $borrower1);
 is( $is, 1, "Item can be held, items in transit are not available" );
 
-Koha::Holds->find($hold->{reserve_id})->found('F')->store;
-
-$is = IsAvailableForItemLevelRequest( $item3, $borrower1);
-is( $is, 0, "Item is neither waiting nor in transit." );
-
 # Cleanup
 $schema->storage->txn_rollback;