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
240 stars 136 forks source link

Validation failed / Missing invoice number #507

Closed banifou closed 1 month ago

banifou commented 1 month ago

I need to generate a valid XRechnung for Germany. I implemented the code advised here: https://www.mustangproject.org/use/#xrechnung. Then I run the validation. It failed with the following errors (after fixing few other errors these two remains):

<error type="24" location="/*:CrossIndustryInvoice[namespace-uri()='urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100'][1]" criterion="normalize-space(rsm:ExchangedDocument/ram:ID) != ''">
    [BR-02]-An Invoice shall have an Invoice number (BT-1). [ID BR-02] from /xslt/en16931schematron/EN16931-CII-validation.xslt)
</error>
<error type="27" location="/rsm:CrossIndustryInvoice/rsm:ExchangedDocument[1]/ram:ID[1]" criterion="false()">
    Document MUST not contain empty elements. [ID PEPPOL-EN16931-R008] from /xslt/XR_30/XRechnung-CII-validation.xslt)
</error>
  1. Invoice number: Is this related to the Leitweg_ID in ReferenceNumber or Number in invoice?
  2. empty elements: How can I get rid of this? Would be also nice if the validator could show these empty elements.

Thanks for any help.

JohnHuynh commented 1 month ago

Actually it should relate to Number in Invoice but not the Leitweg_ID.

According to the technical appendix, the BT-1 part says the following:

Datentyp: udt:IDType . Hinweis: Die nach Artikel 226 (2) der Richtlinie 2006/112/EG [2] geforderte fortlaufende Nummer, die zur Identifizierung der Rechnung innerhalb des Geschäftskontextes, des Zeitrahmens, der Betriebssysteme und der Aufzeichnungen des Verkäufers einmalig vergeben wird. Sie kann auf einer oder mehreren Reihen von Nummern basieren, die alphanumerische Zeichen enthalten dürfen. Es ist kein Identifikationsschema zu verwenden.

I think this is not related to the Leitweg_ID but rather the invoice number that identifies the invoice itself.

I'm not sure what your implementation looks like but if you have an Invoice object, you should be able to set the corresponding invoice number:

var invoice = new Invoice();
invoice.setNumber(myInvoiceNumber);

and the generated xml should contain BT-1.

I also think that the second error refers to the first one, as BT-1's location is at location="/rsm:CrossIndustryInvoice/rsm:ExchangedDocument[1]/ram:ID[1]". So you won't get any errors if your invoice number is set.

Have you set the number?

banifou commented 1 month ago

You are right. Now, everything works fine. Thank you so much!

banifou commented 1 month ago

I have just received a confirmation from "Bundesdruckerei" that only authorities can apply for a Leitweg ID. So how can I generate a valid XRechnung XML, without setting a ReferenceNumber?

banifou commented 1 month ago

For B2B a ReferenceNumber or in German "Leitweg ID" is not mandatory. Omitting ReferenceNumber, the validation fails with this error:

<error type="27" location="/rsm:CrossIndustryInvoice" criterion="rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:BuyerReference[boolean(normalize-space(.))]">[BR-DE-15] Das Element "Buyer reference" (BT-10) muss übermittelt werden. [ID BR-DE-15] from /xslt/XR_30/XRechnung-CII-validation.xslt)</error>

langfr commented 1 month ago

For B2B ReferenceNumber is also a mandatory field. In this case you just don't have a Leitweg-ID and can fill in any other information which helps the seller to associate this invoice with prior delivery or the original order.

image

https://xeinkauf.de/faq/xrechnung#allgemeines Bei der Verwendung von XRechnung im B2B ist keine Leitweg-ID zur Adressierung von XRechnungen notwendig. Im Element „Buyer reference (BT-10)“ kann jeder andere geeignete Bezeichner für interne Lenkungszwecke genutzt werden. Das Element „Buyer reference (BT-10)“ ist lediglich ein Textfeld und verwendet keine Schema-Definitionen.