DeRE · Devoluções, cancelamentos e ajustes


Português

1. Contexto

Na DeRE, os eventos transacionais funcionam como documento fiscal. Uma operação já transmitida não é apagada nem substituída: ela é neutralizada por um novo evento que referencia a operação original. A Brinta gera esse evento a partir de um refund (POST /refunds/) que você envia referenciando a venda original.

Você não reenvia o adquirente, o codBC nem os dados específicos do evento (contrato, beneficiários, destinatário etc.). A Brinta copia tudo da venda original e gera as referências exigidas pela DeRE (chAgrupRef, seqRef).

2. O status do refund define o evento

status do refundQuando usarEvento DeRE
voidedO serviço não chegou a ser prestado, ou a operação foi registrada com erroCancelamento
refundedO serviço já foi prestado e está sendo desfeito depoisDevolução
pendingAinda não definidoNenhum (até mudar para voided ou refunded)
rejectedDescartadoNenhum

O critério é o serviço, não o dinheiro. O que separa cancelamento de devolução é se o serviço foi prestado, e não se o dinheiro já saiu da conta do cliente. Uma tarifa debitada por erro é cancelamento (voided), mesmo que o dinheiro já tenha saído. Um serviço prestado e ainda não cobrado que depois é estornado é devolução (refunded).

refunded é devolução fiscal na DeRE. Na DeRE não há nota fiscal nem nota de crédito: o próprio evento transacional é o documento fiscal. Por isso um refund refunded gera devolução. Não use refunded para correções de dinheiro que não têm relação com o serviço: para estornar um débito duplicado, por exemplo, cancele (voided) a transação duplicada.

Transações (vendas) com status: "rejected" nunca são transmitidas à DeRE. Para desfazer uma venda já enviada, use sempre um refund.

3. Efeitos de cada evento

Cancelamento (voided)Devolução (refunded)
Efeito no tempoRetroativo, na data da operação originalA partir da data da devolução
Crédito do adquirenteSe ele já se apropriou do crédito, o débito é recomposto com acréscimos moratórios desde a apropriaçãoEstorno na competência da devolução, sem retroagir

Usar refunded para algo que na verdade foi um cancelamento deixa a operação original válida no mês dela. Escolha o status com atenção.

4. Refund total e parcial

  • Total: omita items. Todos os itens da venda original são estornados, cada um com o seu evento.
  • Parcial, por item: liste os itens com original_item_id (o items[].id que a Brinta devolveu na venda) e amount (sem tributos) ou final_amount (com tributos), nunca os dois.
  • Um refund parcial sem items é rejeitado: a Brinta não rateia o valor entre os itens.
  • É possível enviar vários refunds parciais contra a mesma venda, desde que a soma por item não ultrapasse o original.
  • Os tributos são recalculados sobre o valor estornado e voltam positivos: o tipo do refund é o que indica que é uma reversão.

Cancelamento total

{
  "original_transaction_external_id": "ABC3595695",
  "transaction_external_id": "CANC-3595695",
  "type": "refund",
  "status": "voided"
}

Devolução parcial de um item

{
  "original_transaction_external_id": "ABC3595695",
  "transaction_external_id": "DEV-3595695-1",
  "type": "refund",
  "status": "refunded",
  "items": [
    { "original_item_id": "033cdb01-e9b9-4fa1-b4cd-750e8906d38d", "amount": 4000 }
  ]
}

5. O que a Brinta faz por você

  • Espera a operação original ser aceita. O evento de cancelamento ou devolução só é transmitido depois que a operação original tiver retorno com sucesso da DeRE. Se o refund chegar antes, a Brinta o retém e envia quando possível.
  • Período fechado. Se a competência da operação já estiver fechada, a Brinta faz a reabertura e o novo fechamento necessários.
  • Prazos. O refund também segue as janelas de transmissão do evento (blocos de 5 ou 7 dias). Envie-o no dia em que acontecer, não no fechamento do mês.

6. Envio em lote

Refunds também podem ser enviados pela Batch API, num lote do tipo refund (cada linha segue o corpo de POST /refunds/). Um lote tem um único tipo, então o lote de refunds não pode conter a venda que ele referencia: envie as vendas, aguarde o lote terminar e depois envie os refunds.

7. Dedução extemporânea

Os eventos D-2201 e D-2252 admitem a dedução extemporânea: uma despesa dedutível vinculada à operação (por exemplo, a corretagem de uma apólice) paga numa competência posterior à da receita, ou que a receita do contrato não consegue absorver.

A dedução não desfaz a operação: a receita continua válida e nada é devolvido ao cliente final. Ela só reduz a base da operação original, a partir da data do ajuste.

Envie um refund com type: "adjustment" e status: "refunded", indicando o item ao qual a despesa se vincula (original_item_id é obrigatório) e o valor da dedução em amount.

{
  "original_transaction_external_id": "APOL-778812",
  "transaction_external_id": "DED-778812-1",
  "type": "adjustment",
  "status": "refunded",
  "items": [
    { "original_item_id": "033cdb01-e9b9-4fa1-b4cd-750e8906d38d", "amount": 350 }
  ]
}

Só é aceito para operações de D-2201 e D-2252.


English

1. Context

In DeRE, transactional events work as the fiscal document. An operation that was already transmitted is not deleted or replaced: it is neutralized by a new event that references the original operation. Brinta generates that event from a refund (POST /refunds/) that you send referencing the original sale.

You don't resend the buyer, the codBC or the event-specific data (contract, beneficiaries, recipient, etc.). Brinta copies everything from the original sale and generates the references DeRE requires (chAgrupRef, seqRef).

2. The refund status defines the event

Refund statusWhen to use itDeRE event
voidedThe service was never rendered, or the operation was recorded in errorCancellation
refundedThe service was already rendered and is being undone afterwardsReturn
pendingNot decided yetNone (until it moves to voided or refunded)
rejectedDiscardedNone

The criterion is the service, not the money. What separates a cancellation from a return is whether the service was rendered, not whether the money already left the customer's account. A fee debited in error is a cancellation (voided), even if the money already left. A service rendered and not yet charged that is later reversed is a return (refunded).

refunded is a fiscal return in DeRE. DeRE has no invoices or credit notes: the transactional event itself is the fiscal document. So a refunded refund produces a return. Don't use refunded for money corrections unrelated to the service: to reverse a duplicate debit, for example, void (voided) the duplicate transaction.

Transactions (sales) with status: "rejected" are never transmitted to DeRE. To undo a sale that was already sent, always use a refund.

3. Effects of each event

Cancellation (voided)Return (refunded)
Effect in timeRetroactive, to the date of the original operationFrom the date of the return
Buyer's creditIf the buyer already took the credit, the debit is restored with late-payment charges from the date it was takenReversed in the period of the return, not retroactively

Using refunded for something that was really a cancellation leaves the original operation valid in its own month. Choose the status carefully.

4. Total and partial refunds

  • Total: leave out items. Every item of the original sale is refunded, each with its own event.
  • Partial, by item: list the items with original_item_id (the items[].id Brinta returned on the sale) and amount (excluding taxes) or final_amount (including taxes), never both.
  • A partial refund without items is rejected: Brinta does not prorate the amount across items.
  • You can send several partial refunds against the same sale, as long as the total per item never exceeds the original.
  • Taxes are recalculated on the refunded amount and come back positive: the refund type is what tells you it is a reversal.

Total cancellation

{
  "original_transaction_external_id": "ABC3595695",
  "transaction_external_id": "CANC-3595695",
  "type": "refund",
  "status": "voided"
}

Partial return of one item

{
  "original_transaction_external_id": "ABC3595695",
  "transaction_external_id": "DEV-3595695-1",
  "type": "refund",
  "status": "refunded",
  "items": [
    { "original_item_id": "033cdb01-e9b9-4fa1-b4cd-750e8906d38d", "amount": 4000 }
  ]
}

5. What Brinta does for you

  • Waits for the original operation to be accepted. The cancellation or return event is only transmitted after the original operation has a successful DeRE response. If the refund arrives earlier, Brinta holds it and sends it as soon as possible.
  • Closed period. If the period of the operation is already closed, Brinta handles the required reopening and new closing.
  • Deadlines. The refund also follows the event's transmission windows (5- or 7-day blocks). Send it the day it happens, not at month end.

6. Batch sending

Refunds can also be sent through the Batch API, in a batch of type refund (each line follows the body of POST /refunds/). A batch holds a single type, so a refund batch cannot include the sale it refers to: send the sales, wait for that batch to finish, then send the refunds.

7. Late deduction

Events D-2201 and D-2252 accept a late deduction (dedução extemporânea): a deductible expense tied to the operation (for example, the brokerage on a policy) paid in a later period than the revenue, or that the contract's revenue cannot absorb.

A deduction does not undo the operation: the revenue stays valid and nothing is returned to the end customer. It only reduces the base of the original operation, from the date of the adjustment.

Send a refund with type: "adjustment" and status: "refunded", naming the item the expense is tied to (original_item_id is required) and the deduction value in amount.

{
  "original_transaction_external_id": "APOL-778812",
  "transaction_external_id": "DED-778812-1",
  "type": "adjustment",
  "status": "refunded",
  "items": [
    { "original_item_id": "033cdb01-e9b9-4fa1-b4cd-750e8906d38d", "amount": 350 }
  ]
}

Only accepted for D-2201 and D-2252 operations.


Did this page help you?