# GetCostElement

## Overview

GetCostElement retrieves a single cost element record by id, returning all fields including code, name, type (PRIMARY or SECONDARY), category, status, validity period (valid-from/to), GL account reference (for primary elements), company reference, and description. This is the primary query for viewing cost element details, validating cost element configuration, and supporting downstream processes such as cost posting validation and allocation rule setup.

## Business Rules

- Accepts a single lookup parameter: `{ id }`
- Returns the full cost element record including all header fields
- For PRIMARY cost elements, the GL account reference is included
- For SECONDARY cost elements, the GL account reference is null
- Returns null if no matching cost element is found
- Lookup is an exact match on id

## Process Flow

```mermaid
flowchart TD
    A[Receive input with id] --> B[SELECT from CostElement where id = input.id]
    B --> C{Cost element found?}
    C -->|Yes| D[Return cost element with all fields]
    C -->|No| E[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **COST_ELEMENT_NOT_FOUND**: Referenced cost element does not exist

## Test Cases

- returns cost element with all fields when found by id
- returns primary cost element with GL account reference populated
- returns secondary cost element with GL account reference as null
- returns null when no cost element matches the given id
