From 889af24ebbc60f069836f6a9f013c7473752e750 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Wed, 17 Feb 2021 03:32:23 +0100 Subject: [PATCH] Bug 7376: (follow-up) Fix C4/Circulation.pm This follow-up patch actually fixes the issue. This patch forbids a patron to return a book to a library from where the book may not return to its home or holding library. Signed-off-by: Julian Maurice Signed-off-by: Baptiste Wojtkowski Signed-off-by: Mathieu Saby --- C4/Circulation.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 3572117a8e..d3d1f26bb3 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1406,15 +1406,26 @@ sub CanBookBeReturned { $message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary } + return ( $allowed, $message ) unless $allowed; + # Make sure there are no branch transfer limits between item's current # branch (holdinbranch) and the return branch - my $to_library = Koha::Libraries->find($to_branch); - if ( !$item->can_be_transferred( { to => $to_library } ) ) { - $allowed = 0; - $message = $item->homebranch; + my $return_library = Koha::Libraries->find($to_branch); + if ( !$item->can_be_transferred( { to => $return_library } ) ) { + return ( 0, $item->homebranch ); + } + + # Make sure there are no branch transfer limits between + # either homebranch and holdinbranch and the return branch + my $home_library = Koha::Libraries->find( $item->homebranch ); + my $holding_library = Koha::Libraries->find( $item->holdingbranch ); + if ( $item->can_be_transferred( { from => $return_library, to => $holding_library } ) + or $item->can_be_transferred( { from => $return_library, to => $home_library } ) ) + { + return ( 1, undef ); } - return ( $allowed, $message ); + return ( 0, $item->homebranch ); } =head2 CheckHighHolds -- 2.39.5