# JournalLine

## Description

JournalLine represents a prepared debit or credit line within a JournalEntry. Each line references a GL account from the coa-management module, specifies either a debit or credit amount (mutually exclusive), and includes an optional line-level description. Amounts are recorded in the company's base currency; multi-currency conversion is outside the current scope. Journal lines are created, modified, and deleted in the context of their parent journal entry's DRAFT lifecycle. Posting copies validated JournalLine effects into immutable AccountingLedger facts.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createJournalEntry](../command/CreateJournalEntry.md) - Creates initial prepared lines under a new DRAFT journal entry
- [updateJournalEntry](../command/UpdateJournalEntry.md) - Replaces prepared lines while the parent journal entry is DRAFT

### Query Definitions

- [GetJournalEntry](../query/GetJournalEntry.md) - Journal lines are returned as part of the parent journal entry

### Models

- JournalLine

### Invariants

- Each journal line must reference an existing GL account
- Each journal line must specify either a debit amount or a credit amount (not both, and not zero for both)
- Debit and credit amounts must be positive values
- Journal lines can only be added to, updated on, or removed from a DRAFT journal entry
- Posting a JournalEntry creates AccountingLedger facts from the prepared JournalLine records
- Line-level description is optional and can be updated while the parent journal entry is in DRAFT status
- RECEIVABLE and PAYABLE classified accounts block direct manual journal postings (control account constraint)

### Relationships

- **References JournalEntry**: Each journal line belongs to a JournalEntry via journalEntryId
- **References Account**: Each journal line references a GL Account via accountId (coa-management module)
- **Optionally Referenced By AccountingLedger**: Posted ledger facts can trace back to the prepared JournalLine
