Bug 18547: On shelf holds allowed > "If all unavailable" ignores default hold policy
authorMirko Tietgen <mirko@abunchofthings.net>
Wed, 3 May 2017 19:13:49 +0000 (21:13 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sun, 26 Nov 2017 14:30:17 +0000 (11:30 -0300)
If in the circ rules matrix you set "On shelf holds allowed" to "If all unavailable",
default hold policy "From home library" is ignored.

Test plan:

- Have a test user from one branch (eg Centerville)

- Set "On shelf holds allowed" to "If all unavailable" for your patron and item
  category (or everyone and everything)
- For "Default checkout, hold and return policy", set hold policy to "From home library"
  -> make sure there is no "Default holds policy by item type" to override the setting

- Have two items for a record.
  1. An item with home branch same as test user (eg Centerville)
  -> check this item out to somebody else
  2. an item with a different home branch (eg Fairfield)
  -> available, not checked out
- Try to place a hold for your test user. Does not work.

- Apply the patch
- Try to place a hold. Should work now.

Followed test plan, worked as intended
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Followed test plan in the intranet and OPAC, worked as intended.
With few assumptions made:
- when the hold works, should be on the item 1 (Centerville)
  item 2 is only there to trigger the bug
- the circ rules were identically setup on each branch and in "Standard rules for all libraries"
Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Reserves.pm

index 78f5ca3..71bbfba 100644 (file)
@@ -1160,6 +1160,10 @@ sub IsAvailableForItemLevelRequest {
         my $any_available = 0;
 
         foreach my $i (@items) {
+
+            my $circ_control_branch = C4::Circulation::_GetCircControlBranch( $i->unblessed(), $borrower );
+            my $branchitemrule = C4::Circulation::GetBranchItemRule( $circ_control_branch, $i->itype );
+
             $any_available = 1
               unless $i->itemlost
               || $i->notforloan > 0
@@ -1168,7 +1172,8 @@ sub IsAvailableForItemLevelRequest {
               || IsItemOnHoldAndFound( $i->id )
               || ( $i->damaged
                 && !C4::Context->preference('AllowHoldsOnDamagedItems') )
-              || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan;
+              || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
+              || $branchitemrule->{holdallowed} == 1 && $borrower->{branchcode} ne $i->homebranch;
         }
 
         return $any_available ? 0 : 1;