diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm index 5526f7d529..29be68ce05 100644 --- a/Koha/Recalls.pm +++ b/Koha/Recalls.pm @@ -142,8 +142,14 @@ sub add_recall { }); my $due_interval = defined $recall_due_date_interval ? $recall_due_date_interval->rule_value : 5; my $timestamp = dt_from_string( $recall->timestamp ); - my $due_date = $timestamp->add( days => $due_interval ); - $checkout->update({ date_due => $due_date }); + my $checkout_timestamp = dt_from_string( $checkout->date_due ); + my $due_date = $timestamp->set( + { + hour => $checkout_timestamp->hour, minute => $checkout_timestamp->minute, + second => $checkout_timestamp->second + } + )->add( days => $due_interval ); + $checkout->update( { date_due => $due_date } ); # get itemnumber of most relevant checkout if a biblio-level recall unless ( $recall->item_level ) { $itemnumber = $checkout->itemnumber; } diff --git a/t/db_dependent/Koha/Recalls.t b/t/db_dependent/Koha/Recalls.t index 63d4c0dd05..a32ed768cb 100755 --- a/t/db_dependent/Koha/Recalls.t +++ b/t/db_dependent/Koha/Recalls.t @@ -136,8 +136,14 @@ is( $due_interval, 3, "Recall due date interval is based on circulation rules" ) }); is( $recall->item_level, 0, "No item provided so recall not flagged as item-level" ); -my $expected_due_date = dt_from_string->add( days => 3 ); -is( t::lib::Dates::compare( $recall->checkout->date_due, $expected_due_date ), 0, "Checkout due date has correctly been extended by recall_due_date_interval days" ); +my $checkout_timestamp = dt_from_string( $recall->checkout->date_due ); +my $expected_due_date = dt_from_string->set( + { hour => $checkout_timestamp->hour, minute => $checkout_timestamp->minute, second => $checkout_timestamp->second } +)->add( days => 3 ); +is( + t::lib::Dates::compare( $recall->checkout->date_due, $expected_due_date ), 0, + "Checkout due date has correctly been extended by recall_due_date_interval days" +); is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" ); my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;