From 138995ff1f32a19f136e61ce6233992e91bd4e81 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 7 Mar 2017 22:06:04 +0000 Subject: [PATCH] Bug 13153 - Waiting hold checked in at different library doesn't re-route item to correct library This patch changes AddReturn to revert a waiting hold whenchecked in at another branch To test: 1 - Place a hold for pickup at current branch 2 - Check in and confirm hold 3 - Change branch 4 - Checkin the item again 5 - Note there is no message to transfer or hold 6 - Note current location (holdingbranch) has changed though status indicates waitingat original branch 7 - Apply patch 8 - Checkin the item again 9 - Note hold is reverted 10 - Note message to confirm hold/transfer 11 - Sign off --- C4/Circulation.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index af5acce..c3d7caf 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2042,15 +2042,22 @@ sub AddReturn { } # find reserves..... - # if we don't have a reserve with the status W, we launch the Checkreserves routine my ($resfound, $resrec); my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} ); - if ($resfound) { + if ($resfound eq 'Waiting' and $resrec->{branchcode} ne $branch){ #If we have a waiting reserve returned at another branch it no longer waiting + $messages->{'WrongTransfer'} = $resrec->{branchcode}; + $messages->{'WrongTransferItem'} = $resrec->{'itemnumber'}; + C4::Reserves::RevertWaitingStatus({itemnumber=>$resrec->{itemnumber}}); + $validTransfert = 1; + $messages->{'ResFound'} = $resrec; + } + elsif ($resfound) { $resrec->{'ResFound'} = $resfound; $messages->{'ResFound'} = $resrec; } + # Record the fact that this book was returned. UpdateStats({ branch => $branch, -- 2.1.4