---
id: CAP-ACC-BAT-011
title: Assign new documents to the appropriate batch stream
feature: FEAT-ACC-BAT-02
product_area: accounting
module: batches
revision: 1
status: draft
product_intent: proposed
implementation_evidence: observed
supersedes:
- inventory CAP-ACC-BAT-005
- inventory RUL-ACC-BAT-045
- inventory RUL-ACC-BAT-046
- inventory RUL-ACC-BAT-047
- journey ACT-ACC-0511
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
intent_sources:
- services-accounting:docs/milestones/ACCT-M1-books-and-invoices.md#D3
purpose: Administrators configure predictable default placement for transactions that do not name a batch.
outcomes:
- Default and ordered matching choices select recurring intake for applicable document facts.
concepts:
- CON-ACC-BAT-001
actors:
- ACT-ACC-006
- ACT-ACC-007
- ACT-ACC-013
surfaces:
- console
- api
permissions:
- key: accounting.batch-assignment-settings.read
  where_checked: api
  scope: tenant
- key: accounting.batch-assignment-settings.update
  where_checked: api
  scope: tenant
- key: accounting.batch-assignment-settings.delete
  where_checked: api
  scope: tenant
rules:
- id: BR-CAP-ACC-BAT-011-01
  proved_by: [ATS-ACC-BAT-011-01, TST-ACC-BAT-056, TST-ACC-BAT-080]
  statement: A unit has one assignment-settings record comprising a required default recurring configuration and
    no more than one hundred ordered rules.
  kind: validation
  enforced_at:
  - api
  - database
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batch-assignment-settings.e2e.spec.js#answers 400 to 101
    rules
  origin: none
- id: BR-CAP-ACC-BAT-011-02
  proved_by: [ATS-ACC-BAT-011-02]
  statement: Saving replaces settings and their entire ordered rule list atomically, assigning positions from one
    and preserving the previous list if replacement fails.
  kind: policy
  enforced_at:
  - service
  - database
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/integration/services/persistence/batch-assignment-settings.integration.spec.js#keeps
    the previous settings and rules after the database refused a rule the save had already replaced them with
  origin: services-accounting:docs/milestones/ACCT-M1-books-and-invoices.md#D3
- id: BR-CAP-ACC-BAT-011-03
  proved_by: [ATS-ACC-BAT-011-03, TST-ACC-BAT-056]
  statement: The first save creates settings, and later saves require the current version rather than a missing
    or stale version.
  kind: validation
  enforced_at:
  - service
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batch-assignment-settings.e2e.spec.js#answers 409 StaleObject
    to a save at the version first read
  origin: none
- id: BR-CAP-ACC-BAT-011-04
  proved_by: [ATS-ACC-BAT-011-04, TST-ACC-BAT-056, TST-ACC-BAT-080]
  statement: Referenced recurring configurations and merchant or bank accounts must belong to the settings’ unit,
    with invalid rule references identified.
  kind: validation
  enforced_at:
  - service
  - database
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batch-assignment-settings.e2e.spec.js#answers 400 to another
    unit’s recurring batch in a rule
  origin: none
- id: BR-CAP-ACC-BAT-011-05
  proved_by: [ATS-ACC-BAT-011-05, TST-ACC-BAT-056, TST-ACC-BAT-066, TST-ACC-BAT-126]
  statement: An assignment rule can select one merchant account or one bank account, but not both.
  kind: validation
  enforced_at:
  - api
  - database
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batch-assignment-settings.e2e.spec.js#answers 400 naming
    bank_account_id to a rule naming both a merchant and a bank account
  origin: none
- id: BR-CAP-ACC-BAT-011-06
  proved_by: [ATS-ACC-BAT-011-05, ATS-ACC-BAT-011-13, TST-ACC-BAT-056, TST-ACC-BAT-066, TST-ACC-BAT-126]
  statement: Transaction, payment and card criteria use the declared vocabulary without duplicates, and an omitted
    or empty criterion means unrestricted.
  kind: validation
  enforced_at:
  - api
  - database
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batch-assignment-settings.e2e.spec.js#answers 400 to a transaction
    type the vocabulary does not have
  origin: none
- id: BR-CAP-ACC-BAT-011-07
  proved_by: [ATS-ACC-BAT-011-06, TST-ACC-BAT-126]
  statement: Selection uses the first rule in position order matching every supplied criterion, including the exact
    bank account, and otherwise returns the default.
  kind: calculation
  enforced_at:
  - service
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/unit/rules/batch-assignment-rules.spec.js#answers the first
    matching rule by position, whatever order the rules are listed in
  origin: none
- id: BR-CAP-ACC-BAT-011-08
  proved_by: [ATS-ACC-BAT-011-06, TST-ACC-BAT-126]
  statement: A transaction lacking a fact matches only an unrestricted criterion for that fact, while the contract
    delegates companion-payment and order facts to the caller.
  kind: calculation
  enforced_at:
  - service
  must_prove: true
  provenance: documented
  source: services-accounting:modules/batches/services/rules/batch-assignment-rules.ts (assignment contract in file
    header)
  origin: none
- id: BR-CAP-ACC-BAT-011-09
  proved_by: [ATS-ACC-BAT-007-09, ATS-ACC-BAT-011-07, ATS-ACC-BAT-011-11, TST-ACC-BAT-004, TST-ACC-BAT-074]
  statement: The selected recurring configuration supplies an accepting active batch, and missing settings, a missing
    active batch or refused intake prevents default assignment even though inactive configuration can still supply
    an Open batch.
  kind: policy
  enforced_at:
  - service
  must_prove: true
  provenance: test
  source: react-console:acceptance/accounting/playwright/journeys/batches-posting/ACT-ACC-0510.spec.ts#ACT-ACC-0510
  origin: none
- id: BR-CAP-ACC-BAT-011-10
  proved_by: [ATS-ACC-BAT-011-08, TST-ACC-BAT-056]
  statement: Evaluation accepts transaction facts and returns the selected recurring configuration and matching
    position, or no position for the default, without writing a transaction.
  kind: calculation
  enforced_at:
  - api
  - service
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batch-assignment-settings.e2e.spec.js#answers the first
    rule by position when two rules match
  origin: none
- id: BR-CAP-ACC-BAT-011-11
  proved_by: [ATS-ACC-BAT-009-15, ATS-ACC-BAT-011-09, ATS-ACC-BAT-011-12, TST-ACC-BAT-056, TST-ACC-BAT-059]
  statement: Read permission covers settings and evaluation, update covers save and delete covers removal, which
    also removes owned rules and releases their recurring references.
  kind: permission
  enforced_at:
  - api
  - console
  must_prove: true
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batches-security.e2e.spec.js#is refused the save 403 permission_missing
  origin: none
- id: BR-CAP-ACC-BAT-011-12
  proved_by: [ATS-ACC-BAT-011-10]
  statement: Default selection returns no batch for pro forma work and prefers a referenced Open order batch before
    consulting assignment rules.
  kind: policy
  enforced_at:
  - service
  must_prove: true
  provenance: observed
  source: services-accounting:modules/batches/services/rules/batch-rules.ts:defaultBatchOf
  origin: none
scenarios:
- id: SC-CAP-ACC-BAT-011-01
  given: Checks use the default stream and the first rule selects the card merchant’s stream.
  when: A card payment and a check arrive without batches.
  then: Each document takes the accepting active batch chosen by its matching rule or default.
  provenance: test
  source: react-console:acceptance/accounting/playwright/journeys/batches-posting/ACT-ACC-0510.spec.ts#ACT-ACC-0510
- id: SC-CAP-ACC-BAT-011-02
  given: An assignment rule specifies the operating bank account.
  when: An administrator evaluates a payment using a different bank account.
  then: Selection uses the default rather than matching the different bank.
  provenance: test
  source: services-accounting:modules/batches/tests/e2e/batch-assignment-settings.e2e.spec.js#REGRESSION — answers
    the default, not the bank account rule, for a payment into another bank account (legacy problem B)
edge_cases: []
constraints:
- Transaction callers supply assignment facts and retain ownership of their documents.
depends_on:
- CAP-ACC-BAT-009
related:
- CAP-ACC-BAT-007
journeys:
- JNY-ACC-BAT-003
open_questions: []
evidence:
- 'Pinned services-accounting (f47cb263), examined sources: aws/api/batch-assignment-settings.routes.ts (getBatchAssignmentSettings,
  saveBatchAssignmentSettings, deleteBatchAssignmentSettings, evaluateBatchAssignment), batch-assignment-settings.schemas.ts,
  services/persistence/batch-assignment-settings.ts, services/rules/batch-assignment-rules.ts, services/assignment/default-batch.ts,
  db/batch-assignment-settings.table.ts, batch-assignment-rules.table.ts, batch-assignment-vocabularies.ts; tests
  e2e/batch-assignment-settings.e2e.spec.js, e2e/batches-security.e2e.spec.js, integration/services/persistence/batch-assignment-settings*.integration.spec.js,
  integration/db/batches.table.integration.spec.js, unit/rules/batch-assignment-rules.spec.js; docs/accounting/recurring-batches.md
  ("The assignment contract").'
- 'Pinned react-console (baf6dae3), examined sources: components/configuration/batch-assignment/** (page, rule dialog,
  rules table, test transaction panel); journeys ACT-ACC-0510, 0511, 0512.'
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-CRY-001, TC-DAT-001, TC-DAT-004, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-PI-001, TC-PI-003]
exercised_by: [FAS-ACC-BAT-02-01, FAS-ACC-BAT-02-02, FAS-ACC-BAT-02-03, FAS-ACC-BAT-02-04, FAS-ACC-BAT-02-05]
suites: [TST-ACC-BAT-004, TST-ACC-BAT-056, TST-ACC-BAT-059, TST-ACC-BAT-066, TST-ACC-BAT-074, TST-ACC-BAT-080, TST-ACC-BAT-126]
---

# Assign new documents to the appropriate batch stream

## Purpose

Administrators configure predictable default placement for transactions that do not name a batch.

## How It Works

An administrator opens a unit’s Batch Assignment settings. They choose a default stream and put more specific rules in priority order. Testing sample facts shows which rule wins without creating a document. Transaction callers gather those facts and ask for placement when no batch is supplied. The selected stream must provide a batch that accepts the document. Missing settings or an unavailable active batch produces a refusal that the caller must resolve.

## Relationships

- Prerequisite: Configure recurring batch streams, which addresses the connected batch work.
- Related outcome: Place documents in eligible batches and protect posted work, which addresses the connected batch work.
