# Unit

## Description

Unit defines an individual unit of measure with its symbol, display name, and conversion factor relative to its category's reference unit. Units support configurable rounding precision for business operations.

Examples: kg (kilogram), lb (pound), ea (each), dz (dozen).

## Domain Model Definitions

### Model type

Stateful

#### State Transitions

```mermaid
stateDiagram-v2
    [*] --> Active: create
    Active --> Inactive: deactivate
    Inactive --> Active: activate
    note right of Active: Reference unit cannot be deactivated
```

| Operation | From | To | Command |
|-----------|------|----|---------|
| deactivate | ACTIVE | INACTIVE | [deactivateUnit](../command/DeactivateUnit.md) |
| activate | INACTIVE | ACTIVE | [activateUnit](../command/ActivateUnit.md) |

### Command Definitions

- [createUnit](../command/CreateUnit.md)
- [activateUnit](../command/ActivateUnit.md)
- [deactivateUnit](../command/DeactivateUnit.md)

### Query Definitions

- [convertQuantity](../query/ConvertQuantity.md)

### Models

- Unit

### Invariants

- Conversion factor must be a positive value
- Reference unit has conversion factor of 1.0
- Symbol must be unique within the category
- Reference unit cannot be deactivated

### Relationships

- **Belongs To Category**: Each unit belongs to exactly one UoMCategory
- **May Be Reference Unit**: A unit may be designated as its category's reference unit
