From 09ceec56d97edeae58ef84110d375515d7a82aa2 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 17 Apr 2023 01:59:10 +0000 Subject: [PATCH] Bug 33364: Prevent Holds to Pull from including items with pending recalls This patch changes the check for pending recalls to include items in transit, as well as items awaiting pickup, to fill a recall request. It then ensures the Holds to Pull report excludes items that have pending recalls. To test: 1. Enable UseRecalls and set the recalls-related circulation rules 2. Check out an item to Patron A 3. Place a hold on the item for Patron B 4. Log into the OPAC as Patron C and search for the item. Place a recall on the item. 5. Go back to the staff interface. Go to Circulation -> Holds to pull 6. Confirm the item shows in the Holds to pull table, with the hold for Patron B 7. Check in the item and confirm the recall as waiting 8. Go back to the Holds to pull page. You may need to manually regenerate the page by running the cronjob in the terminal misc/cronjobs/holds/build_holds_queue.pl 9. Notice that even though the item is allocated for a recall, the hold is showing. It should not be showing in this page. 10. Apply the patch and refresh the page 11. The item allocated to a recall should no longer be showing in the Holds to pull report 12. Go to the record detail page and go to the Recalls tab 13. Revert the recall from its waiting status 14. The record will now show on the Holds to pull page 15. Go to the Circulation -> Check in page 16. Go to the menu in the top-right of the page and click Set library 17. Change your library to a different one 18. Check in the item to confirm the recall as waiting and trigger a transfer 19. Go back to the Holds to pull page, regenerate if needed 20. The item should no longer show on the Holds to pull report 21. Confirm tests pass t/db_dependent/Koha/Item.t Sponsored-by: Auckland University of Technology --- Koha/Item.pm | 4 ++-- circ/pendingreserves.pl | 4 +++- t/db_dependent/Koha/Item.t | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 0d29655938d..56037e3d77e 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -908,7 +908,7 @@ sub has_pending_hold { my $has_pending_recall -Return if whether has pending recall of not. +Return whether item has been allocated to fill a recall request or not =cut @@ -919,7 +919,7 @@ sub has_pending_recall { return Koha::Recalls->search( { item_id => $self->itemnumber, - status => 'waiting', + status => [ 'waiting', 'in_transit' ], } )->count; } diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 21016bc3541..837146d2813 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -196,7 +196,9 @@ my @biblionumbers = $holds->get_column('biblionumber'); my $all_items; if ( $holds->count ) { foreach my $item ( $holds->get_items_that_can_fill->as_list ) { - push @{ $all_items->{ $item->biblionumber } }, $item; + unless ( $item->has_pending_recall ) { + push @{ $all_items->{ $item->biblionumber } }, $item; + } } } diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index d4fbac7f8f3..9f1f451a79c 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -1836,7 +1836,7 @@ subtest 'store() tests' => sub { subtest 'Recalls tests' => sub { - plan tests => 22; + plan tests => 23; $schema->storage->txn_begin; @@ -2017,6 +2017,10 @@ subtest 'Recalls tests' => sub { is( $item1->has_pending_recall, 0, 'Item does not have pending recall' ); + $recall2->start_transfer({ item => $item1 }); + is( $item1->has_pending_recall, 1, 'Item has a pending recall and is in transit to fill it' ); + $recall2->revert_transfer; + # return recall based on recalldate $check_recall = $item1->check_recalls; is( $check_recall->patron_id, $patron1->borrowernumber, "No waiting recall, so oldest recall is returned" ); -- 2.30.2