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).
Summary
Functions
Deletes the minimum stock row for item_uuid, if any. Idempotent — a
no-op (not an error) when no row exists.
Returns the configured minimum quantity for item_uuid as a Decimal.
Returns Decimal.new("0") if no row exists (no minimum configured).
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.
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).
Functions
Deletes the minimum stock row for item_uuid, if any. Idempotent — a
no-op (not an error) when no row exists.
Returns the configured minimum quantity for item_uuid as a Decimal.
Returns Decimal.new("0") if no row exists (no minimum configured).
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.
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).