From 130b769be33e329894d350ed06fb17cea87ba4eb 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 6f4a19da92..211c6101fa 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1247,15 +1247,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.11.0