# GetTrialBalance

## Overview

GetTrialBalance retrieves a single trial balance snapshot by id, including all line items. The trial balance record contains the generation parameters (companyId, accounting period, variant type, generation timestamp) and the full list of line items showing each GL account's opening balance, period debits, period credits, and closing balance. This query supports period-end review, financial statement preparation, and audit evidence retrieval.

## Business Rules

- Accepts a single lookup parameter: `{ id }`
- Returns the full trial balance record including all line items
- Line items include account reference, opening balance, period debits, period credits, and closing balance
- Line items are organized by account group hierarchy and sorted by account code ascending within each group
- Returns null if no matching trial balance is found
- Lookup is an exact match on id

## Process Flow

```mermaid
flowchart TD
    A[Receive input with id] --> B[SELECT from TrialBalance where id = input.id]
    B --> C{Trial balance found?}
    C -->|Yes| D[Load all associated line items]
    D --> E[Return trial balance with line items]
    C -->|No| F[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **TRIAL_BALANCE_NOT_FOUND**: No trial balance matches the given id — caller receives null

## Test Cases

- returns trial balance with lines when found by id
- returns null with empty lines when not found
