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

--- Comment #89 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 211507
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211507&action=edit
Bug 24401: Align POST /checkins with the bug 42383 endpoint design

Ports the main POST /checkins (Checkins#add) endpoint to the design
developed on bug 42383, which is a strict superset of the previous
implementation:

- Enforce the updatecharges.writeoff permission for exempt_fine with an
  explicit 403 (error_code: no_permission_for_exempt_fine), instead of
  silently dropping the flag.
- Reject supplying both item_id and external_id
  (error_code: mutually_exclusive_parameters), and rename the missing
  identifier error to missing_item_identifier.
- Default library_id to the logged in library (the session library, or
  the x-koha-library header), matching AddReturn's own fallback so the
  availability dry-run and the checkin agree. Unknown libraries are
  rejected (400, invalid_parameter_value), and library_id follows the same
  rule as the x-koha-library header: with IndependentBranches, only
  superlibrarians can act on another library (403, library_not_allowed).
- Reject items without a barcode (409, item_without_barcode): AddReturn
  works on barcodes, and an undefined barcode could match another item.
- Support return_date (gated behind the SpecifyReturnDate preference,
  error_code: return_date_not_allowed) and dropbox_mode.
  A return_date that cannot be parsed is rejected (400,
  invalid_parameter_value) instead of causing a 500.
- Return AddReturn's outcome messages: serialize the checkin object's
  object_messages into a `messages` array on the response, resolving the
  previous gap where ~25 outcome messages never reached API consumers.
- Use lower_snake_case error codes (checkin_blocked, confirmation_required,
  etc.), consistent with the rest of the API, and include the item in the
  412 confirmation response.
- Mark both endpoints EXPERIMENTAL in the spec, and document that the 412
  confirmation is a workflow gate, not an authorization control.

The bug 42383 module-policy and bundle-verification hooks are intentionally
left out here: they depend on framework not present on this branch and are
outside the scope of the main checkin endpoint.

Test plan:
1. Apply patch
2. Run the tests:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/checkins.t
=> SUCCESS: Tests pass!
3. Rebuild and validate the API spec:
  k$ yarn api:bundle
  k$ prove xt/api.t
=> SUCCESS: Tests pass!
4. As a user WITHOUT updatecharges.writeoff, POST /checkins with
   exempt_fine: true on an item with an outstanding overdue fine
=> SUCCESS: 403 no_permission_for_exempt_fine, the fine is not forgiven
5. Sign off :-D

Assisted-by: Sonnet 4.6 (Anthropic)
Assisted-by: Opus 5.5 (Anthropic)
Signed-off-by: Tomás Cohen Arazi <[email protected]>
Signed-off-by: Brendan Lawlor <[email protected]>

-- 
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