From 86ec02579566420525344c9d8d85040d42b5b87b Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 28 May 2025 01:56:03 +0000 Subject: [PATCH] Bug 39962: Allocate item to bib-level recall when checkout chosen When a biblio-level recall is requested, the checkout with the oldest due date is chosen to have its due date adjusted and sent a return notice. However the chosen checkout item isn't assigned to the recall. This makes it hard for Koha to know which item to show as 'recalled' on the biblio detail page. This patch allocates the checked out item that gets chosen for the recall by oldest due date, to the recall in the database. This patch then checks if the item has an attached recall to display recall information on the biblio detail page, rather than checking for if the UseRecalls system preference is enabled. To test: 1) Enable the UseRecalls system preference and set recalls-related circulation rules. 2) Find a record with at least one item 3) Check out an item in this record to Patron B 4) Log into the OPAC as Patron A and place a biblio-level recall on the record 5) View the record on the staff interface and look at the holdings table 6) The checked out item should now also show a message that it is recalled. 7) Cancel the recall 8) Go back to the OPAC as Patron A and this time place an item-level recall on the checked out item 9) View the record on the staff interface and confirm the recall message shows as expected 10) Confirm all tests pass t/db_dependent/Koha/Item.t , t/db_dependent/Koha/Recalls.t , t/db_dependent/Koha/Plugins/Recall_hooks.t Sponsored-by: Auckland University of Technology --- Koha/Item.pm | 3 +++ Koha/Recalls.pm | 6 +++++- .../includes/html_helpers/tables/items/catalogue_detail.inc | 5 ++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 0631e734598..c35c2343066 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -2390,6 +2390,9 @@ sub recall { return $recall; } } + if ( $recall->item_id == $self->itemnumber ) { + return $recall; + } } if ($item_level_recall) { diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm index 2881f5948fa..14809afb0f3 100644 --- a/Koha/Recalls.pm +++ b/Koha/Recalls.pm @@ -161,7 +161,11 @@ sub add_recall { if DateTime->compare( $recall_due_date, $checkout_due_date ) == -1; # get itemnumber of most relevant checkout if a biblio-level recall - unless ( $recall->item_level ) { $itemnumber = $checkout->itemnumber; } + # allocate item to biblio-level recall + unless ( $recall->item_level ) { + $itemnumber = $checkout->itemnumber; + $recall->update( { item_id => $itemnumber } ); + } # send notice to user with recalled item checked out my $letter = C4::Letters::GetPreparedLetter( diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 67440510e69..aae3bdaac74 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -584,8 +584,7 @@ } } - [% IF Koha.Preference('UseRecalls') %] - if ( row.recall && ( row.item_id === row.recall.item_id ) ) { + if ( status == 'recalled' && row.recall && ( row.item_id === row.recall.item_id ) ) { if ( row.recall.waiting_date ) { nodes += '%s'.format(_("Waiting recall at %s since %s").format(escape_str(row.recall._strings.pickup_library_id.str), $date(row.recall.waiting_date))); } else { @@ -596,7 +595,7 @@ nodes += '%s'.format(_("Recalled by %s on %s").format(patron_to_html, $date(row.recall.created_date))) } } - [% END %] + if ( status == 'available' ) { nodes += ' %s'.format(_("Available")) } -- 2.39.5