From bd5c5eaa38f75297efde5a096d30ad65eff9a658 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 22 May 2023 11:14:25 +0000 Subject: [PATCH] Bug 33791: Pass itemnumber to $hold->fill Test plan: Without this patch: Place next available level on some book for patron A. Checkout this book directly to patron A. Check old_reserves table for this reserve; does not have itemnumber. With this patch: Do the same. In old_reserves the itemnumber should be saved. Run again t/db_dependent/Koha/Hold.t. Should pass. Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- C4/Reserves.pm | 4 ++-- Koha/Hold.pm | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 8e64605a45..6995399002 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -2022,7 +2022,7 @@ sub MoveReserve { if ($res->{borrowernumber} == $borrowernumber) { my $hold = Koha::Holds->find( $res->{reserve_id} ); - $hold->fill; + $hold->fill({ itemnumber => $itemnumber }); } else { # warn "Reserved"; @@ -2038,7 +2038,7 @@ sub MoveReserve { if ( $borr_res ) { # The item is reserved by the current patron - $borr_res->fill; + $borr_res->fill({ itemnumber => $itemnumber }); } if ( $cancelreserve eq 'revert' ) { ## Revert waiting reserve to priority 1 diff --git a/Koha/Hold.pm b/Koha/Hold.pm index ad9560ff39..e40734fed1 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -777,13 +777,14 @@ sub cancel { =head3 fill $hold->fill; + $hold->fill({ itemnumber => $i }); # optional itemnumber: see MoveReserves This method marks the hold as filled. It effectively moves it to old_reserves. =cut sub fill { - my ( $self ) = @_; + my ( $self, $params ) = @_; $self->_result->result_source->schema->txn_do( sub { my $patron = $self->patron; @@ -792,6 +793,7 @@ sub fill { { found => 'F', priority => 0, + $params->{itemnumber} ? ( itemnumber => $params->{itemnumber} ) : (), } ); -- 2.39.5