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

--- Comment #95 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 209850
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209850&action=edit
Bug 42386: Wire CanItemBeReserved and CanBookBeReserved to the availability
classes

This patch makes C4::Reserves::CanItemBeReserved and CanBookBeReserved
thin wrappers around Koha::Item::Availability::Hold and
Koha::Biblio::Availability::Hold. They return snake_case statuses and
all callers are updated.

As in the legacy routines, the wrappers don't check patron
eligibility (expired, debt_limit, bad_address, card_lost, restricted,
hold_limit). Callers check it separately with
Koha::Patron->can_place_holds, and the staff interface lets it be
overridden.

Changes:
- library_not_found is checked in the wrappers (branchcode -> object)
- limit is returned for the too_many_* statuses
- overrides are passed through to the availability classes
- CanBookBeReserved returns no_items when the record has no items, and
  a reasons arrayref ({ itemnumber, status }) when no item can be
  reserved. When all items fail for the same reason, that reason is
  the status (with its limit), otherwise it is no_item_available
- ILS-DI keeps returning its documented camelCase codes
  (_legacy_hold_code), reporting the last failing item's reason as
  before. These are part of the public ILS-DI API.

Note: club holds store these statuses in
club_holds_to_patron_holds.error_code, which only accepts them after the
DB update and the DBIC schema changes in the next two patches. The club
hold tests are run there.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Holds.t \
           t/db_dependent/Holds/ \
           t/db_dependent/Reserves.t \
           t/db_dependent/Reserves/ \
           t/db_dependent/ILSDI_Services.t \
           t/db_dependent/SIP/Transaction.t \
           t/db_dependent/api/v1/holds.t
=> SUCCESS: Tests pass!
3. In the staff interface, restrict a patron and place a hold for
   them from Search the catalog > Place hold
=> SUCCESS: The restriction is shown as a warning that can be
overridden, and the items are holdable
4. Sign off :-D

Co-authored-by: Martin Renvoize <[email protected]>
Assisted-by: Opus 5.5 (Anthropic)

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to