# GetStockLevel

## Overview

GetStockLevel retrieves the stock level for a specific item at a specific storage location. The input requires both an itemId and a storageLocationId. It returns the on-hand, reserved, incoming, blocked, and computed available quantity. This serves as the core stock inquiry for availability checks, reservation validation, and replenishment decisions.

## Business Rules

- Requires both `itemId` and `storageLocationId`
- Returns a single StockLevel record containing:
  - `onHand` — physical quantity present
  - `reserved` — quantity allocated to outbound orders
  - `incoming` — quantity expected from inbound orders
  - `blocked` — quantity held for quality or other reasons
  - `availableQuantity` — computed as `onHand - reserved - blocked`
- Returns null if no stock level record exists for the item-location pair

## Process Flow

```mermaid
flowchart TD
    A[Receive itemId and storageLocationId] --> B[SELECT from StockLevel where itemId and storageLocationId match]
    B --> C{Record found?}
    C -->|Yes| D[Compute availableQuantity = onHand - reserved - blocked]
    D --> E[Return StockLevel record]
    C -->|No| F[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **STOCK_LEVEL_NOT_FOUND**: No stock level record exists for the given item-location pair — caller receives null

## Test Cases

- returns stock level when found
- returns null when not found
- correctly computes available quantity
- available equals onHand minus reserved minus blocked
