# `PhoenixKitWarehouse.Web.StockLive`
[🔗](https://github.com/BeamLabEU/phoenix_kit_warehouse/blob/0.4.0/lib/phoenix_kit_warehouse/web/stock_live.ex#L1)

LiveView for the Warehouse "In stock" page.

Two views, toggled per-user:
- **Grouped** (default): read-only catalogue/category tree via
  `WarehouseBrowser.stock_sheet`.
- **Flat**: full table-parity view backed by `Andi.Warehouse.StockColumnConfig`
  — global search, per-column filtering, sorting, and configurable columns.

Both views share a **warehouse scope** selector, rendered next to the
Grouped/Flat toggle: "All warehouses" (the `:warehouse_scope` assign is
`nil`, totals aggregate every location via `StockLedger.stock_map/0`) or one
specific warehouse (`:warehouse_scope` holds its `location_uuid`, totals
come from `StockLedger.stock_map_for_location/1`). Persisted per-user via
`ViewConfigs`, same as `stock_view`. Hidden entirely when no warehouse
LocationType is configured (`StockLedger.list_warehouses/0` returns `nil`).

Both views also carry a **deficit indicator** (§5 — `PhoenixKitWarehouse.
Deficits` / `MinStockSettings`), always computed across every warehouse
regardless of `:warehouse_scope` (same as `Deficits.available_by_item/0`).
Grouped shows a light warning icon next to items below their configured
minimum; Flat additionally exposes `Min. quantity` (inline-editable),
`Available`, and `Deficit` columns, a per-row highlight, a "Deficit"
filter, and a "Create supplier order" action button on deficit rows.

Admin-chrome pattern: self-wrapping render with `LayoutWrapper.app_layout`
so the page title lands in the global admin header (see `:self_wrapped_layout`
on_mount). Navigation via `PhoenixKit.Utils.Routes.path/1`.

# `on_mount`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
