# How to add document OCR to TOTVS Protheus

> Source: https://netray.co/integrations/totvs-document-ocr
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Integrations

## Short answer

Scan or receive documents, run layout-aware OCR on your own server, extract fields with a confidence score per field, match them to Protheus masters and orders, and write drafts through ExecAuto. Fiscal XML needs no OCR; the value is in the paper and PDF that still arrives alongside it.

## System

TOTVS Protheus

## Capability

document-ocr

## Intro

Brazilian fiscal rules mean many Protheus plants already receive structured XML for invoices. OCR matters for what the XML does not cover: foreign supplier invoices, import documents, packing lists, certificates of analysis, delivery receipts signed by drivers, and scanned legacy paperwork.

Those documents still have to land on a record in Protheus, where the receiving clerk or the quality inspector would otherwise retype or simply file a paper copy.

A sound OCR setup does three things: reads accurately, shows how sure it is, and writes nothing into the ledger without the same checks a human entry would get.

## Use Cases

### Import invoices and packing lists

**Description:** Foreign supplier invoices and packing lists are read for item, quantity, origin and value, and drafted as inputs to the import process for the comex team to complete.

### Certificates of analysis and test reports

**Description:** Lot numbers, specification values and pass or fail are extracted and attached to the receiving lot in inventory control, so quality sees them at inspection.

### Signed delivery receipts

**Description:** Photos of signed canhotos or delivery receipts are read for invoice number and date, and used to close delivery tracking for the sales invoice.

### Service and freight invoices

**Description:** Non-stock invoices for freight, maintenance or services are coded to cost centers and accounts using supplier history, then queued for AP approval.

### Legacy paper archive indexing

**Description:** Scanned contracts and drawings are classified and indexed by document type and party so they can be linked to supplier and customer records.

## System Surface

- ExecAuto routines for pre-invoice and invoice entry and accounts payable titles, which apply validation when OCR output is posted as a draft.
- Protheus REST services for master lookups: suppliers, products with supplier cross-reference, open purchase orders and cost centers.
- The document attachment feature (banco de conhecimento) in Protheus for linking the scanned image or PDF to a record, with structure varying by release.
- TOTVS Fluig document management and GED where installed, which exposes a REST API for storing and classifying files and routing them to workflows.
- Lot and quality tables used for certificates, accessed through the standard quality routines or custom REST, not by direct inserts.

## How It Works

### Define document types and target records

**Detail:** List each document type, the Protheus record it feeds and the fields needed. Start with one or two types; a general reader that handles all of them poorly is a common trap.

### Capture and pre-process

**Detail:** Receive files from a watched folder, scanners, email or a mobile photo. Deskew, denoise and split multi-page files, and detect document type before extraction.

### Extract with confidence

**Detail:** Use a layout-aware OCR and a vision or language model to produce fields with confidence per field, keeping the image region each value came from.

### Validate against Protheus data

**Detail:** Check supplier exists, items map to products, totals add up, and the order is open. Failures reduce confidence and route to review.

### Review screen for low confidence

**Detail:** Show the image beside the fields, highlight uncertain ones, and let a clerk correct and approve. Corrections feed a list of supplier-specific hints.

### Post as a draft and attach the file

**Detail:** Create the entry through ExecAuto or custom routine and attach the original so audit sees both.

## Example Flows

### Certificate of analysis at receiving

**Trigger:** A PDF certificate arrives with a chemical lot.

**Steps:**

- OCR extracts lot number, product code, test values and result.
- Service finds the receiving lot and compares values to the specification.
- In-spec certificates are attached to the lot automatically.
- Out-of-spec values create a quality alert for the inspector.

**Result:** Quality sees the evidence with the lot at the moment of inspection, and deviations are flagged on receipt.

### Freight invoice coding

**Trigger:** A scanned freight invoice is dropped in the AP folder.

**Steps:**

- OCR reads supplier, document number, date, amount and tax lines.
- Service suggests cost center and account from the supplier's past entries.
- AP clerk confirms or edits in the review screen.
- A payable title is drafted and the file is attached.

**Result:** Typing is replaced by a quick confirmation, and coding becomes more consistent across clerks.

## On Prem

Document images are among the most sensitive data a plant holds: prices, tax ids, drawings, and sometimes controlled technical data. OCR and extraction can run entirely on-prem with open-source OCR engines and open-weight vision-language models on local GPUs, so no scan leaves the network. Connect the pipeline to the AppServer over internal REST and keep the review screen inside the corporate network or behind your VPN. A smaller model is often enough for clean, repeated supplier layouts, and you can reserve a larger one for odd documents. This also helps with export-controlled or customer-restricted drawings, where sending a file to an external cloud OCR service may breach your obligations.

## Security

- Store scans in an encrypted location with access limited by role, and apply the retention period your fiscal rules require.
- Never auto-post above a defined value or for new suppliers without a human check.
- Keep the image, extracted fields, model version and reviewer together in an audit record.
- Separate the OCR service account from Protheus users and give it draft-only routines.

## Options

### Use Fluig or a TOTVS document capture offering if already licensed

**Fit:** Document storage and routing needs, with light extraction.

**Effort:** Configuration plus workflow design.

### Build an in-house pipeline with open-source OCR

**Fit:** A few stable document types and a team comfortable running Python services.

**Effort:** Six to ten weeks for the first type with review screen.

### Partner-built pipeline with on-prem vision models, such as Netray

**Fit:** Many layouts, handwritten or low-quality scans, and data that cannot leave the plant.

**Effort:** Pilot on one document type, measure accuracy, then add types.

## Pitfalls

- Measuring accuracy on clean samples only; test on the worst scans from the receiving dock.
- Treating a total as correct without checking that lines sum to it.
- Skipping the review screen to save time and discovering errors at month-end close.
- Posting OCR output into stock or fiscal tables directly rather than drafts through the standard routines.

## Faq

### Do I need OCR if I already get NF-e XML?

**Answer:** Not for those invoices, since the XML is structured and should be parsed directly. OCR helps with foreign invoices, packing lists, certificates, receipts and any paper documents that arrive without structured data.

### How accurate is OCR on supplier invoices?

**Answer:** It depends on scan quality and layout variety. Clean, repeated layouts can reach high field-level accuracy, while poor scans need review. Use per-field confidence and measure on your own documents before setting auto-post thresholds.

### Can OCR results be written straight into Protheus?

**Answer:** They should be written as drafts through ExecAuto or custom routines so validations run. Direct table inserts bypass business rules and fiscal checks and make later reconciliation painful.

### Can it run without sending documents to the cloud?

**Answer:** Yes. Open-source OCR and open-weight vision-language models run on local GPUs, and the pipeline talks to Protheus over internal REST. Nothing needs to leave your network.

### Where should the scanned files be stored?

**Answer:** Attach them to the Protheus record using its document feature, or store them in Fluig or a file share and link by key. Whichever you choose, keep access controls and fiscal retention rules aligned with the original paper.

## Search terms

totvs protheus document ocr, protheus ocr invoices, ocr for totvs erp, protheus leitura de notas fiscais ocr, protheus certificate of analysis ocr, protheus fluig document capture, automate invoice entry protheus, on-prem ocr totvs

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
