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 <david@davidnind.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Aleisha Amohia 2025-09-11 01:48:26 +00:00 committed by Pedro Amorim
parent f2cca7c630
commit 33f4336974
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 19 additions and 2 deletions

View File

@ -161,11 +161,18 @@ sub get_items_that_can_fill {
collapse => 1, collapse => 1,
} }
)->get_column('itemnumber'); )->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( return Koha::Items->search(
{ {
-or => \@bibs_or_items, -or => \@bibs_or_items,
itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] }, itemnumber => { -not_in => [ @branchtransfers, @waiting_holds, @pending_recalls ] },
onloan => undef, onloan => undef,
notforloan => 0, notforloan => 0,
} }

View File

@ -811,7 +811,7 @@ subtest 'Desks' => sub {
}; };
subtest 'get_items_that_can_fill' => sub { subtest 'get_items_that_can_fill' => sub {
plan tests => 6; plan tests => 7;
Koha::CirculationRules->search( Koha::CirculationRules->search(
{ {
@ -916,6 +916,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' [ $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 # Marking item_5 is no hold allowed
Koha::CirculationRule->new( Koha::CirculationRule->new(
{ {