From c533822aaa3ef430356117532f010e7f1ae1334d Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Thu, 9 Dec 2021 13:50:41 +0000 Subject: [PATCH] Bug 29750: Reserves.pm should check if a patron is eligible to reserve and item before confirming the reserve Test plan: 1. Create two patrons, with the following patron categories: - Patron A -> Patron - Patron B -> Student 2. Create two items attached to a single biblio record: - Book - Continuing resource 3. Create the following circ rules: Patron category, item type, Holds allowed (total), Holds allowed (daily), Holds per record (count) - Patron, Book, 0, 0, 0 - Student, Book, 1, 1, 1 - All, Continuing resources, 1, 1, 1 4. Place a title level hold on the biblio for patron A 5. Place a title level hold on the biblio for patron B 6. Checkin the Book and notice you are prompted to confirm the hold by Patron A - even though according to circ rules they cannot reserve Books 7. Apply patch and restart services 9. Checkin the Book, and notice you're prompted to confirm the hold by Patron B Sponsored-By: Brimbank Library, Australia --- C4/Reserves.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index a42168bc72..0afae3ec87 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -506,6 +506,7 @@ sub CanItemBeReserved { $reservecount = $rowcount->{count}; } + warn $allowedreserves; # we check if it's ok or not if ( defined $allowedreserves && $allowedreserves ne '' ){ if( $allowedreserves == 0 ){ @@ -566,6 +567,7 @@ sub CanItemBeReserved { } } + warn $pickup_branchcode; if ($pickup_branchcode) { my $destination = Koha::Libraries->find({ branchcode => $pickup_branchcode, @@ -913,6 +915,7 @@ sub CheckReserves { next if ( ($hold_fulfillment_policy eq 'homebranch') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) ); next if ( ($hold_fulfillment_policy eq 'holdingbranch') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) ); next unless $item->can_be_transferred( { to => Koha::Libraries->find( $res->{branchcode} ) } ); + next if (CanItemBeReserved( $res->{borrowernumber}, $item->itemnumber, $res->{branchcode}, { ignore_hold_counts => 1 } )->{status} ne 'OK'); $priority = $res->{'priority'}; $highest = $res; last if $local_hold_match; -- 2.11.0