https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27834

Martin Renvoize (ashimema) <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #187297|0                           |1
        is obsolete|                            |

--- Comment #12 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 189543
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=189543&action=edit
Bug 27834: Use new CircControlCheckoutLimitScope system preference

This patch updates the TooMany function to use the new
CircControlCheckoutLimitScope system preference, providing explicit
control over how checkout limits (maxissueqty and patron_maxissueqty)
are calculated, independent of the CircControl preference.

Previously, the TooMany function conflated two separate concerns:
1. CircControl - which circulation rules to apply
2. Checkout counting scope - which checkouts count toward limits

This caused the checkout counting behavior to change based on CircControl,
even when libraries wanted consistent limit enforcement regardless of
which circulation rules applied.

The new CircControlCheckoutLimitScope preference offers three options:

* 'all' (default) - Count all patron checkouts across all libraries
* 'item' - Count only checkouts of items from the same library as the
  item being checked out (follows HomeOrHoldingBranch preference)
* 'checkout' - Count only checkouts made at the same library as the
  current checkout

Implementation note: When scope is 'item', the system counts checkouts
of items from the same library as the item being checked out (using the
item's homebranch or holdingbranch). This applies regardless of whether
the matching circulation rule is branch-specific or general (branch=*),
ensuring consistent behavior across all rule types.

This gives libraries explicit, flexible control over checkout limit scope
while maintaining CircControl's intended purpose of rule selection.

Test plan:
1. Apply patches and update database:
   perl installer/data/mysql/updatedatabase.pl

2. Verify new preference exists:
   Administration > System preferences > Circulation
   Search for "CircControlCheckoutLimitScope"
   Default value should be 'all'

3. Set up test environment:
   - Create two branches (Branch1, Branch2)
   - Create a patron category and item type
   - Create a patron in Branch1
   - Create items from both branches
   - Set circulation rules for both branches:
     * Branch1: maxissueqty = 1 for itemtype/category
     * Branch2: maxissueqty = 1 for itemtype/category

4. Test scope = 'checkout':
   a. Set CircControlCheckoutLimitScope = 'checkout'
   b. Log in as staff from Branch1
   c. Check out item from Branch1 to patron → succeeds
   d. Try to check out another item from Branch1 → blocked (limit: 1)
   e. Log in as staff from Branch2
   f. Check out item from Branch2 to same patron → succeeds
   g. Expected: Checkouts at different libraries don't count together

5. Test scope = 'all':
   a. Set CircControlCheckoutLimitScope = 'all'
   b. Return all items
   c. Log in as staff from Branch1
   d. Check out item from Branch1 to patron → succeeds
   e. Log in as staff from Branch2
   f. Try to check out item from Branch2 to same patron → blocked
   g. Expected: All patron checkouts count toward limit regardless of location

6. Test scope = 'item':
   a. Set CircControlCheckoutLimitScope = 'item'
   b. Set HomeOrHoldingBranch = 'homebranch'
   c. Return all items
   d. Check out item from Branch1 to patron → succeeds
   e. Try to check out another item from Branch1 → blocked (limit: 1)
   f. Check out item from Branch2 to same patron → succeeds
   g. Expected: Only items from same home library count together
   h. Note: When checking out an item, only checkouts of items from
      the same library as that item count toward the limit

7. Test scope applies to all rule types:
   a. With scope='item', test with a general rule (branch=*)
   b. Check out items from different branches
   c. Expected: Scope still applies - only items from the same branch
      as the item being checked out are counted

8. Test independence from CircControl:
   a. Test each scope with CircControl = 'PickupLibrary'
   b. Test each scope with CircControl = 'ItemHomeLibrary'
   c. Test each scope with CircControl = 'PatronLibrary'
   d. Expected: CircControlCheckoutLimitScope behavior is consistent
      regardless of CircControl setting

9. Run tests:
   prove t/db_dependent/Circulation/TooMany.t

10. Test with patron_maxissueqty:
    - Set up patron-level limits instead of item-type limits
    - Verify all three scopes work correctly
    - Test with both rule types active

11. Verify existing functionality:
    - Test on-site checkouts still work
    - Test item type hierarchies still work
    - Test unlimited ("") limits still work
    - prove t/db_dependent/Circulation/

Sponsored-by: University of the Arts London
Signed-off-by: Ray Delahunty <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to