From 8869ec630601c3e8afb25a840fdde4786cb38e33 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 --- C4/Reserves.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index b3dbb7bd0ae..949dffed171 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -163,7 +163,7 @@ BEGIN { itemnumber => $itemnumber, found => $found, itemtype => $itemtype, - item_gorup_id => $item_group_id + item_group_id => $item_group_id } ); @@ -961,6 +961,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 ); @@ -1756,7 +1757,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) @@ -1792,16 +1794,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); @@ -1827,7 +1832,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