From e1b927bee7a7ba68fd65fd5a2c3dc0e6870f6153 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 (cherry picked from commit bd5c5eaa38f75297efde5a096d30ad65eff9a658) Signed-off-by: Matt Blenkinsop --- 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 84aa00e864..bf92cde2ec 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -2058,7 +2058,7 @@ sub MoveReserve { if ($res->{borrowernumber} == $borrowernumber) { my $hold = Koha::Holds->find( $res->{reserve_id} ); - $hold->fill; + $hold->fill({ itemnumber => $itemnumber }); } else { # warn "Reserved"; @@ -2074,7 +2074,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 d832c2097b..57b7494089 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