---
id: DOM-ACC-BAT-001
title: Batch
realises: CON-ACC-BAT-001
product_area: accounting
module: batches
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
owned_by: SVC-ACC-BAT-batches
readable_by: []
lifecycle: STATE-ACC-BAT-001
custom_fields: none
identity: >-
  Each batch has a system identity scoped to its workspace. Generated identities
  begin with the business unit identity so document validation can identify
  their unit. People use the code, falling back to the name. Stream identities
  derive from configuration names; routing settings use the business unit
  identity.
attributes:
  - name: business unit
    kind: reference
    required: true
    computed: false
    notes: >-
      Creation fixes the owning ledger entity. Documents and ledger records
      reference that same business unit.
  - name: name
    kind: text
    required: true
    computed: false
    notes: A required readable label with uniqueness within the business unit.
  - name: code
    kind: text
    required: false
    computed: false
    notes: >-
      An optional readable number; rolling can render it from the stream code
      template.
  - name: description
    kind: text
    required: false
    computed: false
    notes: 'Optional explanatory text, generated automatically for rolled batches.'
  - name: accounting date
    kind: date
    required: true
    computed: false
    notes: >-
      The ordinary service derives fiscal placement from this date rather than
      accepting placement from the request.
  - name: fiscal year and period
    kind: computed
    required: true
    computed: true
    notes: >-
      Service-derived placement in the business unit calendar; creation and
      moves into a different period require an open destination.
  - name: type
    kind: enum
    required: true
    computed: false
    notes: >-
      Transaction is the ordinary default. Legacy is carried; deferred revenue
      and cost of goods sold are fiscal system types.
  - name: status
    kind: enum
    required: true
    computed: false
    notes: >-
      Lifecycle vocabulary retained by the record. Named commands, posting
      outcomes and fiscal work produce its changes.
  - name: currency
    kind: reference
    required: false
    computed: false
    notes: >-
      When omitted, validation fills the business unit base currency; a
      different currency is rejected.
  - name: automatic close time
    kind: date
    required: false
    computed: false
    notes: >-
      An offset-bearing close instant or date-only local midnight. Ordinary
      persistence keeps it only for Open batches; direct posting bypasses that
      cleanup and can retain the value.
  - name: automatic close schedule
    kind: reference
    required: false
    computed: true
    notes: >-
      An internally managed single-occurrence schedule, linked by persistence
      rather than supplied by callers.
  - name: posting errors
    kind: collection
    required: true
    computed: true
    notes: >-
      Failures associated with documents from the latest posting attempt;
      reopening and a new attempt remove prior errors.
  - name: posting statistics
    kind: computed
    required: false
    computed: true
    notes: >-
      Persisted generation counts and base amounts, separate from current
      document totals.
  - name: live totals
    kind: computed
    required: false
    computed: true
    notes: >-
      Read-time aggregation of document counts, document amounts, payments,
      refunds and net cash; it is not persisted.
  - name: posted at
    kind: date
    required: false
    computed: true
    notes: 'The current generation timestamp, absent after that posting is taken back.'
  - name: dependents
    kind: collection
    required: false
    computed: true
    notes: >-
      A bounded list of up to one hundred batch dependencies retained by posting
      and removed by unposting.
  - name: last posting job
    kind: reference
    required: false
    computed: true
    notes: >-
      An optional, nonrestrictive link to the latest posting or unposting job,
      whose lifetime can be shorter than the batch.
  - name: originating recurring stream and occurrence
    kind: reference
    required: false
    computed: true
    notes: >-
      Immutable stream and occurrence references used to identify a repeated
      roll delivery.
  - name: protection lock
    kind: enum
    required: false
    computed: false
    notes: >-
      A deletion-only lock or a combined edit-and-delete lock. Unlocking
      requires a request containing only that change.
  - name: version and modification facts
    kind: computed
    required: true
    computed: true
    notes: 'System-managed version, creation facts and most recent modification facts.'
  - name: recurring stream · definition
    kind: collection
    required: false
    computed: false
    notes: >-
      Stream configuration is stored separately: unit, templates, description,
      activity and a linked inline schedule. Unit and schedule identity remain
      fixed; roll frequency is bounded to one per day.
  - name: recurring stream · current intake batch
    kind: reference
    required: false
    computed: true
    notes: >-
      The intake pointer maintained by first-batch creation and rolling;
      deleting its batch clears the pointer.
  - name: recurring stream · schedule facts
    kind: computed
    required: false
    computed: true
    notes: >-
      Schedule-derived next occurrence, human description, latest run and pause
      reason. First-batch refusal exists only in the saving response and is not
      persisted.
  - name: recurring stream · run history
    kind: collection
    required: false
    computed: true
    notes: >-
      The scheduler retains occurrence plans, outcomes, predecessor disposition
      and posting job or refusal.
  - name: routing settings · default stream and rules
    kind: collection
    required: false
    computed: false
    notes: >-
      Business-unit routing configuration holds a required fallback stream and
      at most one hundred priority-ordered rules. Criteria include document,
      payment and card kinds and a merchant or bank account.
relationships:
  - to: DOM-ACC-BAT-003
    cardinality: one-to-many
    ownership: >-
      The batch is the parent of its posting history, with at most one current
      generation.
    cross_service: false
  - to: DOM-ACC-BAT-004
    cardinality: one-to-many
    ownership: >-
      Ledger entries are owned by postings and reference the batch for fiscal
      placement.
    cross_service: false
  - to: DOM-ACC-BAT-005
    cardinality: one-to-many
    ownership: >-
      Revenue plans are posting children reached through the batch posting
      history.
    cross_service: false
invariants:
  - id: INV-DOM-ACC-BAT-001-01
    statement: Batch names cannot repeat within a business unit.
    enforced_at:
      - service
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#refuses
      a name another batch of the unit has 409, name_in_use, in 1.0’s sentence
      (D14)
  - id: INV-DOM-ACC-BAT-001-02
    statement: >-
      Creation fixes the batch business unit and originating stream; neither can
      subsequently be replaced.
    enforced_at:
      - api
      - service
      - database
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/rules/batch-rules.ts:BATCH_FROZEN_FIELDS;
      modules/batches/db/batches.table.ts (batches_write_once_trigger, RHF01)
  - id: INV-DOM-ACC-BAT-001-03
    statement: >-
      Ordinary batch creation and editing calculate fiscal placement from the
      date in the business unit calendar.
    enforced_at:
      - service
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.integration.spec.js#refuses
      a date no fiscal year of the unit holds;
      services-accounting:modules/batches/services/persistence/batches.ts:settledFields
  - id: INV-DOM-ACC-BAT-001-04
    statement: >-
      A batch reference on a document, allocation or posting must identify a
      batch in the referencing record business unit.
    enforced_at:
      - database
    provenance: observed
    source: >-
      services-accounting:modules/batches/db/batches.table.ts:batches_business_unit_id_uq
      (the same-unit composite target)
  - id: INV-DOM-ACC-BAT-001-05
    statement: >-
      The database prevents document batch reassignment into or out of Posting,
      Posted and Downloaded batches and prevents allocation intake into posted
      batches.
    enforced_at:
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/posting/rebuilt-documents.integration.spec.js#refuses,
      in the database, moving a document out of a posted batch (RHA05)
  - id: INV-DOM-ACC-BAT-001-06
    statement: >-
      Deletion fails while a document, posting or entry retains a restrictive
      reference to the batch.
    enforced_at:
      - database
      - service
    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)
  - id: INV-DOM-ACC-BAT-001-07
    statement: >-
      Fiscal accounting exclusively manages system batches; ordinary
      modification, lifecycle actions and deletion reject them.
    enforced_at:
      - service
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/persistence/batches.ts
      (header: isSystemBatch refusals);
      modules/batches/services/actions/batch-actions.ts (header)
  - id: INV-DOM-ACC-BAT-001-08
    statement: >-
      Redelivery of the same stream occurrence cannot create a second batch for
      that occurrence.
    enforced_at:
      - service
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/roll/batch-roller.integration.spec.js#opens
      nothing for the same occurrence delivered again, and answers the same
      batch
  - id: INV-DOM-ACC-BAT-001-09
    statement: >-
      Stream unit and schedule identity cannot change, and schedule validation
      rejects rolls more frequent than once per day.
    enforced_at:
      - service
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/e2e/recurring-batches.e2e.spec.js#answers
      400 to a schedule that would run more often than once a day
  - id: INV-DOM-ACC-BAT-001-10
    statement: >-
      Routing references must stay within their business unit; a rule cannot
      combine merchant-account and bank-account criteria.
    enforced_at:
      - api
      - service
      - database
    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
  - id: INV-DOM-ACC-BAT-001-11
    statement: >-
      A recurring stream cannot be removed while routing references it or
      generated batches remain, except for the unused current batch removed with
      it.
    enforced_at:
      - service
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/e2e/recurring-batches.e2e.spec.js#answers
      409 naming the settings and how they name it
  - id: INV-DOM-ACC-BAT-001-12
    statement: >-
      A read in one workspace cannot retrieve a batch belonging to a different
      workspace.
    enforced_at:
      - database
      - api
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/batches.queries.integration.spec.js#reads
      another tenant’s batch as absent
physical:
  - accounting.batches
  - accounting.batches_v
  - accounting.recurring_batches
  - accounting.batch_assignment_settings
  - accounting.batch_assignment_rules
  - >-
    accounting.schedules (the automatic close and roll schedules, owned by the
    maintenance module)
evidence:
  - >-
    services-accounting at f47cb263: modules/batches/db/batches.table.ts,
    batches.view.ts, recurring-batches.table.ts,
    batch-assignment-settings.table.ts, batch-assignment-rules.table.ts;
    services/persistence/batches.ts, recurring-batches.ts,
    batch-assignment-settings.ts, batch-totals.ts;
    services/rules/batch-rules.ts; metadata/batches.object.ts;
    export/batches.dataset.ts, batch-settings.dataset.ts;
    docs/accounting/recurring-batches.md
  - >-
    react-console at baf6dae3: components/accounting/batches/batch-model.ts;
    lib/accounting/transactions/http/batches.ts
  - 'FND-ACC-BAT-054: ordinary and engine close-schedule cleanup differ'
---

# Batch

## What It Models

A batch gives finance staff one collection to review and complete. Its logical object also describes the recurring intake and routing configuration that supply successive collections. These facets have separate physical records and permission families.

## Identity and Attributes

The attribute rows distinguish editable configuration from live totals, recorded posting results and system-managed scheduling facts. The same object describes both a collection and the configuration that feeds it; this does not merge their identities.

## Relationships

Posting history connects a batch to its ledger results and deferred revenue plans. Source documents belong to Transactions, while Books supplies the financial entity and calendar. The Accounting maintenance module supplies scheduling storage and delivery.

## Invariants

The invariant rows identify the responsible enforcement layer. Calendar derivation belongs to ordinary persistence; database references and triggers protect ownership, intake and deletion. These protections do not establish a general status-history record.

## How It Is Stored and Shared

Batch Management controls the collection and intake records. Transactions uses its in-process selection and validation functions. Query projections support reporting, and workspace export includes both collection data and intake configuration. Attention publishing is a separate, gated Platform integration.

## Open Design Questions

Product still needs to resolve carried lifecycle states, configuration replacement policy and missing status history. The first-batch refusal is response-only, and recurring configuration does not expose that refusal or the schedule pause reason.
