# `ExReconcile.Transaction`
[🔗](https://github.com/ARTARNA/ex_reconcile/blob/v0.1.0/lib/ex_reconcile/transaction.ex#L1)

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}

# `t`

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

# `label`

```elixir
@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`

```elixir
@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: %{}}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
