# `PhoenixKitManufacturing.Schemas.Machine`
[🔗](https://github.com/BeamLabEU/phoenix_kit_manufacturing/blob/0.4.1/lib/phoenix_kit_manufacturing/schemas/machine.ex#L1)

Schema for manufacturing machines (the machines reference book).

A machine is a piece of production equipment: a CNC mill, a press, a
laser cutter, etc. Machines are categorized by many-to-many machine
type links via `MachineTypeAssignment`, so a single machine can carry
several type tags. `MachineTypeAssignment.machine_type_uuid` is a soft
reference (no `belongs_to`/FK) — see that schema's moduledoc — so this
schema does not expose a `machine_types` association; resolving the
linked types for a machine goes through
`PhoenixKitManufacturing.Machines`/`EntitiesRegistry` instead.

The passport columns (`model`, `manufacture_year`, `commissioned_on`,
`warranty_until`, `to_last_on`, `to_interval_days`, `to_next_on`,
`notes`) and the soft location link (`location_uuid`, `space_uuid`) are
first-class columns as of schema V2. `location_uuid`/`space_uuid` are
intentionally *not* `belongs_to` associations — `phoenix_kit_locations`
is a soft, optional cross-module reference read via
`PhoenixKitManufacturing.Machines.location_label/2`, never joined.

`to_next_on` is auto-computed from `to_last_on` + `to_interval_days`
whenever both are present and the caller didn't explicitly submit a
`to_next_on` value of its own — see `maybe_compute_next_maintenance/1`.

The freeform `metadata` JSONB column holds the remaining passport/spec
fields driven by each linked machine type's `field_template` (power
rating, working area, …) that aren't modeled as columns here. `data`
holds multilang translations.

# `t`

```elixir
@type t() :: %PhoenixKitManufacturing.Schemas.Machine{
  __meta__: term(),
  code: term(),
  commissioned_on: term(),
  data: term(),
  description: term(),
  inserted_at: term(),
  location_note: term(),
  location_uuid: term(),
  machine_type_assignments: term(),
  manufacture_year: term(),
  manufacturer: term(),
  metadata: term(),
  model: term(),
  name: term(),
  notes: term(),
  serial_number: term(),
  space_uuid: term(),
  status: term(),
  to_interval_days: term(),
  to_last_on: term(),
  to_next_on: term(),
  updated_at: term(),
  uuid: term(),
  warranty_until: term()
}
```

# `changeset`

```elixir
@spec changeset(t(), map()) :: Ecto.Changeset.t()
```

Builds a changeset for a machine.

# `statuses`

```elixir
@spec statuses() :: [String.t()]
```

The list of valid status values.

---

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