Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdditionalDocumentReference error #68

Closed
idilalemdar opened this issue Feb 18, 2025 · 7 comments
Closed

AdditionalDocumentReference error #68

idilalemdar opened this issue Feb 18, 2025 · 7 comments
Assignees

Comments

@idilalemdar
Copy link

Hello,

I have been trying to create an Invoice with UBL2.1, specifically UBLTR. Everything UBLTR asks is OK in my invoice, except when I try to send my invoice to the provider, the response body shows me this error:

<response_message>The element 'Invoice' in namespace
    'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2' has invalid child element
    'AdditionalDocumentReference' in namespace
    'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'. List of possible
    elements expected: 'PaymentAlternativeCurrencyCode, AccountingCost, LineCountNumeric' in
    namespace 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'.Shematron
    Control : Valid
    Invoice Serializer : Valid
</response_message>

I do not understand, AdditionalDocumentReference is a valid field under Invoice type and the example XML I have, which is a valid UBLTR Invoice, also has this field. I have been able to resolve all other UBL schematron errors but I am clueless on this one. Any help is deeply appreciated, thank you very much in advance.

@phax phax self-assigned this Feb 18, 2025
@idilalemdar
Copy link
Author

Same error message also exists when I completely omit the AdditionalDocumentReference field in the invoice.

@phax
Copy link
Owner

phax commented Feb 19, 2025

@idilalemdar sorry for the late response. Can you please share the document you want to parse. It seems like the order of elements is incorrect according to the XML Schema.

@idilalemdar
Copy link
Author

No problem. I cannot share the whole document but I have 2 AdditionalDocumentReference's, rigth before them I have these lines:

<cbc:DocumentCurrencyCode xmlns="">TRY</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode xmlns="">TRY</cbc:TaxCurrencyCode>
<cbc:PricingCurrencyCode xmlns="">TRY</cbc:PricingCurrencyCode>
<cbc:PaymentCurrencyCode xmlns="">TRY</cbc:PaymentCurrencyCode>

And after the two AdditionalDocumentReference, I have fields like cac:Signature, cac:AccountingSupplierParty, cac:AccountingCustomerParty etc.

@phax
Copy link
Owner

phax commented Feb 19, 2025

Sorry, I can't make sense of the error message.
See e.g. https://github.com/phax/peppol-commons/blob/master/peppol-testfiles/src/main/resources/external/peppol-ubl/test-invoices/success/BII04%20XML%20example%20full%20core%20data%2001.xml for a valid UBL 2.1 document that contains an AdditionalDocumentReference. hth

@idilalemdar
Copy link
Author

idilalemdar commented Feb 20, 2025

The example XML I have has xmlns="" as namespace under most of direct children of invoice, including AdditionalDocumentREference, like:

<cac:AdditionalDocumentReference xmlns="">
        <cbc:ID>1234567</cbc:ID>
        <cbc:IssueDate>yyyy-mm-dd</cbc:IssueDate>
        <cbc:DocumentType></cbc:DocumentType>
    </cac:AdditionalDocumentReference>

However the invoice I create does not include it:

<cac:AdditionalDocumentReference>
        <cbc:ID>1234567</cbc:ID>
        <cbc:IssueDate>yyyy-mm-dd</cbc:IssueDate>
        <cbc:DocumentType>DOCTYPE</cbc:DocumentType>
    </cac:AdditionalDocumentReference>

Besides, the example XML2s namespaces look like this:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
         xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
         xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
         xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
         xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
         xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
         xmlns:ubltr="urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents"
         xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
         xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 UBL-Invoice-2.1.xsd">
    <ext:UBLExtensions>
        <ext:UBLExtension>
            <ext:ExtensionContent>
                <ds:Signature Id="SIGNATURE-ID">

whereas the invoice I generate:

<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
         xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
         xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
         xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
      <cec:UBLExtensions>
          <cec:UBLExtension>
              <cec:ExtensionContent>
                  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIGNATURE-ID">

Could it be that these differences would cause any error in UBLTR? Also mentioned about this here: #56 (comment)

@phax
Copy link
Owner

phax commented Feb 20, 2025

The empty xmlns in your example has no impact:

<cac:AdditionalDocumentReference xmlns="">
        <cbc:ID>1234567</cbc:ID>
        <cbc:IssueDate>yyyy-mm-dd</cbc:IssueDate>
        <cbc:DocumentType></cbc:DocumentType>
    </cac:AdditionalDocumentReference>

As this example uses the cac prefix, the XML namespace URI for cac (as defined in xmlns:cac) is used.
Please read https://www.w3.org/TR/xml-names/ on more details on XML namespaces - they are commonly misunderstood.

This also applies to your second example: the namespace prefix list does not matter. You could also use the following namespace prefixes, and the example would be identical, as long as the cac namespace URI is identical to the hugo namespace URI and cbc to bla:

<hugo:AdditionalDocumentReference xmlns="">
        <bla:ID>1234567</bla:ID>
        <bla:IssueDate>yyyy-mm-dd</bla:IssueDate>
        <bla:DocumentType></bla:DocumentType>
    </hugo:AdditionalDocumentReference>

Think of namespace prefixes as "macros" that make the file shorter when you serialize it to disk. The "in-memory" representation always uses the URLs resolved from the namespace prefixes

@phax phax closed this as completed Mar 6, 2025
@idilalemdar
Copy link
Author

For those who might encounter the same problem in the future, here is the solution:

Turns out that UBLTR invoice also requires the element cbc:LineCountNumeric, where it denotes the number of invoice lines. Example invoice did not have that field, so I didn't add it at first but adding LineCountNumeric field solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants