# GetAccount

## Overview

GetAccount retrieves a single GL account record by id or by code within a CoA. The input is a union type — callers specify exactly one lookup variant. This serves as the core account lookup for existence checks, uniqueness validation, and all account lifecycle commands.

## Business Rules

- Accepts one of two lookup variants:
  - `{ id }` — retrieves by unique identifier
  - `{ chartOfAccountsId, code }` — retrieves by account code within a specific CoA
- Returns the full account record including all fields (id, chartOfAccountsId, accountGroupId, code, name, accountType, classification, currencyRestriction, reconciliation, defaultTaxCode, tags, status, successorAccountId, hasPostedTransactions, timestamps)
- Returns null if no matching account is found
- All comparisons are exact

## Process Flow

```mermaid
flowchart TD
    A[Receive input] --> B{Which variant?}
    B -->|id| C[SELECT from Account where id = input.id]
    B -->|chartOfAccountsId + code| D[SELECT from Account where chartOfAccountsId = input.chartOfAccountsId AND code = input.code]
    C --> E{Account found?}
    D --> E
    E -->|Yes| F[Return account record]
    E -->|No| G[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **ACCOUNT_NOT_FOUND**: No account matches the given criteria — caller receives null

## Test Cases

- returns account when found by id
- returns null when account not found by id
- returns account when found by code within CoA
- returns null when account not found by code within CoA
