# `SefazNfe.Events`
[🔗](https://github.com/devaction-labs/sefaz_nfe/blob/v0.5.0/lib/sefaz_nfe/events.ex#L1)

Builders for the MOC's post-authorization events and for inutilização.

These are the only documents this library composes. AD-001 keeps NF-e XML
with the ERP because it carries tax arithmetic; an event carries none — it is
a key, a protocol and a justification — so composing it here does not make
this a second fiscal engine.

Each element is signed on its own `Id`, whose shape the MOC fixes: `ID` plus
the event code, the access key and the two digit sequence for an event, and
`ID` plus code, UF, year, CNPJ, model, series and number range for a voided
range. A malformed `Id` is rejected by schema validation, so it is built here
rather than left to the caller.

# `cancel`

```elixir
@spec cancel(map()) :: binary()
```

Event 110111, cancelling an authorized NF-e.

# `correction`

```elixir
@spec correction(map()) :: binary()
```

Event 110110, the Carta de Correção Eletrônica.

`xCondUso` is the fixed legal text the MOC requires verbatim; SEFAZ rejects
the event if it differs, so it is not a caller's field.

# `epec`

```elixir
@spec epec(map()) :: binary()
```

Event 110140, the EPEC (Evento Prévio de Emissão em Contingência).

`opts.epec` is what `SefazNfe.EPEC.extract/1` read from the NF-e: its values
are copied, never derived, so the numbers SEFAZ registers are the NF-e's own.
Like the manifestation it is processed by the Ambiente Nacional (`cOrgao` 91),
and `opts.tax_id` is the emitter, the event's author. The element order of
`detEvento` is the XSD's (`e110140NFe_v1.00.xsd`).

# `manifestation`

```elixir
@spec manifestation(atom(), map()) :: binary()
```

Manifestação do destinatário: events 210200, 210210, 210220 and 210240.

This is how a recipient answers a document that DistDFe delivered, and it is
what unlocks the full XML of a note you only received a summary of. Unlike
cancel and CCe, these are processed by the Ambiente Nacional rather than by
the issuing state, so `cOrgao` is 91.

`:not_performed` requires a justification; the other three take none.

# `manifestation_types`

```elixir
@spec manifestation_types() :: [atom()]
```

The four manifestação types this library builds.

# `void_numbers`

```elixir
@spec void_numbers(map()) :: binary()
```

`inutNFe` for `NFeInutilizacao4`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
