Bugzilla – Attachment 180069 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.40 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-03-31 14:54:32 UTC
(
hide
)
Description:
Bug 7376: Transfer limits should be checked at check-in
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-03-31 14:54:32 UTC
Size:
5.40 KB
patch
obsolete
>From d5b260740d3e2d5fa9cc82e30c9f51610496663e Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Mon, 16 Dec 2024 10:48:17 +0100 >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> >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > C4/Circulation.pm | 40 +++++++++++++++++++++++++++------------- > 1 file changed, 27 insertions(+), 13 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 31794b7c..3572117a 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1006,7 +1006,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} ); > > if ( !$can_be_returned ) { > $issuingimpossible{RETURN_IMPOSSIBLE} = 1; >@@ -1364,7 +1364,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 > >@@ -1387,22 +1387,31 @@ sub CanBookBeReturned { > my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; > > # assume return is allowed to start >- my $allowed = 1; >+ 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' && $branch ne $item->homebranch ) { > $allowed = 0; >- $message = $item->{'homebranch'}; >- } elsif ( $allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'} ) { >+ $message = $to_branch = $item->homebranch; >+ } elsif ( $allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch ) { > $allowed = 0; >- $message = $item->{'holdingbranch'}; >+ $message = $to_branch = $item->holdingbranch; > } elsif ( $allowreturntobranch eq 'homeorholdingbranch' >- && $branch ne $item->{'homebranch'} >- && $branch ne $item->{'holdingbranch'} ) >+ && $branch ne $item->homebranch >+ && $branch ne $item->holdingbranch ) > { > $allowed = 0; >- $message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary >+ $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 ); >@@ -1671,7 +1680,7 @@ sub AddIssue { > > # 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'} ); > >@@ -2130,6 +2139,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 >@@ -2284,12 +2297,13 @@ 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.30.2
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
|
180069
|
180070
|
180071
|
180072
|
180073
|
180074
|
180075
|
180076
|
180590
|
180591
|
180592
|
180593
|
180594
|
180595
|
180596
|
180597
|
181055
|
181056
|
181057
|
181058
|
181059
|
181060
|
181061
|
181062
|
181064
|
181065
|
181066
|
181067
|
181068
|
181069
|
181070
|
181071