https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43602 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 206598 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206598&action=edit Bug 43602: Replace complete/cancel with a generic PATCH edit action Replaces the three narrow, non-REST actions (complete, cancel, patron_cancel - the last two DELETE-based) with a single PATCH edit()/patron_edit() action that drives every status transition (pending/processing/completed/canceled), delivery URL updates and pickup library reassignment through one endpoint, matching the shape of Koha::REST::V1::ILL::ISO18626::Requests#edit. The previous DELETE-based cancel routes are confirmed unused outside this codebase (only reachable from our own staff and OPAC templates, migrated in the next commit), so removing them is safe. patron_edit is intentionally narrower than the staff edit action: a patron may only set status to CANCELED on their own request, matching what patron_cancel used to allow. A new _rejected_status_transition($article_request, $new_status) guard, shared by edit() and patron_edit(), rejects two cases the underlying Koha::ArticleRequest status methods (set_pending/process/complete/cancel) deliberately do not guard against themselves, so as not to change behavior for their other callers (opac-article-request-cancel.pl, Koha::ArticleRequest::ScanImport): re-running a transition on a request already in a terminal status - notably re-cancelling an already-CANCELED request, which would re-run the fee refund logic - and "transitioning" to the status the request is already in. The guard runs before any database mutation in edit(), so a rejected transition returns 400 without partially applying the urls/library_id changes from the same request body. Also wraps add()/patron_add()'s request() + store() calls in Koha::Database->new->schema->txn_do(sub {...}), matching Koha::REST::V1::ILL::Requests#add: request() charges an article-request fee debit before store() runs, and store() can still throw (WrongFormat, or an FK constraint not caught by the pre-validation added in the previous commit); without the transaction a thrown exception would leave that fee debit orphaned with no corresponding article request. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.