# GetSerialNumber

## Overview

GetSerialNumber retrieves a serial number record by id or by serialNumber + itemId combination. The input is a union type — callers specify either an id or a serialNumber-itemId pair. It includes the current state and storage location of the serial number.

## Business Rules

- Accepts one of two lookup variants:
  - `{ id }` — retrieves by unique identifier
  - `{ serialNumber, itemId }` — retrieves by serial number and item combination
- Returns the full SerialNumber record including:
  - Current status (e.g., available, reserved, in-use, scrapped)
  - Current `storageLocationId`
- Returns null if no matching serial number is found

## Process Flow

```mermaid
flowchart TD
    A[Receive input] --> B{Which field?}
    B -->|id| C[SELECT from SerialNumber where id = input.id]
    B -->|serialNumber + itemId| D[SELECT from SerialNumber where serialNumber = input.serialNumber AND itemId = input.itemId]
    C --> E{Serial found?}
    D --> E
    E -->|Yes| F[Return SerialNumber record with status and location]
    E -->|No| G[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **SERIAL_NUMBER_NOT_FOUND**: No serial number matches the given criteria — caller receives null

## Test Cases

- returns serial when found by id
- returns serial when found by serialNumber and itemId
- returns null when not found
- includes current status and location
