Skip to content

Documentation / @facturometro/parser / parseInvoice

Function: parseInvoice() ​

parseInvoice(xml): ParseResult<UncheckedInvoice>

Defined in: parse.ts:175

Parses a UBL invoice.

Parameters ​

xml ​

string

The document, as text.

Returns ​

ParseResult<UncheckedInvoice>

The model, the structural diagnostics and whether any of them is fatal.

Throws ​

When the document is not well-formed XML.

Throws ​

When the document element is neither a UBL Invoice nor a UBL CreditNote.

Throws ​

When the document is a credit note.

Example ​

ts
import { parseInvoice } from '@facturometro/parser';

const { diagnostics, document } = parseInvoice(xml);
document.id; // string | undefined

MIT licensed. Specification artefacts belong to OpenPEPPOL, CEN and OASIS.