How to parse invoice number?

In this step by step guide you will learn how to parse invoice numbers with different formats using one template.

 

1. First, create a new Document Parser template using the Online Template Editor

2. Next, click the Load Test PDF or Image button and select your source file.

3. Then, click the +Add Objects button.

4. Select Add FIELD based on TEXT SEARCH.

5. You can use the Name field to rename the object. Let's name it invoiceId.

6. Paste this Regex pattern in the Expression field.

(?is)(?:\bInvoice|\bNumber).*?(?<value>(?-i)INV-[A-Z0-9]+)( |\r?$)

7. Repeat steps 3 to 5. This time use the name invoiceIdFallback.

8. And paste this 2nd pattern in the Expression field. 

(?i)(?:Invoice Number|Invoice #|Invoice No\.?|Receipt No\.?|CREDIT NOTE No\.?|REF NO\.?)\s*:?\s+(?<value>.*?)( |\r?$)

9. Repeat steps 3 to 5 again. Now use the name invoiceIdFallback2.

10. This time paste this 3rd pattern in the Expression field.

(?i)(?:\bInvoice|\bNumber)\s*:?\s+(?<value>.*?)( |\r?$)

11. Click the Edit Template button.

12. Scroll down until you see the object for invoiceIdFallback.

13. Add the line "coalesceWith": "invoiceId" after "regex": true.

14. Add the same line for invoiceIdFallback2.

 {
"name": "invoiceId",
"objectType": "field",
"fieldProperties": {
"fieldType": "macros",
"expression": "(?is)(?:\\bInvoice|\\bNumber).*?(?<value>(?-i)INV-[A-Z0-9]+)( |\\r?$)",
"regex": true
},
"id": 2
},
{
"name": "invoiceIdFallback",
"objectType": "field",
"fieldProperties": {
"fieldType": "macros",
"expression": "(?i)(?:Invoice Number|Invoice #|Invoice No\\.?|Receipt No\\.?|CREDIT NOTE No\\.?|REF NO\\.?)\\s*:?\\s+(?<value>.*?)( |\\r?$)",
"regex": true,
"coalesceWith": "invoiceId"
},
"id": 3
},
{
"name": "invoiceIdFallback2",
"objectType": "field",
"fieldProperties": {
"fieldType": "macros",
"expression": "(?i)(?:\\bInvoice|\\bNumber)\\s*:?\\s+(?<value>.*?)( |\\r?$)",
"regex": true,
"coalesceWith": "invoiceId"
},
"id": 4
}

15. Click the Run Template button and test it with your different documents.

 

You can explore our Document Parser API Docs here. For any questions, feel free to contact our support team.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.