Accrue.Connect.Account (accrue v0.3.0)

Copy Markdown View Source

Ecto schema for accrue_connect_accounts — the local projection of a Stripe Connected Account (D5-02, CONN-01/03).

Predicates (D3-04, pattern 3)

Never inspect raw booleans on the account struct. Use the predicates below — each ships 3 clauses (struct match, bare-map match, catch-all) so they work equally well on %__MODULE__{} rows and on raw atom/string keyed maps returned from the processor before the changeset settles.

Changesets

  • changeset/2 — strict path; validates :type inclusion and requires [:stripe_account_id, :type].
  • force_status_changeset/2 — webhook path (D3-17); bypasses required validation so out-of-order account.updated reducers can settle arbitrary state without tripping the strict gate.

Summary

Functions

Builds a changeset for creating or updating a connected account. Validates :type and enforces the unique stripe_account_id constraint.

True if the account can accept charges.

True if the account has been deauthorized (D5-05).

True if the account owner finished the onboarding flow.

Webhook-path changeset (D3-17). Casts only the state fields so out-of-order account.updated reducers can settle arbitrary state without failing the user-path required-field guard.

True if the account has charges, payouts, AND onboarding completed — the canonical "ready to do business" predicate.

True if Stripe has approved payouts for the account.

Canonical list of Connect account types (D5-02).

Types

t()

@type t() :: %Accrue.Connect.Account{
  __meta__: term(),
  capabilities: term(),
  charges_enabled: term(),
  country: term(),
  data: term(),
  deauthorized_at: term(),
  details_submitted: term(),
  email: term(),
  id: term(),
  inserted_at: term(),
  lock_version: term(),
  owner_id: term(),
  owner_type: term(),
  payouts_enabled: term(),
  requirements: term(),
  stripe_account_id: term(),
  type: term(),
  updated_at: term()
}

Functions

changeset(account_or_changeset, attrs \\ %{})

@spec changeset(
  %Accrue.Connect.Account{
    __meta__: term(),
    capabilities: term(),
    charges_enabled: term(),
    country: term(),
    data: term(),
    deauthorized_at: term(),
    details_submitted: term(),
    email: term(),
    id: term(),
    inserted_at: term(),
    lock_version: term(),
    owner_id: term(),
    owner_type: term(),
    payouts_enabled: term(),
    requirements: term(),
    stripe_account_id: term(),
    type: term(),
    updated_at: term()
  }
  | Ecto.Changeset.t(),
  map()
) :: Ecto.Changeset.t()

Builds a changeset for creating or updating a connected account. Validates :type and enforces the unique stripe_account_id constraint.

charges_enabled?(arg1)

@spec charges_enabled?(
  %Accrue.Connect.Account{
    __meta__: term(),
    capabilities: term(),
    charges_enabled: term(),
    country: term(),
    data: term(),
    deauthorized_at: term(),
    details_submitted: term(),
    email: term(),
    id: term(),
    inserted_at: term(),
    lock_version: term(),
    owner_id: term(),
    owner_type: term(),
    payouts_enabled: term(),
    requirements: term(),
    stripe_account_id: term(),
    type: term(),
    updated_at: term()
  }
  | map()
) :: boolean()

True if the account can accept charges.

deauthorized?(arg1)

@spec deauthorized?(
  %Accrue.Connect.Account{
    __meta__: term(),
    capabilities: term(),
    charges_enabled: term(),
    country: term(),
    data: term(),
    deauthorized_at: term(),
    details_submitted: term(),
    email: term(),
    id: term(),
    inserted_at: term(),
    lock_version: term(),
    owner_id: term(),
    owner_type: term(),
    payouts_enabled: term(),
    requirements: term(),
    stripe_account_id: term(),
    type: term(),
    updated_at: term()
  }
  | map()
) :: boolean()

True if the account has been deauthorized (D5-05).

details_submitted?(arg1)

@spec details_submitted?(
  %Accrue.Connect.Account{
    __meta__: term(),
    capabilities: term(),
    charges_enabled: term(),
    country: term(),
    data: term(),
    deauthorized_at: term(),
    details_submitted: term(),
    email: term(),
    id: term(),
    inserted_at: term(),
    lock_version: term(),
    owner_id: term(),
    owner_type: term(),
    payouts_enabled: term(),
    requirements: term(),
    stripe_account_id: term(),
    type: term(),
    updated_at: term()
  }
  | map()
) :: boolean()

True if the account owner finished the onboarding flow.

force_status_changeset(account_or_changeset, attrs \\ %{})

@spec force_status_changeset(
  %Accrue.Connect.Account{
    __meta__: term(),
    capabilities: term(),
    charges_enabled: term(),
    country: term(),
    data: term(),
    deauthorized_at: term(),
    details_submitted: term(),
    email: term(),
    id: term(),
    inserted_at: term(),
    lock_version: term(),
    owner_id: term(),
    owner_type: term(),
    payouts_enabled: term(),
    requirements: term(),
    stripe_account_id: term(),
    type: term(),
    updated_at: term()
  }
  | Ecto.Changeset.t(),
  map()
) :: Ecto.Changeset.t()

Webhook-path changeset (D3-17). Casts only the state fields so out-of-order account.updated reducers can settle arbitrary state without failing the user-path required-field guard.

fully_onboarded?(acct)

@spec fully_onboarded?(
  %Accrue.Connect.Account{
    __meta__: term(),
    capabilities: term(),
    charges_enabled: term(),
    country: term(),
    data: term(),
    deauthorized_at: term(),
    details_submitted: term(),
    email: term(),
    id: term(),
    inserted_at: term(),
    lock_version: term(),
    owner_id: term(),
    owner_type: term(),
    payouts_enabled: term(),
    requirements: term(),
    stripe_account_id: term(),
    type: term(),
    updated_at: term()
  }
  | map()
) :: boolean()

True if the account has charges, payouts, AND onboarding completed — the canonical "ready to do business" predicate.

payouts_enabled?(arg1)

@spec payouts_enabled?(
  %Accrue.Connect.Account{
    __meta__: term(),
    capabilities: term(),
    charges_enabled: term(),
    country: term(),
    data: term(),
    deauthorized_at: term(),
    details_submitted: term(),
    email: term(),
    id: term(),
    inserted_at: term(),
    lock_version: term(),
    owner_id: term(),
    owner_type: term(),
    payouts_enabled: term(),
    requirements: term(),
    stripe_account_id: term(),
    type: term(),
    updated_at: term()
  }
  | map()
) :: boolean()

True if Stripe has approved payouts for the account.

types()

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

Canonical list of Connect account types (D5-02).