Accrue.Billing.MeteredRenewalActions (accrue v1.1.1)

Copy Markdown View Source

Opens immutable metered renewal windows from canonical Braintree renewal evidence.

Summary

Functions

author_local_invoice(metered_renewal_id)

@spec author_local_invoice(Ecto.UUID.t()) ::
  {:ok,
   %{
     invoice: Accrue.Billing.Invoice.t(),
     renewal: Accrue.Billing.MeteredRenewal.t()
   }}
  | {:error, term()}

mark_invoice_authored(renewal, invoice, attrs \\ %{})

@spec mark_invoice_authored(
  Accrue.Billing.MeteredRenewal.t(),
  Accrue.Billing.Invoice.t(),
  map()
) ::
  {:ok, Accrue.Billing.MeteredRenewal.t()} | {:error, term()}

open_braintree_renewal_window(subscription_processor_id, evt_ts, evt_id, raw_type)

@spec open_braintree_renewal_window(
  String.t(),
  DateTime.t() | nil,
  String.t() | nil,
  String.t()
) :: {:ok, Accrue.Billing.MeteredRenewal.t() | :ignored} | {:error, term()}

process_metered_renewal(metered_renewal_id)

@spec process_metered_renewal(Ecto.UUID.t()) ::
  {:ok,
   %{
     attempt: Accrue.Billing.MeteredChargeAttempt.t() | nil,
     renewal: Accrue.Billing.MeteredRenewal.t()
   }}
  | {:error, term()}

settle_metered_renewal(metered_renewal_id, opts \\ [])

@spec settle_metered_renewal(
  Ecto.UUID.t(),
  keyword()
) ::
  {:ok,
   %{
     attempt: Accrue.Billing.MeteredChargeAttempt.t(),
     renewal: Accrue.Billing.MeteredRenewal.t()
   }}
  | {:error, term()}