Bug 39985: Set items.onloan when recall adjusts checkout due date

This enhancement ensures the due date stored in items.onloan is changed when a recall causes a checkout due date to change.

To test:

1. Enable UseRecalls syspref and set corresponding circulation rules:
    - Recalls allowed
    - Recalls per record
    - On shelf recalls allowed - set to "If any unavailable"
    - Recall due date interval - set to 1
    - Recall pickup period
2. Check out an item to a patron (Patron A)
  2a. Make sure this patron has a primary email address set
  2b. Check the patron's messaging preferences - make sure this patron has the 'Email' checkbox checked for the 'Return recalled item' notice
3. Go to Tools -> Notices & slips and find the RETURN_RECALLED_ITEM notice. In the Email notice, change "[% checkout.date_due | $KohaDates %]" to "[% item.onloan | $KohaDates %]" and Save.
4. Log into the OPAC as another patron
5. Search for the item checked out in step 2, and place a recall on that item
6. Search for that item in the staff interface
=> Note that the item status says, "Checked out to <patron>: due <tomorrow>"
7. Create the following SQL report in the reports module, using the barcode of the item that was recalled:
SELECT onloan FROM items WHERE barcode='xxxxxxxxx'
8. Run the report
=> The onloan value is still set to the item's original due date, not the updated due date of tomorrow
9. Go to Patron A's account again and view their Notices tab. Click on the 'Notification to return a recalled item'
=> The original due date is used in the notice.
10. Apply the patch and restart services
11. Reset to run the tests again:
    - Check in the item, but do not confirm the recall in the pop-up
    - Go to the biblio detail page and cancel the recall
12. Repeat steps 2 to 5.
13. Run your report again (step 8)
=> The onloan value should now show the updated due date of tomorrow
14. View Patron A's latest 'Notification to return a recalled item' notice (step 9)
=> The updated due date should be used in the notice.
15. Confirm tests pass
    - t/db_dependent/Koha/Recalls.t

Sponsored-by: Auckland University of Technology
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 95f2639d64)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Aleisha Amohia 2025-07-09 03:25:01 +00:00 committed by Paul Derscheid
parent bb90bd0bab
commit 7c8dbf75ec
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 14 additions and 3 deletions

View File

@ -157,8 +157,13 @@ sub add_recall {
second => $checkout_due_date->second
}
)->add( days => $due_interval );
$checkout->update( { date_due => $recall_due_date } )
if DateTime->compare( $recall_due_date, $checkout_due_date ) == -1;
# update checkout due date if recall due date is sooner
if ( DateTime->compare( $recall_due_date, $checkout_due_date ) == -1 ) {
$checkout->update( { date_due => $recall_due_date } );
$checkout->item->onloan( $recall_due_date->ymd() );
$checkout->item->store( { log_action => 0, skip_holds_queue => 1 } );
}
# get itemnumber of most relevant checkout if a biblio-level recall
unless ( $recall->item_level ) { $itemnumber = $checkout->itemnumber; }

View File

@ -18,7 +18,7 @@
use Modern::Perl;
use Test::NoWarnings;
use Test::More tests => 24;
use Test::More tests => 25;
use t::lib::Dates;
use t::lib::TestBuilder;
use t::lib::Mocks;
@ -141,6 +141,12 @@ ok(
$checkout_due_date_after_recall lt $initial_checkout_due_date,
"Checkout due date has been moved backwards"
);
$item2 = Koha::Items->find( $item2->itemnumber );
$checkout_due_date_after_recall = dt_from_string($checkout_due_date_after_recall);
is(
t::lib::Dates::compare( $checkout_due_date_after_recall->ymd(), $item2->onloan ), 0,
"items.onloan is updated with adjusted due date"
);
Koha::CirculationRules->set_rule(
{