PhoenixKitWarehouse.Transfer (PhoenixKitWarehouse v0.2.2)

Copy Markdown View Source

Summary

Functions

Changeset for cancelling a transfer (from draft or in_transit, programmatic fields only — no cast). attrs carries :performed_by_uuid and, only when cancelling from in_transit, :lines — the reverse-posting audit snapshot (see PhoenixKitWarehouse.Transfers.cancel_transfer/2). Cancelling from draft never touches :lines since no stock movement happened yet.

Changeset for creating/editing a draft transfer. Both locations may be nil at this stage — the keeper hasn't necessarily chosen the source and destination warehouses yet. They only become mandatory when shipping (see ship_changeset/3).

Changeset for correcting a transfer (note + storage_folder only — lines/locations immutable once shipped).

Changeset for receiving a transfer (in_transit -> done, programmatic fields only — no cast). Locations are already guaranteed to be set at this point (the transfer went through ship_changeset/3 first), but the same validate_required/2 is applied here too for symmetry and as a guard against data corruption.

Changeset for shipping a transfer (draft -> in_transit, programmatic fields only — no cast). Requires both locations to already be set on the record (chosen earlier via changeset/2) and requires them to differ from each other.

Changeset for soft-deleting a transfer.

Changeset for setting the storage folder (programmatic — single field).

Types

t()

@type t() :: %PhoenixKitWarehouse.Transfer{
  __meta__: term(),
  cancelled_at: term(),
  created_by_uuid: term(),
  deleted_at: term(),
  deleted_by_uuid: term(),
  destination_location_uuid: term(),
  inserted_at: term(),
  lines: term(),
  note: term(),
  number: term(),
  performed_by_uuid: term(),
  received_at: term(),
  shipped_at: term(),
  source_location_uuid: term(),
  source_refs: term(),
  status: term(),
  storage_folder_uuid: term(),
  updated_at: term(),
  uuid: term()
}

Functions

cancel_changeset(transfer, attrs)

Changeset for cancelling a transfer (from draft or in_transit, programmatic fields only — no cast). attrs carries :performed_by_uuid and, only when cancelling from in_transit, :lines — the reverse-posting audit snapshot (see PhoenixKitWarehouse.Transfers.cancel_transfer/2). Cancelling from draft never touches :lines since no stock movement happened yet.

changeset(transfer, attrs)

Changeset for creating/editing a draft transfer. Both locations may be nil at this stage — the keeper hasn't necessarily chosen the source and destination warehouses yet. They only become mandatory when shipping (see ship_changeset/3).

correction_changeset(transfer, attrs)

Changeset for correcting a transfer (note + storage_folder only — lines/locations immutable once shipped).

receive_changeset(transfer, audited_lines, performed_by_uuid)

Changeset for receiving a transfer (in_transit -> done, programmatic fields only — no cast). Locations are already guaranteed to be set at this point (the transfer went through ship_changeset/3 first), but the same validate_required/2 is applied here too for symmetry and as a guard against data corruption.

ship_changeset(transfer, audited_lines, performed_by_uuid)

Changeset for shipping a transfer (draft -> in_transit, programmatic fields only — no cast). Requires both locations to already be set on the record (chosen earlier via changeset/2) and requires them to differ from each other.

Note: source_location_uuid/destination_location_uuid are not part of this changeset's own changes (they're read from transfer's existing data, unchanged), so the distinctness check is implemented via get_field/2 + add_error/3 rather than validate_change/3 — the latter only inspects changeset.changes and never fires for a field that isn't being changed. Mirrors the validate_no_self_parent/ validate_not_self_parent idiom used elsewhere in the PhoenixKit ecosystem (phoenix_kit_locations/schemas/space.ex, phoenix_kit_catalogue/schemas/category.ex).

soft_delete_changeset(transfer, attrs)

Changeset for soft-deleting a transfer.

statuses()

storage_changeset(transfer, attrs)

Changeset for setting the storage folder (programmatic — single field).