Bug 31105: Holds to pull counts items from other branches when independentbranches is active

Holds to pull should not show items from other branches that shares a
record when IndependentBranches is active. Except for superlibrarians.

Test plan:
1- Have IndependentBranches set to Yes
2- Have a record with an item from the current branch and another item from a different branch. We will call them branch A and branch B respectively
3- Have a patron from branch A place a hold on that record
4- Have a staff account on branch A and B with the following permissions:
    - circulate (all)
    - catalogue
5- Go to circulation > holds to pull
6- Notice under "Libraries" it displays branch A and B. Also, it shows 2 under "Items available"
7- Checkout the item from branch A to another patron
8- Go back to circulation > holds to pull
9- Notice under "Libraries" it displays branch B even though we are in branch A
10- Apply the patch
11- Return the checked out item from step 7
12- Redo step 5 to 9 with superlibrarian privileges and notice nothing changed
13- Redo step 11-12 but using accounts from step 4 and notice Holds to
pull only shows information relevant to their branch

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Shi Yao Wang 2022-07-05 12:03:52 -04:00 committed by Tomas Cohen Arazi
parent da6426ad8b
commit 87e589d79f
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 3 additions and 2 deletions

View file

@ -76,6 +76,7 @@ sub filter_by_for_hold {
withdrawn => 0,
notforloan => { '<=' => 0 }, # items with negative or zero notforloan value are holdable
( C4::Context->preference('AllowHoldsOnDamagedItems')? (): ( damaged => 0 ) ),
( C4::Context->only_my_library() ? ( homebranch => C4::Context::mybranch() ) : () ),
};
if ( C4::Context->preference("item-level_itypes") ) {

View file

@ -181,8 +181,8 @@ if ( !C4::Context->preference('AllowHoldsOnDamagedItems') ){
$where{'itembib.damaged'} = 0;
}
if ( C4::Context->preference('IndependentBranches') ){
$where{'itembib.holdingbranch'} = C4::Context->userenv->{'branch'};
if ( C4::Context->only_my_library() ){
$where{'me.branchcode'} = C4::Context->userenv->{'branch'};
}
# get all distinct unfulfilled reserves