Extract a VAT number

Parent Previous Next

Extracting a VAT Number



Description


When extracting a VAT number a number of rules or requirements apply:


This example does not pretend to be complete in how VAT numbers should be extracted, it is only intended as an example in how to extract a fixed format value from a document.



Example


In this example we will configure an extraction field to extract the Belgian VAT numbers from a document.

To simplify the setup, we assume that the document already contains the text (as in a searchable pdf) and no additional OCR needs to be done prior to the extraction.



Step 1: Know the VAT number format to extract


For Belgium a VAT number must have the following format: BE0123.456.789

This format transforms into the following regular expression:  (BE)0[0-9]{9}

Note that the regular expression does not include optional characters to make the VAT number more readable.



Step 2: Define the Locator profile


Next step is to create a new Locator profile.

Add the format of the VAT number to look for:


Define in the pattern the regular expression for the Belgian VAT number format and also list optional characters to ignore (characters that make the VAT number easier to read on a document).


Note the Max alternatives field setting, it  contains the maximum number of valid alternatives to return.

In this example it is set to 5, meaning that the first 5 values matching the Belgian VAT number format are stored.



Step 3: Define the VAT numbers to ignore (ex. own VAT numbers)


When reading VAT numbers from an invoice, usually the own VAT number is also present.

As we don't want this number to be returned as a valid VAT number, we must enter this number in the exclude format list.



Save the locator with the name 'VAT Number'.


We now have created a locator that will find Belgian formatted VAT numbers and that will exclude automatically our own VAT number.



Step 4: Define the Extraction Fields profile


Now the extraction field that will contain the actual value(s) can be defined.

Create a new Extraction Fields profile and save it with the name 'Invoice fields'.

Add a new extraction field and enter the settings as shown below:


The setting Max alt is set to 2, meaning that at most 2 VAT numbers are returned.

As the setting Merge is not checked, the values are returned as a list.

If this setting were checked, the values are returned as a concatenated list and considered to be 1 value (see the extract an address example).


At this moment the 'Invoice fields' profile contains only 1 extraction field, this can now be extended with additional fields that need to be extracted from invoices.