@milchrechnungat/core
v0.11.1
Published
Canonical EN 16931 invoice model with parsers and renderers for ebInterface 6.1, PEPPOL BIS 3.0, Factur-X 1.0, ZUGFeRD 2.3, and XRechnung 3.0 (CII + UBL)
Maintainers
Readme
@milchrechnungat/core
Parse and render European e-invoices against a shared canonical model. Supports ebInterface 6.1 (Austria) and PEPPOL BIS 3.0 (EU-wide). The canonical model implements the EN 16931 semantic standard.
Install
pnpm add @milchrechnungat/core
# or
npm install @milchrechnungat/coreUsage
import { parsePeppolBis30, renderEbInterface61 } from "@milchrechnungat/core";
// Parse a PEPPOL BIS 3.0 XML document
const result = parsePeppolBis30(xmlBytes); // Uint8Array → ParseResult
if (!result.ok) throw new Error(result.errors[0].message);
// Render the canonical invoice as ebInterface 6.1
const rendered = renderEbInterface61(result.canonical); // canonical → RenderResult
if (!rendered.ok) throw new Error(rendered.errors[0].message);
console.log(new TextDecoder().decode(rendered.bytes));All parsers and renderers are pure functions — no I/O, no network, no global state.
Supported formats
| Format | Direction | |--------|-----------| | PEPPOL BIS 3.0 | parse + render | | ebInterface 6.1 | parse + render |
Conversion matrix
CONVERSION_MATRIX describes every source→target format pair, its status, and which lossiness concerns apply.
import { CONVERSION_MATRIX, getAvailableTargets, getConversionEntry } from "@milchrechnungat/core";
import type { FormatId } from "@milchrechnungat/core";
// All entries (4 for 2 formats: 2×2)
console.log(CONVERSION_MATRIX);
// Only actionable targets for a given source (status "available" or "partial")
const targets = getAvailableTargets("ebinterface-6.1");
// → [{ source: "ebinterface-6.1", target: "peppol-bis-3.0", status: "partial", noteKeys: [...] }]
// Look up a specific pair
const entry = getConversionEntry("peppol-bis-3.0", "ebinterface-6.1");
// → { source: "peppol-bis-3.0", target: "ebinterface-6.1", status: "partial", noteKeys: ["conversion.payment-means-mapping"] }noteKeys are namespaced i18n keys (e.g. "conversion.payment-means-mapping") that describe known lossiness for that direction. The core ships the keys; translation strings live in the consuming application.
| Source | Target | Status | noteKeys |
|--------|--------|--------|----------|
| ebinterface-6.1 | ebinterface-6.1 | unavailable | — |
| ebinterface-6.1 | peppol-bis-3.0 | partial | charge-total-allocation, buyer-reference-required |
| peppol-bis-3.0 | ebinterface-6.1 | partial | payment-means-mapping |
| peppol-bis-3.0 | peppol-bis-3.0 | unavailable | — |
Helper functions:
| Function | Returns |
|----------|---------|
| getConversionEntry(source, target) | The single ConversionEntry for that pair, or undefined |
| getAvailableTargets(source) | All entries where status is "available" or "partial" |
| getAllTargets(source) | All entries for the source, including "unavailable" and "coming_soon" |
License
Apache 2.0 — Copyright 2026 Rudolf Bohrer
