stephanstapel/ZUGFeRD-csharp

InvoiceDescriptor.Load cannot load version xrechnung_2.0

Chips100 opened this issue · 2 comments

Reading any XRechnung by calling InvoiceDescriptor.Load with version string urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0 leads to an UnsupportedException with message No ZUGFeRD invoice reader was able to parse this stream!.

Peeking into the source code, I would either guess that it is missing from the list of validURIs in InvoiceDescriptor21Reader:

"urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.1", // XRechnung 2.1

Or the InvoiceDescriptor20Reader does not pick it up, although it should. It lists the prefix as a valid URI, but the implementation of _IsReadableByThisReaderVersion checks for a complete match, not just a prefix match:

"urn:cen.eu:EN16931:2017", // Profil EN 16931 (COMFORT)" +

Could you share some insight on this? Is it on purpose?

If I remember it correctly, I removed support for XRechnung 2.0 a long time ago since the format should not exist any more in practise, being replaced by later versions.
This step can be reverted if necessary, it should go into InvoiceDescriptor21Reader.cs
Could you add this to the code and test with your files?

Thanks for the quick response - yes, adding it to the validURIs in the InvoiceDescriptor21Reader solves my problem; everything seems to be parsed correctly. I created a PR with the change, hoping it might make it into a future version.