PhoenixKitStaff.Schemas.Employment (PhoenixKitStaff v0.6.0)

Copy Markdown View Source

One span in a staff person's employment history (core V136).

Each row records an employment period: the employment_type, a translatable job_title, the org placement at the time (primary_department_uuid plus a primary_team_uuid snapshot), the date range (employment_end_date nil = the open/current span), work_location, and free-text notes.

The DB enforces at most one open span per person (partial unique index on staff_person_uuid WHERE employment_end_date IS NULL); PhoenixKitStaff.Employments is the sole write path and closes the prior open span when a new one starts, then denormalizes the current span onto Person (sync_current/1).

job_title is translatable (same translations JSONB shape as Person/Skill).

Summary

Functions

Translated job_title in lang (primary-column fallback).

Whether this span is the open/current one (no end date).

DB-column field names that participate in the translations JSONB.

Types

t()

@type t() :: %PhoenixKitStaff.Schemas.Employment{
  __meta__: term(),
  department:
    PhoenixKitStaff.Schemas.Department.t()
    | Ecto.Association.NotLoaded.t()
    | nil,
  employment_end_date: Date.t() | nil,
  employment_start_date: Date.t() | nil,
  employment_type: String.t() | nil,
  inserted_at: DateTime.t() | nil,
  job_title: String.t() | nil,
  notes: String.t() | nil,
  person:
    PhoenixKitStaff.Schemas.Person.t() | Ecto.Association.NotLoaded.t() | nil,
  primary_department_uuid: UUIDv7.t() | nil,
  primary_team_uuid: UUIDv7.t() | nil,
  staff_person_uuid: UUIDv7.t() | nil,
  team: PhoenixKitStaff.Schemas.Team.t() | Ecto.Association.NotLoaded.t() | nil,
  translations: translations_map(),
  updated_at: DateTime.t() | nil,
  uuid: UUIDv7.t() | nil,
  work_location: String.t() | nil
}

translations_map()

@type translations_map() :: %{
  optional(String.t()) => %{optional(String.t()) => String.t()}
}

Functions

changeset(employment, attrs)

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

localized_job_title(e, lang)

@spec localized_job_title(t(), String.t() | nil) :: String.t() | nil

Translated job_title in lang (primary-column fallback).

open?(employment)

@spec open?(t()) :: boolean()

Whether this span is the open/current one (no end date).

translatable_fields()

@spec translatable_fields() :: [String.t()]

DB-column field names that participate in the translations JSONB.