Skip to content

Instantly share code, notes, and snippets.

View jstaerk's full-sized avatar

Jochen Staerk jstaerk

View GitHub Profile
@jstaerk
jstaerk / gist:ad7b58a021b050cc4e4e05156f9a9be3
Last active August 1, 2021 19:36
Deepl translation of draft article on open-source hybrid e-invoice libraries

(Draft by Jochen Staerk on 2021-08-21)

Use of libraries

Many developers have written PDF or XML files before. So another export for electronic invoices can't be that difficult.

Unfortunately, calculation rules, code lists and, in the case of government invoices, country-specific requirements such as the XInvoice, as well as details such as the correct rounding in the correct places, make it quite complicated in detail. There are things that can be unfamiliar: For example, the gross price is considered to be the net list price without sales tax. Other things are simply assumed: There is the recommendation for fixed namespace prefixes . And with Factur-X/ZUGFeRD, the embedding in valid PDF/A also causes some headaches, keyword PDF/A Extension Schema.

It can be made easier by using appropriate libraries. The following free open source libraries can at least also write hybrid invoices in Factur-X/ZUGFeRD format, read PDFs with embedded XML:

  • Konik (java and .net, ZUGFeRD 1 only, GPL).
@jstaerk
jstaerk / Main.java
Created August 1, 2021 18:27
Phive XRechnung validation erroring [SAX] cvc-elt.1.a: Deklaration des Elements "rsm:CrossIndustryInvoice" kann nicht gefunden werden.
import java.io.File;
import java.util.Locale;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import com.helger.commons.error.IError;
import com.helger.phive.api.execute.ValidationExecutionManager;
@jstaerk
jstaerk / Freightlist.java
Created October 29, 2016 15:11
OptaPlanner 6.5 constraint programming "freightlist" example (public domain)
package test12;
import java.util.Collection;
import java.util.List;
import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;
import org.optaplanner.core.api.domain.solution.PlanningSolution;
import org.optaplanner.core.api.domain.solution.Solution;
import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;