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

# Validation rules for purchase orders

> Review the preconfigured validation rules of the Order Document Definition, covering amount and currency checks, database lookups, and optional tax rules.

The Order Document Definition includes the following preconfigured validation rules. You can disable any of these rules in the settings of the Order Document Definition, or create your own [validation rules](/flexi-capture/templates/rules).

## General validation rules

### Total

| Rule                                             | Description                                                                                                          |
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| **Separate currency from amount in Total field** | Separates the currency symbol from the amount if OCR fails to differentiate it from the digits.                      |
| **Amount check**                                 | Adds up the line item prices and additional costs and compares the result against the number in the **Total** field. |

### LineItems

| Rule                                                            | Description                                                                                              |
| --------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| **Check item amount**                                           | Checks that the amount in each line item equals the quantity multiplied by the price minus the discount. |
| **Separate currency from amount in LI\_UnitPrice field**        | Separates the currency symbol from the amount if OCR fails to differentiate it from the digits.          |
| **Separate currency from amount in LI\_TotalPriceNetto field**  | Separates the currency symbol from the amount if OCR fails to differentiate it from the digits.          |
| **Separate currency from amount in LI\_TotalPriceBrutto field** | Separates the currency symbol from the amount if OCR fails to differentiate it from the digits.          |
| **Quantity is required**                                        | Makes sure that the quantity of goods has been detected.                                                 |
| **Hide currency if total empty**                                | Removes the value from the **Currency** field if no **Total** field has been detected.                   |
| **Check LineItems currency value**                              | Checks the value in the **Currency** field.                                                              |

### ArticleNumberBU

| Rule                                                | Description                                                                                                                 |
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| **Article Number must be found in database**        | Indicates whether only the article number or both the article number and the business unit must be present in the database. |
| **Article Number and BU must be found in database** | Indicates whether only the article number or both the article number and the business unit must be present in the database. |

### Issuer

| Rule                                        | Description                                                                               |
| ------------------------------------------- | ----------------------------------------------------------------------------------------- |
| **Buyer must be found in database**         | Indicates whether buyer details must be present in the database or added to the database. |
| **Buyer details must be added to database** | Indicates whether buyer details must be present in the database or added to the database. |

### DeliveryDate

| Rule                                            | Description                                                                   |
| ----------------------------------------------- | ----------------------------------------------------------------------------- |
| **Delivery date must be later than order date** | Checks that the detected delivery date is later than the detected order date. |

### Currency

| Rule                             | Description                                                                                           |
| -------------------------------- | ----------------------------------------------------------------------------------------------------- |
| **Set currency to CAD or USD**   | Sets the currency depending on the country of the business unit (CAD for Canada and USD for the USA). |
| **Detect national currency**     | Determines the currency based on the country of the business unit.                                    |
| **Copy currency from LineItems** | Copies the currency from **LineItems** (if available).                                                |
| **Check currency value**         | Checks the value of the **Currency** field if the **Total** is not empty.                             |

### BU

| Rule                                                          | Description                                                                                       |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **Information about business unit must be added to database** | Indicates whether business unit details must be present in the database or added to the database. |
| **Business unit must be found in database**                   | Indicates whether business unit details must be present in the database or added to the database. |

## Enable the tax rules

The tax rules are identical to those used in invoice projects but are disabled by default.

To enable them, turn on the **Taxes** option:

<Steps>
  <Step title="Open Document Definition Properties">
    In the Document Definition Editor, click **Document Definition → Document Definition Properties...**.
  </Step>

  <Step title="Open Additional Fields and Features">
    In the dialog box that opens, click the **Document Definition Settings** tab and then click the **Edit...** button in the **Additional Fields and Features** group.
  </Step>
</Steps>

## Tax validation rules for the Order Document Definition

All tax rules apply to the **Amounts** field group.

| Rule                                                  | Description                                                                                                                                                                                                                                                                         |
| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Check Total field if total tax amount is optional** | Checks that the sum of all the pre-tax amounts (NetAmount0, NetAmount1, and NetAmount2), tax amounts (TaxAmount1 and TaxAmount2), and additional costs (AdditionalCosts) equals the amount indicated in the **Total** field. This rule can only be used for German purchase orders. |
| **Check Total field if total tax amount is required** | Checks that the sum of all the pre-tax amounts (NetAmount0, NetAmount1 and NetAmount2), tax amount (TotalTaxAmount), and additional costs (AdditionalCosts) equals the amount indicated in the **Total** field. This rule can only be used for non-German purchase orders.          |

### TotalTaxAmount

| Rule                                                       | Description                                                                                                                                                              |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Check Total Tax field**                                  | The following check is performed: `TotalTaxAmount = TaxAmount1 + TaxAmount2 + Additional Tax Groups / TaxAmount`. This rule can only be used for non-UK purchase orders. |
| **Total Tax is a required field**                          | Checks that the `Amounts\TotalTaxAmount` field is filled in. This rule can only be used for non-German purchase orders.                                                  |
| **Separate currency from amount in TotalTaxAmount field**  | Separates the currency symbol from the amount if OCR fails to differentiate it from the digits.                                                                          |
| **Complete Total Tax field if only one tax rate is found** | Automatically completes the `Amounts\TotalTaxAmount` field for documents that contain only one tax rate.                                                                 |
| **Complete Total Tax field if it is optional**             | Automatically completes the `Amounts\TotalTaxAmount` field for countries where this field is optional. This rule can only be used for German purchase orders.            |

### TotalNetAmount

| Rule                                                      | Description                                                                                                                                                                                 |
| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Verify net total against order items**                  | Adds up the values in the TotalPriceNetto column in the LineItems table and checks the result against the amount in TotalNetAmount.                                                         |
| **Separate currency from amount in TotalNetAmount field** | Separates the currency symbol from the amount if OCR fails to differentiate it from the digits.                                                                                             |
| **Check Net Total field**                                 | The following check is performed: `TotalNetAmount = NetAmount0 + NetAmount1 + NetAmount2`. If the TotalNetAmount field is empty, this rule completes this field with the calculated amount. |

### Additional Tax Groups

| Field                | Rule                                                    | Description                                                                                                                                           |
| -------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| TaxRate, TaxAmount   | **If tax rate is detected, pre-tax amount is required** | Checks that each detected tax rate has a corresponding non-empty NetAmount field.                                                                     |
| TaxRate              | **Complete Tax Rate field if it is empty**              | Calculates the amount for the TaxRate field and completes this field if no tax rate has been found on the image but other tax fields have been found. |
| TaxRate              | **Tax Rate field must not be empty**                    | Checks that each detected net amount or tax amount has a corresponding non-empty TaxRate field.                                                       |
| TaxAmount            | **Check Tax field**                                     | The following check is performed: `TaxAmount = NetAmount * (TaxRate/100)`.                                                                            |
| TaxAmount, NetAmount | **Separate currency from amount in TaxAmount field**    | Separates the currency symbol from the amount if OCR fails to differentiate it from the digits.                                                       |

<Note>
  When using an external database, the country of a document is the country of the vendor's business unit. If no external database is used, the country is determined by an automatic country detector.
</Note>
