Koha-clms/Koha/REST/V1
Tomás Cohen Arazi 78906e00da
Bug 42443: (QA follow-up) Use POST /transfers/{transfer_id}/cancellation
Cancelling a transfer is a state change on the resource, not a deletion of
it, so it should be modelled as an action sub-resource rather than a DELETE
on the transfer itself. This aligns the endpoint with the API coding
guidelines (REST2: non-CRUD actions use action sub-resources; REST3.2:
conflicts return 409) and with the design used in bug 43454.

Changes:
- Replace DELETE /transfers/{transfer_id} with
  POST /transfers/{transfer_id}/cancellation
- Rename the controller method delete() to cancel(), look the transfer up
  with objects->find_rs, and return 200 with the updated resource
  representation instead of 204 with an empty body
- Make cancellation_reason optional, defaulting to 'Manual', matching the
  legacy returns.pl behaviour
- Return 409 with a structured error_code ('already_arrived',
  'already_cancelled') when the transfer cannot be cancelled, instead of a
  bare 400
- Update the transfers to receive page to POST to the new endpoint and to
  treat 404/409 as "already gone, refresh the table"
- Adapt the tests accordingly, including coverage for the default reason
- The *_date API attribute names introduced by this bug are kept, as they
  are the guideline-compliant form (REST1.3.4.1: *_date, not date_*)

Test plan:
1. Apply patch
2. Run the tests:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/transfers.t
=> SUCCESS: Tests pass!
3. Rebuild and validate the API spec:
  k$ yarn api:bundle
  k$ prove xt/api.t
=> SUCCESS: Tests pass!
4. In the staff interface, go to Circulation -> Transfers to receive,
   click "Cancel transfer" on a row
=> SUCCESS: The transfer is cancelled and the row drops off the table
5. Cancel the same transfer again from a second tab
=> SUCCESS: The API returns 409 (already_cancelled) and the row is
   treated as already gone
6. Sign off :-D

Assisted-by: Sonnet 4.6 (Anthropic)
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-04 11:23:41 +00:00
..
Acquisitions Bug 29668: Adapt to current guidelines 2026-01-21 15:28:16 -07:00
Auth Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Biblios Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
CashRegisters Bug 40445: Add configuration options and UI enhancements 2026-07-27 12:12:36 +00:00
Clubs Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Config Bug 22639: Add GET /config/search_mappings endpoint 2026-04-15 11:37:17 -06:00
ERM Bug 42130: ERM - Index biblio when local title is created/updated 2026-06-05 14:25:54 +00:00
ILL Bug 37762: (QA follow-up): Warn and return 500 on schema validation failure in progress_request 2026-05-15 08:11:12 -06:00
OAuth Bug 40736: (QA follow-up) Avoid redundant CGISESSID cookie lookups 2026-08-14 12:09:23 +00:00
Patrons Bug 35797: (QA follow-up) Use https in API comment 2026-08-14 12:09:26 +00:00
Preservation Bug 37622: Remove location from 2 preservation 'update' routes 2025-09-26 10:36:53 -06:00
SIP2 Bug 37893: Fix http links 2025-11-18 11:21:20 -07:00
StockRotation Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ActionLogs.pm Bug 29016: (QA follow-up) Document the action_logs list controller 2026-05-05 13:42:11 -06:00
AdditionalContents.pm Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
AdvancedEditorMacro.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ArticleRequests.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Auth.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
AuthorisedValueCategories.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
AuthorisedValues.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Authorities.pm Bug 41901: Allow duplicate check when adding authority via API 2026-04-29 09:09:12 -06:00
BackgroundJobs.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Biblios.pm Bug 39337: Add is_opac_suppressed helper to C4::Context 2026-08-25 08:56:25 +00:00
Bookings.pm Bug 41898: Introduce 'issued' status and update booking display/filtering 2026-07-27 15:53:33 +00:00
CSPReports.pm Bug 38365: Make swagger-cli happy 2026-03-16 11:57:37 +01:00
Checkouts.pm Bug 23909: Apply hold policy to OPAC REST self-checkout 2026-05-01 11:04:20 -06:00
CirculationRules.pm Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Cities.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
DeletedBiblios.pm Bug 17387: (follow-up) fix embed items on get deleted biblio 2026-04-15 14:10:28 -06:00
DeletedItems.pm Bug 17387: (follow-up) address review feedback 2026-04-15 14:10:27 -06:00
ERM.pm Bug 39320: Preparation: ERM counts API endpoint 2026-01-13 15:03:20 -07:00
ExtendedAttributeTypes.pm Bug 39438: (bug 38446 follow-up) Add agreement_period to /erm/extended_attribute_types 2026-01-30 10:54:11 -07:00
Holds.pm Bug 41801: (QA follow-up) Ensure toggling priority sets correct rank 2026-03-21 20:28:16 +00:00
ILL.pm Bug 42845: Add ILL config endpoint for Vue app 2026-07-27 15:53:48 +00:00
ImportBatchProfiles.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ImportRecordMatches.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ItemTypes.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Items.pm Bug 40154: prevent deletion of items with holds 2026-02-10 10:52:04 -07:00
Libraries.pm Bug 42206: (follow-up) Rename to /closed_dates, improve efficiency 2026-05-01 11:04:25 -06:00
Lists.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
OAuth.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Patrons.pm Bug 41733: Honor EmailPatronRegistrations in the API 2026-04-15 11:37:13 -06:00
Preservation.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Quotes.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
RecordSources.pm Bug 35380: Change record sources to by systemdefined 2026-03-26 09:46:15 +01:00
ReturnClaims.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
SearchFilter.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Static.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Status.pm Bug 41107: Add /status/version API endpoint 2026-03-23 09:33:54 +01:00
Suggestions.pm Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
Sysprefs.pm Bug 41994: Implement /sysprefs route to list system preferences 2026-04-15 11:37:05 -06:00
Tickets.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
TransferLimits.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Transfers.pm Bug 42443: (QA follow-up) Use POST /transfers/{transfer_id}/cancellation 2026-09-04 11:23:41 +00:00
TwoFactorAuth.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00