e-bon
e-bon.ro
TypeScript SDK

client.reports

Reference for the ReportsResource — live device reads (capabilities, telemetry, fiscal memory, electronic journal), X/Z/periodic prints and the ANAF archive export, mirroring /api/v1/devices/{deviceId}/reports.

client.reports

client.reports wraps /api/v1/devices/{deviceId}/reports/* — every method dispatches a command to the device through the cloud relay and returns the device's answer. There is no stored report model; the device's fiscal memory and electronic journal are the source of truth. See the matching REST documentation at Reports API.

The device must be online; offline devices surface as EBonApiError with a 503 connectivity code. The slow reads (readMf, readEj, printPeriodic, exportAnaf) use extended per-request timeouts aligned with the server's command budgets.

Range type

type ReportRange =
  | { fromDate: string; toDate: string } // YYYY-MM-DD, inclusive
  | { fromZ: number; toZ: number };      // Z numbers, inclusive

client.reports.getCapabilities(deviceId)

Which live-report operations the device driver supports.

async getCapabilities(deviceId: string): Promise<ReportCapabilitiesResponse>

Returns { capabilities: FiscalReportingCapabilities, deviceId, timestamp }. Gate your UI on these flags.

const { capabilities } = await client.reports.getCapabilities('dev_01HZ...');
if (capabilities.canReadMfStructured) { /* show Z history */ }

client.reports.getTelemetry(deviceId)

Fiscal memory + electronic journal counter telemetry.

async getTelemetry(deviceId: string): Promise<ReportTelemetryResponse>

Returns { mfInfo: FiscalMfInfo, ejInfo: FiscalEjInfo, deviceId, timestamp }.

client.reports.readMf(deviceId, range)

Read Z-closure rows from fiscal memory (Z history).

async readMf(deviceId: string, range: ReportRange): Promise<MfReadResponse>

Returns { mf: FiscalMfReadResult, deviceId, timestamp } — one { date, zNumber, grossTotalCents } entry per Z closure in the range.

const { mf } = await client.reports.readMf('dev_01HZ...', {
  fromDate: '2026-06-01',
  toDate: '2026-06-30',
});

client.reports.readEj(deviceId, range)

Read electronic journal text blocks.

async readEj(deviceId: string, range: ReportRange): Promise<EjReadResponse>

Returns { ej: FiscalEjReadResult, deviceId, timestamp } — verbatim lines per Z block plus totalLines.

client.reports.printX(deviceId)

Produce an X (daily running totals) report on the device.

async printX(deviceId: string): Promise<XZReportResponse>

Returns { report: DeviceReportSummary | null, deviceId, timestamp }.

client.reports.runZ(deviceId)

Run a Z (end-of-day) closure. Destructive — resets daily counters and advances fiscal memory.

async runZ(deviceId: string): Promise<XZReportResponse>

client.reports.printPeriodic(deviceId, range)

Print a periodic fiscal-memory report on the device's paper.

async printPeriodic(deviceId: string, range: ReportRange): Promise<PrintPeriodicResponse>

Returns { success: true, deviceId, timestamp }.

client.reports.exportAnaf(deviceId, request)

Export the ANAF monthly archive (base64 ZIP) from the device.

async exportAnaf(deviceId: string, request: AnafExportRequest): Promise<AnafExportResponse>

request is a ReportRange plus an optional storageTarget: 'ramdisk' | 'sdcard'. Returns { export: { filename, base64, sizeBytes }, deviceId, timestamp } — decode base64 and save as a .zip.

const { export: archive } = await client.reports.exportAnaf('dev_01HZ...', {
  fromDate: '2026-06-01',
  toDate: '2026-06-30',
});
await fs.writeFile(archive.filename, Buffer.from(archive.base64, 'base64'));

HTTP-level failures surface as EBonApiError — see Errors and /en/api/errors.