From 921580c34510904c550337d64eeaf1a188f799be Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Aug 2020 15:51:17 +0200 Subject: [PATCH] Bug 24598: Complete transfer for hold if checked out Content-Type: text/plain; charset=utf-8 When an item that has triggered a hold is in transit to a library, if the item is accidently shelved instead of scanned at the pickup library, and then checked out to another patron, the holds shows the item still in transit in the status, but says that it is waiting at the library, and the since date has vanished! Test plan: 1) Place an item at Library A on hold for Patron 1 of Library B with pickup library at Library B 2) Check in the item at Library A to trigger the hold transfer 3) At Library B, check out the item to Patron 2 (click Yes) => The hold is not marked as in transit and is back to priority 1 Signed-off-by: Fridolin Somers Signed-off-by: Marcel de Rooy --- C4/Circulation.pm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 5c05326123..aa917a9e2d 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1448,18 +1448,22 @@ sub AddIssue { C4::Reserves::MoveReserve( $item_object->itemnumber, $borrower->{'borrowernumber'}, $cancelreserve ); # Starting process for transfer job (checking transfert and validate it if we have one) - my ($datesent) = GetTransfers( $item_object->itemnumber ); - if ($datesent) { + if ( my $transfer = $item_object->get_transfer ) { # updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) - my $sth = $dbh->prepare( - "UPDATE branchtransfers - SET datearrived = now(), - tobranch = ?, - comments = 'Forced branchtransfer' - WHERE itemnumber= ? AND datearrived IS NULL" - ); - $sth->execute( C4::Context->userenv->{'branch'}, - $item_object->itemnumber ); + $transfer->set( + { + datearrived => dt_from_string, + tobranch => C4::Context->userenv->{branch}, + comments => 'Forced branchtransfer' + } + )->store; + if ( $transfer->reason eq 'Reserve' ) { + my $hold = $item_object->holds->search( { found => 'T' } )->next; + if ( $hold ) { # Is this really needed? + $hold->set( { found => undef } )->store; + C4::Reserves::ModReserveMinusPriority($item_object->itemnumber, $hold->reserve_id); + } + } } # If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. -- 2.11.0