ExReconcile.Transaction (ExReconcile v0.1.0)

Copy Markdown View Source

Represents a single financial transaction.

Fields

  • :id - optional reference/correlation identifier (e.g. check number, payment reference). Used as the primary key when match_on: [:id] is set.
  • :date - optional Date.t() of the transaction.
  • :amount - required numeric amount. Use integers (e.g. cents) wherever possible to avoid floating-point precision issues during comparison.
  • :description - optional free-text narrative (payee name, memo, etc.).
  • :meta - arbitrary map for any extra fields you want to carry through (e.g. currency, account number, original CSV row). Not used in matching or diff output by default.

Examples

iex> ExReconcile.Transaction.new(amount: 1050, date: ~D[2024-03-01], description: "Coffee")
%ExReconcile.Transaction{amount: 1050, date: ~D[2024-03-01], description: "Coffee"}

iex> ExReconcile.Transaction.new(%{id: "TXN-42", amount: 5000})
%ExReconcile.Transaction{id: "TXN-42", amount: 5000}

Summary

Functions

Returns a short human-readable label for display in diffs and reports.

Build a Transaction from a keyword list or map.

Types

t()

@type t() :: %ExReconcile.Transaction{
  amount: number(),
  date: Date.t() | nil,
  description: String.t() | nil,
  id: term() | nil,
  meta: map()
}

Functions

label(txn)

@spec label(t()) :: String.t()

Returns a short human-readable label for display in diffs and reports.

Examples

iex> ExReconcile.Transaction.label(%ExReconcile.Transaction{amount: 1050, date: ~D[2024-01-15], description: "Coffee"})
"[2024-01-15] Coffee 1050"

new(fields)

@spec new(keyword() | map()) :: t()

Build a Transaction from a keyword list or map.

Raises KeyError if :amount is missing.

Examples

iex> ExReconcile.Transaction.new(amount: 100)
%ExReconcile.Transaction{amount: 100, meta: %{}}