# ListJournalEntries

## Overview

ListJournalEntries retrieves a list of journal entries with various filters. This query supports journal review workflows, period-end reconciliation, review inquiries, and source-document reconciliation by allowing filtering on company, period, status, and date range. Results are sorted by entryDate descending.

## Business Rules

- companyId is required — journal entries are always scoped to a company
- Optional filters:
  - `accountingPeriodId` — filter by accounting period
  - `status` — filter by status (DRAFT, CANCELLED, POSTED)
  - `dateRange` — filter by entry date range (startDate and endDate)
- All filters can be combined; when multiple filters are provided, results must match all criteria (AND logic)
- Returns full journal entry records including header fields (journal lines are not included in list results for performance)
- Results are sorted by entryDate descending
- Returns an empty list if no journal entries match the filters

## Process Flow

```mermaid
flowchart TD
    A[Receive input with companyId] --> B[Build query scoped to companyId]
    B --> C{Filters provided?}
    C -->|Yes| D[Apply accountingPeriodId, status, and/or dateRange filters]
    C -->|No| E[Return all journal entries for company]
    D --> E
    E --> F[Sort by entryDate descending]
    F --> G[Return journal entry list]
```

## External Dependencies

- None

## Error Scenarios

- None

## Test Cases

- returns all journal entries for a company
- returns journal entries filtered by accounting period
- returns journal entries filtered by status
- returns journal entries filtered by date range
- returns empty list when no journal entries match
