Skip to content

HaciendaRepresentacion

Generates the printable representation of a Hacienda electronic document with its QR code, computed from the 50-digit numeric key. It can take an already-issued document (by passing its key, it recovers the data saved in the database) or receive a document in JSON to preview the representation before issuing it. Returns a self-contained HTML, ready to print or export to PDF.

FieldTypeRequiredDescription
credentials_idcredentialsYesHacienda credential
clavetextNoNumeric key (50 digits) of the issued document (fetches data from the database)
comprobantejsonNoDocument in JSON to preview (if no key is provided)

This module requires a hacienda credential type with the following fields:

  • Certificate (.p12): the issuer’s digital certificate
  • Certificate password
  • Issuer’s cedula/tax ID (9 to 12 digits)
  • ATV user and password (Hacienda’s IDP)
  • Environment: sandbox (testing) or production
{
"clave": "50601012600310123456700100001010000000001100000001",
"html": "...",
"qrImage": "data:image/png;base64,..."
}
{
"credentials_id": "cred-hacienda-prod",
"clave": "50601012600310123456700100001010000000001100000001"
}
  • If a key is passed, the node fetches the already-issued document from the database (type, sequential, receptor, totals) and builds the QR with its real status.
  • If there is no issued document yet, a document in JSON with its items can be passed to preview the representation before sending it to Hacienda.
  • The HTML is self-contained (styles included) and meant to be printed or exported to PDF directly.
  • If the key is not found in the database, the node returns an error instead of generating a representation with empty data.