---
id: WF-COM-ORD-010
title: Cancel lines of an accepted order
trigger: A caller requests cancellation of quantities from an accepted purchase.
product_area: commerce
module: orders
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-COM-ORD-014
  - CAP-COM-ORD-013
  - CAP-COM-ORD-009
  - CAP-COM-ORD-004
moves:
  - STATE-COM-ORD-009
  - STATE-COM-ORD-004
  - STATE-COM-ORD-003
  - STATE-COM-ORD-008
crosses:
  - SVC-COM-ORD-orders
  - SVC-COM-ORD-participants
  - SVC-COM-ORD-entitlements
  - SVC-ACC-TRX-transactions
  - SVC-PFM-OPS-audit
idempotency: >-
  Live line occupancy refuses overlapping cancellation requests. Execution and keyed settlement recognize
  existing work rather than cancelling or refunding quantities twice.
concurrency: >-
  One live cancellation occupies each line. Order locking and conditional seller and shipping fences protect
  execution; settlement only advances from the eligible executing state.
hops:
  - 'n': 1
    actor_or_service: Orders route
    action: >-
      Establish self-service, staff or reasoned override authority; require acceptance; create and evaluate a
      numbered request using seller advice, invoice caps, fees, refunds and approval rules.
    anchor: 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts:requestCancellation'
    seam: sync
    on_failure: >-
      Invalid order, party, permission or workspace refuses the request; denied evaluations retain a rejected
      document.
    left_inconsistent: A console preview itself creates a document and occupies its lines.
    observer: Observed through the requester; Order 360 Changes card.
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#refuses a placed order 409
      order_not_cancellable, another member 403 not_your_party, a reader 403 permission_missing, another
      tenant 404
  - 'n': 2
    actor_or_service: Approver
    action: Record a reasoned approval or rejection of a waiting cancellation as a staff intervention.
    anchor: 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts:approveCancellation'
    seam: sync
    on_failure: Console access and approval permission are required.
    left_inconsistent: No unauthorized decision commits.
    observer: Observed through sale history; intervention log.
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#refuses a member on the console
      approve route 403, and a clerk approving 403 permission_missing
  - 'n': 3
    actor_or_service: Cancellation transaction
    action: >-
      Recheck an aged plan and atomically cancel or fence delivery, release resources, update cancelled units
      and offer uses, revoke grants, request settlement and enter execution.
    anchor: 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts:executeCancellation'
    seam: sync
    on_failure: Changed plans or refused fences roll back execution and leave prepared with an explanation.
    left_inconsistent: No partial cancellation execution commits.
    observer: Observed through the requester; sale history.
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#fences a DELIVERED seat through the
      participant’s commerce_claim_cancellation, and the participant’s cancel gives the capacity back
  - 'n': 4
    actor_or_service: Shipping (fulfilment module)
    action: 'After commit, cancel fenced shipping lines, remove empty packages and request carrier label voids.'
    anchor: 'services-commerce:modules/orders/services/cancellations/shipping-fence-port.ts'
    seam: sync
    on_failure: Failures are logged while the committed fence remains effective.
    left_inconsistent: A carrier label can remain active for cancelled shipping work.
    observer: Observed through observed through shipments card; carrier.
    provenance: observed
    source: 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts'
  - 'n': 5
    actor_or_service: Delivery register worker (fulfilment module)
    action: Dispatch cancellation obligations to their sellers and settle from each recorded outcome.
    anchor: 'services-commerce:modules/fulfillment/services/register/obligation-worker.ts'
    seam: queue
    on_failure: Failed domain reversal ends with exceptions; default policy keeps settlement behind reversal.
    left_inconsistent: Product work and money can remain unreversed.
    observer: Observed through fulfilment card; recorded operational exceptions.
    provenance: observed
    source: >-
      services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellationAfterObligation
  - 'n': 6
    actor_or_service: Adjustment worker (fulfilment module)
    action: >-
      At the configured domain or fence stage, credit invoice lines, charge fees from released value and
      refund or credit the balance.
    anchor: 'services-commerce:modules/fulfillment/services/adjustments/adjustment-worker.ts:executeAdjustment'
    seam: sync
    on_failure: Refusals create adjustment exceptions; stale or uncertain work resumes through facts or reconciliation.
    left_inconsistent: Executing documents can await financial completion.
    observer: Observed through observed through adjustment exceptions; Transactions card.
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee invoice, applies the
      freed money to it and refunds the remainder
  - 'n': 7
    actor_or_service: Settlement
    action: >-
      Complete or record exceptions, cancel an order with no remaining items, refresh financial figures and
      request schedule reduction.
    anchor: 'services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellation'
    seam: sync
    on_failure: Mirror and schedule failures are logged; schedule reduction refusal appears only in history.
    left_inconsistent: Future installments can remain unchanged after cancellation.
    observer: Observed through sale history; mirror sweep.
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#shows the cancellation’s credit on
      the order’s money mirror at once, read right after the cancel
branches:
  - Goods already handed to a carrier require the return path.
  - Refund thresholds and seller-required authorization can require approval.
  - Cancelling the purchased line restores its personal single-use promotion code.
waits:
  - 'Approval, seller cancellation and financial confirmation can each suspend progress.'
evidence:
  - >-
    services-commerce at c8b66a98: modules/orders/services/cancellations/*.ts;
    services/installments/installment-cancellation.ts; aws/api/post-purchase.routes.ts;
    tests/e2e/cancellations.e2e.spec.js; modules/fulfillment/services/adjustments/adjustment-worker.ts.
  - >-
    react-console at baf6dae3: components/commerce/order-flows/cancel-lines-dialog.tsx;
    lib/commerce/order-flows/live.ts.
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-TEN-004, TC-CRY-001, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-DAT-004, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-AVL-004, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-VEN-001, TC-VEN-002, TC-VEN-003, TC-PRV-001, TC-PRV-002]
---

# Cancel lines of an accepted order

## What It Does

Cancellation evaluates quantities, authority and settlement, then fences the affected purchase in one domain transaction. Completion waits for application reversal and the configured financial plan.

## The Flow

```mermaid
sequenceDiagram
  participant R as Requester
  participant O as Orders
  participant A as Selling application
  participant W as Register and adjustment worker
  participant X as Accounting
  R->>O: request (lines, quantities)
  O->>A: cancellation advice
  O->>X: read position
  O-->>R: plan (approved, awaiting approval or rejected)
  R->>O: execute
  O->>A: one transaction: fence or release claims, cancel obligations, quantities, redemptions, grants, adjustment requested
  W->>A: cancel delivered work
  W->>X: memo, fee invoice, refund or credit
  O->>O: settle, order cancelled when nothing remains
```

## When Something Fails

Execution rollback preserves quantities and claims if a fence or plan changes. After commit, application and money failures are handled as outstanding work or exceptions. Carrier-label cleanup can fail independently, and schedule reduction failure lacks its own exception.

## Open Design Questions

The console preview creates a real occupying request. Closing that dialog needs a defined cleanup behavior, and full-order fee refund remains undecided.
