MoneyHub.Transactions (MoneyHub v1.0.0)

Copy Markdown View Source

Transaction data: list and fetch transactions, with date-range and account filtering, and manual category correction.

See Transactions and Categorising Transactions.

Summary

Functions

Creates a single manual transaction (for a manual, non-bank-connected account). attrs typically includes "accountId", "amount", "description", and "date".

Creates multiple manual transactions in a single call. transactions is a list of the same shape accepted by create/3.

Deletes a manual transaction (one created via create/3 or create_many/3).

Removes all splits from a transaction, merging it back into a single line.

Fetches a single transaction by id.

Lists transactions for the user identified by token.

Lists file attachments (e.g. receipts) attached to a transaction.

Lists the current splits on a transaction.

Splits a transaction into multiple parts, each with its own amount and category - for example splitting a supermarket trip into "groceries" and "household".

Updates arbitrary attributes on a transaction. Use update_category/4 for the common case of just correcting the category.

Corrects a transaction's category, recording the user's override (and training future automatic categorisation for similar transactions).

Replaces a transaction's splits with a new set.

Types

transaction()

@type transaction() :: map()

Functions

create(config, token, attrs)

@spec create(MoneyHub.Config.t(), String.t(), map()) ::
  {:ok, transaction()} | {:error, MoneyHub.Error.t()}

Creates a single manual transaction (for a manual, non-bank-connected account). attrs typically includes "accountId", "amount", "description", and "date".

create_many(config, token, transactions)

@spec create_many(MoneyHub.Config.t(), String.t(), [map()]) ::
  {:ok, [transaction()]} | {:error, MoneyHub.Error.t()}

Creates multiple manual transactions in a single call. transactions is a list of the same shape accepted by create/3.

delete(config, token, transaction_id)

@spec delete(MoneyHub.Config.t(), String.t(), String.t()) ::
  :ok | {:error, MoneyHub.Error.t()}

Deletes a manual transaction (one created via create/3 or create_many/3).

delete_splits(config, token, transaction_id)

@spec delete_splits(MoneyHub.Config.t(), String.t(), String.t()) ::
  :ok | {:error, MoneyHub.Error.t()}

Removes all splits from a transaction, merging it back into a single line.

get(config, token, transaction_id)

@spec get(MoneyHub.Config.t(), String.t(), String.t()) ::
  {:ok, transaction()} | {:error, MoneyHub.Error.t()}

Fetches a single transaction by id.

list(config, token, opts \\ [])

@spec list(MoneyHub.Config.t(), String.t(), keyword()) ::
  {:ok, [transaction()]} | {:error, MoneyHub.Error.t()}

Lists transactions for the user identified by token.

Options

  • :account_id - filter to a single account.
  • :from_date / :to_date - ISO 8601 date strings ("2024-01-01").
  • :category - filter by category id.
  • :limit / :offset - pagination.

list_files(config, token, transaction_id)

@spec list_files(MoneyHub.Config.t(), String.t(), String.t()) ::
  {:ok, [map()]} | {:error, MoneyHub.Error.t()}

Lists file attachments (e.g. receipts) attached to a transaction.

list_splits(config, token, transaction_id)

@spec list_splits(MoneyHub.Config.t(), String.t(), String.t()) ::
  {:ok, [map()]} | {:error, MoneyHub.Error.t()}

Lists the current splits on a transaction.

split(config, token, transaction_id, splits)

@spec split(MoneyHub.Config.t(), String.t(), String.t(), [map()]) ::
  {:ok, transaction()} | {:error, MoneyHub.Error.t()}

Splits a transaction into multiple parts, each with its own amount and category - for example splitting a supermarket trip into "groceries" and "household".

splits is a list of %{"amount" => amount, "category" => category_id} maps. See Transaction Splits.

update(config, token, transaction_id, attrs)

@spec update(MoneyHub.Config.t(), String.t(), String.t(), map()) ::
  {:ok, transaction()} | {:error, MoneyHub.Error.t()}

Updates arbitrary attributes on a transaction. Use update_category/4 for the common case of just correcting the category.

update_category(config, token, transaction_id, category_id)

@spec update_category(MoneyHub.Config.t(), String.t(), String.t(), String.t()) ::
  {:ok, transaction()} | {:error, MoneyHub.Error.t()}

Corrects a transaction's category, recording the user's override (and training future automatic categorisation for similar transactions).

update_splits(config, token, transaction_id, splits)

@spec update_splits(MoneyHub.Config.t(), String.t(), String.t(), [map()]) ::
  {:ok, transaction()} | {:error, MoneyHub.Error.t()}

Replaces a transaction's splits with a new set.