From 1bd757bd689cb8af096da644d0f307130a820d27 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 10 Mar 2020 09:02:22 -0400 Subject: [PATCH] Bug 24860: Skip non-matching item group holds in CheckReserves Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert Signed-off-by: Katrin Fischer --- C4/Reserves.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index a94d66d2a8..10eb089a9b 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -162,7 +162,7 @@ BEGIN { itemnumber => $itemnumber, found => $found, itemtype => $itemtype, - item_gorup_id => $item_group_id + item_group_id => $item_group_id } ); @@ -957,6 +957,7 @@ sub CheckReserves { # See if this item is more important than what we've got so far if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) { $item ||= Koha::Items->find($itemnumber); + next if $res->{item_group_id} && ( !$item->item_group || $item->item_group->id != $res->{item_group_id} ); next if $res->{itemtype} && $res->{itemtype} ne $item->effective_itemtype; $patron ||= Koha::Patrons->find( $res->{borrowernumber} ); my $branch = GetReservesControlBranch( $item->unblessed, $patron->unblessed ); @@ -1749,7 +1750,8 @@ sub _Findgroupreserve { reserves.itemnumber AS itemnumber, reserves.reserve_id AS reserve_id, reserves.itemtype AS itemtype, - reserves.non_priority AS non_priority + reserves.non_priority AS non_priority, + reserves.item_group_id AS item_group_id FROM reserves JOIN biblioitems USING (biblionumber) JOIN hold_fill_targets USING (reserve_id) @@ -1785,16 +1787,19 @@ sub _Findgroupreserve { reserves.itemnumber AS itemnumber, reserves.reserve_id AS reserve_id, reserves.itemtype AS itemtype, - reserves.non_priority AS non_priority + reserves.non_priority AS non_priority, + reserves.item_group_id AS item_group_id FROM reserves JOIN biblioitems USING (biblionumber) JOIN hold_fill_targets USING (reserve_id) + LEFT JOIN item_group_items ON ( item_group_items.item_id = hold_fill_targets.itemnumber ) WHERE found IS NULL AND priority > 0 AND item_level_request = 0 AND hold_fill_targets.itemnumber = ? AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) AND suspend = 0 + AND reserves.item_group_id = item_group_items.item_group_id ORDER BY priority }; $sth = $dbh->prepare($title_level_target_query); @@ -1820,7 +1825,8 @@ sub _Findgroupreserve { reserves.itemnumber AS itemnumber, reserves.reserve_id AS reserve_id, reserves.itemtype AS itemtype, - reserves.non_priority AS non_priority + reserves.non_priority AS non_priority, + reserves.item_group_id AS item_group_id FROM reserves WHERE reserves.biblionumber = ? AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) -- 2.30.2