From 02a39faeee6fa72ec796beff98e564a739274fbb Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Wed, 15 Mar 2023 14:18:22 +0000 Subject: [PATCH] Bug 33200: IndependentBranchesTransfers does not prevent holds from creating transfers This patch don't concider hold made from other branches when IndependentBranchesTransfers is set to Yes and the connected user is not a SuperLibrarian To test, you must have - IndependentBranches, IndependentBranchesPatronModifications and IndependentBranchesTransfers preferences set to Yes - canreservefromotherbranches must be set to Don't allow - Circulation rules that allow holds and checkouts - Two libraries (I used Midway (A) and Centerville (B)) - A record with two items, one at each library, with barcodes, check out the one from library A - Two non-superlibrarian staff user, one in each library, with at least catalogue and holds permissions, this is what I gave them - circulate (all) - catalogue - delete_borrowers - edit_borrowers - reserveforothers (all) 1. Log in to the staff interface with the non-superlibrarian staff user from library A 2. Go to the record with the two items, click 'Place hold' 3. Place a hold for a user, without changing anything (should be for 'next available item') 4. Log out and log back in with the non-superlibrarian staff user from library B 5. Check in the item from library B, which should be available --> Hold is confirmed for patron from library A, transfer is created 6. Click on 'Confirm hold and transfer' 7. Optionally, you can log out and log back in as staff from library A 8. Go to Circulation > Transfers to receive (should this even be available with IndependentBranchesTransfers turned on?) --> Item from other branch is there 9. Apply the patch 10. Create an other record with two items, one at each library, with barcodes, check out the one from library A 11. repeat step 1, 2, 3, 4, 5 --> The 'Hold found' popup is not shown, because there is no hold for this item in the user branch (library B) 12. repeat step 7,8 --> Item from other branch is not there --- C4/Reserves.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 987543e1cd..a9a49fd4b7 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -909,6 +909,8 @@ sub CheckReserves { # Find this item in the reserves my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days, $ignore_borrowers); + # When IndependentBranchesTransfers remove the reserve make form other branches + @reserves = _Removereserve( @reserves ); # $priority and $highest are used to find the most important item # in the list returned by &_Findgroupreserve. (The lower $priority, @@ -1843,6 +1845,29 @@ sub _Findgroupreserve { return @results; } +=head2 _Removereserve + + @reserves = &_Removereserve( @reserves ); + +Check transfers is allowed from system preference and remove the reserves made from other branches + +C<&_Removereserve> returns : +C<@results> is an array of references-to-hash whose keys are mostly +fields from the reserves table of the Koha database, plus + +=cut + +sub _Removereserve { + my ( @reserves) = @_; + my @results; + if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) { + foreach my $res (@reserves) { + push( @results, $res ) if ($res->{branchcode} eq C4::Context->userenv->{'branch'}); + } + } + return @results; +} + =head2 _koha_notify_reserve _koha_notify_reserve( $hold->reserve_id ); -- 2.34.1