# GetInternalOrder

## Overview

GetInternalOrder retrieves a single internal order record by id, returning all fields including order number, order type (OVERHEAD, INVESTMENT, ACCRUAL), description, status (CREATED, RELEASED, TECHNICALLY_COMPLETED, CLOSED), responsible person, responsible cost center reference, validity period (valid-from/to), company reference, and optional budget assignment. This is the primary query for viewing internal order details, validating order status for cost postings, and reviewing accumulated costs against budgets.

## Business Rules

- Accepts a single lookup parameter: `{ id }`
- Returns the full internal order record including all header fields
- Includes the responsible cost center reference
- Includes the budget assignment reference if one exists
- Returns null if no matching internal order is found
- Lookup is an exact match on id

## Process Flow

```mermaid
flowchart TD
    A[Receive input with id] --> B[SELECT from InternalOrder where id = input.id]
    B --> C{Internal order found?}
    C -->|Yes| D[Load responsible cost center reference]
    D --> E[Load budget assignment if present]
    E --> F[Return internal order with all fields]
    C -->|No| G[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **INTERNAL_ORDER_NOT_FOUND**: Internal order with the specified ID does not exist

## Test Cases

- returns internal order with all fields when found by id
- returns internal order with responsible cost center reference populated
- returns internal order with budget assignment when one exists
- returns internal order without budget assignment when none exists
- returns null when no internal order matches the given id
