> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nekt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TOTVS Protheus as a data source

> Bring receivables with bank slip data, customers, products, prices, stock, and sales orders from TOTVS Protheus to your Lakehouse.

TOTVS Protheus is an ERP widely used by Brazilian companies for finance, sales, inventory, and invoicing. This connector reads Protheus through its own REST service, using the standard framework API that queries Protheus tables (GenericQuery), so it works on Protheus servers on TOTVS Cloud and on your own infrastructure.

## Before you start

Ask your Protheus administrator (or your TOTVS partner) to check the following:

* **The Protheus REST service is running and reachable from the internet over HTTPS**, for example `https://mycompany.protheus.cloudtotvs.com.br:4050/rest`. Nekt runs in the cloud, so an address that only works inside your network cannot be used. The connection sends the Protheus user and password on every request, so `http://` addresses are refused.
* **The REST service has security enabled** (`SECURITY=1` in the REST configuration). The API this connector uses only runs with security on.
* **The Protheus framework library (LIB) is up to date.** The GenericQuery API is part of the framework libraries released since 2022. Environments on TOTVS Cloud on a supported release already have it.
* **A Protheus user for the integration** with access to the tables of the streams you want (for example, accounts receivable, customers, products). To receive CPF/CNPJ, e-mail, and phone numbers, the user also needs access to personal and sensitive data (LGPD) in the Protheus Configurator: otherwise Protheus hides those columns and they arrive empty (the run log lists them).
* **The company group code and a branch code** the user can access (for example, `01` and `0101`).

> [!NOTE]
>
> Each request opened by the connector uses a Protheus REST thread, like any other integration with the Protheus API. Schedule the source outside peak hours if your REST service has few threads.

## Configuring TOTVS Protheus as a Source

In the [Sources](https://app.nekt.ai/sources) tab, click on the "Add source" button located on the top right of your screen. Then, select the **TOTVS Protheus** option from the list of connectors.

Click **Next** and you'll be prompted to add your access.

### 1. Add account access

The following configurations are available:

* **Protheus REST URL**: Address of the Protheus REST service including its path, as reached from the internet, for example `https://mycompany.protheus.cloudtotvs.com.br:4050/rest`.
* **Username** and **Password**: The Protheus user for the integration.
* **Company group code**: The Protheus company group (grupo de empresas) to extract, for example `01`. To extract more than one company group, create one source per group.
* **Branch code**: Any branch (filial) of that group the user can access, for example `0101`. It only opens the session: the data of every branch of the group is extracted, and each record carries its branch in the `*_filial` column.
* **Start date** (optional): Limits accounts receivable to those issued on or after this date, plus every receivable that is still open, and sales orders and their items to orders issued on or after this date. Leave it empty to read the whole history. If you set it, keep in mind:
  * A receivable issued before this date stays in the table only while it is open. When it is paid, it disappears from the table (it does not show up as paid).
  * Receivables issued before this date that were already paid are never loaded.
  * Moving the date forward makes the tables smaller.
  * Totals of received amounts from this table are complete only for receivables issued on or after this date.
* **Page size** (advanced): Records requested per call. Lower it if the Protheus REST service times out.
* **Verify SSL certificate** (advanced): Turn off only if your Protheus server uses a self-signed or incomplete certificate.

Once you're done, click **Next**.

### 2. Select streams

Choose which data streams you want to sync. Before extracting anything, Nekt checks every selected stream with Protheus. If the user cannot read a table, or a table is not used in your Protheus environment, the run stops before extracting anything and the run log lists each stream and what to fix. Give the user access to the table or unselect the stream.

Select the streams and click **Next**.

### 3. Configure data streams

Customize how you want your data to appear in your catalog. Select the desired layer where the data will be placed, a folder to organize it inside the layer, a name for each table (which will effectively contain the fetched data) and the type of sync.

* **Layer**: Choose between the existing layers on your catalog. This is where you will find your new extracted tables as the extraction runs successfully.
* **Folder**: A folder can be created inside the selected layer to group all tables being created from this new data source.
* **Table name**: We suggest a name, but feel free to customize it. You have the option to add a **prefix** to all tables at once and make this process faster!
* **Sync Type**: Every stream is FULL\_TABLE: each run replaces the table with what Protheus has at that moment, within the **Start date** limit described above. Read more about Sync Types [here](https://docs.nekt.com/get-started/core-concepts/types-of-sync).

Once you are done configuring, click **Next**.

### 4. Configure data source

Describe your data source for easy identification within your organization, not exceeding 140 characters.

To define your [Trigger](https://docs.nekt.com/get-started/core-concepts/triggers), consider how often you want data to be extracted from this source and the load on your Protheus REST service. Accounts receivable and sales orders are usually the largest tables: use the **Start date** to keep them bounded.

Optionally, you can define some additional settings:

* **Delta Log Retention**: Determine for how long we should store old states of this table as it gets updated. Read more about this resource [here](https://docs.nekt.com/get-started/core-concepts/resource-control).

Once you are ready, click **Next** to finalize the setup.

### 5. Check your new source

You can view your new source on the [Sources](https://app.nekt.ai/sources) page. If needed, manually trigger the source extraction by clicking on the arrow button. Once executed, your data will appear in your Catalog.

> [!WARNING]
>
> For you to be able to see it on your [Catalog](https://app.nekt.ai/catalog), you need at least one successful source run.

## Good to know

* **Column names are the Protheus field names** in lower case (`E1_NUM` becomes `e1_num`), so anyone who knows the Protheus data dictionary recognizes them. Custom fields (`*_X...`) and any other field Protheus returns are kept in the `extra_fields` column as JSON.
* **Bank slips (2nd copy):** the accounts receivable stream brings the bank's own number (`e1_numbco`, nosso número), the barcode as stored in Protheus (`e1_codbar`), the due dates, the amount, and the open balance. Nekt also derives the 47-digit typeable line (`boleto_digitable_line`) from the barcode, validating the check digits. The barcode is only present for receivables already registered with the bank (CNAB return, online bank API, or slip printing). The slip PDF or a slip URL is not available through the Protheus API.
* **Stock**: `b2_qatu` is the physical quantity per product and warehouse. Reserved (`b2_reserva`) and committed (`b2_qemp`) quantities are separate columns, so the available quantity is `b2_qatu - b2_reserva - b2_qemp`.
* **Prices**: the commercial prices are in the Price table items stream (`da1_prcven` per table and product). `b1_prv1` in Products is only the base price registered on the product.
* **Deleted records** in Protheus are not extracted, and they disappear from the tables on the next run.
* **Text values** come without the trailing blanks Protheus pads its fields with. Dates are stored as `YYYY-MM-DD`; an empty Protheus date is stored empty.
* **Records changed during a run**: Nekt reads each table in the order of its key, continuing from the last record read, so records added or removed elsewhere in the table during the run do not make it skip others. A record added during the run in a part of the table already read, or removed after it was read, shows up correctly on the next run.

# Streams and Fields

## Available streams

The table below lists every stream, its **slug** (the exact identifier to pass when creating the source via API), the Protheus table it reads, and its sync type.

| Stream | Slug | Protheus table | Sync |
| - | - | - | - |
| Accounts receivable and bank slips | `accounts_receivable` | SE1 - Contas a Receber | Full table |
| Customers | `customers` | SA1 - Clientes | Full table |
| Products | `products` | SB1 - Produtos | Full table |
| Product complements | `product_complements` | SB5 - Complemento de Produto | Full table |
| Price tables | `price_tables` | DA0 - Tabelas de Preço | Full table |
| Price table items | `price_table_items` | DA1 - Itens da Tabela de Preço | Full table |
| Stock balances | `stock_balances` | SB2 - Saldos em Estoque | Full table |
| Warehouses | `warehouses` | NNR - Locais de Estoque | Full table |
| Sales orders | `sales_orders` | SC5 - Pedidos de Venda | Full table |
| Sales order items | `sales_order_items` | SC6 - Itens dos Pedidos de Venda | Full table |
| Sales representatives | `sellers` | SA3 - Vendedores | Full table |
| Payment terms | `payment_terms` | SE4 - Condições de Pagamento | Full table |
| Branches | `branches` | Company group branches (framework API) | Full table |

## Fields by stream

> [accordion] Accounts receivable and bank slips
>
> Stream name: `accounts_receivable`. Source: SE1 - Contas a Receber.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `e1_filial`, `e1_prefixo`, `e1_num`, `e1_parcela`, `e1_tipo`, `e1_cliente`, `e1_loja`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `e1_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `e1_prefixo` | String | Receivable prefix (E1\_PREFIXO), part of the receivable key. |
> | `e1_num` | String | Receivable number (E1\_NUM), usually the invoice number. |
> | `e1_parcela` | String | Installment of the receivable (E1\_PARCELA); blank for a single installment. |
> | `e1_tipo` | String | Receivable type (E1\_TIPO): NF invoice, DP duplicate, BOL bank slip, RA advance, NCC credit note, AB- deduction, etc. |
> | `e1_cliente` | String | Customer code (E1\_CLIENTE); joins customers.a1\_cod. |
> | `e1_loja` | String | Customer store/unit (E1\_LOJA); joins customers.a1\_loja. |
> | `e1_nomcli` | String | Customer short name stored on the receivable (E1\_NOMCLI). |
> | `e1_naturez` | String | Financial nature code (E1\_NATUREZ). |
> | `e1_emissao` | Date | Issue date of the receivable (E1\_EMISSAO). |
> | `e1_vencori` | Date | Original due date (E1\_VENCORI). |
> | `e1_vencto` | Date | Due date (E1\_VENCTO). |
> | `e1_vencrea` | Date | Actual due date, moved to the next business day when needed (E1\_VENCREA). |
> | `e1_valor` | Number | Original amount of the receivable in its currency (E1\_VALOR). |
> | `e1_saldo` | Number | Open balance still to be received (E1\_SALDO); 0 when fully settled. |
> | `e1_vlcruz` | Number | Amount converted to the local currency (E1\_VLCRUZ). |
> | `e1_moeda` | Number | Currency number of the receivable (E1\_MOEDA); 1 is the local currency. |
> | `e1_descont` | Number | Discount granted (E1\_DESCONT). |
> | `e1_juros` | Number | Interest charged (E1\_JUROS). |
> | `e1_multa` | Number | Late fee charged (E1\_MULTA). |
> | `e1_acresc` | Number | Additions to the amount (E1\_ACRESC). |
> | `e1_decresc` | Number | Reductions of the amount (E1\_DECRESC). |
> | `e1_valliq` | Number | Net amount received on the last settlement (E1\_VALLIQ). |
> | `e1_porcjur` | Number | Daily interest rate (%) used for late payment (E1\_PORCJUR). |
> | `e1_baixa` | Date | Date of the last settlement (E1\_BAIXA); empty while nothing was received. |
> | `e1_status` | String | Receivable status (E1\_STATUS): A open, B settled. |
> | `e1_situaca` | String | Collection situation (E1\_SITUACA): 0 portfolio, 1 simple collection, 2 discounted, 3 pledged, 4 linked, 5 lawyer, 6 judicial, etc. |
> | `e1_portado` | String | Bank code of the collecting bank (E1\_PORTADO). |
> | `e1_agedep` | String | Agency of the collecting bank (E1\_AGEDEP). |
> | `e1_conta` | String | Account at the collecting bank (E1\_CONTA). |
> | `e1_numbco` | String | Bank's own number of the slip, 'nosso número' (E1\_NUMBCO). |
> | `e1_codbar` | String | Bank slip barcode as stored in Protheus (E1\_CODBAR). |
> | `e1_coddig` | String | Bank slip typeable line as stored in Protheus (E1\_CODDIG); not filled on every release or setup. |
> | `e1_idcnab` | String | CNAB identifier sent to the bank (E1\_IDCNAB). |
> | `e1_numbor` | String | Collection batch (borderô) number (E1\_NUMBOR). |
> | `e1_databor` | Date | Date of the collection batch (E1\_DATABOR). |
> | `e1_vend1` | String | Code of the main sales representative (E1\_VEND1); joins sellers.a3\_cod. |
> | `e1_pedido` | String | Sales order number that originated the receivable (E1\_PEDIDO). |
> | `e1_serie` | String | Invoice series (E1\_SERIE). |
> | `e1_fatura` | String | Number of the grouping invoice, when the receivable was grouped (E1\_FATURA). |
> | `e1_origem` | String | Protheus routine that created the receivable (E1\_ORIGEM). |
> | `e1_filorig` | String | Branch where the receivable originated (E1\_FILORIG). |
> | `e1_hist` | String | Free-text history of the receivable (E1\_HIST). |
> | `boleto_barcode` | String | 44-digit bank slip barcode, validated (general check digit) by the connector from E1\_CODBAR or E1\_CODDIG; null when Protheus has no valid bank slip for the receivable. |
> | `boleto_digitable_line` | String | 47-digit bank slip typeable line (linha digitável) derived by the connector from the barcode, following the FEBRABAN layout; null when there is no valid bank slip. |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Customers
>
> Stream name: `customers`. Source: SA1 - Clientes.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `a1_filial`, `a1_cod`, `a1_loja`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `a1_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `a1_cod` | String | Customer code (A1\_COD). |
> | `a1_loja` | String | Customer store/unit (A1\_LOJA); a customer may have several. |
> | `a1_nome` | String | Customer legal name (A1\_NOME). |
> | `a1_nreduz` | String | Customer trade/short name (A1\_NREDUZ). |
> | `a1_pessoa` | String | Person type (A1\_PESSOA): F individual, J company. |
> | `a1_tipo` | String | Customer type for taxes (A1\_TIPO): F final consumer, L rural producer, R reseller, S ICMS substitution, X export. |
> | `a1_cgc` | String | CNPJ (company) or CPF (individual) of the customer (A1\_CGC). |
> | `a1_inscr` | String | State registration (A1\_INSCR). |
> | `a1_inscrm` | String | Municipal registration (A1\_INSCRM). |
> | `a1_email` | String | E-mail of the customer (A1\_EMAIL). |
> | `a1_ddd` | String | Area code of the phone (A1\_DDD). |
> | `a1_tel` | String | Phone number (A1\_TEL). |
> | `a1_contato` | String | Contact person (A1\_CONTATO). |
> | `a1_end` | String | Street address (A1\_END). |
> | `a1_complem` | String | Address complement (A1\_COMPLEM). |
> | `a1_bairro` | String | District (A1\_BAIRRO). |
> | `a1_mun` | String | City name (A1\_MUN). |
> | `a1_cod_mun` | String | City IBGE code (A1\_COD\_MUN). |
> | `a1_est` | String | State abbreviation (A1\_EST). |
> | `a1_cep` | String | ZIP code (A1\_CEP). |
> | `a1_pais` | String | Country code (A1\_PAIS). |
> | `a1_endcob` | String | Billing address (A1\_ENDCOB). |
> | `a1_bairroc` | String | Billing district (A1\_BAIRROC). |
> | `a1_munc` | String | Billing city (A1\_MUNC). |
> | `a1_estc` | String | Billing state (A1\_ESTC). |
> | `a1_cepc` | String | Billing ZIP code (A1\_CEPC). |
> | `a1_vend` | String | Code of the customer's sales representative (A1\_VEND); joins sellers.a3\_cod. |
> | `a1_cond` | String | Default payment term (A1\_COND); joins payment\_terms.e4\_codigo. |
> | `a1_tabela` | String | Default price table (A1\_TABELA); joins price\_tables.da0\_codtab. |
> | `a1_naturez` | String | Default financial nature (A1\_NATUREZ). |
> | `a1_risco` | String | Credit risk rating (A1\_RISCO): A to E. |
> | `a1_lc` | Number | Credit limit (A1\_LC). |
> | `a1_venclc` | Date | Credit limit expiry date (A1\_VENCLC). |
> | `a1_ultcom` | Date | Date of the last purchase (A1\_ULTCOM). |
> | `a1_dtcad` | Date | Registration date (A1\_DTCAD). |
> | `a1_hpage` | String | Web site (A1\_HPAGE). |
> | `a1_msblql` | String | Blocked flag (A1\_MSBLQL): 1 blocked, 2 or blank active. |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Products
>
> Stream name: `products`. Source: SB1 - Produtos.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `b1_filial`, `b1_cod`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `b1_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `b1_cod` | String | Product code (B1\_COD). |
> | `b1_desc` | String | Product description/title (B1\_DESC). |
> | `b1_tipo` | String | Product type (B1\_TIPO): PA finished good, MP raw material, ME merchandise, etc. |
> | `b1_um` | String | Unit of measure (B1\_UM). |
> | `b1_segum` | String | Second unit of measure (B1\_SEGUM). |
> | `b1_conv` | Number | Conversion factor between the two units (B1\_CONV). |
> | `b1_grupo` | String | Product group code (B1\_GRUPO). |
> | `b1_locpad` | String | Default warehouse (B1\_LOCPAD); joins warehouses.nnr\_codigo. |
> | `b1_prv1` | Number | Base sale price registered on the product (B1\_PRV1); price tables hold the commercial prices. |
> | `b1_custd` | Number | Standard cost (B1\_CUSTD). |
> | `b1_uprc` | Number | Last purchase price (B1\_UPRC). |
> | `b1_codbar` | String | Barcode / EAN of the product (B1\_CODBAR). |
> | `b1_posipi` | String | NCM tax classification (B1\_POSIPI). |
> | `b1_cest` | String | CEST code (B1\_CEST). |
> | `b1_origem` | String | Tax origin of the goods (B1\_ORIGEM). |
> | `b1_peso` | Number | Net weight (B1\_PESO). |
> | `b1_pesbru` | Number | Gross weight (B1\_PESBRU). |
> | `b1_ts` | String | Default outgoing tax operation code, TES (B1\_TS). |
> | `b1_te` | String | Default incoming tax operation code, TES (B1\_TE). |
> | `b1_ucom` | Date | Date of the last purchase (B1\_UCOM). |
> | `b1_msblql` | String | Blocked flag (B1\_MSBLQL): 1 blocked, 2 or blank active. |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Product complements
>
> Stream name: `product_complements`. Source: SB5 - Complemento de Produto.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `b5_filial`, `b5_cod`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `b5_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `b5_cod` | String | Product code (B5\_COD); joins products.b1\_cod. |
> | `b5_ceme` | String | Extended product name/description (B5\_CEME). |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Price tables
>
> Stream name: `price_tables`. Source: DA0 - Tabelas de Preço.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `da0_filial`, `da0_codtab`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `da0_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `da0_codtab` | String | Price table code (DA0\_CODTAB). |
> | `da0_descri` | String | Price table description (DA0\_DESCRI). |
> | `da0_datde` | Date | First day the table is valid (DA0\_DATDE). |
> | `da0_horade` | String | Time the table starts being valid (DA0\_HORADE). |
> | `da0_datate` | Date | Last day the table is valid (DA0\_DATATE); empty when open-ended. |
> | `da0_horate` | String | Time the table stops being valid (DA0\_HORATE). |
> | `da0_condpg` | String | Payment term tied to the table (DA0\_CONDPG). |
> | `da0_ativo` | String | Active flag (DA0\_ATIVO): 1 active, 2 inactive. |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Price table items
>
> Stream name: `price_table_items`. Source: DA1 - Itens da Tabela de Preço.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `da1_filial`, `da1_codtab`, `da1_item`, `da1_codpro`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `da1_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `da1_codtab` | String | Price table code (DA1\_CODTAB); joins price\_tables.da0\_codtab. |
> | `da1_item` | String | Item number inside the price table (DA1\_ITEM). |
> | `da1_codpro` | String | Product code (DA1\_CODPRO); joins products.b1\_cod. |
> | `da1_grupo` | String | Product group, for prices set per group (DA1\_GRUPO). |
> | `da1_prcven` | Number | Sale price (DA1\_PRCVEN). |
> | `da1_vlrdes` | Number | Discount value (DA1\_VLRDES). |
> | `da1_perdes` | Number | Discount percentage (DA1\_PERDES). |
> | `da1_prcmax` | Number | Maximum price (DA1\_PRCMAX). |
> | `da1_ativo` | String | Active flag (DA1\_ATIVO): 1 active, 2 inactive. |
> | `da1_estado` | String | State the price applies to (DA1\_ESTADO); blank for every state. |
> | `da1_tpoper` | String | Operation type the price applies to (DA1\_TPOPER). |
> | `da1_qtdlot` | Number | Quantity up to which the price applies, for tiered prices (DA1\_QTDLOT). |
> | `da1_indlot` | String | Lot/tier indicator (DA1\_INDLOT). |
> | `da1_moeda` | Number | Currency number of the price (DA1\_MOEDA). |
> | `da1_datvig` | Date | Date the price becomes valid (DA1\_DATVIG). |
> | `da1_frete` | Number | Freight value (DA1\_FRETE). |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Stock balances
>
> Stream name: `stock_balances`. Source: SB2 - Saldos em Estoque.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `b2_filial`, `b2_cod`, `b2_local`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `b2_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `b2_cod` | String | Product code (B2\_COD); joins products.b1\_cod. |
> | `b2_local` | String | Warehouse code (B2\_LOCAL); joins warehouses.nnr\_codigo. |
> | `b2_qatu` | Number | Current physical quantity in stock (B2\_QATU). |
> | `b2_reserva` | Number | Quantity reserved (B2\_RESERVA). |
> | `b2_qemp` | Number | Quantity committed to production orders (B2\_QEMP). |
> | `b2_qpedven` | Number | Quantity in sales orders not yet released (B2\_QPEDVEN). |
> | `b2_salpedi` | Number | Quantity in purchase orders still to arrive (B2\_SALPEDI). |
> | `b2_qaclass` | Number | Quantity waiting for classification (B2\_QACLASS). |
> | `b2_cm1` | Number | Average unit cost in the local currency (B2\_CM1). |
> | `b2_vatu1` | Number | Total stock value in the local currency (B2\_VATU1). |
> | `b2_dinvent` | Date | Date of the last inventory count (B2\_DINVENT). |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Warehouses
>
> Stream name: `warehouses`. Source: NNR - Locais de Estoque.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `nnr_filial`, `nnr_codigo`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `nnr_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `nnr_codigo` | String | Warehouse code (NNR\_CODIGO). |
> | `nnr_descri` | String | Warehouse description (NNR\_DESCRI). |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Sales orders
>
> Stream name: `sales_orders`. Source: SC5 - Pedidos de Venda.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `c5_filial`, `c5_num`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `c5_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `c5_num` | String | Sales order number (C5\_NUM). |
> | `c5_tipo` | String | Order type (C5\_TIPO): N normal, D return, B goods for processing, C/I/P price complements. |
> | `c5_cliente` | String | Customer code (C5\_CLIENTE); joins customers.a1\_cod. |
> | `c5_lojacli` | String | Customer store/unit (C5\_LOJACLI); joins customers.a1\_loja. |
> | `c5_client` | String | Delivery customer code (C5\_CLIENT). |
> | `c5_lojaent` | String | Delivery customer store/unit (C5\_LOJAENT). |
> | `c5_condpag` | String | Payment term (C5\_CONDPAG); joins payment\_terms.e4\_codigo. |
> | `c5_tabela` | String | Price table used (C5\_TABELA); joins price\_tables.da0\_codtab. |
> | `c5_vend1` | String | Main sales representative (C5\_VEND1); joins sellers.a3\_cod. |
> | `c5_emissao` | Date | Order date (C5\_EMISSAO). |
> | `c5_tpfrete` | String | Freight type (C5\_TPFRETE): C CIF, F FOB, T third party, S none. |
> | `c5_frete` | Number | Freight value (C5\_FRETE). |
> | `c5_transp` | String | Carrier code (C5\_TRANSP). |
> | `c5_moeda` | Number | Currency number (C5\_MOEDA). |
> | `c5_descont` | Number | Discount value of the order (C5\_DESCONT). |
> | `c5_liberok` | String | Release flag (C5\_LIBEROK): S when the order was released. |
> | `c5_blq` | String | Block flag (C5\_BLQ): blank unblocked, 1 business rule, 2 budget. |
> | `c5_nota` | String | Invoice number, once invoiced (C5\_NOTA). |
> | `c5_serie` | String | Invoice series (C5\_SERIE). |
> | `c5_mennota` | String | Message printed on the invoice (C5\_MENNOTA). |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Sales order items
>
> Stream name: `sales_order_items`. Source: SC6 - Itens dos Pedidos de Venda.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `c6_filial`, `c6_num`, `c6_item`, `c6_produto`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `c6_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `c6_num` | String | Sales order number (C6\_NUM); joins sales\_orders.c5\_num. |
> | `c6_item` | String | Item number inside the order (C6\_ITEM). |
> | `c6_produto` | String | Product code (C6\_PRODUTO); joins products.b1\_cod. |
> | `c6_descri` | String | Product description on the item (C6\_DESCRI). |
> | `c6_um` | String | Unit of measure (C6\_UM). |
> | `c6_qtdven` | Number | Quantity sold (C6\_QTDVEN). |
> | `c6_prcven` | Number | Unit sale price (C6\_PRCVEN). |
> | `c6_prunit` | Number | List unit price before discounts (C6\_PRUNIT). |
> | `c6_valor` | Number | Total value of the item (C6\_VALOR). |
> | `c6_descont` | Number | Discount percentage (C6\_DESCONT). |
> | `c6_valdesc` | Number | Discount value (C6\_VALDESC). |
> | `c6_qtdent` | Number | Quantity already delivered/invoiced (C6\_QTDENT). |
> | `c6_local` | String | Warehouse the item ships from (C6\_LOCAL). |
> | `c6_tes` | String | Tax operation code, TES (C6\_TES). |
> | `c6_cf` | String | Fiscal operation code, CFOP (C6\_CF). |
> | `c6_entreg` | Date | Delivery date (C6\_ENTREG). |
> | `c6_cli` | String | Customer code (C6\_CLI). |
> | `c6_loja` | String | Customer store/unit (C6\_LOJA). |
> | `c6_nota` | String | Invoice number, once invoiced (C6\_NOTA). |
> | `c6_serie` | String | Invoice series (C6\_SERIE). |
> | `c6_datfat` | Date | Invoicing date (C6\_DATFAT). |
> | `c6_blq` | String | Block flag of the item (C6\_BLQ): R residue eliminated, S manual block. |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Sales representatives
>
> Stream name: `sellers`. Source: SA3 - Vendedores.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `a3_filial`, `a3_cod`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `a3_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `a3_cod` | String | Sales representative code (A3\_COD). |
> | `a3_nome` | String | Sales representative name (A3\_NOME). |
> | `a3_nreduz` | String | Short name (A3\_NREDUZ). |
> | `a3_tipo` | String | Type (A3\_TIPO): I internal, E external, P partner. |
> | `a3_cgc` | String | CNPJ or CPF of the sales representative (A3\_CGC). |
> | `a3_email` | String | E-mail (A3\_EMAIL). |
> | `a3_dddtel` | String | Area code of the phone (A3\_DDDTEL). |
> | `a3_tel` | String | Phone number (A3\_TEL). |
> | `a3_comis` | Number | Default commission percentage (A3\_COMIS). |
> | `a3_msblql` | String | Blocked flag (A3\_MSBLQL): 1 blocked, 2 or blank active. |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Payment terms
>
> Stream name: `payment_terms`. Source: SE4 - Condições de Pagamento.
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `e4_filial`, `e4_codigo`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `e4_filial` | String | Branch (filial) code of the record; blank when the table is shared by every branch of the company. |
> | `e4_codigo` | String | Payment term code (E4\_CODIGO). |
> | `e4_tipo` | String | Payment term type (E4\_TIPO), which defines how E4\_COND is read. |
> | `e4_cond` | String | Payment term rule (E4\_COND), e.g. 30,60,90 for days after issue. |
> | `e4_descri` | String | Payment term description (E4\_DESCRI). |
> | `e4_msblql` | String | Blocked flag (E4\_MSBLQL): 1 blocked, 2 or blank active. |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |

> [accordion] Branches
>
> Stream name: `branches`. Source: Company group branches (framework API).
>
> **Sync Strategy:**
>
> * Full table (the whole table is read on every run)
> * Primary key(s): `enterprise_group`, `code`
>
> | Field | Type | Description |
> | :- | :- | :- |
> | `enterprise_group` | String | Company group code (grupo de empresas, M0\_CODIGO); the first part of the tenantId. |
> | `company_code` | String | Company code inside the group (Gestão Corporativa layout). |
> | `unit_of_business` | String | Business unit code inside the company (Gestão Corporativa layout). |
> | `code` | String | Branch code (M0\_CODFIL), as found in the \*\_filial columns of the other streams. Branch (filial) code of the record. |
> | `description` | String | Branch name (M0\_NOME / M0\_FILIAL). |
> | `title` | String | Branch legal or trade name (M0\_NOMECOM). |
> | `cgc` | String | CNPJ of the branch (M0\_CGC). |
> | `state_registration` | String | State registration of the branch (M0\_INSC). |
> | `city_registration` | String | Municipal registration of the branch (M0\_INSCM). |
> | `street` | String | Street address of the branch (M0\_ENDENT). |
> | `complement` | String | Address complement of the branch. |
> | `neighborhood` | String | District of the branch (M0\_BAIRENT). |
> | `city` | String | City of the branch (M0\_CIDENT). |
> | `city_code` | String | City IBGE code of the branch (M0\_CODMUN). |
> | `state` | String | State of the branch (M0\_ESTENT). |
> | `zip_code` | String | ZIP code of the branch (M0\_CEPENT). |
> | `phone` | String | Phone of the branch (M0\_TEL). |
> | `extra_fields` | String (JSON) | Every other field Protheus returned for the record (custom fields, fields of newer releases), as a JSON object keyed by the lower-case Protheus field name. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.