Skip to main content
Introducing packages.sweber.dev
Documentation menuCLI

CLI

Validate invoices from the command line or in CI, extract XML from PDFs and check Leitweg-IDs.

npx @sweberdev/summand validate invoices/*.xml invoices/*.pdf
valid   invoices/RE-1001.xml  XRechnung 3.0  0 error(s), 0 warning(s)
INVALID invoices/RE-1002.pdf  EN 16931 (PDF)  1 error(s), 2 warning(s)
  error   BR-CO-15 (line 214): Invoice total amount with VAT (BT-112) = Invoice total amount without VAT (BT-109) + Invoice total VAT amount (BT-110).

The exit code is 1 when at least one invoice is invalid, so it can guard a CI step or a script.

Commands

CommandDoes
summand validate <files...>Validate XML and PDF files
summand extract <file.pdf> [--out file.xml]Write the embedded XML of a ZUGFeRD / Factur-X PDF
summand leitweg <id>Check a Leitweg-ID and print the correct check digits

validate options

OptionEffect
--jsonOne JSON result per line (JSON Lines)
--xrechnungApply XRechnung rules to every invoice
--strict-extendedEXTENDED: EN 16931 violations are errors
--warnings-as-errorsExit 1 on warnings too
--quietOnly the summary line per file

In code

import { runCli } from "@sweberdev/summand/cli";
const code = await runCli(["validate", "invoice.xml"]);