# ListJournalEntries

## Overview

ListJournalEntries retrieves a list of journal entries with various filters. This query supports journal review workflows, period-end reconciliation, audit inquiries, and subledger-to-GL reconciliation by allowing filtering on company, period, journal type, 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
  - `journalType` — filter by journal type (Sales, Purchase, Cash, Bank, Miscellaneous, Opening, Closing)
  - `status` — filter by status (DRAFT, POSTED, REVERSED)
  - `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, journalType, 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

- **EMPTY_RESULT**: No records match the given criteria

## Test Cases

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