AuroraMeter.Schema.CreditBalance (Aurora Meter v0.4.0)

View Source

A tenant's prepaid credit balance, one row per tenant, in micro-dollars (1e-6 USD; see AuroraMeter.Credits.Money).

  • balance — everything granted minus everything settled, debited or expired; signed, because a settlement may exceed its hold.
  • held — the sum of pending holds; balance - held is what AuroraMeter.Credits.available/1 returns.
  • promotional — the part of balance that came from promotional grants; consumed before paid credit and the only part that can expire.
  • low_balance_threshold — per-tenant override of :credits_low_balance_threshold.

The row is only ever changed by the AuroraMeter.Credits ledger under a FOR UPDATE lock, alongside an AuroraMeter.Schema.CreditTransaction.

Summary

Functions

Builds a changeset for a balance row (used for the threshold setter).

Types

t()

@type t() :: %AuroraMeter.Schema.CreditBalance{
  __meta__: term(),
  balance: term(),
  currency: term(),
  held: term(),
  id: term(),
  inserted_at: term(),
  low_balance_threshold: term(),
  promotional: term(),
  tenant_key: term(),
  updated_at: term()
}

Functions

changeset(balance, attrs)

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

Builds a changeset for a balance row (used for the threshold setter).