From cde445c217a5e8880850f22bdbfc1f29011dd8f8 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 30 Jul 2020 12:36:24 +0000 Subject: [PATCH] Bug 18958: (follow-up) Also find waiting holds for the current item/patron In the first patch we deal with the situation where the pickup location doesn't match the checked in location This patch takes care fo the situation for holds not being transferred Same test plan, but holds and items can all be for single library --- C4/Reserves.pm | 2 +- t/db_dependent/Reserves.t | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 3962a95d70..017f846268 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1685,7 +1685,7 @@ sub _Findgroupreserve { FROM reserves JOIN biblioitems USING (biblionumber) JOIN hold_fill_targets USING (biblionumber, borrowernumber) - WHERE ( ( found IS NULL AND priority > 0 ) OR found='T' ) + WHERE ( ( found IS NULL AND priority > 0 ) OR found IN ('T','W') ) AND item_level_request = 0 AND hold_fill_targets.itemnumber = ? AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 7b8650689a..9dac8dc758 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -1080,7 +1080,7 @@ subtest 'RevertWaitingStatus' => sub { subtest 'CheckReserves additional test' => sub { - plan tests => 3; + plan tests => 6; my $biblio = $builder->build_sample_biblio(); my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } }); @@ -1134,6 +1134,7 @@ subtest 'CheckReserves additional test' => sub { } }); + # We set one reserve in transit - equivalent to checking it in at another branch and confirming transfer ModReserveAffect( $item_1->itemnumber, $reserve1->borrowernumber, 1, $reserve1->reserve_id ); my ($status, $matched_reserve, $possible_reserves) = CheckReserves($item_1->itemnumber); @@ -1141,6 +1142,15 @@ subtest 'CheckReserves additional test' => sub { is( $matched_reserve->{reserve_id}, $reserve1->reserve_id, "We got the Transit reserve"); is( scalar @$possible_reserves, 1, 'We only get the one matched'); + + # We set the reserve to waiting - equivalent to checking it in at pickup location and confirming + ModReserveAffect( $item_1->itemnumber, $reserve1->borrowernumber, 0, $reserve1->reserve_id ); + ($status, $matched_reserve, $possible_reserves) = CheckReserves($item_1->itemnumber); + + is( $status, 'Waiting', "We found a reserve" ); + is( $matched_reserve->{reserve_id}, $reserve1->reserve_id, "We got the Waiting reserve"); + is( scalar @$possible_reserves, 1, 'We only get the one matched'); + }; sub count_hold_print_messages { -- 2.11.0