Manufacturers — company directory used as the source of items.
Hard-deletes only (manufacturers are reference data, not user content).
Status field is "active" / "inactive"; inactive manufacturers
remain in the DB but are filtered from item dropdowns.
Public surface is re-exported from PhoenixKitCatalogue.Catalogue via
defdelegate, so callers can keep using the canonical context module.
Summary
Functions
Returns a changeset for tracking manufacturer changes.
Creates a manufacturer.
Hard-deletes a manufacturer from the database.
Fetches a manufacturer by UUID. Returns nil if not found.
Fetches a manufacturer by UUID. Raises Ecto.NoResultsError if not found.
Stamps :manufacturer_name on each item — the replacement for the
preload(:manufacturer) that V179's federated reference made impossible.
Every item this CRM party is recorded as the manufacturer of, for the catalogue panel on that party's page in CRM.
Lists manufacturers from all available sources as normalized maps.
Lists all manufacturers, ordered by name.
Resolves a manufacturer UUID to a unified map regardless of source.
Batch form of resolve/1 — see
PhoenixKitCatalogue.Catalogue.Suppliers.resolve_many/1. This is the call
that hydrates a page of items without one cross-module lookup per row.
Updates a manufacturer with the given attributes.
Functions
@spec change_manufacturer(PhoenixKitCatalogue.Schemas.Manufacturer.t(), map()) :: Ecto.Changeset.t(PhoenixKitCatalogue.Schemas.Manufacturer.t())
Returns a changeset for tracking manufacturer changes.
@spec create_manufacturer( map(), keyword() ) :: {:ok, PhoenixKitCatalogue.Schemas.Manufacturer.t()} | {:error, Ecto.Changeset.t(PhoenixKitCatalogue.Schemas.Manufacturer.t())}
Creates a manufacturer.
Required attributes
:name— manufacturer name (1-255 chars)
Optional attributes
:description,:website,:contact_info,:logo_url,:notes:status—"active"(default) or"inactive":data— flexible JSON map
@spec delete_manufacturer( PhoenixKitCatalogue.Schemas.Manufacturer.t(), keyword() ) :: {:ok, PhoenixKitCatalogue.Schemas.Manufacturer.t()} | {:error, Ecto.Changeset.t(PhoenixKitCatalogue.Schemas.Manufacturer.t())}
Hard-deletes a manufacturer from the database.
@spec get_manufacturer(Ecto.UUID.t()) :: PhoenixKitCatalogue.Schemas.Manufacturer.t() | nil
Fetches a manufacturer by UUID. Returns nil if not found.
@spec get_manufacturer!(Ecto.UUID.t()) :: PhoenixKitCatalogue.Schemas.Manufacturer.t()
Fetches a manufacturer by UUID. Raises Ecto.NoResultsError if not found.
@spec hydrate( [PhoenixKitCatalogue.Schemas.Item.t()] | PhoenixKitCatalogue.Schemas.Item.t() ) :: [PhoenixKitCatalogue.Schemas.Item.t()] | PhoenixKitCatalogue.Schemas.Item.t()
Stamps :manufacturer_name on each item — the replacement for the
preload(:manufacturer) that V179's federated reference made impossible.
One call per page, two queries at most, whatever mix of local and CRM
manufacturers the page contains. Items whose reference resolves to nothing
fall back to their stored manufacturer_name_snapshot, and then to nil,
so a deleted party degrades to the last known name rather than a blank.
Accepts a single item or a list, and is a no-op for anything without a manufacturer.
@spec items_manufactured_by(Ecto.UUID.t()) :: [PhoenixKitCatalogue.Schemas.Item.t()]
Every item this CRM party is recorded as the manufacturer of, for the catalogue panel on that party's page in CRM.
Matches the party's own uuid AND any local manufacturer row projecting it, so items that still store the pre-move local uuid are included. Deleted items excluded.
Lists manufacturers from all available sources as normalized maps.
CRM parties holding an active manufacturer role come first, then local
rows ordered by name. Local rows already linked to a CRM party are omitted:
the party side of the same company is in the list already, and emitting both
would show one company twice.
@spec list_manufacturers(keyword()) :: [PhoenixKitCatalogue.Schemas.Manufacturer.t()]
Lists all manufacturers, ordered by name.
Options
:status— filter by status (e.g."active","inactive"). When nil (default), returns all manufacturers.
@spec resolve(Ecto.UUID.t()) :: {:ok, map()} | :error
Resolves a manufacturer UUID to a unified map regardless of source.
Returns {:ok, map} with keys :uuid, :name, :email, :phone,
:website, :source (:crm | :local), or :error when the uuid is
unknown to both sources. CRM is consulted first and only when the CRM
module is loaded.
@spec resolve_many([Ecto.UUID.t()]) :: %{required(Ecto.UUID.t()) => map()}
Batch form of resolve/1 — see
PhoenixKitCatalogue.Catalogue.Suppliers.resolve_many/1. This is the call
that hydrates a page of items without one cross-module lookup per row.
@spec update_manufacturer( PhoenixKitCatalogue.Schemas.Manufacturer.t(), map(), keyword() ) :: {:ok, PhoenixKitCatalogue.Schemas.Manufacturer.t()} | {:error, Ecto.Changeset.t(PhoenixKitCatalogue.Schemas.Manufacturer.t())}
Updates a manufacturer with the given attributes.