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

Configuration struct controlling how `ExReconcile.reconcile/3` behaves.

Build one via `new/1` (or pass keyword options directly to `ExReconcile.reconcile/3`).

## Options

| Option | Type | Default | Description |
|---|---|---|---|
| `:match_on` | `[atom]` | `[:amount, :date]` | Fields used to find candidate pairs. |
| `:amount_tolerance` | `number` | `0` | Maximum absolute difference in amount that still counts as a match. |
| `:date_tolerance` | `non_neg_integer` | `0` | Maximum absolute difference in days for date matching. |
| `:description_match` | `:case_insensitive \| :ignore` | `:case_insensitive` | How descriptions are compared when checking for discrepancies or matching. |

## Valid `match_on` fields

- `:id` - match when both transactions carry the same non-nil `:id`.
- `:amount` - match when `abs(left.amount - right.amount) <= amount_tolerance`.
- `:date` - match when `abs(Date.diff(left.date, right.date)) <= date_tolerance`.
- `:description` - match when descriptions are equal after normalisation (trim + downcase).

## Examples

    iex> ExReconcile.Config.new(match_on: [:id], amount_tolerance: 0)
    %ExReconcile.Config{match_on: [:id], amount_tolerance: 0, date_tolerance: 0, description_match: :case_insensitive}

    iex> ExReconcile.Config.new(match_on: [:amount, :date], date_tolerance: 2)
    %ExReconcile.Config{match_on: [:amount, :date], date_tolerance: 2, amount_tolerance: 0, description_match: :case_insensitive}

# `description_match`

```elixir
@type description_match() :: :case_insensitive | :ignore
```

# `t`

```elixir
@type t() :: %ExReconcile.Config{
  amount_tolerance: number(),
  date_tolerance: non_neg_integer(),
  description_match: description_match(),
  match_on: [atom()]
}
```

# `new`

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

Create a `Config` from options, validating all values.

Raises `ArgumentError` on invalid input.

---

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