> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Context rules

> Create and manage EXACT, TOLERANCE, DATE_LAG, and FUZZY match rules from the Rules tab of a context's setup page in the Matcher UI.

Use the **Rules** tab in a context's setup page to define and manage match rules that control how transactions are paired during reconciliation. Rules specify the criteria the match engine uses to identify corresponding transactions across data sources.

## Accessing the Rules tab

***

<Steps>
  <Step>
    Navigate to **Configure → Contexts** in the left sidebar.
  </Step>

  <Step>
    Select a context from the list to open its setup page.
  </Step>

  <Step>
    Select the **Rules** tab.
  </Step>
</Steps>

<Note>
  The global **Context Switcher** in the sidebar lets you change the active reconciliation context at any time.
</Note>

## Rules list

***

The Rules tab lists match rules in priority order. Rules evaluate top to bottom; the first match wins. Each visible row shows the rule's strategy and a short configuration summary, with **Move rule up** / **Move rule down** arrows, an **Edit rule** button, and a **Delete rule** button.

For contexts with 100 rules or fewer, priority is assigned automatically when you create a rule — a new rule is appended to the end of the chain. To change precedence, reorder the list with the up/down arrows. There is no priority field in the form.

<Warning>
  The Rules tab loads only the first 100 rules by priority and provides no pagination. Rules after that cannot be viewed or managed here. **Add rule** derives the new priority from those 100 rules; once a rule at priority 101 is hidden, the next creation attempt conflicts with it and fails.
</Warning>

## Creating a rule

***

<Steps>
  <Step>
    In the **Rules** tab, click the **Add rule** button.
  </Step>

  <Step>
    A dialog opens. Select a **Strategy**:

    | Strategy      | Description                      |
    | ------------- | -------------------------------- |
    | **Exact**     | Field-for-field equality         |
    | **Tolerance** | Amount/date within a band        |
    | **Date lag**  | Settlement delay window          |
    | **Fuzzy**     | Approximate reference similarity |

    Depending on the strategy, different fields appear (see below).
  </Step>

  <Step>
    Click **Create rule**.
  </Step>
</Steps>

<Warning>
  Strategy is fixed after creation. To change a rule's strategy, delete the rule and recreate it.
</Warning>

## Rule types

***

### EXACT

Matches transactions by comparing fields for exact equality.

Top-level toggles:

| Field               | Description                 |
| ------------------- | --------------------------- |
| **Match amount**    | Compare transaction amounts |
| **Match currency**  | Require currency equality   |
| **Match date**      | Compare transaction dates   |
| **Match reference** | Compare reference fields    |

The **Advanced** section adds:

| Field                                  | Description                                                                                                                                                |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Date precision**                     | Precision for date comparison: `DAY` or `TIMESTAMP`                                                                                                        |
| **Case-insensitive reference compare** | Ignore case when comparing references                                                                                                                      |
| **Reference must be present**          | When **Match reference** is enabled, require a non-empty reference value                                                                                   |
| **Match base amount**                  | Also match on the base (pre-conversion) amount                                                                                                             |
| **Match base currency**                | Also match on the base currency                                                                                                                            |
| **Sign mode**                          | How amount signs compare: `same` matches like signs, `opposite` matches a refund against its charge, `ignore` compares magnitudes only                     |
| **Match score**                        | Accepted configuration value (0–100). It is stored but does not determine awarded confidence, which uses the engine's fixed weighted comparison components |
| **Base-match score**                   | Accepted configuration value (0–100). It is stored but does not determine awarded confidence                                                               |
| **Allocation (1:N / N:1)**             | Partial allocation settings (see below)                                                                                                                    |
| **Match fields**                       | Composite-key editor for matching on additional named fields, combined with the toggles above                                                              |

### TOLERANCE

Matches transactions within a numeric or date tolerance band.

Top-level fields:

| Field                  | Description                                                                                                                              |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Absolute tolerance** | Fixed amount tolerance. The effective amount band uses the larger of this and the percentage-derived amount tolerance                    |
| **Percent tolerance**  | Percentage-derived amount tolerance (e.g., `0.005` = 0.5%). The effective amount band uses the larger of this and the absolute tolerance |
| **Date window (days)** | Allowed date drift between sides (0–3650)                                                                                                |
| **Match currency**     | Require currency equality                                                                                                                |

<Note>
  Zero tolerances are valid — both values default to `0`, which makes the amount band require equality after the default `HALF_UP` rounding at scale `2`.
</Note>

The **Advanced** section adds:

| Field                                           | Description                                                                                                                                                                                       |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Rounding mode**                               | How values round before comparison: `HALF_UP`, `BANKERS`, `FLOOR`, `CEIL`, or `TRUNCATE`                                                                                                          |
| **Rounding scale**                              | Decimal places for rounding (0–10)                                                                                                                                                                |
| **Percentage base**                             | Which side the percent tolerance is measured against: `MAX`, `MIN`, `AVERAGE`, `LEFT`, or `RIGHT`                                                                                                 |
| **Match reference**                             | Compare reference fields                                                                                                                                                                          |
| **Case-insensitive reference compare**          | Ignore case when comparing references                                                                                                                                                             |
| **Reference must be present**                   | When **Match reference** is enabled, require a non-empty reference value                                                                                                                          |
| **Match base amount** / **Match base currency** | Also match on the base amount/currency                                                                                                                                                            |
| **Sign mode**                                   | `same`, `opposite`, or `ignore` (as for EXACT)                                                                                                                                                    |
| **Match score** / **Base-match score**          | Accepted configuration values (0–100). They are stored but do not determine awarded confidence, which uses the engine's fixed weighted comparison components                                      |
| **FX variance band**                            | Extra cross-currency tolerance above the match band, as a decimal fraction (`0.0001` = 1 basis point). A residual within it still matches and records an FX rate-variance exception; `0` disables |
| **Lockbox deduction band**                      | Short-pay tolerance for N:M lockbox matching, as a decimal fraction of the invoice face (`0.05` = 5%); `0` disables                                                                               |
| **Business-day & timezone**                     | Holiday calendar and timezone for date comparison                                                                                                                                                 |
| **Allocation (1:N / N:1)**                      | Partial allocation settings (see below)                                                                                                                                                           |
| **Match fields**                                | Composite-key editor, as for EXACT                                                                                                                                                                |

### DATE\_LAG

Matches transactions that occur within a configurable number of days of each other.

Top-level fields:

| Field                | Description                                                                                         |
| -------------------- | --------------------------------------------------------------------------------------------------- |
| **Min days**         | Minimum day lag allowed (0–3650; defaults to `0`)                                                   |
| **Max days**         | Maximum day lag allowed (0–3650; defaults to `0`)                                                   |
| **Direction**        | Which side is expected to be earlier: `ABS` (absolute), `LEFT_BEFORE_RIGHT`, or `RIGHT_BEFORE_LEFT` |
| **Inclusive bounds** | Include the min/max day boundaries                                                                  |

<Note>
  **Max days** must be greater than or equal to **Min days**. Exclusive bounds (`Inclusive bounds` off) with **Min days** set to `0` are rejected, because that would exclude same-day transactions.
</Note>

The **Advanced** section adds:

| Field                                  | Description                                                                                                                                                                                                                                |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Fee tolerance**                      | Maximum absolute difference between the transaction amounts (defaults to `0`)                                                                                                                                                              |
| **Match currency**                     | Require currency equality                                                                                                                                                                                                                  |
| **Match reference**                    | Off by default; enable to require reference equality                                                                                                                                                                                       |
| **Case-insensitive reference compare** | Ignore case when comparing references                                                                                                                                                                                                      |
| **Reference must be present**          | When **Match reference** is enabled, require a non-empty reference value                                                                                                                                                                   |
| **Match score**                        | Accepted configuration value (0–100). It is stored but does not determine awarded confidence, which uses the engine's fixed weighted comparison components                                                                                 |
| **Business-day & timezone**            | **Holiday calendar** (`US Federal` or `Brazil ANBIMA`), **Timezone** (IANA zone, defaults to UTC), and **Count business days only** — measure the lag in business days, skipping the calendar's weekends and holidays. Requires a calendar |
| **Allocation (1:N / N:1)**             | Partial allocation settings (see below)                                                                                                                                                                                                    |

DATE\_LAG rules have no base-amount options (`Match base amount` / `Match base currency` are only available on EXACT and TOLERANCE).

### FUZZY

Matches transactions by approximate reference similarity, with configurable financial checks on amount, currency, and date. Fuzzy matches always propose for review — they never auto-confirm.

Top-level fields:

| Field                  | Description                                                                                                                                                                                                                         |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Minimum similarity** | Reference similarity threshold as a ratio from 0 to 1 (`0.80` = 80% similar). References below it are rejected; if they clear it and the enabled financial checks pass, the pair receives a graded confidence score. Default `0.80` |
| **Match amount**       | Compare transaction amounts                                                                                                                                                                                                         |
| **Match currency**     | Require currency equality                                                                                                                                                                                                           |
| **Match date**         | Compare transaction dates                                                                                                                                                                                                           |

The **Advanced** section adds:

| Field                         | Description                                                                                                                                                                                              |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Date precision**            | `DAY` or `TIMESTAMP`                                                                                                                                                                                     |
| **Reference must be present** | Defaults to on — two blank references would otherwise compare as fully similar                                                                                                                           |
| **Sign mode**                 | `same`, `opposite`, or `ignore`                                                                                                                                                                          |
| **Match score**               | Accepted configuration value (0–100; default `70`). It is stored but does not determine awarded confidence; fuzzy confidence uses the engine's fixed weighted components and graded reference similarity |
| **Allocation (1:N / N:1)**    | Partial allocation settings (see below)                                                                                                                                                                  |

FUZZY rules have no reference-equality toggle and no base-amount options.

## Allocation settings

***

EXACT, TOLERANCE, DATE\_LAG, and FUZZY rules include an **Allocation (1:N / N:1)** block inside the **Advanced** section:

| Field                          | Description                                                                                                                              |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Allow partial allocation**   | Match a set of items against one counterpart, splitting the amount across them; an unallocated remainder carries forward as an open item |
| **Fee-aware split**            | Consume each leg's gross share (net + fee) from the counterpart instead of its net amount alone. Off uses net only                       |
| **Allocation direction**       | Order legs are consumed in; defaults to left-to-right                                                                                    |
| **Allocation tolerance mode**  | How the residual is bounded: `ABS` (absolute amount) or `PERCENT` (fraction, `0.01` = 1%). Defaults to `ABS`                             |
| **Allocation tolerance value** | Residual the split may leave; defaults to `0`                                                                                            |
| **Allocate on base amount**    | Use the base amount instead of the converted amount for allocation                                                                       |

## Previewing a rule

***

The rule dialog includes a **Preview matches** panel. Click **Run preview** to test the rule before saving. The preview is read-only: it uses up to 5,000 extraction-complete unmatched transactions, forms only 1:1 pairs, and does not apply fee normalization, FX variance bands, or allocation. The panel shows how many pairs **Would match**, the unmatched left/right counts, and up to 25 highest-scoring would-match pairs. Nothing is saved.

## Editing a rule

***

Click the **Edit rule** button on a rule to open the dialog. The **Strategy** selector is disabled — strategy is fixed after creation. Update the remaining fields and click **Save changes**.

## Reordering rules

***

Use the **Move rule up** / **Move rule down** arrows on the list to change rule precedence. Rules evaluate top to bottom; the first match wins.

## Deleting a rule

***

Click the **Delete rule** button on a rule and confirm in the **Delete rule?** dialog. The rule is removed from the chain; remaining rules keep their order.
