ExReconcile.Config (ExReconcile v0.1.0)

Copy Markdown View Source

Configuration struct controlling how ExReconcile.reconcile/3 behaves.

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

Options

OptionTypeDefaultDescription
:match_on[atom][:amount, :date]Fields used to find candidate pairs.
:amount_tolerancenumber0Maximum absolute difference in amount that still counts as a match.
:date_tolerancenon_neg_integer0Maximum absolute difference in days for date matching.
:description_match:case_insensitive | :ignore:case_insensitiveHow 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}

Summary

Functions

Create a Config from options, validating all values.

Types

description_match()

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

t()

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

Functions

new(opts \\ [])

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

Create a Config from options, validating all values.

Raises ArgumentError on invalid input.