ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
168 stars 99 forks source link

Zugferd Importer throws exception for French Invoice when extracting Zugferd Version #401

Open Sarenor opened 3 days ago

Sarenor commented 3 days ago

This code in getVersion() throws an exception for a french Invoice I recently stumbled across:

        if (head.contains("<rsm:CrossIndustryDocument") //
            || head.contains("<CrossIndustryDocument") //
            || head.contains("<SCRDMCCBDACIDAMessageStructure") //
            || head.contains("<rsm:SCRDMCCBDACIOMessageStructure")) { //
            version = 1;
        } else if (head.contains("<rsm:CrossIndustryInvoice")) {
            version = 2;
        } else {
            throw new Exception("ZUGFeRD version could not be determined");
        }

because the head for the Invoice contains this:

<ns3:CrossIndustryInvoice xmlns="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:ns2="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:ns3="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:ns4="urn:un:unece:uncefact:data:standard:QualifiedDataType:100">
    <ns3:ExchangedDocumentContext>
        <ns2:GuidelineSpecifiedDocumentContextParameter>
            <ns2:ID>urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended</ns2:ID>
        </ns2:GuidelineSpecifiedDocumentContextParameter>
    </ns3:ExchangedDocumentContext>

As far as I can tell, this should be a valid Zugferd 2 but the version detection code doesn't recognize it because of the namespace prefixes.