Bugzilla – Attachment 120903 Details for
Bug 7376
Transfer limits should be checked at check-in
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7376: Allow passing 'transferbranch' to CanBookBeReturned
Bug-7376-Allow-passing-transferbranch-to-CanBookBe.patch (text/plain), 4.08 KB, created by
Victor Grousset/tuxayo
on 2021-05-12 19:44:45 UTC
(
hide
)
Description:
Bug 7376: Allow passing 'transferbranch' to CanBookBeReturned
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2021-05-12 19:44:45 UTC
Size:
4.08 KB
patch
obsolete
>From 839170dcb888aafc63687239574eef5e0106b2d2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 17 Feb 2021 14:43:01 +0000 >Subject: [PATCH] Bug 7376: Allow passing 'transferbranch' to CanBookBeReturned > >This patch adds the optional 'tranferbranch' parameter to the >CanBookBeReturned routine. This allows for passing the correct >'ReturnToX' transfer to be tested at return time for transfer limit >restrictions. >--- > C4/Circulation.pm | 45 ++++++++++++++++++--------------------------- > 1 file changed, 18 insertions(+), 27 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 241654cdd0..256547e856 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1231,7 +1231,7 @@ sub CanBookBeIssued { > > =head2 CanBookBeReturned > >- ($returnallowed, $message) = CanBookBeReturned($item, $branch) >+ ($returnallowed, $message) = CanBookBeReturned($item, $branch, [$transferbranch]) > > Check whether the item can be returned to the provided branch > >@@ -1256,45 +1256,36 @@ Returns: > =cut > > sub CanBookBeReturned { >- my ($item, $branch) = @_; >+ my ($item, $returnbranch, $transferbranch) = @_; > my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; > > # assume return is allowed to start > my $allowed = 1; >- my $to_branch = $branch; > my $message; > > # identify all cases where return is forbidden >- if ($allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch) { >+ if ($allowreturntobranch eq 'homebranch' && $returnbranch ne $item->homebranch) { > $allowed = 0; >- $message = $to_branch = $item->homebranch; >- } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) { >+ $message = $item->homebranch; >+ } elsif ($allowreturntobranch eq 'holdingbranch' && $returnbranch ne $item->holdingbranch) { > $allowed = 0; >- $message = $to_branch = $item->holdingbranch; >- } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) { >+ $message = $item->holdingbranch; >+ } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $returnbranch ne $item->homebranch && $returnbranch ne $item->holdingbranch) { > $allowed = 0; >- $message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary >+ $message = $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 $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); >+ # identify cases where transfer rules prohibit return >+ if ( defined($transferbranch) && $allowed ) { >+ my $from_library = Koha::Libraries->find($returnbranch); >+ my $to_library = Koha::Libraries->find($transferbranch); >+ if ( !$item->can_be_transferred({ from => $from_library, to => $to_library }) ) { >+ $allowed = 0; >+ $message = $transferbranch; >+ } > } > >- return (0, $item->homebranch); >+ return ($allowed, $message); > } > > =head2 CheckHighHolds >@@ -2085,7 +2076,7 @@ sub AddReturn { > } > > # check if the return is allowed at this branch >- my ($returnallowed, $message) = CanBookBeReturned($item, $branch); >+ my ($returnallowed, $message) = CanBookBeReturned($item, $branch, $returnbranch); > > unless ($returnallowed){ > $messages->{'Wrongbranch'} = { >-- >2.31.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7376
:
6954
|
21715
|
21805
|
22016
|
22017
|
22323
|
22357
|
22696
|
23168
|
76559
|
76866
|
76876
|
92740
|
92774
|
93190
|
93191
|
93192
|
93193
|
93194
|
93195
|
93196
|
107077
|
107078
|
107079
|
115369
|
115370
|
116493
|
116494
|
116927
|
116928
|
116937
|
116938
|
120897
|
120898
|
120899
|
120900
|
120901
|
120902
|
120903
|
144435
|
144436
|
144437
|
144438
|
144439
|
144440
|
144441