Skip to content

Billing validation XRechnung

Max Körlinge edited this page Mar 4, 2021 · 3 revisions

Billing Validation

I am writing this because there was very little documentation on how to generate proper DiGA bills to be found elsewhere, and if I don't write it down now, I will most likely forget how to find the information again if we need it. I cannot guarantee how correct all the information is or if it will stay that way in the future.

XRechnung

XRechnung is a german e-invoice format. Billing to the DiGA API has to be sent in XRechnung format with a few extra rules (atleast to the bitmarck endpoint). One confusing part about XRechnung is that you can actually send a valid XRechnung in two completely different formats - UBL (Universal Business Language) or UN/CEFACT Cross Industry Invoice (CII). If you search for XRechnung resources you might therefor find very different looking documents. Since Bitmarck's validator only processes and contains examples for the CII format (although by definition I think it should accept both), let's focus on the CII format.

You can find bitmarck's validation tool here. It seems that this is the actual tool being used by the bitmarck endpoint when sending bills to it, so it is a very good point of information. You can also find some sort of German official entity's (ITPLR) validator for XRechnung here. ITPLR also has a repository with valid test invoices which is useful. You can find them at the path xrechnung-testsuite/src/test/business-cases/standard/ in this repository.

However, neither of these resources contain schematron rules for CII and it doesn't contain any XSD files which can be used for Java class generation by JAXB which we are interested in in this library.

CII

You can find CII schemas (XSD!) at the CEF - Connecting Europe Facility Programme - organization in this repository. By the way, EN16931 is the European standard for electronic invoicing which lead to CII - I think. I found these by googling "EN16931 validator". The actual XSD's we are looking for are here at eInvoicing-EN16931/cii/schema/D16B SCRDM (Subset)/uncoupled clm/CII/uncefact/data/standard/. Once you find these, you realize these are the schemas referred to in bitmarck's test bill. These can be used to generate Java classes through JAXB.

Constructing the bill

Using the CII schemas and bitmarck's test bill you can construct a bill in Java by recreating the test bill piece by piece using JAXB's generated classes. You can check your progress by making test requests with TDRE0 to bitmarck's endpoint. You will receive (in nutzdaten) the result of the validation on their end. That result often contains detailed information on what is wrong. There are DiGA-specific rules that will be evaluated in addition to CII and XRechnung rules, so it might take a few tries to get everything right even by using the method above.

When the errors are in the CII rules, they will refer to which fields are wrong using codes. You can find out more about these codes and what they mean here. These schematron rules are (probably) actually the ones used by the bitmarck validator as well, so with some detective work you can find out exactly what is being evaluated here.

If you send Bitmarck's own test bill (here) using TDRE0 you will get a report saying (.. if you read it carefully) that the structure of the bill was validated but the DiGA code could not be found. Once you get the same response using your Java generated XML bill, you have succeeded in replicating a valid bill.

Next: I have to figure out exactly what information is supposed to go where in the bill

Field explanations

  • ExchangedDocument->TypeCode is 380 according to this list

Clone this wiki locally