Skip to content

Documentation / einvoice-ts / parseCreditNote

Function: parseCreditNote() ​

parseCreditNote(xml): ParseResult<UncheckedCreditNote>

Defined in: packages/parser/src/parse.ts:236

Parses a UBL credit note.

Parameters ​

xml ​

string

The document, as text.

Returns ​

ParseResult<UncheckedCreditNote>

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

Throws ​

When the document is not well-formed XML, or its elements nest deeper than 1,000 levels (the document element is the first).

Throws ​

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

Throws ​

When the document is an invoice.

Example ​

ts
import { parseCreditNote } from '@einvoice-ts/parser';

const { diagnostics, document } = parseCreditNote(xml);
document.creditNoteLine?.length; // number | undefined

MIT licensed. Specification material belongs to OpenPeppol, CEN and OASIS (see NOTICE). Peppol is a trademark of OpenPeppol AISBL; this project is not affiliated with it.