---
id: DOM-ACC-BAT-004
title: Subledger Entry
realises: CON-ACC-BAT-004
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: []
custom_fields: none
identity: >-
  Ledger headers have workspace-scoped identities. System accounting retains
  supplied identities for the first generation and adds generation suffixes
  later. The duplicate key combines posting, document, schedule entry and
  reversal reference; line position identifies a line within its header.
attributes:
  - name: 'posting, batch and business unit'
    kind: reference
    required: true
    computed: false
    notes: >-
      Permanent generation ownership plus same-unit references to the collection
      and ledger entity.
  - name: accounting date and fiscal placement
    kind: date
    required: true
    computed: false
    notes: >-
      Ordinary generation uses batch placement while retaining the original
      document date separately. System entries use the supplied date and fiscal
      period.
  - name: source document
    kind: reference
    required: false
    computed: false
    notes: >-
      Ordinary postings identify their document; stored headers allow absent
      document fields. Recognition entries retain schedule references.
  - name: customer and payment context
    kind: text
    required: false
    computed: false
    notes: >-
      Optional party identity, original dates and tender details copied into the
      accounting result.
  - name: reversal marker
    kind: reference
    required: false
    computed: false
    notes: >-
      A reference to an original mirrored by fiscal reopening; ordinary
      unposting now removes its generation instead.
  - name: lines
    kind: collection
    required: true
    computed: false
    notes: 'Ordered accounting movements, subject to the minimum line count.'
  - name: line · type
    kind: enum
    required: true
    computed: false
    notes: >-
      A defined accounting vocabulary covering receivables, revenue, deferrals,
      cash, tax and other supported movements.
  - name: line · account
    kind: reference
    required: true
    computed: false
    notes: >-
      The business unit account, including its code and optional name captured
      at posting.
  - name: line · amounts
    kind: money
    required: true
    computed: false
    notes: >-
      Unsigned integer minor units on debit and credit sides in base and
      document currencies, with the document currency code.
  - name: line · dimensions
    kind: reference
    required: false
    computed: false
    notes: >-
      Optional product and financial dimensions, settlement accounts,
      counterpart unit, service dates and document-line references.
  - name: line reporting row
    kind: computed
    required: false
    computed: true
    notes: >-
      A query projection with readable collection and document references, party
      and account labels, reversal markers and major-unit amounts.
relationships:
  - to: DOM-ACC-BAT-003
    cardinality: many-to-one
    ownership: A ledger entry is a child of one posting generation.
    cross_service: false
  - to: DOM-ACC-BAT-001
    cardinality: many-to-one
    ownership: >-
      The batch supplies collection placement; generation ownership stays with
      the posting.
    cross_service: false
  - to: DOM-ACC-BAT-005
    cardinality: many-to-one
    ownership: Only recognition entries reference the revenue-plan entry they release.
    cross_service: false
invariants:
  - id: INV-DOM-ACC-BAT-004-01
    statement: >-
      At commit, an entry must contain at least two lines and have equal debit
      and credit totals in base and each document currency.
    enforced_at:
      - database
      - service
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/subledger-entries.integration.spec.js#refuses
      an entry whose debits and credits differ, at commit, by the balance
      constraint
  - id: INV-DOM-ACC-BAT-004-02
    statement: >-
      Ledger amounts are non-negative integer minor units, with movement
      direction expressed by debit or credit position.
    enforced_at:
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/ledger-minor-units.integration.spec.js#converts
      each line with its unit's base exponent and its transaction currency's,
      and each schedule entry with its schedule's
  - id: INV-DOM-ACC-BAT-004-03
    statement: >-
      Append-only triggers reject changes to existing ledger headers and lines,
      including writes by the table owner.
    enforced_at:
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/subledger-entries.integration.spec.js#cannot
      be updated even by the table owner: the append-only trigger refuses it,
      naming the table
  - id: INV-DOM-ACC-BAT-004-04
    statement: >-
      Ledger removal is restricted to the guarded deletion of a current ordinary
      posting in its workspace or a guarded workspace-deletion purge.
    enforced_at:
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/posting/unpost-deletes-entries.integration.spec.js#is
      the only way to delete a ledger row: the application role is refused a
      direct delete
  - id: INV-DOM-ACC-BAT-004-05
    statement: Every ledger account reference must belong to the entry business unit.
    enforced_at:
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/subledger-entries.integration.spec.js#refuses
      a line whose G/L account belongs to another business unit, by the
      same-unit foreign key
  - id: INV-DOM-ACC-BAT-004-06
    statement: >-
      Within a posting, the duplicate key prevents repeating the same document,
      schedule-entry and reversal-reference combination.
    enforced_at:
      - database
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/persistence/subledger-entries.integration.spec.js#refuses
      a second entry of the same transaction in the same posting, by the
      no-duplicates key
  - id: INV-DOM-ACC-BAT-004-07
    statement: >-
      The rebuilt invoice and memo evidence preserves source-line references on
      generated lines; it does not prove a universal reference requirement
      across posting kinds.
    enforced_at:
      - service
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/posting/rebuilt-documents.integration.spec.js#traces
      every line of every entry to a line of a document in the batch
  - id: INV-DOM-ACC-BAT-004-08
    statement: >-
      An entry belonging to another workspace is returned as absent, using the
      same response as an unknown entry.
    enforced_at:
      - database
      - api
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/e2e/subledger-entries.e2e.spec.js#answers
      an entry of another tenant as it answers an absent one: the same status
      and error type
physical:
  - accounting.subledger_entries
  - accounting.subledger_entry_lines
  - accounting.subledger_entry_lines_v
evidence:
  - >-
    services-accounting at f47cb263:
    modules/batches/db/subledger-entries.table.ts,
    subledger-entry-lines.table.ts, subledger-entry-lines.view.ts;
    metadata/subledger-entry-lines.object.ts;
    queries/subledger-entry-lines.query.ts;
    services/persistence/subledger-entries.ts;
    services/rules/subledger-entry-rules.ts; export/subledger.dataset.ts;
    docs/accounting/batches.md
  - >-
    react-console at baf6dae3:
    components/accounting/batches/batch-entries-tab.tsx;
    lib/accounting/transactions/http/batch-posting.ts
  - >-
    FND-ACC-BAT-052: creation cut-off cannot recover subsequently deleted
    entries
  - >-
    FND-ACC-BAT-053: planning reversal uniqueness is broader than the observed
    duplicate key
---

# Subledger Entry

## What It Models

A subledger entry is the journal result of document or fiscal accounting. A header identifies its generation and financial placement; ordered lines describe balanced movements between accounts. It has no editable lifecycle.

## Identity and Attributes

The attribute rows separate original business context from the account and amount snapshots required to explain the result. Not every stored header must identify a document, and the duplicate constraint is scoped to a posting generation.

## Relationships

Generation ownership belongs to the posting. The batch provides placement, while recognition connects a ledger result to a revenue-plan entry. Account and dimension definitions come from their owning Accounting modules.

## Invariants

Commit-time checks and immutable-row triggers make the ledger safeguards independent of ordinary callers. Guarded functions provide the permitted removal paths. The invariant rows state the scope of each safeguard rather than extending fixture evidence to every document kind.

## How It Is Stored and Shared

Batch Management writes the ledger and exposes entry reads. Platform serves the subledger-line reporting projection. Workspace export selects surviving rows by creation cut-off; it cannot reconstruct rows later removed through unposting. External-ledger delivery remains unbuilt.

## Open Design Questions

The console can build an account summary from a capped entry read without identifying it as partial. Historical export semantics need reconciliation with ordinary deletion, and the retained service bypass switch must not be mistaken for removal of the database account guard.
