From d95333388f8451ebb78f7171ecc961679d4439fa Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 6 Sep 2023 00:13:48 +0000 Subject: [PATCH] Bug 34722: Prevent other items from displaying to fill item-level recalls This patch prevents other items attached to a record from being displayed as 'recalled' by item-level recalls. To test: 1. Ensure UseRecalls system preference is enabled and circulation rules relevant to recalls are configured. Set 'on shelf recalls allowed' circulation rule 'if any unavailable' for ease of testing. 2. Search for a record that has multiple items, or create one with multiple items. Check out two of the items (Item A and Item B) to a patron, Patron A. 3. Log into the OPAC as another patron, Patron B. Search for the record and place a recall. Choose to recall a specific item and select Item A. 4. Go back to the staff interface and view the catalogue detail page for the record. Notice that every item has a 'recalled by...' message, even though Item A was specifically recalled. 5. Log into the OPAC as another patron, Patron C. Search for the record and place a recall. Choose to recall a specific item, notice every item has a 'recalled by...' message. Select Item B and Confirm. 6. In your terminal, the 'Other items are not returned for item-level recalls' test should fail when running prove t/db_dependent/Koha/Item.t 7. Apply the patch and restart services 8. Confirm tests at t/db_dependent/Koha/Item.t now pass 9. Refresh the staff interface, confirm only Items A and B have the recalled message and the recall patron information for each item is accurate 10. Log into the OPAC as another patron, Patron D. Search for the record and place a recall. Choose to recall a specific item. Confirm only Items A and B have the recalled message. Sponsored-by: Toi Ohomai Institute of Technology Signed-off-by: David Nind --- Koha/Item.pm | 14 ++++++++++++-- t/db_dependent/Koha/Item.t | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index dba357e680..d51eaeecea 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1842,11 +1842,21 @@ sub recall { }, { order_by => { -asc => 'created_date' } } )->as_list; + + my $item_level_recall; foreach my $recall (@recalls) { - if ( $recall->item_level and $recall->item_id == $self->itemnumber ){ - return $recall; + if ( $recall->item_level ) { + $item_level_recall = 1; + if ( $recall->item_id == $self->itemnumber ){ + return $recall; + } } } + if ( $item_level_recall ) { + # recall needs to be filled be a specific item only + # no other item is relevant to return + return; + } # no item-level recall to return, so return earliest biblio-level # FIXME: eventually this will be based on priority return $recalls[0]; diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 176e8feed1..310eff6f22 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -1915,7 +1915,7 @@ subtest 'store() tests' => sub { subtest 'Recalls tests' => sub { - plan tests => 22; + plan tests => 23; $schema->storage->txn_begin; @@ -1956,6 +1956,7 @@ subtest 'Recalls tests' => sub { )->store; is( $item1->recall->patron_id, $patron1->borrowernumber, 'Correctly returns most relevant recall' ); + is( $item2->recall, undef, 'Other items are not returned for item-level recalls' ); $recall2->set_cancelled; -- 2.30.2