Skip to main content
A Journal Entry Line (journal_entry_lines) is a single debit or credit leg within a double-entry journal entry. Each line is associated with exactly one JournalEntry and one primary LedgerAccount, carries a decimal debit or credit amount (never both simultaneously, enforced by a CHECK constraint), and may reference an auxiliary ledger account, a tax rate, and a counterparty company for subledger analysis. Lines are created exclusively by the accounting posting engine (invoice-journal-entry builder and payment-settlement pipeline) and are never written directly by end users.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

Data model

Attributes

Relationships

System-computed

  • journal_entry_line_id β€” generated via gen_random_uuid() database default on INSERT; also seeded client-side by randomUUID() in the entity constructor.
  • created_at β€” set to new Date() by MikroORM onCreate hook; never updated.
  • updated_at β€” set to new Date() on onCreate and refreshed by MikroORM onUpdate hook on every flush.
  • deleted_at β€” null on creation; set to a timestamp by soft-delete logic in the accounting posting engine or by cascade from the parent JournalEntry; never hard-deleted in normal operation.
  • debit / credit defaults β€” both default to β€˜0’ at the database level (DEFAULT 0) and in the entity constructor.
  • CHECK constraint chk_jel_debit_credit_exclusive β€” enforced at the database level: NOT (debit > 0 AND credit > 0). A line must be either a debit line or a credit line, never both.
  • posting_metadata β€” populated by the accounting posting engine (journal-entry-persister.service.ts / invoice-journal-entry-draft.builder.ts) with traceability data; not derived from any ORM hook.
  • accounting_currency / accounting_amount β€” populated during FX conversion in the multi-currency posting path; null for same-currency workspaces.
  • Composite indexes: (workspace_pk, journal_entry_pk) and (ledger_account_pk, workspace_pk) are created by the Migration20260311100000 migration for query performance.

Example

Source: apps/api/src/database/entities/JournalEntryLine.ts Β· domain: financial-graph Β· tier: Supporting