# Serial Number Tracking

## Overview

Serial number tracking enables individual unit-level traceability within the inventory module. Each serialized item is assigned a unique serial number that follows it through its inventory lifecycle — from goods receipt or production through to goods issue, return, or disposal. A serialized item always represents exactly one unit of stock, distinguishing it from lot/batch tracking where a single identifier covers multiple units.

Serial numbers are unique per item type: the same serial number cannot exist twice for the same item, ensuring unambiguous identification of every individual unit. The item-management module defers all serial number management to the inventory module, which owns assignment, state transitions, and history.

The inventory module tracks serial numbers only through inventory-relevant states (AVAILABLE, ISSUED, RETURNED, SCRAPPED). Reservation for sales orders and shipment tracking are the responsibility of the sales module, which references serial numbers but does not own their state. This separation aligns with SAP/Oracle approaches and avoids coupling inventory to sales lifecycle concerns.

## Business Purpose

- **Individual unit traceability**: Know exactly which specific unit was shipped to which customer, enabling precise after-sales support
- **Warranty tracking**: Link warranty claims to the exact unit by serial number, with full visibility into manufacture date, shipment date, and transaction history
- **Recall management**: Identify and locate every affected unit by serial number when a product recall is issued
- **Regulatory compliance**: Meet traceability requirements such as DSCSA (Drug Supply Chain Security Act) for pharmaceuticals and similar regulations in electronics, medical devices, and aerospace
- **Return and repair tracking**: Match returned units to their original shipment and trace repair history across service events
- **Fraud prevention**: Detect duplicate or counterfeit serial numbers entering the supply chain

## Process Flow

The following diagram shows the lifecycle states of a serialized item from initial assignment through terminal states.

```mermaid
flowchart TD
    A[Goods Receipt / Production] -->|Assign serial number| B(AVAILABLE)
    B -->|Goods issue| C(ISSUED)
    C -->|Customer returns unit| D(RETURNED)
    D -->|Inspect and restock| B
    D -->|Unit is defective| E(SCRAPPED)
    B -->|Unit damaged on site| E(SCRAPPED)
```

Serial numbers are assigned at the point of goods receipt (for purchased items) or at the end of production (for manufactured items). Once assigned, a serial number is immutable and permanently associated with that specific physical unit. A serial number is always associated with a StorageLocation — its location changes through stock movements.

## Scenario Patterns

- **Goods receipt serialization**: A purchase order is received and each individual unit is assigned a unique serial number during the inbound inspection or put-away process
- **Production serialization**: A manufacturing work order completes and each finished unit is assigned a serial number before being admitted to inventory
- **Goods issue**: A stock movement issues a serialized unit from inventory, transitioning it from AVAILABLE to ISSUED. The sales module may reference the serial number for shipment and customer tracking
- **Customer return**: An issued unit is returned by the customer, transitioning to RETURNED for inspection and disposition
- **Restock after return**: An inspected returned unit passes quality checks and is restocked as AVAILABLE at a StorageLocation
- **Scrap disposition**: A returned or site-damaged unit is deemed unfit for sale and transitioned to SCRAPPED, removing it from inventory
- **Warranty lookup**: A customer contacts support with a serial number; the system retrieves the full transaction history including receipt date, issue date, and any prior returns
- **Recall execution**: A product recall is initiated; the system queries all serial numbers for the affected item and identifies their current state and location (at storage location or issued)

## Test Cases

- Each serialized item has a quantity of exactly 1; the system rejects any transaction that would result in a fractional or multi-unit quantity for a serial number
- Serial numbers are unique per item type; assigning a duplicate serial number for the same item is rejected
- Serial numbers for different item types may overlap (e.g., item A serial "001" and item B serial "001" can coexist)
- A serial number can only be assigned during goods receipt or production completion
- Once assigned, a serial number cannot be changed or reassigned to a different physical unit
- State transitions follow the defined lifecycle: AVAILABLE -> ISSUED, ISSUED -> RETURNED, RETURNED -> AVAILABLE or SCRAPPED, AVAILABLE -> SCRAPPED
- An AVAILABLE serial can transition directly to SCRAPPED (e.g., on-site damage)
- An ISSUED serial cannot transition directly to AVAILABLE; it must pass through RETURNED first
- A SCRAPPED serial is terminal and cannot transition to any other state
- The full transaction history for a serial number is queryable, including all state transitions with timestamps, related stock movements, and StorageLocation changes
- Inventory counts for serialized items reconcile as the sum of individual serial numbers in AVAILABLE state at the counted StorageLocation

## Reference Links

- [Stock Tracking](./stock-tracking.md) — serial numbers are associated with a StorageLocation; for serialized items, on-hand count equals the number of serials in AVAILABLE state
- [Inventory Request](./inventory-request.md) — serial state transitions are driven by inventory operations (goods receipt assigns, goods issue transitions to ISSUED)
- [Location Management](./location-management.md) — StorageLocation provides the spatial axis for serial number location
- [Oracle Serial Number Management](https://docs.oracle.com/en/cloud/saas/supply-chain-and-manufacturing/25a/fammi/manage-serial-numbers.html)
- [SAP Serial Number Management](https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/f42e19a0e7404ebdbf6ec38ca93c1498/e54d9e616e2b1014b3fc9daa49709e5e.html)
- [DSCSA — FDA Drug Supply Chain Security Act](https://www.fda.gov/drugs/drug-supply-chain-integrity/drug-supply-chain-security-act-dscsa)
