Bug 41131

Summary: Branch Transfer Limits basic editor allows one to prevent transfers from a library to itself and block related holds
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: CirculationAssignee: Nick Clemens (kidclamp) <nick>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle, nick
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Crowdfunding goal: 0
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41131: Don't allow limiting transfers from/to a single branch

Description Andrew Fuerste-Henry 2025-10-29 15:05:02 UTC
The branch transfer limits basic editor will always indicate that transfers from a branch to itself are allowed -- when the page loads, it always puts a checkmark under "Allow transfer" for the branch for which one is defining limits. But this checkmark is not reflected in the database.

To recreate:
- disable AllowHoldPolicyOverride
- set UseBranchTransferLimits to Enforce; set BranchTransferLimitsType to itemtype (the also exists when enforcing by collection code, but its impact on holds is easier to see with itemtypes)
- go to the branch transfer limits page, see that Allow Transfers is checked for all branches and all itemtypes
- in a report, SELECT * FROM branch_transfer_limits, confirm no results -- we put a row in this table for every transfer that's blocked
- back on the branch transfer limits, uncheck "Allow transfer" for Books going from Centerville to Centerville, click Save
- On save, the page reloads and shows a checkmark under "Allow transfer" for Books going from Centerville to Centerville
- back in reports, run your query again, see there is a row in branch_transfer_limits to block the transfer of Books from Centerville to Centerville
- Attempt to place a hold on an item currently at Centerville for pickup at Centerville, confirm Koha will not allow this hold

This cannot be recreated in the advanced editor.
Comment 1 Nick Clemens (kidclamp) 2025-10-29 15:27:16 UTC
Created attachment 188561 [details] [review]
Bug 41131: Don't allow limiting transfers from/to a single branch

We say that you cannot limit transfers internally within a branch, but
it seems we do allow you to, and don't show you when we do

To test:
1 - Go to Admin->Library transfer limits
2 - On a branches page, uncheck the box for that branch
    e.g. don't allow FIC to transfer to CPL from CPL
3 - Save
4 - Note the box is still checked
5 - Check the DB
    SELECT * FROM branch_transfer_limits;
6 - There is a line to/from CPL!
7 - Apply patches
8 - updatedatabase
9 - Repeat 5 - the line is deleted!
10 - Try to create the rule again, not the box is now disabled
11 - Be sneaky, enable the box, uncheck it and save, no rule created
12 - Be sneaky, edit the HMTL for another button to make it limiting CPL to CPL, save, no rule created
13 - Sign off