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 does not recognize XRechnung Zugferd Profile #395

Closed Sarenor closed 1 day ago

Sarenor commented 1 week ago

A PDF with an embedded XRechnung like this

<ram:GuidelineSpecifiedDocumentContextParameter>
    <ram:ID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>

is recognized as a valid Zugferd Document, but no Profile could be found for it. Would it make sense to change the getZugferdProfile() method in the ZUGFeRDImporter.java

    public String getZUGFeRDProfil() {
        switch (this.extractString("//*[local-name() = 'GuidelineSpecifiedDocumentContextParameter']//*[local-name() = 'ID']")) {
            case "urn:cen.eu:en16931:2017":
            case "urn:ferd:CrossIndustryDocument:invoice:1p0:comfort":
                return "COMFORT";
            case "urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic":
            case "urn:ferd:CrossIndustryDocument:invoice:1p0:basic":
                return "BASIC";
            case "urn:factur-x.eu:1p0:basicwl":
                return "BASIC WL";
            case "urn:factur-x.eu:1p0:minimum":
                return "MINIMUM";
            case "urn:ferd:CrossIndustryDocument:invoice:1p0:extended":
            case "urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended":
                return "EXTENDED";
            // new addition
            case "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0":
                return "XRECHNUNG";
            default:
                return "";
        }
    }

Or would it be better to fold this into EXTENDED?

jstaerk commented 6 days ago

sounds like a very good idea👍, actually it would be sufficient to scan for "xrechnung" in the guideline ID to return XRechnung, no need to restrict to version 3...

Sarenor commented 6 days ago

That would mean breaking up the switch, probably, but that's fine. I'll try to send in a PR later today.