ZUGFeRD-CSharp Documentation
repository·master·Indexed 19 days ago
https://github.com/stephanstapel/zugferd-csharpAn open-source library for creating and processing ZUGFeRD invoices, currently in a maintenance-only phase. The documentation includes detailed information on the XRechnung Bundle (versions 2.3.1 and 3.0.1), featuring a domain-agnostic Validator, XRechnung Schematron for German CIUS business rules (EN16931:2017), XSL Transformers for HTML and PDF visualization, and a test suite for verification.
What's inside ZUGFeRD-CSharp
- XRechnung Schematron provides Schematron rules for the XML validation of German CIUS (XRechnung) business rules. These rules ensure compliance with the EN16931:2017 standard.
Overview of the XRechnung Bundle
masterThe XRechnung Bundle is an integrated collection of components designed to support the XRechnung standard. It includes the specification, syntax bindings, validation tools, and visualization resources required to work with XRechnung XML documents.
Bundle Components (Version 2.3.1):
Name Version Description XRechnung Specification 2.3.1 The core standard documentation XRechnung Syntax-Binding compatible with 2.3.1 Mapping for XRechnung 2.3.x Validator 1.5.0 The core checking engine XRechnung Validator Configuration 2023-05-12 Configuration for XRechnung validation XRechnung Schematron 1.8.2 Technical implementation of business rules XRechnung Visualization 2023-05-12 HTML and PDF rendering tools XRechnung Testsuite 2023-05-12 Valid test documents for verification Overview of the XRechnung Bundle components
masterThe XRechnung Bundle is an integrated collection of tools and documentation for the XRechnung standard. It includes the specification, syntax bindings, a validator, configuration files, Schematron rules, visualization tools, and a test suite.
Bundle Components (Version 3.0.1)
Name Version Description XRechnung Specification 3.0.1 The core standard documentation. XRechnung Syntax-Binding compatible with 3.0.x Mapping for the XRechnung 3.0.x standard. Validator 1.5.0 The core engine used to check XML documents. XRechnung Validator Configuration 2023-09-22 Configuration specifically for XRechnung validation. XRechnung Schematron 2.0.1 Technical implementation of business rules. XRechnung Visualization 2023-09-22 Tools for rendering invoices. XRechnung Testsuite 2023-09-22 Valid test documents for verification. How the Validator works
masterThe Validator is a domain-agnostic program that checks XML documents against specific validation rules (XML Schema and Schematron) based on their document types.
Key Behaviors:
- Aggregation: It aggregates results into a conformity report containing a status (
validorinvalid) and a recommendation (acceptorreject). - Configuration-Driven: The tool itself does not know specific document contents or rules. It relies on a Validator Configuration to define which rules to apply.
- Rule Flexibility: Through configuration, you can specify which conformity rules a document is allowed to violate while still receiving an
acceptrecommendation for further processing.
- Aggregation: It aggregates results into a conformity report containing a status (
Understand XRechnung Schematron versioning
masterThe project uses Semantic Versioning (MAJOR.MINOR.PATCH). Understanding these increments is critical for managing XML validation compatibility:
- MAJOR version: Incremented for incompatible changes. Rules are updated such that XML previously valid under a previous major version will DEFINITELY NOT validate against the new version.
- MINOR version: Incremented when adding functionality (e.g., adding new codelist terms or accepting new optional XML elements). CAUTION: A minor update might break your specific validation scenario or your ability to accept certain XML content.
- PATCH version: Incremented for backwards-compatible bug fixes.
Add line items with automatic or manual IDs
masterWhen adding trade line items via
AddTradeLineItem, you can choose between two modes:- Automatic ID Generation: If you do not provide a
lineID, the library generates sequential IDs (e.g., '1', '2'). - Manual ID Assignment: If you provide a
lineIDstring, the library uses your specific identifier. This is useful when converting existing ERP system invoices to ZUGFeRD/Factur-X.
Use the
lineIDparameter in theAddTradeLineItemmethod to control this behavior.// Automatic generation desc.AddTradeLineItem("Item name", 23.99m, QuantityCodes.H87, "Detail description", ...); // Manual assignment (e.g., for ERP migration) desc.AddTradeLineItem(lineID: "0001", 23.99m, QuantityCodes.H87, "Item name", "Detail description", ...);- Automatic ID Generation: If you do not provide a
Understand FacturX and UBL XML structures
masterZUGFeRD implementations often involve complex XML structures based on FacturX or UBL (Universal Business Language). If you need to understand the underlying schema and data models for these formats, refer to the official documentation links provided below.
- FacturX Documentation: http://doc.factoorsharp.com/
- UBL Invoice Syntax (Peppol): https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/
Compare ZUGFeRD-CSharp and FactoorSharp
masterDecide between the open-source library and the commercial successor based on your requirements:
ZUGFeRD-CSharp (Open Source)
- Status: Maintenance only.
- Updates: Bug fixes and stability improvements only.
- Best for: Existing projects that only require basic ZUGFeRD processing and do not need new features.
FactoorSharp (Commercial Successor)
- Status: Active product development.
- Features:
- Validation component: Validates ZUGFeRD, Factur-X, and PDF documents using tools like Mustang, Valitool, and VeraPDF.
- Visualization component: Generates high-quality PDF representations from electronic invoice data.
- Standard Support: Early integration of upcoming e-invoicing regulatory requirements.
- Support: Professional technical assistance and integration help.
- Best for: New projects, production-grade environments, and compliance-heavy workflows.
XRechnung Schematron Rules
masterThe
xrechnung-schematroncomponent provides the technical implementation of the XRechnung business rules using Schematron rules for XML validation.Note on recent updates (v1.8.2):
- Includes merged UBL Invoice and CreditNote code.
- Introduces new rules:
BR-DEX-13,BR-DEX-14, andBR-DEX-15. - Warning: These new rules may trigger error messages if existing normative requirements are not met, as they are being integrated into the specification's informational tables.
Use XRechnung Validator Configuration for XRechnung validation
masterTo validate XRechnung documents using the generic Validator tool, you must provide an XRechnung Validator Configuration. This configuration contains all necessary resources for the EN16931 standard, including:
- XML Schemas
- Schematron rules (via
xrechnung-schematron) - Current versions of all required validation assets.
This configuration bridges the gap between the generic validator engine and the specific requirements of the XRechnung standard.
Use the XRechnung Testsuite for verification
masterThe
XRechnung Testsuiteprovides a collection of valid test documents that adhere to the XRechnung standard.Use cases:
- Software Development: Use these documents to test IT specialist processes (Fachverfahren) to ensure they correctly interpret the XRechnung specification.
- Integration Testing: Incorporate these documents into your own testing procedures to verify compliance with complex specification requirements.
Install ZUGFeRD-csharp via NuGet
masterTo use the library in your project, install the
ZUGFeRD-csharppackage using NuGet or the Visual Studio Package Manager.dotnet add package ZUGFeRD-csharp