ZUGFeRD-CSharp Documentation

repository·master·Indexed 19 days ago

https://github.com/stephanstapel/zugferd-csharp

An 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.

Tokens
7.6K
Snippets
17
Records
35
Agent score
64%

What's inside ZUGFeRD-CSharp

  1. Overview of the XRechnung Bundle

    master

    The 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):

    NameVersionDescription
    XRechnung Specification2.3.1The core standard documentation
    XRechnung Syntax-Bindingcompatible with 2.3.1Mapping for XRechnung 2.3.x
    Validator1.5.0The core checking engine
    XRechnung Validator Configuration2023-05-12Configuration for XRechnung validation
    XRechnung Schematron1.8.2Technical implementation of business rules
    XRechnung Visualization2023-05-12HTML and PDF rendering tools
    XRechnung Testsuite2023-05-12Valid test documents for verification
  2. Overview of the XRechnung Bundle components

    master

    The 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)

    NameVersionDescription
    XRechnung Specification3.0.1The core standard documentation.
    XRechnung Syntax-Bindingcompatible with 3.0.xMapping for the XRechnung 3.0.x standard.
    Validator1.5.0The core engine used to check XML documents.
    XRechnung Validator Configuration2023-09-22Configuration specifically for XRechnung validation.
    XRechnung Schematron2.0.1Technical implementation of business rules.
    XRechnung Visualization2023-09-22Tools for rendering invoices.
    XRechnung Testsuite2023-09-22Valid test documents for verification.
  3. How the Validator works

    master

    The 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 (valid or invalid) and a recommendation (accept or reject).
    • 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 accept recommendation for further processing.
  4. Understand XRechnung Schematron versioning

    master

    The 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.
  5. Add line items with automatic or manual IDs

    master

    When adding trade line items via AddTradeLineItem, you can choose between two modes:

    1. Automatic ID Generation: If you do not provide a lineID, the library generates sequential IDs (e.g., '1', '2').
    2. Manual ID Assignment: If you provide a lineID string, the library uses your specific identifier. This is useful when converting existing ERP system invoices to ZUGFeRD/Factur-X.

    Use the lineID parameter in the AddTradeLineItem method 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", ...);
  6. Understand FacturX and UBL XML structures

    master

    ZUGFeRD 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.

  7. Compare ZUGFeRD-CSharp and FactoorSharp

    master

    Decide 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.
  8. XRechnung Schematron Rules

    master

    The xrechnung-schematron component 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, and BR-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.
  9. Use XRechnung Validator Configuration for XRechnung validation

    master

    To 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.

  10. Use the XRechnung Testsuite for verification

    master

    The XRechnung Testsuite provides 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.