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

# Purchase order matching

> Match invoices against purchase orders in ABBYY FlexiCapture: connect PO databases, enable comparison rules, and verify line items against order items.

A purchase order (PO) is a commercial document issued by a buyer to a seller, indicating types, quantities, and agreed prices for the products or services that the seller will provide to the buyer. An invoice is a commercial document issued by a seller to a buyer, indicating the products, quantities, and agreed prices for the products or services the seller has provided to the buyer.

Many companies keep track of purchase orders. Invoices issued by suppliers contain the numbers of the respective purchase orders. When processing invoices, you can compare the products and services stated in them with those stated in the respective purchase orders.

This may be useful, for example, if you want to skip the verification stage for invoices that match a previously confirmed purchase order.

By default, matching invoices against purchase orders is disabled.

## Enable the comparison of invoices with purchase orders

### Enable the feature in FlexiCapture for Invoices

<Steps>
  <Step title="Open the Document Definitions dialog box">
    From the **Project** menu, select **Document Definitions...**.
  </Step>

  <Step title="Edit the Document Definition">
    In the dialog box that opens, click **Edit...**.
  </Step>

  <Step title="Open the Document Definition properties">
    From the **Document Definition** menu, select **Document Definition Properties...**.
  </Step>

  <Step title="Open the Document Definition settings">
    In the dialog box that opens, click the **Document Definition Settings** tab.
  </Step>

  <Step title="Open the Document Definition features">
    Click the **Edit...** button next to the **Additional Fields and Features** group to open the **Document Definition Features** dialog box.
  </Step>

  <Step title="Enable purchase order matching">
    Select the **Purchase order matching** option.
  </Step>
</Steps>

### Connect a database of purchase orders

<Steps>
  <Step title="Open the Data Sets tab">
    In the main window of the Document Definition editor, select **Document Definition → Document Definition Properties...**. In the dialog box that opens, click the **Data Sets** tab.

    A **data set** is a table that specifies the structure of data and either stores data or takes it from an external database.
  </Step>

  <Step title="Set up the PurchaseOrders data set">
    Select **Purchase Orders** from the list and click **Set Up...**.

    Note the structure of the connected data. For more information, see [PurchaseOrders data set](/flexi-capture/invoice-reader/ir-columns-po). If there is no such table in your database, you may need to create a corresponding view using the tools available in your database software.
  </Step>

  <Step title="Specify the connection">
    In the **PurchaseOrders** data set dialog box, specify the string used to connect to your ODBC-compatible database of purchase orders and the data schema to be used, and then select the table or database view.
  </Step>

  <Step title="Map the columns">
    Specify the correspondences between the columns in the data set and in the external database.
  </Step>
</Steps>

The program now finds purchase order numbers and total amounts on invoices and compares them with those stored in the purchase order database.

### Connect purchase order line items

If required, repeat the first two steps of [Connect a database of purchase orders](#connect-a-database-of-purchase-orders) to open the **Data Sets** tab of the **Document Definition Properties** dialog box.

<Steps>
  <Step title="Set up the PurchaseOrdersItems data set">
    Select **PurchaseOrdersItems** from the list and click **Set Up...**.

    Note the structure of the connected data. For more information, see [PurchaseOrdersItems data set](/flexi-capture/invoice-reader/ir-columns-po-items). The number of a purchase order must be identical to the one specified in the purchase order database. The **PurchaseOrders** data set column is required; all other columns are optional. If there is no such table in your database, you may need to create a corresponding view using the tools available in your database software.
  </Step>

  <Step title="Specify the connection">
    In the **PurchaseOrdersItems** data set dialog box, specify the string used to connect to your ODBC-compatible database of purchase orders and the data schema to be used, and then select the table or database view.
  </Step>

  <Step title="Map the columns">
    Specify the correspondences between the columns in the data set and in the external database.
  </Step>
</Steps>

For more information, see [Detecting the main fields](/flexi-capture/invoice-reader/ir-search-fields).

### Enable the capture of invoice line items

For more information, see [Additional fields](/flexi-capture/invoice-reader/ir-additional-fields).

### Set up comparison rules

FlexiCapture for Invoices offers several predefined rules. The Administrator should enable the rules required for their specific project. This can be done on the **Rules** tab of the **Document Definition Properties** dialog box.

| Rule                                                                                  | Description                                                                                                                                                                                                                                              | Where it is stored | Default status                                          |
| ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------- |
| Check purchase order number and amount                                                | Checks if the order number and amount captured from an invoice correspond to the orders in the PurchaseOrders data set.                                                                                                                                  | PurchaseOrder      | Enabled                                                 |
| Match invoice line item with order item                                               | Checks if a line item in an invoice corresponds to its respective line item in the purchase order. You can specify which should be compared and how.                                                                                                     | LineItems          | Enabled, if the Line items extraction option is enabled |
| Check invoice line items count against order items count                              | Checks if the number of line items in an invoice is the same as the number of line items in the corresponding purchase order.                                                                                                                            | PurchaseOrder      | Disabled                                                |
| Check if invoice line items are matched with unique order items                       | Checks if there are multiple line items in an invoice associated with one and the same line item in the purchase order.                                                                                                                                  | PurchaseOrder      | Disabled                                                |
| Collect matched order items (necessary for proper work of PO Matching at items level) | Compiles a list of PO line items that are already associated with their corresponding invoice line items. In the case of manual comparison, the Operator sees only those invoice line items for which no match has yet been found in the purchase order. | PurchaseOrder      | Enabled                                                 |

## Compare invoice line items with the purchase order

FlexiCapture for Invoices offers several comparison methods:

* Compare the number and amount of an invoice with those in the purchase order (invoice header comparison).
* Compare the line items of an invoice with those in the purchase orders (invoice line item comparison).

### Compare invoice items with purchase order items

If **Purchase order matching** is selected, the **Purchase Orders** group is displayed in the data form when you verify invoices.

For each purchase order found on an invoice, a group element is displayed that consists of the following:

* Order number
* Total amount
* **Details...** button
* **Order Checked** checkboxes

Clicking **Details...** displays the details of the purchase order (provided the Administrator has connected the corresponding database with PO details) at the bottom of the document image window, so that invoice items can be easily compared with purchase order items.

To confirm that the invoice matches the purchase order, the Operator can select the **Order Checked** checkbox. This check box can only be selected manually. When selected, it shows that the Operator has compared the values of the **Order Number** and **Total** fields in the invoice with those in the purchase order and confirmed the match. Once the match has been confirmed by the Operator, the values of these fields are not checked automatically by a rule.

If an order has not been detected on the image and is not displayed in the data form, click the **Add 'Purchase Order' Instance** link at the bottom of the **Purchase Orders** group. An empty element is added to the **Purchase Orders** group. Enter the values of the **Order Number** and **Total** fields by selecting the values on the image or by keying them manually. The values you enter are automatically checked by a rule against the PO database.

### <a id="itembyitem" />Item-by-item comparison

To compare an invoice against its purchase order, line items extracted from the invoice can be used. The Operator may also need to select the appropriate PO item for each invoice item.

If line item capture is enabled, the **Line Items** group is displayed on the data form. This group contains the line items captured from the invoice image.

FlexiCapture automatically matches invoice line items with the PO counterparts. To match items manually, the Operator clicks the button inside the **OrderItemId** column and selects the PO item from the list that opens.

If an invoice line item cannot be matched with a purchase order item but is still valid, the Operator selects the **Is valid** checkbox for this line item.

Depending on the settings configured by the Administrator, the following rule checks are performed:

* The number of line items in a purchase order must be the same as the number of invoice line items associated with that order.
* All invoice line items are matched with different PO line items or have been marked as valid by the Operator.
