From 077a409b6a9f7ee19c864b566ae04ec30756e2a7 Mon Sep 17 00:00:00 2001 From: Lyon3 Team Date: Fri, 13 Sep 2019 10:51:38 +0200 Subject: [PATCH] Bug 7376 Transfer limits should be checked at check-in --- C4/Circulation.pm | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index e346e2d..ad42213 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1158,7 +1158,7 @@ sub CanBookBeReturned { $message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary } - return ($allowed, $message); + return ($allowed, $message, $allowreturntobranch); } =head2 CheckHighHolds @@ -1924,7 +1924,28 @@ sub AddReturn { } # check if the return is allowed at this branch - my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); + my ($returnallowed, $message, $allowedbranch) = CanBookBeReturned($item_unblessed, $branch); + if ($allowedbranch eq 'anywhere') { + # if we try a checkin that would result in a forbidden branchtransfer, refuse the return as well + # first, find branchtransferlimit value for this item + my $branchtransferlimitvalue = $itemtype; + $branchtransferlimitvalue = $item_unblessed->{ccode} + if C4::Context->preference("item-level_itypes") + && C4::Context->preference("BranchTransferLimitsType") eq 'ccode'; + + if ( $item_unblessed->{'homebranch'} ne $branch + && ( + C4::Context->preference("IndependentBranches") + or ( C4::Context->preference("UseBranchTransferLimits") + and not IsBranchTransferAllowed($item_unblessed->{'homebranch'}, $branch, $branchtransferlimitvalue ) ) + ) + ) { + $returnallowed = 0; + $message = $item_unblessed->{'homebranch'}; + } + + } + unless ($returnallowed){ $messages->{'Wrongbranch'} = { Wrongbranch => $branch, -- 2.1.4