# `PhoenixKitWarehouse.MinStockSettings`
[🔗](https://github.com/BeamLabEU/phoenix_kit_warehouse/blob/0.4.0/lib/phoenix_kit_warehouse/min_stock_settings.ex#L1)

Context for the per-item minimum stock threshold (§5, deficit tracking).

Backed by `phoenix_kit_warehouse_min_stock` (introduced in core PhoenixKit
migration V144), a small side table with at most one row per `item_uuid`
(enforced by a unique index). Items without a row — or whose row has
`min_quantity == 0` — are treated as having no configured minimum:
`min_stock_map/0` only returns rows where
`min_quantity > 0`, since a zero threshold isn't meaningfully different
from "not configured" for deficit purposes (see the upcoming
`PhoenixKitWarehouse.Deficits`).

# `delete_min_quantity`

Deletes the minimum stock row for `item_uuid`, if any. Idempotent — a
no-op (not an error) when no row exists.

# `get_min_quantity`

Returns the configured minimum quantity for `item_uuid` as a Decimal.
Returns `Decimal.new("0")` if no row exists (no minimum configured).

# `min_stock_map`

Returns `%{item_uuid => Decimal}` for every item with a configured minimum
greater than zero. Items with no row, or a row whose `min_quantity` is
exactly `0`, are omitted — see the moduledoc.

# `set_min_quantity`

Sets (upserts) the minimum quantity for `item_uuid`. `qty` is coerced via
`StockLedger.to_decimal/1` (accepts a Decimal, a number, or a comma/dot
decimal string).

Returns `{:ok, %MinStock{}}` on success, `{:error, changeset}` if the
coerced quantity fails validation (e.g. negative).

---

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