From 3971569d36302b6fceb94cf4f81106bfde02dff2 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. --- C4/Circulation.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index d77c7c4b42..241654cdd0 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1276,15 +1276,25 @@ 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.31.1