---
id: WF-ACC-BAT-010
title: Assign a new document to a batch
trigger: Document creation requests a default collection because none was supplied.
product_area: accounting
module: batches
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
implements:
  - CAP-ACC-BAT-011
  - CAP-ACC-BAT-007
crosses:
  - SVC-ACC-BAT-batches
idempotency: >-
  Selection has no writes; Transactions owns idempotency of the subsequent
  document mutation.
concurrency: >-
  Selection runs in the document caller transaction. Database batch-movement
  protection refuses conflicting posted intake, but this read is not a general
  reservation of an Open collection.
hops:
  - 'n': 1
    actor_or_service: Transactions
    action: >-
      Return no collection for pro forma work. A carried order hook can prefer
      an Open order collection, but the native binding omits that reader and
      uses routing.
    anchor: >-
      services-accounting:modules/batches/services/assignment/default-batch.ts:defaultBatchFor
    seam: sync
    on_failure: >-
      No selection may be returned; the document caller decides whether it is
      required.
    left_inconsistent: Selection itself changes no record.
    observer: The document caller
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/assignment/default-batch.ts:defaultBatchFor
  - 'n': 2
    actor_or_service: Batch assignment rules
    action: >-
      Evaluate saved routing in priority order and use the fallback stream when
      no criteria match.
    anchor: >-
      services-accounting:modules/batches/services/rules/batch-assignment-rules.ts:chooseRecurringBatch
    seam: sync
    on_failure: Missing settings return no chosen stream for the caller to handle.
    left_inconsistent: Selection itself changes no record.
    observer: The document caller
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/batches-for-documents.ts
      (chooseRecurringBatch)
  - 'n': 3
    actor_or_service: Default batch
    action: >-
      Read the selected stream intake pointer and apply transaction-batch,
      business-unit and Open-or-Error intake checks.
    anchor: >-
      services-accounting:modules/batches/services/assignment/default-batch.ts:activeBatchForAssignment
    seam: sync
    on_failure: Missing intake or invalid eligibility returns the applicable refusal.
    left_inconsistent: The document mutation does not proceed through successful selection.
    observer: The document caller
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/assignment/default-batch.ts:activeBatchForAssignment
branches:
  - >-
    Deactivation stops stream rolling but does not automatically disable its
    retained eligible intake collection.
waits: []
evidence:
  - >-
    services-accounting at f47cb263:
    modules/batches/services/assignment/default-batch.ts;
    services/rules/batch-assignment-rules.ts, batch-rules.ts;
    modules/transactions/services/batches-for-documents.ts;
    docs/accounting/recurring-batches.md#The assignment contract
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, 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-DAT-001, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-005]
---

# Assign a new document to a batch

## What It Does

Default selection connects document creation to saved business-unit routing. It chooses a stream and validates that stream current collection before Transactions writes the document. Pro forma work and an absent default require caller-specific handling.

## The Flow

```mermaid
flowchart LR
  D[New document facts] --> R[Saved routing evaluation]
  R --> S[Chosen stream]
  S --> B[Read current collection]
  B --> V[Intake eligibility]
  V --> T[Return to document caller]
```

## When Something Fails

Selection can return no choice or an eligibility refusal without writing anything. The document caller owns the final required-batch response. The unused native order hook is documented as a carried option rather than a built Commerce integration.

## Open Design Questions

Transactions must supply complete companion facts and define absent-selection behavior for each document kind.
