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

            Bug ID: 41977
           Summary: Hold fee not charged for title-level holds when all
                    items have negative notforloan status
   Initiative type: ---
        Sponsorship ---
            status:
           Product: Koha
           Version: Main
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Circulation
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
                CC: [email protected], [email protected]

When a hold is placed on a title where all items have a negative notforloan
value (e.g. -1 = "Ordered" — the Koha convention for "not for loan, but
holdable"), no reservation fee is charged, even when the applicable circulation
rule specifies a hold_fee.

The same hold placed on a title where items have notforloan = 0 (available)
correctly generates the charge.

Steps to Reproduce

1. Configure a circulation rule with a hold_fee for a patron category and item
type (e.g. "Adult Fiction Paperback").
2. Set HoldFeeMode to any_time_is_placed.
3. Create a biblio with one or more items, all with a negative notforloan value
(e.g. -1, "Ordered").
4. Place a hold on that biblio for a patron in the matching category.
5. Observe the patron's account — no reservation fee is applied.

Expected: Reservation fee is charged at hold placement, matching the fee that
would apply once the item is received.

Actual: No fee is charged. The patron can hold the title free of charge for its
entire on-order period, then be charged when it arrives — inconsistent and
unfair to patrons who paid for the same hold earlier.

Root Cause

In Koha/Hold.pm, _calculate_title_hold_fee() searches for items to base the fee
on using this filter:

  -or => [
      { 'me.notforloan' => 0 },
      { 'me.notforloan' => undef }
  ]

This excludes items with negative notforloan values. When all items on a biblio
are in an "Ordered" state (negative notforloan), no items match, @fees is
empty, and the method returns 0 — causing charge_hold_fee() to skip the charge
entirely.

However, Koha's own holdability convention (documented in
IsAvailableForItemLevelRequest() and CheckReserves()) explicitly states:

  "item with negative or zero notforloan value is holdable" (notforloan > 0
blocks holds; notforloan <= 0 allows them)

The fee calculation code does not follow this same convention, causing the
mismatch.

Fix

Change the notforloan filter in _calculate_title_hold_fee() (Koha/Hold.pm) from
matching only = 0 to matching <= 0:

  # Before
  -or => [
      { 'me.notforloan' => 0 },
      { 'me.notforloan' => undef }
  ]

  # After
  -or => [
      { 'me.notforloan' => { '<=', 0 } },
      { 'me.notforloan' => undef }
  ]

This aligns fee calculation with the holdability logic used consistently
elsewhere in the codebase.

Test Plan

1. Apply patch.
2. Configure a hold_fee circulation rule for a patron category and item type.
3. Create a biblio with items having notforloan = -1 (Ordered).
4. Place a title-level hold for a matching patron.
5. Confirm a reservation fee is now added to the patron's account.
6. Confirm that items with notforloan = 1 (positive, truly not holdable) still
produce no fee.
7. Run prove t/db_dependent/Koha/Hold.t.

-- 
You are receiving this mail because:
You are the assignee for the bug.
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