From 9fa02f8212c787f46f0e90bcb0ad74528fddab05 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 11 Sep 2025 01:48:26 +0000 Subject: [PATCH] Bug 33364: Prevent Holds to Pull from including items with pending recalls This patch checks for waiting or in_transit items allocated to recalls, and excludes them from the Holds to Pull report. To test: 1. Enable UseRecalls and set the recalls-related circulation rules 2. Check out an item to Patron A 3. Place an item-level hold on the item for Patron B 4. Log into the OPAC as Patron C and search for the item. Place an item-level recall on the item. 5. Go back to the staff interface and check in the item. This should prompt a pop-up to confirm the recall as waiting. Confirm the recall as waiting. 6. Go to Circulation -> Holds to pull. 7. Notice that even though the item is allocated for a recall, the hold is showing. It should not be showing in this page. 8. Apply the patch, restart services and refresh the page 9. The item allocated to a recall should no longer be showing in the Holds to pull report 10. Go to the record detail page and go to the Recalls tab 11. Revert the recall from its waiting status 12. Go back to the Holds to pull page. The record will now show for the hold. 13. Go to the Circulation -> Check in page 14. Go to the menu in the top-right of the page and click Set library 15. Change your library to a different one 16. Check in the item to confirm the recall as waiting and trigger a transfer 17. Go back to the Holds to pull page 19. The item should no longer show on the Holds to pull report 20. Confirm tests pass t/db_dependent/Koha/Holds.t Sponsored-by: Catalyst IT Signed-off-by: David Nind Signed-off-by: Lisette Scheer Signed-off-by: Lucas Gass --- Koha/Holds.pm | 9 ++++++++- t/db_dependent/Koha/Holds.t | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Koha/Holds.pm b/Koha/Holds.pm index 7c6d5b9f50..3b8b92d790 100644 --- a/Koha/Holds.pm +++ b/Koha/Holds.pm @@ -161,11 +161,18 @@ sub get_items_that_can_fill { collapse => 1, } )->get_column('itemnumber'); + my @pending_recalls = Koha::Recalls->search( + { 'status' => [ 'waiting', 'in_transit' ] }, + { + columns => ['item_id'], + collapse => 1, + } + )->get_column('item_id'); return Koha::Items->search( { -or => \@bibs_or_items, - itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] }, + itemnumber => { -not_in => [ @branchtransfers, @waiting_holds, @pending_recalls ] }, onloan => undef, notforloan => 0, } diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t index 40dd2b3206..5114de678e 100755 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -808,7 +808,7 @@ subtest 'Desks' => sub { }; subtest 'get_items_that_can_fill' => sub { - plan tests => 6; + plan tests => 7; Koha::CirculationRules->search( { @@ -913,6 +913,16 @@ subtest 'get_items_that_can_fill' => sub { [ $item_2->itemnumber, $item_5->itemnumber ], 'Only item 2 and 5 are available for filling the hold' ); + my $waiting_recall = $builder->build_object( + { class => 'Koha::Recalls', value => { item_id => $item_5->itemnumber, status => 'waiting' } } ); + $items = $holds->get_items_that_can_fill; + is_deeply( + [ map { $_->itemnumber } $items->as_list ], + [ $item_2->itemnumber ], + 'Only item 2 is available for filling the hold as item 5 is allocated to a pending recall' + ); + $waiting_recall->delete; + # Marking item_5 is no hold allowed Koha::CirculationRule->new( {