Voile.Schema.Master.MemberType (Voile v0.1.23)

Copy Markdown View Source

Summary

Functions

Return the allowed collections map (jsonb) for policy checks

Return true if this member type can renew loans

Return true if this member type can make reservations

Compute ends_at given a start_date (DateTime) and the member type's membership_period_days. Returns {:ok, DateTime} or :no_period.

Compute next renewal datetime using recurrence_unit and recurrence_interval.

Return a map summarizing entitlements / quotas for UI or checks

Return true if member type is institutional

Max number of items this member type can borrow

Use for patch-style updates where not all fields are present

Functions

allowed_collections(member_type)

Return the allowed collections map (jsonb) for policy checks

can_renew?(member_type)

Return true if this member type can renew loans

can_reserve?(member_type)

@spec can_reserve?(
  t :: %Voile.Schema.Master.MemberType{
    __meta__: term(),
    allowed_collections: term(),
    auto_renew: term(),
    can_renew: term(),
    can_reserve: term(),
    currency: term(),
    description: term(),
    digital_access: term(),
    exhibition_preview_access: term(),
    fine_per_day: term(),
    id: term(),
    inserted_at: term(),
    institutional: term(),
    is_active: term(),
    max_concurrent_loans: term(),
    max_days: term(),
    max_event_bookings_per_year: term(),
    max_fine: term(),
    max_items: term(),
    max_renewals: term(),
    max_reserves: term(),
    membership_fee: term(),
    membership_period_days: term(),
    metadata: term(),
    name: term(),
    priority_level: term(),
    publicly_listed: term(),
    recurrence_interval: term(),
    recurrence_unit: term(),
    shop_discount_percent: term(),
    slug: term(),
    ticket_discount_percent: term(),
    updated_at: term()
  }
) :: boolean()

Return true if this member type can make reservations

compute_ends_at(member_type, start)

Compute ends_at given a start_date (DateTime) and the member type's membership_period_days. Returns {:ok, DateTime} or :no_period.

Example: MemberType.compute_ends_at(member_type, ~U[2025-01-01 00:00:00Z])

compute_next_renewal(mt, from)

Compute next renewal datetime using recurrence_unit and recurrence_interval.

  • Supports recurrence_unit: "days" out of the box.
  • For "months" or "years" we recommend using Timex or Calendar operations in your application code because months/years are variable-length. Returns {:ok, DateTime} | :not_applicable | {:error, reason}.

entitlement_summary(mt)

Return a map summarizing entitlements / quotas for UI or checks

institutional?(member_type)

Return true if member type is institutional

max_items(member_type)

Max number of items this member type can borrow

update_changeset(member_type, attrs \\ %{})

Use for patch-style updates where not all fields are present