Recognize VAT invoices with OCR

Updated at:

1. Component introduction

Note

Prerequisites: None

Recommended subsequent component: Conditional Branch. You can use a branch condition to check whether the OCR call was successful and then design the subsequent flow.

This component uses OCR to recognize key fields on special, general, and electronic VAT invoices. These fields include the invoice code, number, and issue date. For more information, see Example.

2. Inputs

Note

For information about each input, see the help text in the component panel of the application flow editor.

3. Outputs

Note

For information about each output, see the help text in the component panel of the application flow editor.

3.1. Key API return results

This output returns a dictionary of key recognition results from the API. The following table describes the keys and values in the dictionary.

Key

Key meaning

Value data type

invoiceCode

Invoice code

string

invoiceNumber

Invoice number

string

invoiceDate

Issue date

string

machineCode

Machine code

string

checkCode

Check code

string

purchaserName

Purchaser name

string

passwordArea

Password area

string

invoiceAmountPreTax

Amount before tax

string

invoiceTax

Tax amount

string

totalAmountInWords

Total amount in words

string

totalAmount

Total amount

string

sellerName

Seller name

string

sellerTaxNumber

Seller tax ID

string

sellerContactInfo

Seller address and phone number

string

sellerBankAccountInfo

Seller bank and account number

string

drawer

Issuer

string

title

Title

string

invoiceType

Invoice type (General Electronic Invoice, Special Electronic Invoice, Special Invoice, General Invoice, or Universal Invoice)

string

3.2. Error message

This output returns the error code and error message as a string. For more information, see the OCR Error Center.

https://next.api.aliyun.com/document/ocr-api/2021-07-07/errorCode

4. Component usage example

4.1. Component configuration example

  1. For AI engine, select Alibaba Cloud OCR.

  2. For Image file path to recognize, enter the path of the image file. This example uses the following image.

    image

  3. Keep the default values for the advanced options.

4.2. Example execution result

image

5. Flow example

5.1. Build the flow

  1. Use the Recognize VAT Invoices with OCR component to specify the path of the image file to be recognized.

  2. Use the Conditional Branch component to check whether the OCR call was successful. Set the condition so that `v_recognize_invoice_success_1` is equal to the Boolean value `True`.

  3. In the success branch, use the Get Value of a Specified Key component to retrieve a specific key from the dictionary of API return results. This example retrieves `purchaserName` (Purchaser name).

  4. Use the Log Record component to print the retrieved value.

  5. In the failure branch, use the Log Record component to print the error message. image

5.2. Execution result

As shown in the following figure, after the OCR service call succeeds, the recognition result is printed in the log panel.