Business Rules Validation Extension

Prev Next

What is the Rossum Business Rules Validation extension

Rossum’s Business Rules Validation extension is a flexible tool that helps you validate extracted and annotated data based on your own business rules. It allows you to check both line items and header fields. If a validation fails, you’ll receive notifications in the form of info, warning, or error messages. This extension makes it easy for you to quickly verify if the data in processed documents is correct and spot any discrepancies.

Common business rules that extension will help you validate

Account Payable Business Rules

  • Total Amount is equal to the sum of the Total Base and the Total Tax

  • Total Amount for a line item is equal to the sum of the Amount Base (unit price) and the Item Tax

  • Total Amount is equal to the sum of the line items’ Total Amount

  • Due Date is within 120 days of the Issue Date

  • Total Amount is equal to the Amount (unit price with tax) multiplied by the Quantity

  • Total Tax is equal to the Tax Base multiplied by the Tax Rate

Logistics Business Rules

  • Delivery Date cannot be empty

Sales Order Business Rules

  • The Item Code in line items section must follow specific format for each vendor

  • Delivery Date is present either in header information or in the line items. If it is on line item level, all delivery dates for all the items should be the same.

How to Set Up the Business Rules Validation Extension

Setting up the extension involves a few straightforward steps:

Step 1: Prepare your queues and schemas

Start by identifying the Queues containing the documents that require this extension. Then, determine the schema IDs of the fields that the extension will use to check the business rule.

Step 2: Activate the Business Rules Validation Extension in the Rossum Store

To activate the extension, follow these steps in the Rossum application:

  1. Click on the Extensions tab at the top of the app and choose the Rossum store option to access all available extensions

  2. Type or select the Business Rules Validation extension

  3. Click on Add

Step 3: Specify the queues to which you want to add the extension

In Rossum Store Extension Settings scroll down to Queues and select the desired queues where you wish to utilise the extension. Remember to save your changes after selecting the appropriate queues.

Step 4: Configure the Business Rules

You can configure the extension either through the Configuration field directly in the app or by using the settings attribute of the hook API object. The configuration follows JSON format and includes a list of business rules that validate values extracted from your documents. You can find available configuration parameters in the table below.

Available configuration parameters

Attribute

Type

Required

Default value

Description

checks

list

yes

It is a parent attribute that holds all the rules.

rule

string

yes

The business rule that will be validated. Expression engine is used – documentation can be found here.

message

string

yes

A message that is shown when business rules validation fails.

type

string

no

error

Type of the message.

Possible values:

error – a red error message – stops the automation. Confirming the document is not possible.

warning – an orange warning message – does not stop the automation, confirming the document is possible.

info – a blue info message – does not stop the automation, confirming the document is possible.

automation_blocker

boolean

no

false

Allows you to define custom rules for document automation. The behaviour is determined by the attribute setting:

false – automation is stopped if the check fails but only if it returns an “error” message type. The document is held for user review.

true – automation is stopped every time the check fails, no matter the message type it returns. The document is held for user review. If the check returns an “info” or “warning” message, the annotator will have the option to manually confirm the document.

Please note that the automation blocker can only be applied to individual data points and cannot be used at the document level.

Example can be found here.

queue_ids

list of integers

no

[]

List of queue IDs.

Subset of queues to which the extension is assigned and applied.

If not specified, validation applies to all queues to which the function is assigned.

Example can be found here.

condition

string

no

““

The condition that has to be met in order for validation to be applied.

For example you can apply rules only to documents coming from a specific vendor.

Expression engine is used – documentation can be found here.

active

boolean

no

true

true – the business rule is active

false – the business rule is skipped

Example can be found here.

and, or, all

list

no

Allows you to create structured business rules with a dedicated message for each part of the business rule e.g. {checks: [{rule...}{and:[{rule...}{or:[{rule...}{rule...}][][}

Automation blocker

Automation will be stopped if the specified rule is not satisfied.

{
  "type": "info",
  "automation_blocker": true,
  "rule": "{date_issue} < '2023-05-10'",
  "message": "If not satisfied, the business rule will halt automation, 
even if the message type is set to info."
}

Queue IDs

The business rule will only be enforced on queues specified in the queue_ids parameter.

{
  "queue_ids": [1239, 4356]
  "rule": "{date_due} == '2023-05-10'",
  "message": "The business rule will exclusively apply to specific queues."
}

Active

If set to false, the business rule will not be evaluated.

{
  "active": false,
  "rule": "{date_issue} < '2023-05-10'",
  "message”: “The business rule will be bypassed."
}

Variables

It is also possible to define variables for better readability of the business rules (not in condition yet).

{
    "checks": [
        {
  “rule”: “{sum_total} > 5”    
}
],
    "variables": {
        "sum_total": "sum({item_line_total_amount, default=0})",
        "sum_quantity": "sum({item_quantity})",
        "number_items" : "len({item_amount})"
    }
}

Empty values

If you need to check whether a value on a document is empty or not, you can use two functions: is_empty() and has_value(). For further details, please refer to the Expression Engine documentation.

Configuration examples

During the setup of business rules, you have the ability to refer to extracted data from a document using the schema IDs assigned to specific fields. For instance, if the field “Total Amount” has the schema ID “amount_total,” you should utilize “{amount_total}” within your business rules to reference that particular value.

Account Payable Business Rules

  • Total Amount is equal to the sum of the Total Base and the Total Tax

"rule": "{amount_total} == {amount_total_base} + {amount_total_tax}",
"message": "Total amount is not equal to the sum of amount base and the tax"
  • Total Amount for a line item is equal to the sum of the Amount Base (unit price) and the Item Tax

"rule": "{item_amount_total} == {item_amount_base} + {item_tax}",
"message": "Line total is not equal to the sum of line amount base and the tax"
  • Total Amount is equal to the sum of the line items’ Total Amount

"rule": "sum({item_amount_total}) == {amount_total}",
"message": "The sum of line items is not equal to the total amount."
  • Due Date is within 120 days of the Issue Date

"rule": "{date_due} <= {date_issue} + timedelta(days=120)",
"message": "Due date is not within 120 days of the issue date."
  • Total Amount is equal to the Amount (unit price with tax) multiplied by the Quantity

"rule": "{item_amount_total} == {item_amount} * {item_quantity}",
"message": "Line item total is not equal to unit price multiplied by quantity."

Logistics Business Rules

  • Delivery Date cannot be empty

"rule": "has_value({date_delivery})",
"message": "Delivery date cannot be empty."

Sales Order Business Rules

  • The Item Code in line items section must follow specific format on invoices from Rossum

"rule": "regexp('[\\d]{2}-X-[\\d]+',{item_code})",
"condition": "{sender_name} == 'Rossum'",
"message": "Rossum item code is - two-digit number followed by "-X-" and then one or more digits. "
  • Delivery date is present either in header information or in the line items. If it is on line item level, all delivery dates for all the items should be the same.

"or": [
    {
        "rule": "has_value({delivery_date})",
        "message": "Delivery date is empty."
    },
    {
        "and": [
            {
                "rule": "has_value({line_delivery_date})".
                "message": "Line item delivery date cannot be empty."            
            },
            {
                "rule": "unique_len({line_delivery_date}) == 1".
                "message": "Delivery date of all items must be the same."
            }
        ]
    }
]

Important:

  • In case of rules that apply to line items the extension displays the message for all the items that are breaking the rule.

  • It is not possible to use “ symbol in rule content, please use ‘ instead.

  • To build complex, string-based, validation rule you can use regular expressions.