klst-de / e-invoice

create xml invoice conforming to CIUS XRechnung or €uropean standard EN16931
Apache License 2.0
12 stars 6 forks source link
cius cross-industry-invoice en16931 euro-invoice factur-x jar ubl un-cefact xml xml-invoice xrechnung zugferd

e-invoice

The goal is to have a jar, which can be used to create a valid xml invoice conforming to franco-german XRechnung or european standard EN16931-1:2017.

The goal is not to build a validator for a xml invoice. For this use EN-16931 - Validation artefacts or XRechnung validator.

european standard EN16931-1:2017

defines a semantic data model for a core invoice. This "€uro invoice" standard uses two syntax schemes alternatively. You have a choice:

Link to eu/cefdigital and a rough overview on CEN/Technical Committee TC 434 and EN 16931. Link to comparison UN/CEFACT vs. UBL.

What is a CIUS?

The EN16931 data model contains many optional elements. Specific countries, groups, or organisations may create individual specifications for the core model in their respective domains (known as a ‘CIUS’).

A “Core Invoice Usage Specification” (CIUS) is a specification that provides a seller with detailed guidance, explanations and examples, as well as rules (business rules) related to the actual implementation and use of structured information elements present in the core invoice model in a specific trading situation. An instance document created following a given CIUS shall always be compliant with the European Standard EN16931-1:2017. [peppol.eu]

Example

this snippet creates a valid xml invoice similar to (xrechnung-testsuite)

  static final String PROFILE_XRECHNUNG = CoreInvoice.PROFILE_XRECHNUNG;
  static final DocumentNameCode CommercialInvoice = DocumentNameCode.CommercialInvoice;
  static final String EUR = "EUR"; 
...
  CoreInvoice invoice = GenericInvoice.getFactory().createInvoice(PROFILE_XRECHNUNG, CommercialInvoice);
  invoice.setId("123456XX");
  invoice.setIssueDate("2016-04-04");
  invoice.addNote("Es gelten unsere Allgem. Geschäftsbedingungen, die Sie unter […] finden."); // optional
  invoice.setDocumentCurrency(EUR);
  invoice.setOrderReference("1234567890");           // optional
  invoice.setBuyerReference("04011000-12345-34");
...
  CoreInvoiceLine line = invoice.createInvoiceLine("1"      // invoice line number
    , new Quantity("XPP", new BigDecimal(1))
    , new Amount(EUR, new BigDecimal(288.79))               // line net amount
    , new UnitPriceAmount(EUR, new BigDecimal(288.79))      // price
    , "Zeitschrift [...]"                                   // itemName
    , TaxCategoryCode.StandardRate, new BigDecimal(7));     // VAT category code, rate 7%
  invoice.addLine(line);
...
  transformer.fromModel(invoice);  // returns byte[] xml

Core Invoice Overview