Bugzilla – Attachment 120897 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: Transfer limits should be checked at check-in
Bug-7376-Transfer-limits-should-be-checked-at-chec.patch (text/plain), 5.85 KB, created by
Victor Grousset/tuxayo
on 2021-05-12 19:43:55 UTC
(
hide
)
Description:
Bug 7376: Transfer limits should be checked at check-in
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2021-05-12 19:43:55 UTC
Size:
5.85 KB
patch
obsolete
>From e62a6910b4453095c24b8009fd4cc65fd6cd2502 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Fri, 30 Aug 2019 16:30:07 +0000 >Subject: [PATCH] Bug 7376: Transfer limits should be checked at check-in > >Test case: > * UseBranchTransferLimits must be set > * define your branch transfer limit. Refuse transfers from libraryA to libraryB > * checkout a book owned by libraryB, from libraryB, with a librarian located at libraryB > * move the librarian to libraryA ("Set Library" link top/right) > * check-in the book => it's possible whatever your setup > >After the patch, the behaviour respect the branch transfer limit parameter: >you can check-in if you accept transfers, you can't if you refuse them. > >(Note: IndependantBranches must be OFF, otherwise it's not possible to do the checkin whatever the branch transfer limits) > >Sponsored-by: National Library of Finland > >Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> >--- > C4/Circulation.pm | 65 +++++++++++++++++++++++++++++------------------ > 1 file changed, 40 insertions(+), 25 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 10db0d226a..d77c7c4b42 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -963,7 +963,7 @@ sub CanBookBeIssued { > > my $patron = Koha::Patrons->find( $issue->borrowernumber ); > >- my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); >+ my ( $can_be_returned, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); > > unless ( $can_be_returned ) { > $issuingimpossible{RETURN_IMPOSSIBLE} = 1; >@@ -1237,7 +1237,7 @@ Check whether the item can be returned to the provided branch > > =over 4 > >-=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) >+=item C<$item> is a Koha::Item object > > =item C<$branch> is the branchcode where the return is taking place > >@@ -1256,26 +1256,35 @@ Returns: > =cut > > sub CanBookBeReturned { >- my ($item, $branch) = @_; >- my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; >- >- # assume return is allowed to start >- my $allowed = 1; >- my $message; >- >- # identify all cases where return is forbidden >- if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) { >- $allowed = 0; >- $message = $item->{'homebranch'}; >- } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) { >- $allowed = 0; >- $message = $item->{'holdingbranch'}; >- } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) { >- $allowed = 0; >- $message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary >- } >- >- return ($allowed, $message); >+ my ($item, $branch) = @_; >+ 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) { >+ $allowed = 0; >+ $message = $to_branch = $item->homebranch; >+ } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) { >+ $allowed = 0; >+ $message = $to_branch = $item->holdingbranch; >+ } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) { >+ $allowed = 0; >+ $message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary >+ } >+ >+ # 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; >+ } >+ >+ return ($allowed, $message); > } > > =head2 CheckHighHolds >@@ -1499,7 +1508,7 @@ sub AddIssue { > if ( $actualissue and not $switch_onsite_checkout ) { > # This book is currently on loan, but not to the person > # who wants to borrow it now. mark it returned before issuing to the new borrower >- my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); >+ my ( $allowed, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); > return unless $allowed; > AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); > # AddReturn certainly has side-effects, like onloan => undef >@@ -1939,6 +1948,10 @@ This book has was returned to the wrong branch. The value is a hashref > so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> > contain the branchcode of the incorrect and correct return library, respectively. > >+=item C<Transferlimit> >+ >+A transfer limit exists between item's holding branch and the return branch. >+ > =item C<ResFound> > > The item was reserved. The value is a reference-to-hash whose keys are >@@ -2062,12 +2075,14 @@ sub AddReturn { > } > > # check if the return is allowed at this branch >- my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); >+ my ($returnallowed, $message) = CanBookBeReturned($item, $branch); >+ > unless ($returnallowed){ > $messages->{'Wrongbranch'} = { > Wrongbranch => $branch, > Rightbranch => $message >- }; >+ } if $message; >+ > $doreturn = 0; > my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); > $indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); >-- >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
|
175690
|
175691
|
175692
|
175693
|
175694
|
175695
|
175696
|
175697