Skip to content

Repository files navigation

invoice4j

LicenseJava

invoice4j is a modular, open-source Java library for creating, reading, validating, and converting electronic invoices.

The project provides support for multiple e-invoicing standards, including ZUGFeRD, Factur-X, XRechnung, and PEPPOL BIS.

Status: Early development


Features

  • EN 16931 compliant domain model
  • ZUGFeRD / Factur-X support
  • XRechnung support
  • Built-in invoice calculation engine
  • XML validation
  • Pure Java, no external services

Supported Standards

  • UN/CEFACT CII
  • ZUGFeRD
  • XRechnung
  • UBL (planned)
  • PEPPOL (planned)

Invoice Calculation Engine

invoice4j contains a built-in calculation engine that automatically derives invoice totals according to EN 16931.

Features

  • Calculates invoice line totals (BT-131)
  • Supports fixed and percentage discounts
  • Supports line and document level allowances/charges
  • Calculates VAT breakdowns (BG-23)
  • Calculates invoice monetary summation (BG-22)
  • Centralized monetary arithmetic and rounding
  • Validates calculation consistency

Installation

Requirements

  • Java 23 or later
<dependency>
<groupId>io.github.jcodeforge</groupId>
<artifactId>invoice4j-zugferd</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>io.github.jcodeforge</groupId>
<artifactId>invoice4j-xr</artifactId>
<version>0.4.0</version>
</dependency>

Only add the module(s) you need. Both modules automatically include the shared invoice4j-base dependency.

Gradle (Kotlin DSL)

implementation("io.github.jcodeforge:invoice4j-zugferd:0.4.0")
implementation("io.github.jcodeforge:invoice4j-xr:0.4.0")

Gradle (Groovy)

implementation 'io.github.jcodeforge:invoice4j-zugferd:0.4.0'
implementation 'io.github.jcodeforge:invoice4j-xr:0.4.0'

invoice4j-zugferd supports ZUGFeRD and Factur-X documents. invoice4j-xr supports XRechnung. Both modules automatically include the shared core library.


Quick Start

Complete runnable examples are available here:

invoice4j-base/src/main/java/io/github/jcodeforge/invoice4jbase/examples/QuickStart.java
invoice4j-zugferd/src/main/java/io/github/jcodeforge/invoice4jzugferd/examples/QuickStart.java

Run the example to see how to create an invoice and calculate its totals using the InvoiceCalculator.


Examples

// Create and calculate an invoiceInvoiceinvoice = newInvoiceCalculator().calculate(TestInvoiceFactory.createMinimalInvoice());
// Create a ZUGFeRD PDFFileinputPdf = newFile("invoice.pdf");
FileoutputPdf = newFile("zugferd-invoice.pdf");
ZugferdPdfWriter.builder()
.invoice(invoice)
.profile(ZugferdProfile.EN16931)
.prettyPrint(true)
.build()
.write(inputPdf, outputPdf);
System.out.println("ZUGFeRD invoice written to: " + outputPdf);
// Read the ZUGFeRD PDF backInvoiceparsedInvoice = ZugferdPdfReader.builder()
.build()
.read(outputPdf);
System.out.println("Invoice number: " + parsedInvoice.getInvoiceNumber());
System.out.println("Seller: " + parsedInvoice.getSeller().getName());
System.out.println("Buyer: " + parsedInvoice.getBuyer().getName());
System.out.println(
"Payable amount: "
+ parsedInvoice.getMonetarySummation()
.getPayableAmount()
.getAmount()
+ " "
+ parsedInvoice.getCurrency()
);

Running Tests

Clone the repository and execute:

mvn test

To run the complete verification including integration tests:

mvn verify

Roadmap

VersionMilestoneStatus
v0.1.0Core Model - Invoice calculation engineFinished
v0.2.0CII XMLFinished
v0.3.0ZUGFeRDFinished
v0.4.0XRechnung CIIFinished
v0.5.0XRechnung UBLIn Progress
v1.0.0Public ReleasePlanned
v1.1.0PEPPOL SupportPlanned
v1.2.0Additional European e-Invoice FormatsPlanned
v1.3.0Streaming APIsPlanned
v1.4.0Digital Signatures (XAdES/PAdES)Planned

See the GitHub Milestones for the detailed implementation plan and progress.


Contributing

Contributions, bug reports, feature requests, and discussions are welcome.

If you would like to contribute, please open an issue.


License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.


Support

If invoice4j is useful to you, consider supporting its development.

Development of invoice4j requires time for implementing new features, improving documentation, maintaining standards compatibility, and providing support.

Donate with PayPal

PayPal:https://paypal.me/juniorscholle

Early Development Notice

invoice4j is currently in an early development stage.

The project is published at this stage to gather feedback from developers and users working with electronic invoices such as ZUGFeRD and XRechnung.

The goal is to find out whether invoice4j solves real-world problems and whether the architecture, API design, and supported standards meet the needs of the community.

At this stage:

  • The API may still change.
  • Some features are not implemented yet.
  • Documentation is actively being improved.
  • Production usage is not recommended until a stable release is available

Feedback is highly appreciated:

  • Feature requests
  • Missing invoice fields or standards
  • API design suggestions
  • Real-world use cases
  • Bug reports

If you work with electronic invoices and have requirements or suggestions, please open an issue or start a discussion.

Thank you for helping shape invoice4j.

Articles

About

Modern Java library for electronic invoicing. Create, validate, calculate, and convert EN 16931, ZUGFeRD, Factur-X, XRechnung, and PEPPOL invoices with a clean, immutable API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages