I am trying to post an invoice under UBL 2.1 (to the Government of Jordan's National E-Invoicing System as it happens). I keep getting an error like: "Invalid content was found starting with element: ...UBLVersionID".
It complains that it is expecting "One of..." various elements, at least some of which are actually present in the XML. That list varies depending on where I put the cbc:UBLVersionID
element.
Can anybody shed some light on my darkness?
The XML I am posting (base64 encoded and then passed in a string as part of a JSON object) is:
<?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:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">
<cbc:ProfileID>reporting:1.0</cbc:ProfileID>
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:ID>TestInvo1</cbc:ID>
<cbc:UUID>1</cbc:UUID>
<cbc:IssueDate>2025-03-12</cbc:IssueDate>
<cbc:InvoiceTypeCode name="012">388</cbc:InvoiceTypeCode>
<cbc:Note>Ordered in our booth at the convention.</cbc:Note>
<cbc:DocumentCurrencyCode>JOD</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>JOD</cbc:TaxCurrencyCode>
<cac:AdditionalDocumentReference>
<cbc:ID>Doc1</cbc:ID>
<cbc:UUID>1</cbc:UUID>
</cac:AdditionalDocumentReference>
<cac:AccountingSupplierParty>
<cac:Party>
<cac:PostalAddress>
<cac:Country>
<cbc:IdentificationCode>JO</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>4081730</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>شركة طه وقشوع للزراعة ذ.م.م</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:SellerSupplierParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID>9852</cbc:ID>
</cac:PartyIdentification>
</cac:Party>
</cac:SellerSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="NIN">9641010111</cbc:ID>
</cac:PartyIdentification>
<cac:PostalAddress>
<cbc:PostalZone>11814</cbc:PostalZone>
<cbc:CountrySubentityCode>JO-AM</cbc:CountrySubentityCode>
<cac:Country>
<cbc:IdentificationCode>JO</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>1</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>The buyercompany inc.</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
<cac:AccountingContact>
<cbc:Telephone>06555555</cbc:Telephone>
</cac:AccountingContact>
</cac:AccountingCustomerParty>
<cac:PaymentMeans>
<cbc:PaymentMeansCode listID="UN/ECE 4461">31</cbc:PaymentMeansCode>
<cbc:PaymentDueDate>2009-12-31</cbc:PaymentDueDate>
<cbc:PaymentChannelCode>IBAN</cbc:PaymentChannelCode>
<cbc:PaymentID>Payref1</cbc:PaymentID>
<cac:PayeeFinancialAccount>
<cbc:ID>DK1212341234123412</cbc:ID>
<cac:FinancialInstitutionBranch>
<cac:FinancialInstitution>
<cbc:ID>DKDKABCD</cbc:ID>
</cac:FinancialInstitution>
</cac:FinancialInstitutionBranch>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>False</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="JO">1</cbc:Amount>
</cac:AllowanceCharge>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="JO">16</cbc:TaxAmount>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:TaxExclusiveAmount currencyID="JO">101</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="JO">116</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="JO">1</cbc:AllowanceTotalAmount>
<cbc:PayableAmount currencyID="JO">116</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="PCE">1</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="JO">50</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="JO">8</cbc:TaxAmount>
<cbc:RoundingAmount currencyID="JO">58</cbc:RoundingAmount>
<cac:TaxSubtotal>
<cbc:TaxAmount currencyID="JO">8</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
<cbc:Percent>16</cbc:Percent>
<cac:TaxScheme>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Name>Test Item 1</cbc:Name>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="JO">51</cbc:PriceAmount>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>False</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>DISCOUNT</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="JO">1</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>
<cac:InvoiceLine>
<cbc:ID>2</cbc:ID>
<cbc:InvoicedQuantity unitCode="PCE">1</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="JO">50</cbc:LineExtensionAmount>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="JO">8</cbc:TaxAmount>
<cbc:RoundingAmount currencyID="JO">58</cbc:RoundingAmount>
<cac:TaxSubtotal>
<cbc:TaxAmount currencyID="JO">8</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5305">S</cbc:ID>
<cbc:Percent>16</cbc:Percent>
<cac:TaxScheme>
<cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Name>Test Item 2</cbc:Name>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="JO">50</cbc:PriceAmount>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>False</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>DISCOUNT</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="JO">0</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>
</Invoice>
Error:
{
"EINV_RESULTS": {
"status": "ERROR",
"INFO": [],
"WARNINGS": [],
"ERRORS": [
{
"type": "ERROR",
"status": "ERROR",
"EINV_CODE": "XSD_INVALID",
"EINV_CATEGORY": "XSD validation",
"EINV_MESSAGE": "Schema validation failed; XML does not comply with UBL 2.1 standards per ISTD invoice regulations, ColumnNumber : 20, LineNumber : 4, message : cvc-complex-type.2.4.a: Invalid content was found starting with element '{\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\":UBLVersionID}'. One of '{\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\":ProfileExecutionID, \"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\":ID}' is expected."
}
]
},
"EINV_STATUS": "NOT_SUBMITTED",
"EINV_SINGED_INVOICE": null,
"EINV_QR": null,
"EINV_NUM": null,
"EINV_INV_UUID": null
}
As I mentioned, the exact content of that "expected" list varies depending on where I put the UBLVersionID
element.
The UBL Invoice schema InvoiceType
defines the child elements as an ordered sequence of elements. Some of those elements are optional, but if they are present they need to be in the order that they are listed in the sequence.
In your document the, the cbc:UBLVersionID
is after the cbc:ProfileID
and it should be before it.
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:ProfileID>reporting:1.0</cbc:ProfileID>
<cbc:ID>TestInvo1</cbc:ID>
...
Then your next error will be that cac:SellerSupplierParty
should come after cac:AccountingCustomerParty
.
And then the next errors will be that False
is not a valid value for an xs:boolean
property. It should be false
everywhere you have cbc:ChargeIndicator
:
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>