---
id: ATS-COM-ORD-014
scope: CAP-COM-ORD-014
product_area: commerce
module: orders
revision: 2
status: proposed
approved_by: null
approved_at: null
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
scenarios:
  - id: ATS-COM-ORD-014-01
    title: Cancellation refuses invalid order or access context
    level: api
    proves:
      - BR-CAP-COM-ORD-014-01
    preconditions: 'A placed order is accessed by another member, reader or workspace.'
    steps:
      - do: Request cancellation in the refusal cases.
        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
    expected: 'The results identify order_not_cancellable, not_your_party, permission_missing or not found.'
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        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
      - TST-COM-ORD-076
    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
    category: permission
    expected_provenance: test
    expected_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
  - id: ATS-COM-ORD-014-02
    title: An uncomplicated cancellation completes from its plan
    level: api
    proves:
      - BR-CAP-COM-ORD-014-02
    preconditions: An accepted order has an undelivered shirt and an unaffected mug.
    steps:
      - do: Cancel the shirt using the request’s execution path.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers 200 with the document
          completed in the one request: allowed, executed, the money moved, the customer status cancelled
    expected: 'The document records allowed and executed quantity, completed money work and cancellation status.'
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers 200 with the document
        completed in the one request: allowed, executed, the money moved, the customer status cancelled
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers 200 with the document
      completed in the one request: allowed, executed, the money moved, the customer status cancelled
    category: transition
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers 200 with the document
      completed in the one request: allowed, executed, the money moved, the customer status cancelled
  - id: ATS-COM-ORD-014-03
    title: Remaining lines determine the order’s cancellation state
    level: api
    proves:
      - BR-CAP-COM-ORD-014-03
    preconditions: An accepted order has two separate item lines.
    steps:
      - do: Cancel the shirt and then the mug.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting
          fulfil obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order
          still accepted
    expected: The first closure preserves the other line and the last closure makes the order cancelled.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting fulfil
        obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order still
        accepted
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lists the order’s cancellations
        and reads one; cancelling the mug too closes the order cancelled (B5)
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting fulfil
      obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order still
      accepted
    category: transition
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting fulfil
      obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order still
      accepted
  - id: ATS-COM-ORD-014-04
    title: Domain cancellation precedes its refund
    level: api
    proves:
      - BR-CAP-COM-ORD-014-04
    preconditions: An application has already delivered the purchased membership fixture.
    steps:
      - do: Request cancellation and process the queued cancellation obligation.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers executing: a cancel
          obligation stands open at once (nothing to fence: the type claims nothing), the line executed, the
          domain action shown
    expected: Application cancellation completes before the recorded money adjustment and document completion.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers executing: a cancel
        obligation stands open at once (nothing to fence: the type claims nothing), the line executed, the
        domain action shown
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
        participant’s cancel, which settles the document completed and runs the refund after the domain
        (ADR-13)
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers executing: a cancel
      obligation stands open at once (nothing to fence: the type claims nothing), the line executed, the
      domain action shown
    category: interaction
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers executing: a cancel
      obligation stands open at once (nothing to fence: the type claims nothing), the line executed, the
      domain action shown
  - id: ATS-COM-ORD-014-05
    title: Invoice credit differs from refundable funding
    level: unit
    proves:
      - BR-CAP-COM-ORD-014-05
    preconditions: 'The fixtures cancel two of five discounted units with tax, limited funding and refundable fractions.'
    steps:
      - do: Assemble the plans and apply the invoice cap helper.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#credits 2 of 5
          units at the discounted amount with the tax share, estimates the refund from the funded part, and
          approves the document
    expected: Unit value and tax form the credit; funding and deductions limit only the estimated refund.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#credits 2 of 5
        units at the discounted amount with the tax share, estimates the refund from the funded part, and
        approves the document
      - >-
        services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#reduces the
        estimate by the refundable fraction and the non-refundable part, and caps it at what was funded
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#credits no more than the invoice
        line still owes, so Accounting does not refuse the memo as an over-application
      - TST-COM-ORD-131
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#credits 2 of 5 units
      at the discounted amount with the tax share, estimates the refund from the funded part, and approves the
      document
    category: boundary
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#credits 2 of 5 units
      at the discounted amount with the tax share, estimates the refund from the funded part, and approves the
      document
  - id: ATS-COM-ORD-014-06
    title: Fee planning includes a billable fallback
    level: unit
    proves:
      - BR-CAP-COM-ORD-014-06
    preconditions: 'Frozen terms or application advice include a fee, with a case lacking any fee product.'
    steps:
      - do: Assemble cancellation fee and settlement cases.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#takes the
          participant’s fee, else the frozen terms’, else none, and waives an amount with no product with a
          warning
    expected: >-
      Billable fees use their product and freed money, while an unbillable fee becomes a warning and is
      waived.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#takes the
        participant’s fee, else the frozen terms’, else none, and waives an amount with no product with a
        warning
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee invoice, applies
        the freed money to it and refunds the remainder
      - TST-COM-ORD-131
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#takes the
      participant’s fee, else the frozen terms’, else none, and waives an amount with no product with a
      warning
    category: edge
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#takes the
      participant’s fee, else the frozen terms’, else none, and waives an amount with no product with a
      warning
  - id: ATS-COM-ORD-014-07
    title: Approval blocks overlapping execution
    level: api
    proves:
      - BR-CAP-COM-ORD-014-07
    preconditions: Application advice requires review and another case exceeds a threshold.
    steps:
      - do: 'Request cancellation, try a duplicate, approve with a reason and execute.'
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s request for
          approval (participant_requires_approval) and refuses a second request on the line 409
          line_already_cancelling (B38)
    expected: The held request blocks the duplicate and proceeds through recorded approval before execution.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s request for
        approval (participant_requires_approval) and refuses a second request on the line 409
        line_already_cancelling (B38)
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the approver approve it with
        a reason, and staff execute it; the intervention on the history
      - >-
        services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#waits for a person
        when the participant requires approval, and when the refund is above the order type’s threshold
      - TST-COM-ORD-076
      - TST-COM-ORD-131
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s request for approval
      (participant_requires_approval) and refuses a second request on the line 409 line_already_cancelling
      (B38)
    category: concurrency
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s request for approval
      (participant_requires_approval) and refuses a second request on the line 409 line_already_cancelling
      (B38)
  - id: ATS-COM-ORD-014-08
    title: Deadline overrides retain authorization checks
    level: api
    proves:
      - BR-CAP-COM-ORD-014-08
    preconditions: A line is past its cancellation deadline.
    steps:
      - do: Request as a customer and attempt clerk and administrator overrides.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#rejects the member’s request
          with after_cancellation_deadline, the customer status declined; nothing moved on the order
    expected: >-
      The customer is declined, the clerk cannot override and the administrator’s reason permits evaluation
      subject to approval.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#rejects the member’s request with
        after_cancellation_deadline, the customer status declined; nothing moved on the order
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#allows an administrator’s
        override at once with its reason, and refuses a clerk’s override 403 override_not_permitted
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#rejects the member’s request with
      after_cancellation_deadline, the customer status declined; nothing moved on the order
    category: permission
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#rejects the member’s request with
      after_cancellation_deadline, the customer status declined; nothing moved on the order
  - id: ATS-COM-ORD-014-09
    title: Carrier handoff redirects cancellation to return
    level: api
    proves:
      - BR-CAP-COM-ORD-014-09
    preconditions: The shipping fence reports goods already handed off.
    steps:
      - do: Request cancellation of that line.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers must_return with
          shipment_handed_off once the shipping fence says the unit shipped
    expected: The result is must_return with shipment_handed_off.
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers must_return with
        shipment_handed_off once the shipping fence says the unit shipped
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers must_return with
      shipment_handed_off once the shipping fence says the unit shipped
    category: edge
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers must_return with
      shipment_handed_off once the shipping fence says the unit shipped
  - id: ATS-COM-ORD-014-10
    title: Approval is unavailable to ordinary purchasers
    level: api
    proves:
      - BR-CAP-COM-ORD-014-10
    preconditions: A cancellation waits for an approver.
    steps:
      - do: Try its approval action as a portal member and an ordinary clerk.
        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
    expected: Both requests return 403.
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        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
      - TST-COM-ORD-076
    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
    category: permission
    expected_provenance: test
    expected_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
  - id: ATS-COM-ORD-014-11
    title: Partial-order cancellation preserves the other purchase
    level: api
    proves:
      - AS-JNY-COM-ORD-005-01
      - AS-JNY-COM-ORD-005-02
    preconditions: A paid order contains separate shirt and mug purchases.
    steps:
      - do: Cancel the affected shirt line.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting
          fulfil obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order
          still accepted
    expected: Only the affected value and tax are credited while the remaining sale stays accepted.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting fulfil
        obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order still
        accepted
      - >-
        services-commerce:modules/orders/tests/e2e/order-discount-tax.e2e.spec.js#credits the Book’s net on
        its invoice line and its tax on the tax line, then refunds the whole $44.74 (COMM-M1 R7-1)
      - TST-COM-ORD-076
      - TST-COM-ORD-080
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting fulfil
      obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order still
      accepted
    category: interaction
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the line’s waiting fulfil
      obligation itself, grows quantity_cancelled and closes the line; the mug untouched, the order still
      accepted
  - id: ATS-COM-ORD-014-12
    title: Waiting line-grain delivery refuses a partial request
    level: unit
    proves:
      - BR-CAP-COM-ORD-014-15
    preconditions: A waiting delivery treats all remaining units as one line.
    steps:
      - do: Plan a cancellation of fewer units than remain.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#refuses more
          than the line has left, and a part of a waiting line-grain line (whole_line_only, D-P7-05)
    expected: The plan reports whole_line_only and permits zero units.
    negative: true
    data_needs: 'A controlled workspace with the parties, commercial setup and application responses described above.'
    bound_to:
      - >-
        services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#refuses more than
        the line has left, and a part of a waiting line-grain line (whole_line_only, D-P7-05)
      - TST-COM-ORD-131
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#refuses more than
      the line has left, and a part of a waiting line-grain line (whole_line_only, D-P7-05)
    category: validation
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#refuses more than
      the line has left, and a part of a waiting line-grain line (whole_line_only, D-P7-05)
  - id: ATS-COM-ORD-014-13
    title: Withdrawal frees a cancellation’s occupied line
    category: transition
    level: api
    proves:
      - BR-CAP-COM-ORD-014-11
    preconditions: A member has an approved unexecuted cancellation.
    steps:
      - do: 'Try a duplicate, withdraw the original and request again.'
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the member withdraw an
          approved, unexecuted request (a second request refused meanwhile), then request again
    expected: The duplicate is refused before withdrawal and a later request is accepted.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the member withdraw an
        approved, unexecuted request (a second request refused meanwhile), then request again
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the member withdraw an
      approved, unexecuted request (a second request refused meanwhile), then request again
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the member withdraw an
      approved, unexecuted request (a second request refused meanwhile), then request again
  - id: ATS-COM-ORD-014-14
    title: Cancellation returns capacity to the selling application
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-014-12
    preconditions: An accepted line has one committed seat and a reservation.
    steps:
      - do: Execute cancellation and inspect the owner’s claim and reservation.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#releases the claim through the
          participant’s function: one seat committed before, none after, the ledger released for cancellation
    expected: No seat claim remains and the reservation records release for cancellation.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#releases the claim through the
        participant’s function: one seat committed before, none after, the ledger released for cancellation
      - TST-COM-ORD-076
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#releases the claim through the
      participant’s function: one seat committed before, none after, the ledger released for cancellation
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#releases the claim through the
      participant’s function: one seat committed before, none after, the ledger released for cancellation
  - id: ATS-COM-ORD-014-15
    title: Cancellation credit is visible on the immediate order read
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-014-13
    preconditions: The fixture paid order has a cancellable line.
    steps:
      - do: Cancel the line and immediately read the order.
        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
    expected: The money summary includes that cancellation’s credit.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        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
      - TST-COM-ORD-076
    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
    expected_provenance: test
    expected_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
  - id: ATS-COM-ORD-014-16
    title: Plan cancellation updates both future collection and current money
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-009-06
      - BR-CAP-COM-ORD-014-13
    preconditions: A deposit sale has a paid installment and future unpaid shares.
    steps:
      - do: Cancel one line and inspect the schedule and order money.
        provenance: proposed
        source:
          - >-
            services-commerce:modules/orders/tests/e2e/installments.e2e.spec.js#reduced the remaining
            installments: the mug’s part gone from the two scheduled ones, the paid one untouched, on the
            history
          - >-
            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
    expected: >-
      The paid installment is unchanged, future shares shrink and the cancellation credit appears on the
      order.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    source:
      - >-
        services-commerce:modules/orders/tests/e2e/installments.e2e.spec.js#reduced the remaining
        installments: the mug’s part gone from the two scheduled ones, the paid one untouched, on the history
      - >-
        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
    exercises:
      - CAP-COM-ORD-014
      - CAP-COM-ORD-009
    related_capabilities:
      - CAP-COM-ORD-009
    expected_provenance: proposed
    expected_source:
      - >-
        services-commerce:modules/orders/tests/e2e/installments.e2e.spec.js#reduced the remaining
        installments: the mug’s part gone from the two scheduled ones, the paid one untouched, on the history
      - >-
        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
  - id: ATS-COM-ORD-014-17
    title: Cancellation revokes the purchased right without removing use history
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-013-08
      - BR-CAP-COM-ORD-014-04
    preconditions: A completed purchased grant has one recorded use.
    steps:
      - do: Cancel its line and retry the buyer’s download.
        provenance: proposed
        source:
          - >-
            services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
            with the reason, refuses the download 409 entitlement_not_active, and writes the history
          - >-
            services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to
            the participant’s cancel, which settles the document completed and runs the refund after the
            domain (ADR-13)
    expected: 'The grant is revoked, the original use remains and the download is refused.'
    negative: true
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    source:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
        with the reason, refuses the download 409 entitlement_not_active, and writes the history
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
        participant’s cancel, which settles the document completed and runs the refund after the domain
        (ADR-13)
    exercises:
      - CAP-COM-ORD-014
      - CAP-COM-ORD-013
    related_capabilities:
      - CAP-COM-ORD-013
    expected_provenance: proposed
    expected_source:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
        with the reason, refuses the download 409 entitlement_not_active, and writes the history
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
        participant’s cancel, which settles the document completed and runs the refund after the domain
        (ADR-13)
  - id: ATS-COM-ORD-014-18
    title: Carrier handoff redirects the buyer to a return
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-014-09
      - BR-CAP-COM-ORD-016-03
    preconditions: The purchased goods have been handed to the carrier and are within their return window.
    steps:
      - do: 'Request cancellation, then request a return.'
        provenance: proposed
        source:
          - >-
            services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers must_return with
            shipment_handed_off once the shipping fence says the unit shipped
          - >-
            services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the
            built-in policy: the RMA numbered with its deadline, the lines authorized, the customer told to
            send it back
    expected: Cancellation directs the buyer to return; the eligible return receives receiving authority.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    source:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers must_return with
        shipment_handed_off once the shipping fence says the unit shipped
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
        policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
    exercises:
      - CAP-COM-ORD-014
      - CAP-COM-ORD-016
    related_capabilities:
      - CAP-COM-ORD-016
    expected_provenance: proposed
    expected_source:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers must_return with
        shipment_handed_off once the shipping fence says the unit shipped
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
        policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
  - id: ATS-COM-ORD-014-19
    title: Plan-line cancellation releases rights and offer use alongside money
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-014-01
      - BR-CAP-COM-ORD-013-01
      - BR-CAP-COM-ORD-009-01
      - BR-CAP-COM-ORD-004-01
    preconditions: An accepted installment line has a grant and a personal single-use promotion.
    steps:
      - do: >-
          Cancel the line, run required domain reversal and inspect rights, redemption, credit and future
          schedule.
        provenance: proposed
        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
          - >-
            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
          - >-
            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
          - 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts'
          - >-
            services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellationAfterObligation
          - >-
            services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee invoice,
            applies the freed money to it and refunds the remainder
          - >-
            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
    expected: >-
      The linked resources and future collection reflect the cancellation; the personal-code restoration
      expectation remains a product-versus-implementation gap.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    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
      - >-
        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
      - >-
        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
      - 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts'
      - >-
        services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellationAfterObligation
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee invoice, applies
        the freed money to it and refunds the remainder
      - >-
        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
    exercises:
      - CAP-COM-ORD-014
      - CAP-COM-ORD-013
      - CAP-COM-ORD-009
      - CAP-COM-ORD-004
    workflows:
      - WF-COM-ORD-010
    expected_provenance: proposed
    expected_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
      - >-
        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
      - >-
        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
      - 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts'
      - >-
        services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellationAfterObligation
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee invoice, applies
        the freed money to it and refunds the remainder
      - >-
        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
evidence:
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#allows an
    administrator’s override at once with its reason, and refuses a clerk’s override 403
    override_not_permitted
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers 200 with
    the document completed in the one request: allowed, executed, the money moved, the customer status
    cancelled
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers
    executing: a cancel obligation stands open at once (nothing to fence: the type claims nothing), the line
    executed, the domain action shown
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers
    must_return with shipment_handed_off once the shipping fence says the unit shipped
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#cancels the
    line’s waiting fulfil obligation itself, grows quantity_cancelled and closes the line; the mug untouched,
    the order still accepted
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#credits no more
    than the invoice line still owes, so Accounting does not refuse the memo as an over-application
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s
    request for approval (participant_requires_approval) and refuses a second request on the line 409
    line_already_cancelling (B38)
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by
    the worker to the participant’s cancel, which settles the document completed and runs the refund after the
    domain (ADR-13)
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the approver
    approve it with a reason, and staff execute it; the intervention on the history
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lists the order’s
    cancellations and reads one; cancelling the mug too closes the order cancelled (B5)
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee
    invoice, applies the freed money to it and refunds the remainder
  - >-
    Examined reference: 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
  - >-
    Examined reference: 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
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#rejects the
    member’s request with after_cancellation_deadline, the customer status declined; nothing moved on the
    order
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/order-discount-tax.e2e.spec.js#credits the
    Book’s net on its invoice line and its tax on the tax line, then refunds the whole $44.74 (COMM-M1 R7-1)
  - >-
    Examined reference:
    services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#credits 2 of 5 units
    at the discounted amount with the tax share, estimates the refund from the funded part, and approves the
    document
  - >-
    Examined reference:
    services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#reduces the estimate
    by the refundable fraction and the non-refundable part, and caps it at what was funded
  - >-
    Examined reference:
    services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#refuses more than the
    line has left, and a part of a waiting line-grain line (whole_line_only, D-P7-05)
  - >-
    Examined reference:
    services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#takes the
    participant’s fee, else the frozen terms’, else none, and waives an amount with no product with a warning
  - >-
    Examined reference:
    services-commerce:modules/orders/tests/unit/cancellations/cancellation-plan.spec.js#waits for a person
    when the participant requires approval, and when the refund is above the order type’s threshold
coverage:
  rule: 'gap: FND-COM-ORD-071'
  transition: 'gap: FND-COM-ORD-071'
  validation: covered
  permission: 'gap: FND-COM-ORD-071'
  edge: covered
  failure: 'gap: FND-COM-ORD-071'
  boundary: covered
  concurrency: covered
  invariant: 'gap: FND-COM-ORD-071'
  interaction: covered
coverage_definition: Covered means a design scenario exists; executable coverage and execution results are separate.
permission_coverage:
  - key: commerce.cancellations.read
    where_checked: api
    scenarios:
      - ATS-COM-ORD-014-08
      - ATS-COM-ORD-014-10
    gap: FND-COM-ORD-071
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-071
  - key: commerce.cancellations.create
    where_checked: api
    scenarios:
      - ATS-COM-ORD-014-08
      - ATS-COM-ORD-014-10
    gap: FND-COM-ORD-071
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-071
  - key: commerce.cancellations.update
    where_checked: api
    scenarios:
      - ATS-COM-ORD-014-08
      - ATS-COM-ORD-014-10
    gap: FND-COM-ORD-071
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-071
  - key: commerce.cancellations.approve
    where_checked: api
    scenarios:
      - ATS-COM-ORD-014-08
      - ATS-COM-ORD-014-10
    gap: FND-COM-ORD-071
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-071
  - key: commerce.cancellations.override
    where_checked: service
    scenarios:
      - ATS-COM-ORD-014-08
      - ATS-COM-ORD-014-10
    gap: FND-COM-ORD-071
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-071
transition_coverage:
  - state_model: STATE-COM-ORD-004
    from: placed
    to: accepted
    trigger: 'Billing permits terms or no-payment acceptance, or successful payment covers the required amount.'
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#answers 200: the attempt
      succeeded with Accounting’s payment, the order accepted, the pro forma converted by that first money
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-004
    from: placed
    to: tender_uncertain
    trigger: Accounting cannot give a final payment result.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#answers uncertain, the order
      tender_uncertain, the attempt uncertain naming Accounting’s intent
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-004
    from: tender_uncertain
    to: accepted
    trigger: Recovery confirms enough captured payment to accept.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#accepts the order once
      Accounting holds the payment, with one charge and the payment on the attempt
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-004
    from: tender_uncertain
    to: placed
    trigger: Recovery ends without enough payment or finds no remaining open attempt.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/tender/tender-order.ts'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-004
    from: placed
    to: voided
    trigger: A staff void or elapsed-deadline pass ends the sale.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/checkout/tests/e2e/order-void.e2e.spec.js#answers 200 with the order voided,
      carrying the reason, its lines and the history
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-004
    from: accepted
    to: cancelled
    trigger: Completed cancellation leaves no item quantity standing.
    scenarios:
      - ATS-COM-ORD-014-03
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lists the order’s cancellations and
      reads one; cancelling the mug too closes the order cancelled (B5)
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-004
    from: accepted
    to: closed
    trigger: The lifecycle offers closure without a current producer.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/orders.ts:ORDER_TRANSITIONS'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-009
    from: requested
    to: evaluating
    trigger: The new request begins evaluation.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts:requestCancellation'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-009
    from: evaluating
    to: approved
    trigger: Evaluation permits the plan without a person.
    scenarios:
      - ATS-COM-ORD-014-02
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#answers 200 with the document
      completed in the one request: allowed, executed, the money moved, the customer status cancelled
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-009
    from: evaluating
    to: awaiting_approval
    trigger: Seller advice or the refund threshold requires a staff decision.
    scenarios:
      - ATS-COM-ORD-014-07
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s request for approval
      (participant_requires_approval) and refuses a second request on the line 409 line_already_cancelling
      (B38)
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-009
    from: evaluating
    to: rejected
    trigger: Evaluation denies every affected line.
    scenarios:
      - ATS-COM-ORD-014-08
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#rejects the member’s request with
      after_cancellation_deadline, the customer status declined; nothing moved on the order
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-009
    from: awaiting_approval
    to: approved
    trigger: An approver records permission to proceed and an explanation.
    scenarios:
      - ATS-COM-ORD-014-07
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the approver approve it with a
      reason, and staff execute it; the intervention on the history
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-009
    from: awaiting_approval
    to: rejected
    trigger: An approver records refusal and an explanation.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/aws/api/post-purchase.routes.ts:rejectCancellation'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-009
    from: approved
    to: executing
    trigger: The caller requests immediate or later execution.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts:executeCancellation'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-009
    from: approved
    to: prepared
    trigger: Execution encounters an application or shipping fence conflict.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-009
    from: approved
    to: withdrawn
    trigger: The requester ends the approved plan before execution.
    scenarios:
      - ATS-COM-ORD-014-13
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#lets the member withdraw an
      approved, unexecuted request (a second request refused meanwhile), then request again
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-009
    from: executing
    to: completed
    trigger: Settlement observes completed reversal and financial work.
    scenarios:
      - ATS-COM-ORD-014-04
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
      participant’s cancel, which settles the document completed and runs the refund after the domain (ADR-13)
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-009
    from: executing
    to: completed_with_exceptions
    trigger: Settlement observes a failed cancellation or financial step.
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellation'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
invariant_coverage:
  - invariant: INV-DOM-COM-ORD-002-01
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/orders.table.ts:orders_total_check, orders_amounts_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-02
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/checkout/tests/e2e/idempotency.e2e.spec.js#answers the stored status and body,
      marked Idempotent-Replayed, and runs the placement once: one order row;
      services-commerce:modules/orders/db/orders.table.ts:orders_checkout_uq
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-03
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/orders.table.ts:orders_number_uq, orders_number_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-04
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/orders.ts:ORDER_TRANSITIONS'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-05
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-lines.table.ts:order_lines_quantity_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-06
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/order-line-purchases.table.ts:order_line_purchases_write_once_trigger
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-07
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#resumes the same attempt on a
      retry, whatever card the retry names, and moves nothing while the intent is processing
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-08
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-invoices.table.ts:order_invoices_idempotency_key_uq'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-09
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-events.table.ts'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-10
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-lines.table.ts:order_lines_order_fk'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-11
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/orders.table.ts:orders_installment_schedule_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-12
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#never stores the card: the
      attempt keeps a reference of the merchant account and the token’s last four only
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-13
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/reservations.table.ts:reservations_subject_check;
      modules/orders/services/persistence/reservations.ts:RESERVATION_TRANSITIONS
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-01
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s request for approval
      (participant_requires_approval) and refuses a second request on the line 409 line_already_cancelling
      (B38); services-commerce:modules/orders/db/cancellation-lines.table.ts:cancellation_lines_active_uidx;
      services-commerce:modules/orders/db/amendment-lines.table.ts:amendment_lines_active_uidx;
      services-commerce:modules/orders/db/return-lines.table.ts:return_lines_active_uidx
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-02
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/cancellations.table.ts:cancellations_override_reason_check;
      modules/orders/db/amendments.table.ts:amendments_override_reason_check;
      modules/orders/db/returns.table.ts:returns_override_reason_check
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-03
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts:requestCancellation;
      services-commerce:modules/orders/services/amendments/amendment-workflow.ts:requestAmendment;
      services-commerce:modules/orders/services/returns/return-workflow.ts:requestReturn;
      services-commerce:modules/orders/services/amendments/promotion-amendment.ts
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-04
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/services/persistence/cancellations.ts:CANCELLATION_TRANSITIONS;
      modules/orders/services/persistence/amendments.ts:AMENDMENT_TRANSITIONS;
      modules/orders/services/persistence/returns.ts:RETURN_TRANSITIONS
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-05
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#credits no more than the invoice
      line still owes, so Accounting does not refuse the memo as an over-application
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-06
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/return-policies.table.ts:return_policies_scope_uq,
      return_policies_scope_check
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-07
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/db/return-authorizations.table.ts:return_authorizations_open_uidx'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-08
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/services/returns/return-workflow.ts;
      services-commerce:modules/orders/services/persistence/returns.ts:recordReturnEvaluation
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-09
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
      participant’s cancel, which settles the document completed and runs the refund after the domain (ADR-13)
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-10
    scenarios: []
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/cancellations.ts'
    note: Broader invariant coverage remains open beyond the concrete examples.
workflow_coverage:
  - workflow: WF-COM-ORD-007
    scenarios:
      - ATS-COM-ORD-009-09
    gap: FND-COM-ORD-071
    provenance: proposed
    source:
      - 'services-commerce:modules/orders/tests/e2e/installments.e2e.spec.js'
      - 'services-commerce:modules/orders/services/placement/place-order.ts:installmentsOfPlacement'
      - 'services-commerce:modules/orders/tests/e2e/installments.e2e.spec.js'
      - >-
        services-commerce:modules/orders/services/installments/installment-schedule.ts:ensureInstallmentSchedule
      - >-
        services-commerce:modules/orders/services/installments/installment-schedule.ts:readOrderInstallmentSchedule
      - 'services-commerce:modules/orders/services/installments/installment-tender.ts'
      - 'services-commerce:modules/orders/services/installments/installment-cancellation.ts'
  - workflow: WF-COM-ORD-008
    scenarios:
      - ATS-COM-ORD-010-12
    gap: FND-COM-ORD-071
    provenance: proposed
    source:
      - 'services-commerce:modules/orders/services/mirror/refresh-money-mirror.ts:refreshMoneyMirrorOf'
      - >-
        services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#mirrors Accounting’s
        position: invoiced and paid in full, nothing due
      - 'services-commerce:modules/orders/services/mirror/refresh-money-mirror.ts'
      - 'services-commerce:modules/fulfillment/services/facts/financial-facts-handler.ts'
      - 'services-commerce:modules/orders/services/orders/financial-sweeps.ts:sweepFinancials'
  - workflow: WF-COM-ORD-009
    scenarios:
      - ATS-COM-ORD-013-15
    gap: FND-COM-ORD-071
    provenance: proposed
    source:
      - 'services-commerce:modules/entitlements/services/register/grant-handler.ts'
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to
        the register: completed, with the grant as its record
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and
        refuses the third 409 insufficient_entitlement
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
        intervention: the log row, the history, the audit event), replays under the same key, refuses the same
        use under another
      - 'services-commerce:modules/fulfillment/services/register/intervention-audit.ts'
      - 'services-commerce:modules/entitlements/services/register/revocation.ts'
      - 'services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts'
  - workflow: WF-COM-ORD-010
    scenarios:
      - ATS-COM-ORD-014-19
    gap: FND-COM-ORD-071
    provenance: proposed
    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
      - >-
        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
      - >-
        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
      - 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts'
      - >-
        services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellationAfterObligation
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee invoice, applies
        the freed money to it and refunds the remainder
      - >-
        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
interaction_coverage:
  - with: CAP-COM-ORD-009
    scenarios:
      - ATS-COM-ORD-014-16
  - with: CAP-COM-ORD-013
    scenarios:
      - ATS-COM-ORD-014-17
  - with: CAP-COM-ORD-016
    scenarios:
      - ATS-COM-ORD-014-18
unproved_rules:
  - rule: BR-CAP-COM-ORD-014-14
    gap: FND-COM-ORD-071
    provenance: unknown
    source: 'services-commerce:docs/milestones/COMM-M1-set-up-what-you-sell.md#D13'
---

# Cancel accepted purchases and settle the result: Capability Test Specification

## Coverage

| Rule | Scenario or finding |
|---|---|
| `BR-CAP-COM-ORD-014-01` | `ATS-COM-ORD-014-01`, `ATS-COM-ORD-014-19` |
| `BR-CAP-COM-ORD-014-02` | `ATS-COM-ORD-014-02` |
| `BR-CAP-COM-ORD-014-03` | `ATS-COM-ORD-014-03` |
| `BR-CAP-COM-ORD-014-04` | `ATS-COM-ORD-014-04`, `ATS-COM-ORD-014-17` |
| `BR-CAP-COM-ORD-014-05` | `ATS-COM-ORD-014-05` |
| `BR-CAP-COM-ORD-014-06` | `ATS-COM-ORD-014-06` |
| `BR-CAP-COM-ORD-014-07` | `ATS-COM-ORD-014-07` |
| `BR-CAP-COM-ORD-014-08` | `ATS-COM-ORD-014-08` |
| `BR-CAP-COM-ORD-014-09` | `ATS-COM-ORD-014-09`, `ATS-COM-ORD-014-18` |
| `BR-CAP-COM-ORD-014-10` | `ATS-COM-ORD-014-10` |
| `BR-CAP-COM-ORD-014-11` | `ATS-COM-ORD-014-13` |
| `BR-CAP-COM-ORD-014-12` | `ATS-COM-ORD-014-14` |
| `BR-CAP-COM-ORD-014-13` | `ATS-COM-ORD-014-15`, `ATS-COM-ORD-014-16` |
| `BR-CAP-COM-ORD-014-14` | no scenario: `FND-COM-ORD-071` |
| `BR-CAP-COM-ORD-014-15` | `ATS-COM-ORD-014-12` |

## Interactions With Related Capabilities

Plan cancellation updates both future collection and current money. A deposit sale has a paid installment and future unpaid shares. Cancel one line and inspect the schedule and order money.

Cancellation revokes the purchased right without removing use history. A completed purchased grant has one recorded use. Cancel its line and retry the buyer’s download.

Carrier handoff redirects the buyer to a return. The purchased goods have been handed to the carrier and are within their return window. Request cancellation, then request a return.

Crossing workflow examples also cover preparation, commitment and recovery at their service handoffs. Their structured bindings distinguish specified outcomes from executable evidence.
