---
id: WF-ACC-CLS-004
title: Cancel a queued or failed close or reopen
trigger: >-
  A controller confirms cancellation of failed work, or an authorized client
  cancels a queued or failed request.
product_area: accounting
module: close
revision: 1
status: draft
design_intent: proposed
implementation_evidence: inconsistent
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-ACC-CLS-012
moves:
  - STATE-ACC-CLS-001
  - STATE-ACC-CLS-002
crosses:
  - SVC-ACC-CLS-fiscal-close
idempotency: >-
  Cancellation uses run state rather than a command key. A second request
  encounters the final cancelled state and is refused without another state
  restoration.
concurrency: >-
  Cancellation takes the period lock and refreshes the run, then rejects running
  work. A cancelled queued job later refuses execution; its finished run should
  remain unchanged. Failure handling’s earlier read still needs race
  verification.
hops:
  - 'n': 1
    actor_or_service: Console run page
    action: >-
      On a failed run, ask for cancellation confirmation and send it; the
      displayed text currently promises reversal of completed steps.
    anchor: >-
      react-console:components/accounting/close/close-run-view.tsx:CancelCloseDialog
    seam: sync
    on_failure: The dialog retains and displays the refusal.
    left_inconsistent: Opening or submitting the dialog does not itself change the books.
    observer: The controller sees the confirmation and error.
    provenance: observed
    source: >-
      react-console:components/accounting/close/close-run-view.tsx:CancelCloseDialog
  - 'n': 2
    actor_or_service: Cancel route (reconciliation function)
    action: Require read access and then the close or reopen grant matching the run.
    anchor: >-
      services-accounting:modules/fiscal-close/aws/api/fiscal-close.routes.ts:fiscalCloseRoutes
    seam: sync
    on_failure: Missing action authority returns a refusal.
    left_inconsistent: The run remains unchanged.
    observer: The client receives the permission error.
    provenance: test
    source: >-
      services-accounting:modules/fiscal-close/tests/integration/services/jobs/close-job.integration.spec.js#refuses
      a cancel to a caller without the close permission
  - 'n': 3
    actor_or_service: Cancel action (one transaction)
    action: >-
      Lock and refresh the run, reject running or final outcomes, restore an
      eligible retained month’s earlier state, then cancel and record its actor
      in one transaction.
    anchor: >-
      services-accounting:modules/fiscal-close/services/jobs/close-run-actions.ts:cancelCloseRun
    seam: sync
    on_failure: >-
      Completed recognition or reversal prevents state restoration and returns
      guidance to retry.
    left_inconsistent: >-
      A refused request preserves any protected month and committed financial
      work.
    observer: The response and committed cancellation event identify the result.
    provenance: test
    source: >-
      services-accounting:modules/fiscal-close/tests/integration/services/jobs/close-job.integration.spec.js#refuses
      the cancel as run-not-cancellable, naming the way out
evidence:
  - >-
    services-accounting at f47cb263:
    modules/fiscal-close/services/jobs/close-run-actions.ts:cancelCloseRun;
    services/ports/revenue-recognition-port.ts (reversal only in closed or
    reopening months); modules/batches/services/posting-period-guard.ts.
  - 'react-console at baf6dae3: components/accounting/close/close-run-view.tsx.'
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-DAT-001, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-AVL-001, 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]
---

# Cancel a queued or failed close or reopen

## What It Does

Cancellation ends eligible waiting or failed requests. It releases a retained close or restores a retained reopen’s previous closed attribution. It cannot reverse a close’s posted revenue or a reopen’s completed reversal.

## The Flow

```mermaid
sequenceDiagram
  actor Staff
  participant API as Recovery service
  Staff->>API: cancel waiting or stopped request
  API->>API: lock month and check eligibility
  alt revenue step completed
    API-->>Staff: refuse and explain recovery
  else eligible
    API->>API: restore period state and cancel run
    API->>API: record cancellation in same transaction
  end
```

## When Something Fails

The service rejects running work and final outcomes. It also refuses cancellation after the relevant revenue step completed. The domain cancellation and its history event commit together. Cancelling a queued run does not stop its job forcibly; later execution discovers the cancelled state and refuses to proceed.

## Open Design Questions

Product must choose the cancellation policy for committed recognition. Meanwhile the confirmation and cancelled outcome should describe the service’s actual state restoration. Customer export omits the job history containing the cancelling actor.
