> ## 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

> Define match rules that control how the engine pairs transactions across data sources for accurate reconciliation results.

Use the **Rules** section in the Matcher module 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. Rules are managed from within a context's detail page.

## Accessing the Rules section

***

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

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

  <Step>
    Scroll to the **Match Rules** section.
  </Step>
</Steps>

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

## Rules list

***

The table lists all match rules configured for the selected context, including their priority, type, and configuration.

## Creating a rule

***

<Steps>
  <Step>
    In the **Match Rules** section of the context detail page, click the **New Rule** button.
  </Step>

  <Step>
    A side panel opens. Fill in the rule details:

    | Field                    | Description                                                         |
    | ------------------------ | ------------------------------------------------------------------- |
    | **Priority** (required)  | Execution order (1–1000). Lower numbers run first.                  |
    | **Rule Type** (required) | The matching strategy to apply: `EXACT`, `TOLERANCE`, or `DATE_LAG` |

    Depending on the rule type, additional fields appear (see below).
  </Step>

  <Step>
    Click **Save Rule** to create the rule.
  </Step>
</Steps>

## Rule types

***

### EXACT

Matches transactions by comparing one or more fields for exact equality.

The **Advanced Settings** section exposes the following match field toggles and options:

| Field                         | Description                                             |
| ----------------------------- | ------------------------------------------------------- |
| **Amount**                    | Toggle on to match by transaction amount                |
| **Match currency**            | Toggle on to require currency match                     |
| **Date**                      | Toggle on to match by transaction date                  |
| **Match reference**           | Toggle on to match by reference field                   |
| **Date Precision**            | Precision level for date matching: `DAY` or `TIMESTAMP` |
| **Case insensitive matching** | Toggle on to ignore case when comparing string fields   |
| **Reference must be set**     | Toggle on to require a reference value for the match    |

### TOLERANCE

Matches transactions within a numeric or date tolerance range.

| Field                           | Description                                                           |
| ------------------------------- | --------------------------------------------------------------------- |
| **Amount Tolerance (Absolute)** | Maximum absolute difference in amount allowed                         |
| **Amount Tolerance (%)**        | Maximum percentage difference in amount allowed (e.g., `0.05` for 5%) |
| **Date Window (Days)**          | Number of days tolerance for date matching                            |

<Note>
  At least one tolerance value must be provided and must be greater than zero.
</Note>

The **Advanced Settings** section for TOLERANCE rules also includes:

| Field                         | Description                                                                                    |
| ----------------------------- | ---------------------------------------------------------------------------------------------- |
| **Rounding Mode**             | How values are rounded before comparison: `HALF_UP`, `BANKERS`, `FLOOR`, `CEIL`, or `TRUNCATE` |
| **Rounding Scale**            | Number of decimal places for rounding (0–10)                                                   |
| **Percentage Base**           | Base value for percentage calculations: `MAX`, `MIN`, `AVERAGE`, `LEFT`, or `RIGHT`            |
| **Match currency**            | Toggle on to require currency match                                                            |
| **Match reference**           | Toggle on to match by reference field                                                          |
| **Case insensitive matching** | Toggle on to ignore case when comparing string fields                                          |
| **Reference must be set**     | Toggle on to require a reference value                                                         |

### DATE\_LAG

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

| Field                   | Description                                        |
| ----------------------- | -------------------------------------------------- |
| **Min Days** (required) | Minimum days lag allowed between transaction dates |
| **Max Days** (required) | Maximum days lag allowed between transaction dates |

The **Advanced Settings** section for DATE\_LAG rules also includes:

| Field               | Description                                                                         |
| ------------------- | ----------------------------------------------------------------------------------- |
| **Inclusive range** | Toggle on to include boundary days in the range                                     |
| **Direction**       | Direction constraint: `ABS` (absolute), `LEFT_BEFORE_RIGHT`, or `RIGHT_BEFORE_LEFT` |
| **Fee Tolerance**   | Fee tolerance amount for date lag matching                                          |
| **Match currency**  | Toggle on to require currency match                                                 |

## Advanced settings (all rule types)

***

All rule types share these advanced options:

| Field                   | Description                                                 |
| ----------------------- | ----------------------------------------------------------- |
| **Match base amount**   | Toggle on to also match on the base (pre-conversion) amount |
| **Match base currency** | Toggle on to also match on the base currency                |
| **Match Score**         | Confidence score assigned to a primary match (0–100)        |
| **Base Match Score**    | Confidence score assigned to a base amount match (0–100)    |

## Allocation settings

***

All rule types include an **Allocation Settings** section for configuring partial allocation behavior:

| Field                              | Description                                                                |
| ---------------------------------- | -------------------------------------------------------------------------- |
| **Allow partial allocation**       | Toggle on to permit matching a single transaction to multiple counterparts |
| **Use base amount for allocation** | Toggle on to use base amount instead of converted amount for allocation    |
| **Allocation Direction**           | Direction of allocation: `LEFT_TO_RIGHT` or `RIGHT_TO_LEFT`                |
| **Tolerance Mode**                 | How allocation tolerance is measured: `ABS` (absolute) or `PERCENT`        |
| **Tolerance Value**                | Threshold for allocation tolerance (absolute or percentage based on mode)  |

## Editing a rule

***

Click the edit icon next to a rule to open the edit panel. Update the fields as needed and click **Update Rule**.

## Deleting a rule

***

Click the delete icon next to a rule and confirm the deletion.
