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 <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Perltidied new code.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Aleisha Amohia 2023-09-06 00:13:48 +00:00 committed by Tomas Cohen Arazi
parent a6ba086a92
commit be375ed01c
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 17 additions and 4 deletions

View file

@ -1834,7 +1834,7 @@ Return the relevant recall for this item
=cut
sub recall {
my ( $self ) = @_;
my ($self) = @_;
my @recalls = Koha::Recalls->search(
{
biblio_id => $self->biblionumber,
@ -1842,11 +1842,23 @@ 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];

View file

@ -1920,7 +1920,7 @@ subtest 'store() tests' => sub {
subtest 'Recalls tests' => sub {
plan tests => 22;
plan tests => 23;
$schema->storage->txn_begin;
@ -1961,6 +1961,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;