npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

xrechnung-generator

v1.1.0

Published

A lightweight Node.js module for creating XRechnung-compliant invoices in the UBL (Universal Business Language) format.

Downloads

65

Readme

XRechnung Generator

XRechnung is a standardized electronic invoice format developed to comply with the European Directive 2014/55/EU, which mandates electronic invoicing in public procurement. It is primarily used in Germany, but it adheres to EU-wide guidelines for electronic invoicing.

A lightweight Node.js module for creating XRechnung-compliant invoices in the UBL (Universal Business Language) format.

Installation

Install the module via npm:

npm install xrechnung-generator

Usage

Import the Module

import XRechnungGenerator from 'xrechnung-generator'

Example: Using the Functions

const invoiceData = {
    id: 'INV-001',
    issueDate: '2024-01-01',
    currency: 'EUR',
    supplier: { name: 'Supplier Ltd.', country: 'DE' },
    customer: { name: 'Customer Ltd.', country: 'DE' },
    taxTotal: { taxAmount: 19, taxPercentage: 19 },
    lineItems: [
        {
            id: 'ITEM-001',
            description: 'Product A',
            quantity: 1,
            unitPrice: 100,
            lineTotal: 100,
        },
    ],
};

// Create a new invoice
const xrechnung = new XRechnungGenerator(invoiceData);
console.log(xrechnung.toXMLString());

API

XRechnungGenerator

const xrechnung = new XRechnungGenerator(invoiceData);
  • invoiceData (InvoiceData): The invoice to convert (see example above).
interface InvoiceData {
  id: string;
  issueDate: string;
  dueDate?: string; // optional
  currency: string;
  totalAmount: number;
  supplier: {
    name: string;
    country: string;
    street?: string; // optional
    postalCode?: string; // optional
    city?: string; // optional
    taxNumber?: string; // optional
    legalEntityID?: string; // optional
  };
  customer: {
    name: string;
    country: string;
    street?: string; // optional
    postalCode?: string; // optional
    city?: string; // optional
    taxNumber?: string; // optional
    legalEntityID?: string; // optional
  };
  taxTotal: {
    taxAmount: number;
    taxPercentage: number;
  };
  paymentDetails?: { // optional
    paymentMeansCode?: string; // optional
    paymentID?: string; // optional
    bankDetails?: { // optional
      accountName?: string; // optional
      iban?: string; // optional
      bic?: string; // optional
      bankName?: string; // optional
    }
  };
  notes?: string[]; // optional
  lineItems: {
    id: string;
    description: string;
    quantity: number;
    unitPrice: number;
    lineTotal: number;
  }[];
}

Methods

  1. toXMLString()

    • Returns the XML representation of the invoice as a string.
    const xmlString = xrechnung.toXMLString();
  2. toBuffer()

    • Returns the XML representation as a Buffer object.
    const buffer = xrechnung.toBuffer();
  3. toBlob()

    • Returns the XML representation as a Blob object (useful for browser environments).
    const blob = xrechnung.toBlob();
    console.log(blob.content);
  4. writeFile(filePath)

    • Writes the XML representation to the specified file path.
    • Parameters:
      • filePath (String): Path to the output file.
    • Returns a Promise.
    xrechnung.writeFile('/path/to/invoice.xrechnung')
        .then(() => console.log('File written successfully.'))
        .catch(console.error);

Contribution

Contributions in the form of bug reports, feature requests, or pull requests are welcome! Please ensure you run the tests and cover new functionality when contributing.

License

This project is licensed under the MIT License.

Hire Me

Looking for a developer with expertise in Node.js? Feel free to reach out to me for freelance projects, collaborations, or full-time opportunities!

Contact me [email protected]