# Pay suppliers, bills and salaries with the CNAB 240 file

> The CNAB 240 payment file sends the company's payments to the bank in one go: transfers, PIX, supplier boletos and salaries.

Fonte: https://docs.kmee.com.br/en/odoo/localizacoes/brasil/financeiro/pagamentos-cnab-240/

The CNAB 240 payment file sends the company's payments to the bank in one go: transfers, PIX, supplier boletos and salaries. The bank layout is configured on screen, field by field, and, when you confirm the bank return, the confirmed payments are settled.

## Before you start

The company has the payment agreement with the bank and the bank's layout manual (or the FEBRABAN CNAB 240 standard layout, version 10.09). The bank journal has the company bank account, and the suppliers and employees have their bank account or PIX key registered.

## Step by step

### 1. How the payment file is organized

The CNAB 240 file is a text file with records of 240 positions. It starts with the file header (record type 0) and ends with the file trailer (type 9), which counts the batches and the records. In between come the batches: each batch has a header (type 1) with the service type and the payment method, one detail record per payment, made of one or more segments (type 3), and a trailer (type 5) with the number of records and the sum of the amounts. Numeric fields are right aligned and filled with zeros, with the decimals implied (6,250.00 is written 000000000625000); text fields are left aligned, in capitals without accents, and filled with spaces. Dates are written DDMMYYYY.

### 2. The segments of each kind of payment

The FEBRABAN standard defines one segment for each kind of payment. Segment A carries the transfer: clearing house (018 for TED, 009 for PIX), the payee bank, branch and account, the name, the payment date and the amount. Segment B adds the payee data and, in PIX, the key type and the key. Segment J carries the payment of a boleto: the 44-digit barcode, the due date, the boleto amount and the amount paid, and segment J-52 identifies the payer and the beneficiary. The service type in the batch header separates supplier payments (20) from salaries (30), and the payment method tells the bank how to pay: 01 credit in an account at the same bank, 41 TED to another holder, 45 PIX transfer, 30 and 31 boletos of the same bank and of other banks.

### 3. When to use the configurable structure

Each bank publishes its own version of the layout, derived from the FEBRABAN standard. In Odoo, the CNAB structure describes the bank layout on screen: the lines in the file order, the batches, and in each segment the fields with start and end positions, type, decimals, fixed value and the Odoo field the content comes from. The module brings payment structures for several banks, in Invoicing > Configuration > CNAB Structures; the example in this guide uses Itaú's, which generates TED, PIX, boleto and salary payments and reads the bank return. To meet a bank or an agreement requirement, the implementation team adjusts the structure following the bank manual, checks the result in the CNAB Preview and approves it, without waiting for programming.

### 4. Set up the payments

In the bank journal, add the CNAB 240 outbound payment method and mark it to import CNAB returns. Create one payment mode per kind of payment (TED, PIX, boleto), with the CNAB 240 method, the fixed bank journal and the domain, mark Payment by CNAB file and choose the bank structure and the payment method of the mode. To pay salaries in their own batch, add to the structure the payment rule for employees, with the TED method and service type 30. Review and approve the structure: the review checks that every line covers positions 1 to 240 and that the batches are complete.

### 5. Generate and send the remittance

Post the supplier bills and the net salaries with the payment mode and the payee bank account. In Vendors > Bills, select the payables and use Action > Add to Payment/Debit Order. In the order, check the payments and the dates; for a boleto, open the payment and enter the 44-digit barcode. Click Confirm Payments and Generate Payment File: the file is attached to the order, with one batch per payment method and service type. Check the batches, the segments and the trailer totals, send the file to the bank and click File Successfully Uploaded.

### 6. Read the bank return

When the bank returns the file, open Vendors > CNAB > Import CNAB Returns, choose the bank journal (the approved structure is filled in), upload the file and import. Each payment becomes an event with the bank occurrence, linked to the remittance by its number: 00 means payment made; codes such as AN (invalid payee account) mean the payment was refused. Click Confirm: the payments made settle the payables against the bank pending payments account, which the bank statement reconciles, and the refused ones remain open for a new remittance with the corrected data.

## Expected result

The payments go to the bank in a single file organized by batch, the file is checked field by field before sending, and, when you confirm the return, the confirmed payments are settled at once.

## If something goes wrong

If a payable cannot be added to the order, check that it is posted, has the payment mode and is not in another order. If a segment comes out with the payee bank data in zeros, register the bank account on the payable and create the order again. If the structure does not appear when importing the return, approve the structure and choose the journal of the same bank.

## Continue the process

- [Prepare supplier payment orders and customer collection orders](https://docs.kmee.com.br/en/odoo/localizacoes/brasil/financeiro/pagar-fornecedores-por-cnab/)
- [Import a bank statement and reconcile](https://docs.kmee.com.br/en/odoo/funcional/financeiro/conciliacao-bancaria/)
- [Review receivables, payables and installments](https://docs.kmee.com.br/en/odoo/funcional/financeiro/parcelas-e-vencimentos/)
