# Item Lifecycle

## Overview

Items are the fundamental SKU-level entity in the ERP system — the sellable, purchasable, and trackable unit. Each item has its own lifecycle state machine, unique SKU identifier, and optional barcode. Items manage their unit of measure independently.

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

## Business Purpose

Items serve as the universal SKU entity across the ERP system. Downstream domains reference items as the fundamental tradeable/trackable unit:

- Sales module creates order lines linked to Items
- Inventory module tracks stock quantities per Item
- Purchasing module creates purchase order lines linked to Items
- Manufacturing module references Items in Bill of Materials

The lifecycle state machine ensures:

- Items are reviewed before becoming transactionally available (DRAFT → ACTIVE)
- Discontinued items are preserved for historical reference (ACTIVE → INACTIVE)
- Previously discontinued items can return to active use (INACTIVE → ACTIVE)
- Only DRAFT items can be permanently deleted; ACTIVE/INACTIVE items are preserved for audit trails

## Process Flow

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

## Scenario Patterns

- **New Item**: An item is created with a unique SKU, name, UoM, and optional barcode
- **Draft Item Review**: Items created in DRAFT status are reviewed, barcodes corrected, and activated
- **Item Deactivation**: A specific SKU is discontinued while other items remain active
- **Item Reactivation**: A previously discontinued SKU is brought back into active use (INACTIVE → ACTIVE)
- **Draft Item Cleanup**: Unwanted items in DRAFT status are deleted before activation
- **SKU Assignment**: Each item receives a globally unique SKU that is immutable once assigned

## Test Cases

- Item lifecycle follows DRAFT → ACTIVE ↔ INACTIVE state machine
- Items can be created in either DRAFT or ACTIVE status
- SKU is required, globally unique, and immutable after assignment
- Barcode must be unique when provided, can be updated
- Only DRAFT items can be deleted; ACTIVE and INACTIVE items cannot
- Only ACTIVE items can be referenced in new transactions (sales orders, purchase orders)
- Items can be activated, deactivated, and reactivated individually
- Item UoM can be updated in DRAFT status; once activated, UoM is locked to preserve transaction consistency

## Reference Links

- [Oracle Item Master](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25a/fammi/define-items-and-item-structures.html)
- [NetSuite Item Master Data](https://www.netsuite.com/portal/resource/articles/inventory-management/item-master-data.shtml)
