Koha-clms/t/db_dependent/api/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
..
iso18626 Bug 37762: (RM follow-up): Tidy t/db_dependent/api/v1/iso18626/request.t 2026-05-15 08:11:13 -06:00
items Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
public Bug 38365: Make swagger-cli happy 2026-03-16 11:57:37 +01:00
acquisitions_baskets.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
acquisitions_funds.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
acquisitions_orders.t Bug 42391: (follow-up) Add missing warning assertions for Object::store 2026-07-27 12:12:29 +00:00
acquisitions_vendor_issues.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
acquisitions_vendors.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
action_logs.t Bug 43082: Fix flaky object filter test in action_logs.t 2026-07-31 13:40:34 +00:00
additional_contents.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
advanced_editor_macros.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
article_requests.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
auth.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
auth_authenticate_api_request.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
auth_basic.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
authorised_values.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
authorities.t Bug 41901: (follow-up) Fix perlcritic violation in unit tests 2026-04-29 09:09:13 -06:00
biblios.t Bug 42391: (follow-up) Add missing warning assertions for Object::store 2026-07-27 12:12:29 +00:00
bookings.t Bug 43241: (follow-up) Use form => for q= params in tests 2026-08-28 16:36:37 +00:00
cash_registers.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
cashups.t Bug 40445: Add configuration options and UI enhancements 2026-07-27 12:12:36 +00:00
checkouts.t Bug 41889: Update API to allow for null patron_id to be returned when listing checkouts 2026-07-01 09:34:39 +00:00
circulation_rules.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
cities.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
clubs_holds.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
config_search_mappings.t Bug 22639: Add GET /config/search_mappings endpoint 2026-04-15 11:37:17 -06:00
deleted_biblios.t Bug 43241: (follow-up) Use form => for q= params in tests 2026-08-28 16:36:37 +00:00
deleted_items.t Bug 17387: (follow-up) move records_restore under editcatalogue permission 2026-04-15 14:10:27 -06:00
edifact_files.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_agreements.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_counter_files.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_counter_logs.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_counter_registries.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
erm_custom_reports.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_documents.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_eholdings_packages.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_eholdings_resources.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_eholdings_titles.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_licenses.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_sushi_services.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
erm_usage_data_providers.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_usage_titles.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
erm_users.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
extended_attribute_types.t Bug 39438: (RM follow-up): Fix failing test 2026-02-06 10:43:09 -07:00
file_transports.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
holds.t Bug 43071: Isolate holds_per_day-sensitive tests from ambient circulation rules 2026-07-27 12:13:08 +00:00
idp.t Bug 40736: Add test 2026-08-14 12:09:22 +00:00
ill_backends.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
ill_batches.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
ill_batchstatuses.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
ill_config.t Bug 42845: Add ILL config endpoint for Vue app 2026-07-27 15:53:48 +00:00
ill_requests.t Bug 40105: Patrons cannot add notes when creating an ILL 2026-03-05 08:33:32 -07:00
ill_users.t Bug 40504: (QA follow-up) Tidy 2026-03-26 14:21:25 +01:00
import_batch_profiles.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
import_record_matches.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
item_groups.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
item_types.t Bug 38136: Refactor database translations (alternative) 2026-04-15 11:37:14 -06:00
items.t Bug 38136: Clear localization cache before testing itemtype localization 2026-04-17 09:17:58 -06:00
jobs.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
libraries.t Bug 42391: (follow-up) Add missing warning assertions for Object::store 2026-07-27 12:12:29 +00:00
oauth.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
pagination.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
password_validation.t Bug 40286: (follow-up) Fix password_validation.t for find_by_identifier behavior 2026-03-23 08:01:09 +01:00
patron_categories.t Bug 26355: (QA follow-up) perl tidy to address qa tool errors 2026-05-01 09:30:03 -06:00
patron_images.t Bug 35797: Syspref, schema path file and tests changes 2026-08-14 12:09:25 +00:00
patrons.t Bug 42207: Allow library embed on GET /patrons/{patron_id} 2026-08-21 15:58:25 +00:00
patrons_accounts.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
patrons_checkouts.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
patrons_extended_attributes.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
patrons_hold_groups.t Bug 41849: Add tests 2026-04-10 09:48:05 -06:00
patrons_holds.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
patrons_password.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
patrons_password_expiration.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
patrons_recalls.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
patrons_self_renewal.t Bug 26355: (QA follow-up) perl tidy to address qa tool errors 2026-05-01 09:30:03 -06:00
preservation_Processings.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
preservation_Trains.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
preservation_WaitingList.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
provider.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
query.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
record_sources.t Bug 35380: Unit tests 2026-03-26 09:50:09 +01:00
responses.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
return_claims.t Bug 42391: (follow-up) Add missing warning assertions for Object::store 2026-07-27 12:12:29 +00:00
search_filters.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
sip2_accounts.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
sip2_institutions.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
sip2_system_preference_overrides.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
smtp_servers.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
status.t Bug 41107: (QA follow-up) Tidy status.t 2026-03-23 09:33:54 +01:00
stockrotation_rotas.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
stockrotationstage.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
suggestions.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
sysprefs.t Bug 41994: Implement /sysprefs route to list system preferences 2026-04-15 11:37:05 -06:00
ticket_updates.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
tickets.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
transfer_limits.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
transfers.t Bug 42443: (QA follow-up) Use POST /transfers/{transfer_id}/cancellation 2026-09-04 11:23:41 +00:00
two_factor_auth.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
unhandled_exceptions.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00