CorvoNfse.Types.Invoice (Corvo NFS-e v0.1.1)

Copy Markdown View Source

Wire shape of an NFS-e invoice.

The SDK returns the invoice as a plain map with these string keys.

Summary

Types

Params for CorvoNfse.Resources.Invoices.create/3 and calculate/2 (camelCase wire keys, passed through unchanged)

Customer input for create_params.

Raw download body returned by pdf/2 and xml/2.

Environment wire value: "test" | "live".

A single entry of Invoices.events/3.

Stage wire value: "pending" | "authorized" | "documents_ready" | "completed" | "failed".

t()

Types

create_params()

@type create_params() :: map()

Params for CorvoNfse.Resources.Invoices.create/3 and calculate/2 (camelCase wire keys, passed through unchanged):

  • companyId or companyTaxId (CNPJ) - the issuing company
  • service (required) - %{code?:, municipalityCode?:, description?:}; code (6 digits) defaults to the company's, then to 100901
  • amount (required) - BRL, positive, up to 2 decimal places
  • competenceDate (required) - YYYY-MM-DD
  • customer (optional) - %{taxId:, name?:, email?:, address?:}; when sent, taxId (CPF or CNPJ) is required
  • discount (optional) - unconditional discount, from 0 up to amount
  • email (optional) - boolean; options.email.send wins when set
  • options (optional) - %{email?: %{send: boolean}, type?: "IMMEDIATE" | "SCHEDULE"}

  • externalId (optional)

customer_input()

@type customer_input() :: map()

Customer input for create_params.

download()

@type download() :: %{
  body: binary(),
  mime_type: String.t() | nil,
  file_name: String.t() | nil
}

Raw download body returned by pdf/2 and xml/2.

download_format()

@type download_format() :: :pdf | :xml | String.t()

environment()

@type environment() :: String.t()

Environment wire value: "test" | "live".

event()

@type event() :: map()

A single entry of Invoices.events/3.

stage()

@type stage() :: String.t()

Stage wire value: "pending" | "authorized" | "documents_ready" | "completed" | "failed".

status()

@type status() :: String.t()
Invoice status wire value: `"queued""processing""authorized"
"rejected""retry_pending""reconciliation_required"

"manual_review" | "failed"`.

t()

@type t() :: %CorvoNfse.Types.Invoice{
  accessKey: String.t() | nil,
  amount: number(),
  authorizedAt: String.t() | nil,
  companyId: String.t(),
  competenceDate: String.t(),
  createdAt: String.t(),
  currency: String.t(),
  customerSnapshot: map(),
  documentKeyVersion: integer(),
  documentsReadyAt: String.t() | nil,
  documentsStatus: String.t(),
  dpsId: String.t() | nil,
  dpsNumber: integer() | nil,
  dpsSeries: String.t() | nil,
  emailSnapshot: map(),
  emailStatus: String.t() | nil,
  environment: environment(),
  externalId: String.t() | nil,
  fiscalProvider: String.t() | nil,
  fiscalSchemaVersion: String.t() | nil,
  id: String.t(),
  idempotencyKey: String.t() | nil,
  issuedAt: String.t() | nil,
  lastEmailSentAt: String.t() | nil,
  lastEmailStatus: String.t() | nil,
  lastErrorCode: String.t() | nil,
  lastErrorMessage: String.t() | nil,
  lastErrorProvider: String.t() | nil,
  nfseNumber: integer() | nil,
  scheduledFor: String.t() | nil,
  serviceSnapshot: map(),
  stage: stage(),
  status: status(),
  taxSnapshot: map(),
  tenantId: String.t(),
  updatedAt: String.t()
}