> For the complete documentation index, see [llms.txt](https://docs.fulfillmenttools.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/doms-toolkit.md).

# Custom routing rules

Custom routing rules (previously known as the DOMS toolkit) help users define factors to consider when selecting the best fulfillment location.

{% hint style="info" %}
Custom routing rules can be created in Backoffice or via API. We recommend using Backoffice to reduce errors. You'll still need to understand how to work with [JSONPath](#introduction-to-jsonpath).
{% endhint %}

You can define fences and ratings:

* [**Fences**](https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/fences.md): Exclude facilities from order routing based on to the selected fences.
* [**Ratings**](https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/ratings.md): Weigh facilities against each other based on the selected ratings.

The table below outlines the fields for custom routing rule fences and ratings within the [routing strategy endpoint](https://docs.fulfillmenttools.com/documentation/apis/api-reference/routing-strategies.md).

<table data-search="false"><thead><tr><th>Field</th><th>Type<select><option value="BQFMQ2JEufL7" label="string" color="blue"></option><option value="ybktxGmgoaR0" label="boolean" color="blue"></option><option value="EguBBKHgvGpP" label="number" color="blue"></option><option value="ODcle6tNybMD" label="enum" color="blue"></option><option value="BCi55ZZwc5S0" label="integer" color="blue"></option><option value="7XzmHyLaWihO" label="object" color="blue"></option></select></th><th>Description</th><th>Possible values</th></tr></thead><tbody><tr><td><code>name</code></td><td><span data-option="BQFMQ2JEufL7">string</span></td><td>The name of the fence. It must be unique.</td><td></td></tr><tr><td><code>nameLocalized</code></td><td><span data-option="BQFMQ2JEufL7">string</span></td><td>An object containing the localized names of the fence for different languages.</td><td></td></tr><tr><td><code>description</code></td><td><span data-option="BQFMQ2JEufL7">string</span></td><td>An optional description to say what the fence has to do. Although optional, it's recommended that you provide a meaningful description.</td><td></td></tr><tr><td><code>descriptionLocalized</code></td><td><span data-option="BQFMQ2JEufL7">string</span></td><td>An object containing the localized descriptions for different languages.</td><td></td></tr><tr><td><code>entity1</code></td><td><span data-option="ODcle6tNybMD">enum</span></td><td>The entity type for the left side. For conditional rules, this is the entity that's evaluated first.</td><td><ul><li><code>ORDER</code></li><li><code>ORDERING_FACILITY</code></li><li><code>ORDERING_FACILITY_GROUPS</code></li></ul></td></tr><tr><td><code>entity2</code></td><td><span data-option="ODcle6tNybMD">enum</span></td><td>The entity type for the right side. For conditional rules, this is the entity that gets evaluated second (or not at all).</td><td><ul><li><code>FACILITY</code></li><li><code>CARRIERCONNECTION</code></li><li><code>LISTING</code></li></ul></td></tr><tr><td><code>type</code></td><td><span data-option="ODcle6tNybMD">enum</span></td><td>Defines whether it's a custom fence or rating.</td><td><ul><li><code>ToolkitFence</code></li><li><code>ToolkitRating</code></li></ul></td></tr><tr><td><code>referenceId</code></td><td><span data-option="BQFMQ2JEufL7">string</span></td><td>An identifier for the fence or the rating. Use a descriptive identifier.</td><td></td></tr><tr><td><code>active</code></td><td><span data-option="ybktxGmgoaR0">boolean</span></td><td>Defines whether the fence or rating is active.</td><td><ul><li><code>true</code></li><li><code>false</code></li></ul></td></tr><tr><td><code>order</code></td><td><span data-option="BCi55ZZwc5S0">integer</span></td><td>Fences only. Determines whether the fence should be executed before or after different fences. Lower numbers have precedence over higher numbers.</td><td></td></tr><tr><td><code>maxPenalty</code></td><td><span data-option="BCi55ZZwc5S0">integer</span></td><td>Ratings only. Determines the weight of the rating in comparison to other ratings. The higher the number, the more important it is.</td><td></td></tr><tr><td><code>rule</code></td><td><span data-option="7XzmHyLaWihO">object</span></td><td>Defines the <a href="#conditional-rule">Conditional rule settings</a>.</td><td></td></tr><tr><td><code>comparisonRule</code></td><td><span data-option="7XzmHyLaWihO">object</span></td><td>Defines the <a href="#comparison-rule">Comparison rule settings</a>.</td><td></td></tr><tr><td><code>optionAggregation</code></td><td><span data-option="ODcle6tNybMD">enum</span></td><td>Ratings evaluating the <code>FACILITY</code> entity only. Only applicable in <a href="https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/complex-routing-with-combinatorics.md">complex routing with combinatorics</a>. Defines how the penalties of the individual facilities within one routing option are aggregated into a single penalty for that option. See the <a href="#option-aggregation">Option aggregation section</a>. Defaults to <code>SUM</code>.</td><td><ul><li><code>MIN</code></li><li><code>MAX</code></li><li><code>SUM</code></li></ul></td></tr></tbody></table>

## Rules

Two rule types that can be defined:

* [Conditional rule](#conditional-rule)
* [Comparison rule](#comparison-rule)

### Conditional rule

Use `rule` to set up a conditional rule. Conditional rules test a certain property of an entity (`order`, `facility`, `listing`) against a predefined static value. It can be used for comparing each side against a fixed value (for example, an order line item has a quantity greater than 3).

It can't be used when using the `comparisonRule` field.

A conditional rule must include:

| Field                 | Description                                                                                                                                                                                                                                                                                       | Possible values                                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **`evaluationScope`** | Defines whether the order is evaluated as a single unit (`WHOLE_ENTITY`), whether each `LINE_ITEM` is evaluated separately, or whether only items of a single transfer are considered (`ASSIGNED_TRANSFER`, fences only). See the [Evaluation scope section](#evaluation-scope) for more details. | <ul><li><code>WHOLE\_ENTITY</code></li><li><code>LINE\_ITEM</code></li><li><code>ASSIGNED\_TRANSFER</code></li></ul> |
| **`leftPart`**        | The first part that's evaluated. The evaluation result determines whether the right part gets evaluated. It consists of an array of `predicates` and a `predicateConnector` that determines how they are connected.                                                                               | See the [Conditional rule parts section](#conditional-rule-parts).                                                   |
| **`operator`**        | What the positive evaluation of the left side means for the execution of the fence as a whole. For now, there is only the equals operator.                                                                                                                                                        | <ul><li><code>EQUALS</code></li></ul>                                                                                |
| **`rightPart`**       | The second part is evaluated if the first evaluation passes. Its evaluation result determines the outcome of the fence. It consists of an array of `predicates` and a `predicateConnector` that determines how they are connected.                                                                | See the [Conditional rule parts section](#conditional-rule-parts).                                                   |

#### Conditional rule parts

The `leftPart` and the `rightPart` of a conditional rule must contain at least one `predicates`. If more than one is used, a `predicateConnector` must also be defined.

| Field                    | Description                                                                                                                                                         | Possible values                                                              |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| **`predicates`**         | An array of one or more predicates.                                                                                                                                 | See the [Conditional rule predicates section](#conditional-rule-predicates). |
| **`predicateConnector`** | `AND` will only make the expression `true` if all predicates evaluate to true. `OR` will make the rule expression `true` if any of the predicates evaluate to true. | <ul><li><code>AND</code></li><li><code>OR</code></li></ul>                   |

#### Conditional rule predicates

`predicates` is an array that consists of the following fields. At least one predicate must be defined. Maximum of 100 predicates.

| Field                    | Description                                                                                                                                             | Possible values                                                                                                                                                                                                                                                  |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`entity`**             | The entity type that can be compared.                                                                                                                   | <ul><li><code>ORDER</code></li><li><code>FACILITY</code></li><li><code>CARRIERCONNECTION</code></li><li><code>LISTING</code></li><li><code>ORDERING\_FACILITY</code> (left side only)</li><li><code>ORDERING\_FACILITY\_GROUPS</code> (left side only)</li></ul> |
| **`entityOperator`**     | The operators determine how an entity's property should be compared to a given value.                                                                   | See the [Entity operators section](#conditional-rules-entity-operators).                                                                                                                                                                                         |
| **`propertyPath`**       | A [JSONPath](#introduction-to-jsonpath) expression defining the property to look at.                                                                    | See the [JSONPath section](#introduction-to-jsonpath).                                                                                                                                                                                                           |
| **`expectedValue`**      | The expected value that the property should match. For example, `2` (`number`), `"WAREHOUSE"` (`string`), `"2024-02-19T16:16:38.107Z"` (`date-string`). |                                                                                                                                                                                                                                                                  |
| **`transformation`**     | \[optional] A [transformation](#transformers).                                                                                                          | See the [Transformers section](#transformers).                                                                                                                                                                                                                   |
| **`transformationArgs`** | \[optional] The arguments for the transformation, if required.                                                                                          | Depends on the `transformation` used. See the [Transformers section](#transformers).                                                                                                                                                                             |

#### Conditional rules entity operators

An `entityOperator` determines how an entity's property should be compared to a given value. They can be divided into two groups: Single value entity operators and array entity operators.

**Single value entity operators**

These operators can only be used for single values, not for arrays.

<table data-search="false"><thead><tr><th>Operator</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>VALUE_EQUALS</code></td><td>Actual value equals <code>expectedValue</code></td><td><code>2 == 2</code></td></tr><tr><td><code>VALUE_NOT_EQUALS</code></td><td>Actual value is not equal to the <code>expectedValue</code></td><td><code>2 != 3</code></td></tr><tr><td><code>VALUE_CONTAINS</code></td><td>Actual value contains <code>expectedValue</code></td><td>The value is <code>HELLO WORLD</code>, and the <code>expectedValue</code> is <code>HELLO</code></td></tr><tr><td><code>VALUE_NOT_CONTAINS</code></td><td>Actual value doesn't contain <code>expectedValue</code></td><td>The value is <code>HELLO WORLD</code>, and <code>expectedValue</code> is <code>HI</code></td></tr><tr><td><code>LESS_THAN</code></td><td>Actual value is less than <code>expectedValue</code></td><td><code>2 &#x3C; 3</code></td></tr><tr><td><code>LESS_EQUALS</code></td><td>Actual value is less than or equal to the <code>expectedValue</code></td><td><code>2 &#x3C;= 3</code>, <code>3 &#x3C;= 3</code></td></tr><tr><td><code>GREATER_THAN</code></td><td>Actual value is greater than the <code>expectedValue</code></td><td><code>3 > 2</code></td></tr><tr><td><code>GREATER_EQUALS</code></td><td>Actual value is greater than or equal to <code>expectedValue</code></td><td><code>3 >= 2</code>, <code>2 >= 2</code></td></tr></tbody></table>

**Array entity operators**

These operators can only be used for arrays, not for single values. They can be grouped into three categories:

* `ANY`: Requires that at least one element of the array satisfies the following condition. If the array is empty, this condition won't be fulfilled.
* `EVERY`: Requires that every element of the array satisfies the following condition. If the array is empty, this condition will be true because no element doesn't fulfill the condition.
* `NONE`: Requires that no element satisfies the following condition, meaning that every element doesn't satisfy the condition. This condition will always be fulfilled, unless there is an element that satisfies the condition, including for empty arrays.

Possible operator values:

{% columns %}
{% column width="33.33333333333333%" %}
`ANY_VALUE_EQUALS`

`ANY_VALUE_GREATER_EQUALS`

`ANY_VALUE_GREATER_THAN`

`ANY_VALUE_LESS_EQUALS`

`ANY_VALUE_LESS_THAN`

`ANY_VALUE_NOT_CONTAINS`
{% endcolumn %}

{% column width="33.33333333333333%" %}
`EVERY_VALUE_EQUALS`

`EVERY_VALUE_GREATER_EQUALS`

`EVERY_VALUE_GREATER_THAN`

`EVERY_VALUE_LESS_EQUALS`

`EVERY_VALUE_LESS_THAN`

`EVERY_VALUE_CONTAINS`

`EVERY_VALUE_NOT_CONTAINS`
{% endcolumn %}

{% column %}
`NO_VALUE_EQUALS`

`NO_VALUE_GREATER_EQUALS`

`NO_VALUE_GREATER_THAN`

`NO_VALUE_LESS_EQUALS`

`NO_VALUE_LESS_THAN`

`NO_VALUE_CONTAINS`

`NO_VALUE_NOT_CONTAINS`
{% endcolumn %}
{% endcolumns %}

**Single value operators versus array operators**

If your actual value is an array, you have to use an array operator. For example, if you use a wildcard operator (`*` or `?()`), you'll get an array of elements (such as `$.orderLineItems[*]`). However, if you use a transformer (such as `COUNT` to get the number of elements or `SUM` to add the quantities of each `orderLineItem`), then you will get a single value and must use a single value operator.

### Comparison rule

Use `comparisonRule` to set up a comparison rule. Comparison rules compare a property of the left-hand side (`order`) with a property of the right-hand side (`order`, `facility`, `listing`). Incompatible with using the rule field.

An example of this could be an order with products of a certain brand that requires a facility tagged with the same brand.

A comparison rule must include:

| Field                    | Description                                                                                                                                                                                                                                                                                       | Possible values                                                                                                      |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **`evaluationScope`**    | Defines whether the order is evaluated as a single unit (`WHOLE_ENTITY`), whether each `LINE_ITEM` is evaluated separately, or whether only items of a single transfer are considered (`ASSIGNED_TRANSFER`, fences only). See the [Evaluation scope section](#evaluation-scope) for more details. | <ul><li><code>WHOLE\_ENTITY</code></li><li><code>LINE\_ITEM</code></li><li><code>ASSIGNED\_TRANSFER</code></li></ul> |
| **`predicates`**         | An array of one or more predicates.                                                                                                                                                                                                                                                               | See the [Comparison rule predicates section](#comparison-rule-predicates).                                           |
| **`predicateConnector`** | `AND` will only make the expression `true` if all predicates evaluate to true. `OR` will make the rule expression `true` if any of the predicates evaluate to true.                                                                                                                               | <ul><li><code>AND</code></li><li><code>OR</code></li></ul>                                                           |

#### Comparison rule predicates

`predicates` is an array that consists of the following fields. At least one predicate must be defined. Maximum of 100 predicates.

<table data-search="false"><thead><tr><th>Field</th><th>Description</th><th>Possible values</th></tr></thead><tbody><tr><td><strong><code>entityOperator</code></strong></td><td>The operators determine how an entity's property should be compared to a given value.</td><td>See the <a href="#conditional-rules-entity-operators">Entity operators section</a>.</td></tr><tr><td><strong><code>leftEntity</code></strong></td><td>The entities that the rating can compare.</td><td><ul><li><code>ORDER</code></li><li><code>FACILITY</code></li><li><code>CARRIERCONNECTION</code></li><li><code>LISTING</code></li><li><code>ORDERING_FACILITY</code></li><li><code>ORDERING_FACILITY_GROUPS</code></li></ul></td></tr><tr><td><strong><code>leftPropertyPath</code></strong></td><td>A string containing a <a href="#introduction-to-jsonpath">JSONPath</a> for the left entity.</td><td>See the <a href="#introduction-to-jsonpath">JSONPath section</a>.</td></tr><tr><td><strong><code>leftTransformation</code></strong></td><td>[optional] The <a href="#transformers">transformation</a> for the left entity.</td><td>See the <a href="#transformers">Transformers section</a>.</td></tr><tr><td><strong><code>leftTransformationArgs</code></strong></td><td>[optional] The arguments for the left transformation, if required.</td><td>Depends on the <code>transformation</code> used. See the <a href="#transformers">Transformers section</a>.</td></tr><tr><td><strong><code>rightEntity</code></strong></td><td>The entities that the rating can compare.</td><td><ul><li><code>ORDER</code></li><li><code>FACILITY</code></li><li><code>CARRIERCONNECTION</code></li><li><code>LISTING</code></li></ul></td></tr><tr><td><strong><code>rightPropertyPath</code></strong></td><td>A string containing a <a href="#introduction-to-jsonpath">JSONPath</a> for the right entity.</td><td>See the <a href="#introduction-to-jsonpath">JSONPath section</a>.</td></tr><tr><td><strong><code>rightTransformation</code></strong></td><td>The <a href="#transformers">transformation</a> for the right entity.</td><td>See the <a href="#transformers">Transformers section</a>.</td></tr><tr><td><strong><code>rightTransformationArgs</code></strong></td><td>The transformation arguments for the right <a href="#transformers">transformation</a>, if required.</td><td>Depends on the <code>transformation</code> used. See the <a href="#transformers">Transformers section</a>.</td></tr></tbody></table>

#### Comparison rules entity operators

An `entityOperator` determines how an entity's property should be compared to a given value.

| Operator              | Description                                                                                  |
| --------------------- | -------------------------------------------------------------------------------------------- |
| `LEFT_CONTAINS_RIGHT` | The left-hand side should contain all values from the right-hand side.                       |
| `RIGHT_CONTAINS_LEFT` | The right-hand side should contain all values from the left-hand side.                       |
| `ALL_MATCHES`         | The arrays of values should be exactly equal.                                                |
| `NO_MATCHES`          | Values should be different, even when comparing a list with a single value (blocklist case). |

## Introduction to JSONPath

We use JSONPath for creating custom routing rules. You'll need to understand the operators, functions, and filters to ensure the custom routing rule works as expected. You can find the full information in the [JSONPath documentation](https://github.com/json-path/JsonPath). You can also use a [JSONPath expression tester tool](https://jsonpath.com/) to ensure your path is valid.

JSONPaths are used in `propertyPath` for [conditional rules](#conditional-rule-predicates) and `leftPropertyPath` and `rightPropertyPath` for [comparison rules](#comparison-rule).

JSONPaths always begin with `$`, which refers to the entity that's defined in the predicate, for example, an `ORDER`. Nested properties are accessed using `.`. Nested array properties, such as `orderLineItems`, `tags`, or `stickers`, are accessed using array brackets (`[` and `]`) with `*` to indicate a wildcard. For example, `$.orderLineItems[*].quantity`.

Instead of a wildcard (`*`), you can use the `?()` syntax. You can then define an arbitrary expression inside the parentheses using the `@` symbol to refer to the entity being tested.

For more specific filtering, use `?()` instead of `*`. Inside the parentheses, define an arbitrary expression using `@` to refer to the entity being tested. You can then access all of its nested attributes and test for an arbitrary condition.

Let's look at some more examples:

| Expression                                                                                   | Description                                                                                                |
| -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `$.tenantOrderId`                                                                            | Gets the order with the specified `tenantOrderId`.                                                         |
| `$.orderLineItems[*].article`                                                                | Gets the articles from all `orderLineItems`, resulting in an array.                                        |
| `$.orderLineItems[?(@.quantity > 3)].article`                                                | Gets the articles from `orderLineItems` with a quantity greater than 3.                                    |
| `$.orderLineItems[?(@.tags.find(tag => tag.id === 'color' && tag.value === 'red'))].article` | Gets the articles of all `OrderLineItems` that have at least one tag of type `color` with the value `red`. |

{% hint style="info" %}
It's recommended to keep your expressions as simple as possible without compromising their functionality to avoid mistakes that could lead to misbehavior of the fence/rating.
{% endhint %}

## Evaluation scope

`evaluationScope` defines how fulfillmenttools evaluates an order. `WHOLE_ENTITY` evaluates the order as a single unit. With `LINE_ITEM`, fulfillmenttools evaluates each order line separately. With `ASSIGNED_TRANSFER`, available for fences only, fulfillmenttools considers only the items that the routing option assigns to the evaluated transfer.

The difference in `evaluationScope` applies only when the left side of the rule doesn't reference the entire order but operates on the `orderLineItem` level.

### **Evaluation scope example**

Let's say we set up the following custom fence definition:

{% columns %}
{% column %}
Left part

```
entity: ORDER 
propertyPath: $.order.orderLineItems[*].tags[?(@.id == 'FAST_RUNNER')].value 
operator: ANY_VALUE_EQUALS 
expectedValue: true
```

{% endcolumn %}

{% column %}
Right part

```
entity: FACILITY 
propertyPath: $.locationType 
expectedValue: WAREHOUSE
```

{% endcolumn %}
{% endcolumns %}

Depending on whether we set the `evalutionScope` to `WHOLE_ENTITY` or `LINE_ITEM`, we we'll see different behavior:

<table><thead><tr><th width="366.67230224609375">WHOLE_ENTITY</th><th>LINE_ITEM</th></tr></thead><tbody><tr><td>If at least one <code>orderLineItem</code> has the tag <code>FAST_RUNNER = true</code>, the entire order must be routed to warehouse locations.</td><td>Only <code>orderLineItems</code> with the tag <code>FAST_RUNNER = true</code> must be routed to warehouse locations. The remaining items can potentially also be routed to locations with types other than warehouse.</td></tr></tbody></table>

#### Assigned transfer

{% hint style="info" %}
`ASSIGNED_TRANSFER` applies only to fences.
{% endhint %}

`WHOLE_ENTITY` evaluates the complete order, and `LINE_ITEM` evaluates a single order line. Neither scope can evaluate the items that travel together in one transfer. Use `ASSIGNED_TRANSFER` for requirements such as a minimum shipment value or maximum shipment size.

A routing option consists of one or more transfers. Each transfer moves a defined set of items out of one facility. With `ASSIGNED_TRANSFER`, order item property paths resolve against the evaluated transfer's items. The `SUM` and `COUNT` [transformations](#transformers) aggregate only that subset. fulfillmenttools evaluates the rule once per transfer. A violation excludes the routing option.

fulfillmenttools evaluates only transfers leaving a facility that sources the items. It doesn't evaluate onward transfers that forward items sourced elsewhere. For example, fulfillmenttools evaluates the transfer leaving a central warehouse. It doesn't evaluate its onward transfer through a cross-docking location to the consumer.

The assigned items can differ between routing options. The same facility can pass a rule in one option and fail it in another. For example, an order of 20 eaches split evenly across two facilities passes a limit of 10 eaches per transfer. The same order shipped from one facility doesn't.

If one facility serves a routing option with more than one transfer, fulfillmenttools evaluates each transfer separately. For example, a second transfer can use a different carrier connection. fulfillmenttools doesn't evaluate the facility's total contribution.

{% hint style="warning" %}
A rule with this scope limits a single transfer, not a facility's workload. A facility can create two transfers within one routing option. Each transfer can pass the rule while the facility exceeds the limit in total. A per-facility limit requires the facility to have one transfer.
{% endhint %}

The advanced routing node view in Backoffice also provides this scope for fences.

#### Scope comparison

Using the fence definition from the [evaluation scope example](#evaluation-scope-example):

| WHOLE\_ENTITY                                                                                                             | LINE\_ITEM                                                                                     | ASSIGNED\_TRANSFER                                                                                                                                                   |
| ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| If at least one `orderLineItem` has the tag `FAST_RUNNER = true`, the entire order must be routed to warehouse locations. | Only `orderLineItems` with the tag `FAST_RUNNER = true` must be routed to warehouse locations. | A transfer must leave a warehouse if its items include at least one item with the tag `FAST_RUNNER = true`. Transfers that carry none of those items are unaffected. |

#### Examples

**Minimum goods value per transfer**

A transfer leaving a store must be worth at least EUR 100.00. Smaller transfers are only allowed from warehouses. The line item total is stored as an article attribute with the `finalLineItemPrice` category. Monetary values use minor units, so EUR 100.00 is `10000` with two decimal places.

{% columns %}
{% column %}
Left part

```
entity: ORDER
propertyPath: $.orderLineItems[*].article.attributes[?(@.category == 'finalLineItemPrice' && @.key == 'value')].value
transformation: SUM
entityOperator: LESS_THAN
expectedValue: 10000
```

{% endcolumn %}

{% column %}
Right part

```
entity: FACILITY
propertyPath: $.locationType
entityOperator: VALUE_EQUALS
expectedValue: WAREHOUSE
```

{% endcolumn %}
{% endcolumns %}

As a fence in the routing strategy node configuration:

```json
{
  "type": "ToolkitFence",
  "referenceId": "min-goods-value-per-transfer",
  "name": "Minimum goods value per transfer",
  "nameLocalized": { "en": "Minimum goods value per transfer" },
  "active": true,
  "order": 1,
  "rule": {
    "evaluationScope": "ASSIGNED_TRANSFER",
    "operator": "EQUALS",
    "leftPart": {
      "predicates": [
        {
          "entity": "ORDER",
          "propertyPath": "$.orderLineItems[*].article.attributes[?(@.category == 'finalLineItemPrice' && @.key == 'value')].value",
          "transformation": "SUM",
          "entityOperator": "LESS_THAN",
          "expectedValue": 10000
        }
      ]
    },
    "rightPart": {
      "predicates": [
        {
          "entity": "FACILITY",
          "propertyPath": "$.locationType",
          "entityOperator": "VALUE_EQUALS",
          "expectedValue": "WAREHOUSE"
        }
      ]
    }
  }
}
```

**Maximum number of eaches per transfer**

A transfer out of a store may carry at most 10 eaches. Larger transfers are reserved for warehouses. `SUM` adds only the quantities of items in that transfer.

```json
{
  "entity": "ORDER",
  "propertyPath": "$.orderLineItems[*].quantity",
  "transformation": "SUM",
  "entityOperator": "GREATER_THAN",
  "expectedValue": 10
}
```

**Maximum number of order lines per transfer**

A transfer out of a store contains at most 10 order lines. `COUNT` counts only the order lines of that transfer. A second transfer in the same routing option is counted separately.

```json
{
  "entity": "ORDER",
  "propertyPath": "$.orderLineItems[*]",
  "transformation": "COUNT",
  "entityOperator": "GREATER_THAN",
  "expectedValue": 10
}
```

Ratings don't support `ASSIGNED_TRANSFER`. To weigh transfer sizes instead of excluding them, use `WHOLE_ENTITY` or `LINE_ITEM`. Where several facilities contribute to one routing option, use [option aggregation](#option-aggregation).

### Option aggregation

{% hint style="info" %}
Option aggregation applies only to complex routing with combinatorics. In standard routing, each facility is rated independently, and the setting has no effect.
{% endhint %}

A routing option can be fulfilled by more than one facility, for example, in order splits or interfacility transfers. `optionAggregation` defines how a custom rating is applied in this case. Each facility in the routing option is checked against the condition, and the results are aggregated into a single penalty for the whole routing option.

It applies only to ratings that evaluate the `FACILITY` entity, not ratings that evaluate `LISTING`.

`optionAggregation` is an enum and can have one of the following options:

* `MIN`: At least one node in the sourcing option must satisfy the condition. Otherwise, `maxPenalty` is applied.
* `MAX`: All nodes in the sourcing option must satisfy the condition. Otherwise, `maxPenalty` is applied.
* `SUM`: Apply `maxPenalty` individually to every node that doesn't satisfy the condition, so one routing option can be charged `maxPenalty` several times. This is the default.

## Transformers

`transformation` allows for modifying the input to `predicates` before it gets evaluated. This can serve multiple purposes. For example, only look at the number of elements, get the total price of all `orderLineItems`, or only consider the beginning of the `tenantOrderId`.

The transformations currently available are:

* `SUM`: Sums the number values of each element, requires an array of elements
* `COUNT`: Counts the number of elements, requires an array of elements
* `SUBSTRING`: Gets a substring of a value, requires `start` and `end` parameters
* `LAST`: Gets the last `n` characters of a string, requires a `length` parameter

### Count transformation

Applies to orders with 10 or more `orderLineItems`.

```json
{
"propertyPath": "$.orderLineItems[*]",
"transformation": "COUNT",
"entityOperator": "GREATER_THAN",
"expectedValue": 10
}
```

### Sum transformation

Applies to orders where the sum of all `orderLineItems` quantities is 100 or more.

```json
{
"propertyPath": "$.orderLineItems[*].quantity",
"transformation": "SUM",
"entityOperator": "GREATER_THAN",
"expectedValue": 100
}
```

### Substring transformation

Applies to orders where any `orderLineItem` has a `tenantArticleId` that begins with `Coca`. Here, we use `transformationArgs` to ensure that the first 4 letters are used.

```json
{
"propertyPath": "$.orderLineItems[*].article.tenantArticleId",
"transformation": "SUBSTRING",
"entityOperator": "ANY_VALUE_EQUALS",
"expectedValue": "Coca",
"transformationArgs": [0, 4]
}
```

### Last characters transformation

Applies to orders where any `orderLineItem` has a `tenantArticleId` that ends with `Christmas special`

```json
{
"propertyPath": "$.orderLineItems[*].article.tenantArticleId",
"transformation": "LAST",
"entityOperator": "ANY_VALUE_EQUALS",
"expectedValue": "Christmas special"
}
```

## Time specifications

It's possible to define a time specification as an expected value, enabling dynamic comparisons during routing processes. For example, a timestamp stored in a `customAttribute` can be compared against the current time using predefined expressions.

* `{today}`: represents the current day, based on the tenant's configured time zone. This expression refers to a date value (for example, `2025-08-07`).
* `{now}`: represents the current timestamp, calculated in UTC+0. This expression refers to a specific timestamp (for example, `2025-08-07T18:00:00.000Z`).

This functionality, for example, allows routing logic to determine whether an item is eligible for release to sales, based on time-based conditions.

{% hint style="info" %}
When using the `"entityOperator": "EQUALS"` for timestamp comparisons, be aware that it includes minutes and seconds. This may lead to unintended mismatches unless the timestamps are precisely aligned.
{% endhint %}

```json
{
"propertyPath": "$.customAttributes.releaseDate",
"transformation": "null",
"entityOperator": "LESS_EQUALS",
"expectedValue": "{today}",
"entity": "LISTING"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/doms-toolkit.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
