# Item

## Description

Item is the fundamental SKU-level entity in the ERP system — the sellable, purchasable, and trackable unit referenced by all downstream modules (Sales, Purchasing, Inventory, Manufacturing). Each item has a lifecycle state machine (DRAFT → ACTIVE ↔ INACTIVE), a globally unique SKU identifier, an optional barcode, and an assigned unit of measure.

Items can be created in either DRAFT or ACTIVE status. DRAFT items require explicit activation before participating in transactions.

## Domain Model Definitions

### Model type

Stateful

#### State Transitions

```mermaid
stateDiagram-v2
    [*] --> Draft: createItem (draft)
    [*] --> Active: createItem (active)
    Draft --> Active: activateItem
    Active --> Inactive: deactivateItem
    Inactive --> Active: reactivateItem
    Draft --> [*]: deleteItem
```

### Command Definitions

- [createItem](../commands/CreateItem.md) - Create a new item in DRAFT or ACTIVE status
- [updateItem](../commands/UpdateItem.md) - Update mutable fields (name, barcode, UoM) of an existing item
- [activateItem](../commands/ActivateItem.md) - Transition item from DRAFT to ACTIVE
- [deactivateItem](../commands/DeactivateItem.md) - Transition item from ACTIVE to INACTIVE
- [reactivateItem](../commands/ReactivateItem.md) - Transition item from INACTIVE to ACTIVE
- [deleteItem](../commands/DeleteItem.md) - Permanently delete a DRAFT item

### Query Definitions

- [GetItem](../queries/GetItem.md) - Retrieve an item by id, sku, or barcode

### Models

- Item

### Invariants

- SKU is required and must be globally unique across all items regardless of status
- SKU is immutable after assignment (cannot be changed once set)
- Barcode must be unique across all items when provided
- Barcode can be updated after creation
- Only DRAFT items can be deleted; ACTIVE and INACTIVE items are preserved for audit trails
- Only ACTIVE items can be referenced in new transactions (sales orders, purchase orders)
- Name is required at creation time
- UoM can be updated only in DRAFT status — once activated, UoM is locked to preserve transaction consistency

### Relationships

- **References Unit**: Each item references a Unit from the primitives module as its unit of measure
- **Referenced By Taxonomy Assignments**: Items are linked to TaxonomyNodes via ItemTaxonomyAssignment (many-to-many)
- **Referenced By Downstream Modules**: Items are referenced by Sales, Purchasing, Inventory, and Manufacturing modules
