@@ -, +, @@ --- Koha/Hold.pm | 13 +++++++------ t/db_dependent/Hold.t | 27 ++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) --- a/Koha/Hold.pm +++ a/Koha/Hold.pm @@ -955,13 +955,14 @@ sub store { if ( exists $updated_columns{reservedate} || $hold_reverted ) { if ( ( C4::Context->preference('DefaultHoldExpirationdate') - && ! exists $updated_columns{expirationdate} ) - || ( C4::Context->preference('DefaultHoldExpirationdate') - && exists $updated_columns{expirationdate} - && $hold_reverted ) - ) + && ( ! exists $updated_columns{expirationdate} || $hold_reverted ) ) + ) { - $self->_set_default_expirationdate; + if($self->patron_expiration_date){ + $self->expirationdate($self->patron_expiration_date); + } else { + $self->_set_default_expirationdate; + } } } } --- a/t/db_dependent/Hold.t +++ a/t/db_dependent/Hold.t @@ -146,7 +146,7 @@ $schema->storage->txn_rollback(); subtest "store() tests" => sub { - plan tests => 6; + plan tests => 7; $schema->storage->txn_begin(); @@ -241,6 +241,31 @@ subtest "store() tests" => sub { is( $hold->expirationdate, $expected_date, 'Expiration date set after reverting holds waiting status.' ); + my $patron_expiration_date = dt_from_string('2023-11-06')->ymd; + $hold = Koha::Hold->new( + { + biblionumber => $biblio->biblionumber, + itemnumber => $item->id, + reservedate => '2023-10-15', + expirationdate => $patron_expiration_date, + waitingdate => '2023-10-15', + borrowernumber => $borrower->borrowernumber, + branchcode => $library->branchcode, + suspend => 0, + patron_expiration_date => $patron_expiration_date, + } + )->store; + $hold->discard_changes; + + $hold->set_waiting; + C4::Reserves::RevertWaitingStatus( + { itemnumber => $item->itemnumber } + ); + $hold->discard_changes; + + is( $hold->expirationdate, + $patron_expiration_date, 'Expiration date set same as patron_expiration_date after reverting holds waiting status.' ); + $schema->storage->txn_rollback(); }; --