From 1aa8485857d5327fca3128caca0fbae5ad90e63b Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Tue, 21 Mar 2023 16:50:45 +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 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index da7e13a75b..170f9d7690 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -894,6 +894,8 @@ sub CheckReserves { # Find this item in the reserves my @reserves = _Findgroupreserve( $item->biblionumber, $item->itemnumber, $lookahead_days, $ignore_borrowers); + # When IndependentBranchesTransfers is activate remove the reserve made from other branches + @reserves = _FilterHoldsForIndependentBranches( @reserves ); # $priority and $highest are used to find the most important item # in the list returned by &_Findgroupreserve. (The lower $priority, @@ -1786,6 +1788,30 @@ 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) = @_; + if ( C4::Context->preference("IndependentBranchesTransfers") && !C4::Context->IsSuperLibrarian() && scalar @reserves) { + my @results; + foreach my $res (@reserves) { + push( @results, $res ) if ($res->{branchcode} eq C4::Context->userenv->{'branch'}); + } + return @results; + } + return @reserves; +} + =head2 _koha_notify_reserve _koha_notify_reserve( $hold->reserve_id ); -- 2.34.1