ExReconcile.Result (ExReconcile v0.1.0)

Copy Markdown View Source

The structured output of ExReconcile.reconcile/3.

Fields

  • :matched - list of {left, right} pairs that were successfully reconciled with no field differences outside configured tolerances.
  • :discrepancies - list of {left, right, [field_diff]} tuples where the pair was matched (same key) but one or more fields differ beyond tolerance. Each field_diff is a map describing the field and the delta; see field_diff/0.
  • :unmatched_left - transactions from the left list with no counterpart in the right.
  • :unmatched_right - transactions from the right list with no counterpart in the left.

field_diff shape

# Amount discrepancy
%{field: :amount, left: 1050, right: 1000, delta: -50}

# Date discrepancy
%{field: :date, left: ~D[2024-01-15], right: ~D[2024-01-16], delta: 1}

# Description discrepancy
%{field: :description, left: "Coffee Shop", right: "COFFESHOP LTD"}

Summary

Functions

Returns true when the reconciliation is clean: no discrepancies and no unmatched transactions on either side.

Returns a summary map with counts for each category.

Types

discrepancy()

field_diff()

@type field_diff() ::
  %{field: :amount, left: number(), right: number(), delta: number()}
  | %{field: :date, left: Date.t(), right: Date.t(), delta: integer()}
  | %{field: :description, left: String.t(), right: String.t()}

pair()

t()

@type t() :: %ExReconcile.Result{
  discrepancies: [discrepancy()],
  matched: [pair()],
  unmatched_left: [ExReconcile.Transaction.t()],
  unmatched_right: [ExReconcile.Transaction.t()]
}

Functions

clean?(r)

@spec clean?(t()) :: boolean()

Returns true when the reconciliation is clean: no discrepancies and no unmatched transactions on either side.

Examples

iex> ExReconcile.Result.clean?(%ExReconcile.Result{})
true

iex> ExReconcile.Result.clean?(%ExReconcile.Result{unmatched_left: [%ExReconcile.Transaction{amount: 1}]})
false

summary(r)

@spec summary(t()) :: map()

Returns a summary map with counts for each category.

Examples

iex> result = %ExReconcile.Result{matched: [{"a", "b"}], unmatched_left: ["c"]}
iex> ExReconcile.Result.summary(result)
%{matched: 1, discrepancies: 0, unmatched_left: 1, unmatched_right: 0, total_left: 2, total_right: 1}