# site-management

## Overview

Manages physical sites (warehouses, offices, stores) under a company. Sites define receiving locations for purchase orders and storage locations for inventory. Site names must be unique per company on both create and update — the flow rejects collisions so each company has an unambiguous site directory.

## Actors Involved

- [Admin](../../actor/admin.md) — initiator

## Flow Diagram

```mermaid
sequenceDiagram
    actor Admin
    participant System

    Admin->>System: Select company
    System-->>Admin: Company context set
    Admin->>System: Create site with name, type, and address
    alt name is unique within company
        System-->>Admin: Site created in ACTIVE status
    else name already used by another site in the same company
        Note over System: rejects with ORGANIZATION_DUPLICATE_NAME<br/>(enforced by erp-kit createSite and updateSite)
        System-->>Admin: Error
    end
    Admin->>System: View site list
    System-->>Admin: Display sites filtered by company
    Admin->>System: View site detail
    System-->>Admin: Display site information
    Admin->>System: Edit site
    alt name still unique within company
        System-->>Admin: Site updated
    else duplicate name
        Note over System: rejects with ORGANIZATION_DUPLICATE_NAME
        System-->>Admin: Error
    end
```

## Stories

- [admin--create-site](story/admin--create-site.md)
- [admin--view-site-list](story/admin--view-site-list.md)
- [admin--view-site-detail](story/admin--view-site-detail.md)
- [admin--edit-site](story/admin--edit-site.md)

> **Out of MVP scope:** deactivate action is not implemented. **`Site.type` is treated as immutable by convention**: the [transfer-order-lifecycle](../transfer-order-lifecycle/README.md) flow depends on its stability. The current resolver (`updateSite`) and edit form do **not** technically refuse a type change — erp-kit's native `updateSite` only validates that the new value is in `VALID_SITE_TYPES`. Operationally, mistyped Sites should be replaced rather than retyped; promoting this convention into a hard refusal is tracked as a gap.
