Autorun AI Docs
Process DesignerBusiness FunctionBusiness Functions Reference

16. Fiscalization


generateInvoiceXml(invoice)

async · returns string (XML)

Generates a fiscalization-compliant XML document from an invoice object.

Prop

Type

const xml = await context.functions.generateInvoiceXml(context.record);

Returned value — a complete XML string conforming to the fiscalization standard:

<?xml version="1.0" encoding="UTF-8"?>
<tns:RacunZahtjev xmlns:tns="http://www.apis-it.hr/fin/2012/types/f73" Id="signXml">
  <tns:Zaglavlje>
    <tns:IdPoruke>abc12345-1234-1234-1234-abcdef012345</tns:IdPoruke>
    <tns:DatumVrijeme>12.03.2026T10:24:00</tns:DatumVrijeme>
  </tns:Zaglavlje>
  <tns:Racun>
    <tns:Oib>12345678901</tns:Oib>
    <tns:IznosUkupno>1500.00</tns:IznosUkupno>
    <tns:NacinPlac>G</tns:NacinPlac>
    <tns:ZastKod>a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4</tns:ZastKod>
    <tns:NakDost>false</tns:NakDost>
  </tns:Racun>
</tns:RacunZahtjev>

validateFiscalizationDocument(authorizationKey, documentContent)

async · returns string

Validates a fiscalization XML document with the tax authority.

Prop

Type

Returned value:

// On success:
"OK"

// On failure:
"ERROR: s006 - Neispravan OIB operatera."

sendFiscalizationDocument(authorizationKey, documentContent)

async · returns string (JIR)

Submits a fiscalization document to the tax authority. Should be called after successful validation.

Prop

Type

Full fiscalization flow:

Generate the XML from the invoice record using generateInvoiceXml
Validate the document against the tax authority using validateFiscalizationDocument
Submit the document with sendFiscalizationDocument and store the returned JIR code on the record
const authKey = "my-auth-key";
const xml = await context.functions.generateInvoiceXml(context.record);

const validation = await context.functions.validateFiscalizationDocument(authKey, xml);
if (validation !== "OK") throw new Error("Validation failed: " + validation);

const jir = await context.functions.sendFiscalizationDocument(authKey, xml);
await context.functions.update("invoices", context.record.ID, { JIR: jir, IsFiscalized: true });

Returned value — a string containing the JIR (Jedinstveni identifikator računa) code assigned by the tax authority:

"12ab34cd-ef56-7890-abcd-ef1234567890"