---
id: ATS-ACC-BAT-006
scope: CAP-ACC-BAT-006
product_area: accounting
module: batches
revision: 2
status: proposed
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
  rhythm-v2-docs: 37405d50d1465ea0571a66095d98ebec4db04175
scenarios:
  - id: ATS-ACC-BAT-006-01
    title: Deletion needs its own permission
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-01
    preconditions: >-
      An empty Open batch is visible to a caller with read and update access
      only.
    steps: Request deletion as that caller.
    expected: The request returns 403 and preserves the record.
    negative: true
    data_needs: Provide a principal without accounting.batches.delete.
    bound_to: []
    provenance: proposed
    source: >-
      services-accounting:modules/batches/aws/api/batch-records.routes.ts:deleteBatch
    category: permission
    test_evidence: []
  - id: ATS-ACC-BAT-006-02
    title: Only eligible empty batches disappear
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-02
      - BR-CAP-ACC-BAT-006-07
    preconditions: An empty Open batch and a Posted batch exist.
    steps: Delete each batch.
    expected: The empty record subsequently returns 404; the Posted record returns 409.
    negative: true
    data_needs: Provide a posted batch.
    bound_to:
      - TST-ACC-BAT-060
      - TST-ACC-BAT-085
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#refuses
      deleting a posted batch
    category: transition
    test_evidence:
      - >-
        services-accounting:modules/batches/tests/e2e/batches.e2e.spec.js#deletes
        it, and then reads it 404
      - >-
        services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#refuses
        deleting a posted batch
  - id: ATS-ACC-BAT-006-03
    title: References explain deletion refusal
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-03
      - INV-DOM-ACC-BAT-001-06
    preconditions: >-
      Separate Open batches are referenced by an invoice, payment, credit or
      posting.
    steps: Delete each referenced batch.
    expected: >-
      Each 409 names the batch and the referencing record kind rather than
      producing a server failure.
    negative: true
    data_needs: Provide one document of each kind.
    bound_to:
      - TST-ACC-BAT-085
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#answers
      409 naming the batch for every table whose restrict foreign key names a
      batch, never a 500 (DEF-ACT-0012)
    category: failure
    test_evidence:
      - >-
        services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#answers
        409 naming the batch for every table whose restrict foreign key names a
        batch, never a 500 (DEF-ACT-0012)
  - id: ATS-ACC-BAT-006-04
    title: Delete locks preserve the batch
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-04
    preconditions: An empty batch carries a deletion lock.
    steps: Request deletion.
    expected: A locked-record conflict returns 409.
    negative: true
    data_needs: Provide no fixtures beyond the stated setup.
    bound_to: []
    provenance: proposed
    source: >-
      services-accounting:modules/batches/services/persistence/batches.ts:deleteBatch
    category: rule
    test_evidence: []
  - id: ATS-ACC-BAT-006-05
    title: System records cannot be deleted manually
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-05
    preconditions: The selected batch is deferred revenue.
    steps: Request ordinary deletion.
    expected: A system-batch 409 preserves the record.
    negative: true
    data_needs: Provide a fiscal close's system batch.
    bound_to:
      - TST-ACC-BAT-063
      - TST-ACC-BAT-074
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/e2e/system-batches.e2e.spec.js#refuses
      DELETE 409 system_batch, the batch still there
    category: edge
    test_evidence:
      - >-
        services-accounting:modules/batches/tests/e2e/system-batches.e2e.spec.js#refuses
        DELETE 409 system_batch, the batch still there
      - >-
        services-accounting:modules/batches/tests/integration/services/close/system-batch-guard.integration.spec.js#refuses
        delete 409 system_batch, the batch unchanged
  - id: ATS-ACC-BAT-006-06
    title: Removing the current batch clears its recurring pointer
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-06
    preconditions: A recurring configuration points to an empty active batch.
    steps: Delete that batch and reread the configuration.
    expected: Deletion succeeds and the configuration has no active-batch reference.
    negative: false
    data_needs: Provide a recurring batch.
    bound_to:
      - TST-ACC-BAT-085
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
      the batch a recurring batch names as its active batch and clears the
      reference (DEF-ACT-0012)
    category: interaction
    test_evidence:
      - >-
        services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
        the batch a recurring batch names as its active batch and clears the
        reference (DEF-ACT-0012)
  - id: ATS-ACC-BAT-006-07
    title: Deletion resolves posting attention
    category: interaction
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-07
      - BR-CAP-ACC-BAT-008-04
    exercises:
      - CAP-ACC-BAT-006
      - CAP-ACC-BAT-008
    workflows:
      - WF-ACC-BAT-001
    preconditions: Attention publication is enabled for an unused Closed batch.
    steps: Delete the batch and inspect its formerly open attention item.
    expected: The batch is absent and its waiting item is resolved.
    negative: false
    data_needs: >-
      An isolated workspace with the stated business-unit calendar, documents
      and configuration.
    bound_to: []
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
      an empty batch with its automatic close’s schedule;
      services-accounting:modules/batches/tests/integration/services/persistence/batch-attention-items.integration.spec.js#resolves
      a reopened batch reopened, and its next close opens the second generation
  - id: ATS-ACC-BAT-006-08
    title: Deleting unused intake clears the stream
    category: interaction
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-06
      - BR-CAP-ACC-BAT-009-06
    exercises:
      - CAP-ACC-BAT-006
      - CAP-ACC-BAT-009
    workflows: []
    preconditions: A stream points to an unused Open batch.
    steps: 'Delete the batch, read the stream and deliver its next roll.'
    expected: >-
      The first read has no active reference; the roll supplies a new Open
      intake batch.
    negative: false
    data_needs: >-
      An isolated workspace with the stated business-unit calendar, documents
      and configuration.
    bound_to: []
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
      the batch a recurring batch names as its active batch and clears the
      reference (DEF-ACT-0012);
      services-accounting:modules/batches/tests/integration/services/roll/batch-roller.integration.spec.js#saves
      a recurring batch whose first batch is refused, with the refusal and no
      batch
  - id: ATS-ACC-BAT-006-09
    title: Posting prevents ordinary deletion
    category: interaction
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-02
      - BR-CAP-ACC-BAT-013-03
    exercises:
      - CAP-ACC-BAT-006
      - CAP-ACC-BAT-013
    workflows: []
    preconditions: Morning contains one eligible invoice.
    steps: 'Post Morning, then attempt deletion and reread its posting and entry.'
    expected: Deletion returns 409 and the Posted batch and its current entry remain.
    negative: true
    data_needs: >-
      An isolated workspace with the stated business-unit calendar, documents
      and configuration.
    bound_to: []
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#refuses
      deleting a posted batch;
      services-accounting:modules/batches/tests/e2e/batch-postings.e2e.spec.js#posts
      a batch as a durable job: the answer is the job, and the job posts the
      batch
  - id: ATS-ACC-BAT-006-10
    title: Unused removal clears scheduling and attention
    category: invariant
    level: api
    proves:
      - BR-CAP-ACC-BAT-006-07
    preconditions: >-
      Attention is enabled for an unused Closed batch whose setup records its
      former close schedule.
    steps: >-
      Delete the batch and inspect the schedule and the outstanding attention
      item.
    expected: >-
      The collection and any owned close schedule are absent and its open
      attention item is resolved.
    negative: false
    data_needs: >-
      Owned records in an isolated workspace with the stated calendar and
      accounting setup.
    bound_to: []
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
      an empty batch with its automatic close’s schedule
evidence:
  - services-accounting at f47cb263: 'Inspected references: scenario-bound tests in modules/batches/tests.'
  - >-
    Pinned design objects, state models and workflows identify invariant and
    interaction obligations; scenario test anchors remain in test_evidence.
product_intent: proposed
coverage:
  rule: covered
  transition: 'gap: FND-ACC-BAT-060'
  validation: 'gap: FND-ACC-BAT-060'
  permission: 'gap: FND-ACC-BAT-060'
  edge: covered
  failure: covered
  boundary: 'gap: FND-ACC-BAT-060'
  concurrency: 'gap: FND-ACC-BAT-060'
  invariant: covered
  interaction: covered
coverage_notes:
  validation: >-
    Deletion from every eligible stored state, deletion racing with intake or
    posting, attention cleanup and malformed-reference handling need focused
    proof.
  boundary: >-
    Deletion from every eligible stored state, deletion racing with intake or
    posting, attention cleanup and malformed-reference handling need focused
    proof.
  concurrency: >-
    Deletion from every eligible stored state, deletion racing with intake or
    posting, attention cleanup and malformed-reference handling need focused
    proof.
  invariant: >-
    Deletion from every eligible stored state, deletion racing with intake or
    posting, attention cleanup and malformed-reference handling need focused
    proof.
rule_coverage:
  - rule: BR-CAP-ACC-BAT-006-01
    scenarios:
      - ATS-ACC-BAT-006-01
    provenance: proposed
    source: >-
      services-accounting:modules/batches/aws/api/batch-records.routes.ts:deleteBatch
  - rule: BR-CAP-ACC-BAT-006-02
    scenarios:
      - ATS-ACC-BAT-006-02
      - ATS-ACC-BAT-006-09
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#refuses
      deleting a posted batch
  - rule: BR-CAP-ACC-BAT-006-03
    scenarios:
      - ATS-ACC-BAT-006-03
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#answers
      409 naming the batch for every table whose restrict foreign key names a
      batch, never a 500 (DEF-ACT-0012)
  - rule: BR-CAP-ACC-BAT-006-04
    scenarios:
      - ATS-ACC-BAT-006-04
    provenance: proposed
    source: >-
      services-accounting:modules/batches/services/persistence/batches.ts:deleteBatch
  - rule: BR-CAP-ACC-BAT-006-05
    scenarios:
      - ATS-ACC-BAT-006-05
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/e2e/system-batches.e2e.spec.js#refuses
      DELETE 409 system_batch, the batch still there
  - rule: BR-CAP-ACC-BAT-006-06
    scenarios:
      - ATS-ACC-BAT-006-06
      - ATS-ACC-BAT-006-08
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
      the batch a recurring batch names as its active batch and clears the
      reference (DEF-ACT-0012)
  - rule: BR-CAP-ACC-BAT-006-07
    scenarios:
      - ATS-ACC-BAT-006-02
      - ATS-ACC-BAT-006-07
      - ATS-ACC-BAT-006-10
    provenance: proposed
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
      an empty batch with its automatic close’s schedule
transition_coverage:
  - state_model: STATE-ACC-BAT-001
    transition: 18
    from: open
    to: deleted
    gap: FND-ACC-BAT-060
    provenance: unknown
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#deletes
      the batch a recurring batch names as its active batch and clears the
      reference (DEF-ACT-0012)
    note: >-
      The existing scenario set is not an exhaustive proof of this transition
      and all its side effects.
  - state_model: STATE-ACC-BAT-001
    transition: 19
    from: closed
    to: deleted
    gap: FND-ACC-BAT-060
    provenance: unknown
    source: >-
      services-accounting:modules/batches/services/rules/batch-rules.ts:assertBatchCanBeDeleted
    note: >-
      The existing scenario set is not an exhaustive proof of this transition
      and all its side effects.
  - state_model: STATE-ACC-BAT-001
    transition: 20
    from: verified
    to: deleted
    gap: FND-ACC-BAT-060
    provenance: unknown
    source: >-
      services-accounting:modules/batches/services/persistence/batches.ts:deleteBatch;
      services-accounting:modules/batches/services/rules/batch-rules.ts:assertBatchCanBeDeleted
    note: >-
      The existing scenario set is not an exhaustive proof of this transition
      and all its side effects.
  - state_model: STATE-ACC-BAT-001
    transition: 21
    from: error
    to: deleted
    gap: FND-ACC-BAT-060
    provenance: unknown
    source: >-
      services-accounting:modules/batches/services/persistence/batches.ts:deleteBatch;
      services-accounting:modules/batches/services/rules/batch-rules.ts:assertBatchCanBeDeleted
    note: >-
      The existing scenario set is not an exhaustive proof of this transition
      and all its side effects.
  - state_model: STATE-ACC-BAT-001
    transition: 22
    from: archived
    to: deleted
    gap: FND-ACC-BAT-060
    provenance: unknown
    source: >-
      services-accounting:modules/batches/services/persistence/batches.ts:deleteBatch;
      services-accounting:modules/batches/services/rules/batch-rules.ts:assertBatchCanBeDeleted
    note: >-
      The existing scenario set is not an exhaustive proof of this transition
      and all its side effects.
  - state_model: STATE-ACC-BAT-001
    transition: 23
    from: posting
    to: deleted
    gap: FND-ACC-BAT-060
    provenance: unknown
    source: >-
      services-accounting:modules/batches/services/persistence/batches.ts:deleteBatch;
      services-accounting:modules/batches/services/rules/batch-rules.ts:assertBatchCanBeDeleted
    note: >-
      The existing scenario set is not an exhaustive proof of this transition
      and all its side effects.
permission_coverage:
  - key: accounting.batches.delete
    surface: api
    scenarios:
      - ATS-ACC-BAT-006-01
    gap: FND-ACC-BAT-060
    provenance: unknown
    source: FND-ACC-BAT-060
    note: >-
      An aggregate persona check does not establish exhaustive allow and deny
      proof for every named surface.
executable_coverage:
  bound_scenarios: 4
  unbound_scenarios:
    - ATS-ACC-BAT-006-01
    - ATS-ACC-BAT-006-04
    - ATS-ACC-BAT-006-07
    - ATS-ACC-BAT-006-08
    - ATS-ACC-BAT-006-09
    - ATS-ACC-BAT-006-10
  gap: FND-ACC-BAT-060
---

# Remove an unused batch safely: Capability Test Specification

## Coverage

The scenarios define focused checks for this outcome. The coverage map distinguishes specified checks from unresolved proof; executable bindings identify inspected assertions and carry no execution result.

| Rule | Proof Specification or Gap |
|---|---|
| `BR-CAP-ACC-BAT-006-01` | `ATS-ACC-BAT-006-01` |
| `BR-CAP-ACC-BAT-006-02` | `ATS-ACC-BAT-006-02`, `ATS-ACC-BAT-006-09` |
| `BR-CAP-ACC-BAT-006-03` | `ATS-ACC-BAT-006-03` |
| `BR-CAP-ACC-BAT-006-04` | `ATS-ACC-BAT-006-04` |
| `BR-CAP-ACC-BAT-006-05` | `ATS-ACC-BAT-006-05` |
| `BR-CAP-ACC-BAT-006-06` | `ATS-ACC-BAT-006-06`, `ATS-ACC-BAT-006-08` |
| `BR-CAP-ACC-BAT-006-07` | `ATS-ACC-BAT-006-02`, `ATS-ACC-BAT-006-07`, `ATS-ACC-BAT-006-10` |

## Interactions With Related Capabilities

Deletion resolves posting attention. Deleting unused intake clears the stream. Posting prevents ordinary deletion. These checks use the related capability’s outcome as part of the setup or verification. Unbound interactions remain proposed until a suite executes the complete chain.
