View Source Glific.Partners.Invoice (Glific v5.1.6)

Invoice model wrapper

Link to this section Summary

Functions

Standard changeset pattern we use for all data types

Return the count of invoices, based on filters

Create an invoice record

Fetch an invoice record by clauses

Update an invoice record

Update the status of an invoice

Link to this section Types

@type t() :: %Glific.Partners.Invoice{
  __meta__: Ecto.Schema.Metadata.t(),
  amount: integer(),
  consulting_hours: integer(),
  customer_id: String.t() | nil,
  end_date: :utc_datetime_usec | nil,
  id: non_neg_integer() | nil,
  inserted_at: :utc_datetime | nil,
  invoice_id: String.t() | nil,
  line_items: map(),
  messages: integer(),
  organization:
    Glific.Partners.Organization.t() | Ecto.Association.NotLoaded.t() | nil,
  organization_id: non_neg_integer() | nil,
  start_date: :utc_datetime_usec | nil,
  status: String.t() | nil,
  updated_at: :utc_datetime | nil,
  users: integer()
}

Link to this section Functions

Link to this function

changeset(invoice, attrs)

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

Standard changeset pattern we use for all data types

@spec count_invoices(map()) :: integer()

Return the count of invoices, based on filters

@spec create_invoice(map()) :: {:ok, t()} | {:error, String.t()}

Create an invoice record

@spec fetch_invoice(map()) :: t() | nil

Fetch an invoice record by clauses

Link to this function

update_invoice(invoice, attrs)

View Source
@spec update_invoice(t(), map()) :: t() | {:error, Ecto.Changeset.t()}

Update an invoice record

Link to this function

update_invoice_status(invoice_id, status)

View Source
@spec update_invoice_status(non_neg_integer(), String.t()) ::
  {:ok | :error, String.t()}

Update the status of an invoice