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

XML is invalid against the XML Schema Definition #196

Closed
nitohu opened this issue Apr 29, 2020 · 2 comments
Closed

XML is invalid against the XML Schema Definition #196

nitohu opened this issue Apr 29, 2020 · 2 comments
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@nitohu
Copy link

nitohu commented Apr 29, 2020

Hello I was trying to generate a PDF file with an embedded XML (ZUGFeRD 2.0 Standard).
I wanted to use the account_invoice_facturx OCA module as a basis for this.

module: account_invoice_facturx
version: 12.0.1.0.0

Current behaviour:
When clicking on the "Print" -> "Invoice" button in the Invoice form inside Odoo, I'm getting the error that the XML is invalid against the XML Schema Definition because another field is expected than given.

factur-x: The XML file is invalid against the XML Schema Definition
factur-x: XSD Error: Element '{urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}SpecifiedTradeSettlementLineMonetarySummation': This element is not expected. Expected is ( {urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}ApplicableTradeTax )., line 35

Traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/facturx/facturx.py", line 144, in check_facturx_xsd
    official_schema.assertValid(t)
  File "src/lxml/etree.pyx", line 3621, in lxml.etree._Validator.assertValid
lxml.etree.DocumentInvalid: Element '{urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}SpecifiedTradeSettlementLineMonetarySummation': This element is not expected. Expected is ( {urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}ApplicableTradeTax )., line 32

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/Users/niklastom.hucke/Dev/odoo-12.0/addons/web/controllers/main.py", line 1671, in report_download
    response = self.report_routes(reportname, docids=docids, converter=converter)
  File "/mnt/c/Users/niklastom.hucke/Dev/odoo-12.0/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/mnt/c/Users/niklastom.hucke/Dev/odoo-12.0/addons/web/controllers/main.py", line 1612, in report_routes
    pdf = report.with_context(context).render_qweb_pdf(docids, data=data)[0]
  File "/mnt/c/Users/niklastom.hucke/Dev/odoo-12.0/addons/base/models/ir_actions_report.py", line 733, in render_qweb_pdf
    return self._post_pdf(save_in_attachment, pdf_content=pdf_content, res_ids=html_ids), 'pdf'
  File "/mnt/c/Users/niklastom.hucke/Dev/Odoo/edi/account_invoice_ubl/models/ir_actions_report.py", line 35, in _post_pdf
    save_in_attachment, pdf_content=pdf_content, res_ids=res_ids)
  File "/mnt/c/Users/niklastom.hucke/Dev/Odoo/edi/account_invoice_facturx/models/ir_actions_report.py", line 34, in _post_pdf
    pdf_content=pdf_content)
  File "/mnt/c/Users/niklastom.hucke/Dev/Odoo/edi/account_invoice_facturx/models/account_invoice.py", line 773, in regular_pdf_invoice_to_facturx_invoice
    facturx_xml_str, level = self.generate_facturx_xml()
  File "/mnt/c/Users/niklastom.hucke/Dev/Odoo/edi/account_invoice_facturx/models/account_invoice.py", line 740, in generate_facturx_xml
    check_facturx_xsd(xml_string, 'factur-x', facturx_level=ns['level'])
  File "/usr/local/lib/python3.6/dist-packages/facturx/facturx.py", line 155, in check_facturx_xsd
    "cause of the problem: %s." % (flavor.capitalize(), unicode(e)))
Exception: The Factur-x XML file is not valid against the official XML Schema Definition. Here is the error, which may give you an idea on the cause of the problem: Element '{urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}SpecifiedTradeSettlementLineMonetarySummation': This element is not expected. Expected is ( {urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}ApplicableTradeTax )., line 32.

Configuration (Installed packages)

  • WkHTMLtoPDF v0.12.4 (with patched qt)
  • factur-x v1.10

Configuration (Odoo Settings)

  • Format: Factur-X (CII)
  • Factur-X Level: EN 16931 (Comfort)
  • Factur-X Refund Type: Type 381 with positive amounts

This error was also present when trying out a different Factur-X Level (Basic) or when trying it with the Refund Type 381 w/ negative amounts.

Generated XML:

<?xml version='1.0' encoding='UTF-8'?>
<rsm:CrossIndustryInvoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
  <rsm:ExchangedDocumentContext>
    <ram:GuidelineSpecifiedDocumentContextParameter>
      <ram:ID>urn:cen.eu:en16931:2017</ram:ID>
    </ram:GuidelineSpecifiedDocumentContextParameter>
  </rsm:ExchangedDocumentContext>
  <rsm:ExchangedDocument>
    <ram:ID>INV/2020/0002</ram:ID>
    <ram:TypeCode>380</ram:TypeCode>
    <ram:IssueDateTime>
      <udt:DateTimeString format="102">20200427</udt:DateTimeString>
    </ram:IssueDateTime>
  </rsm:ExchangedDocument>
  <rsm:SupplyChainTradeTransaction>
    <ram:IncludedSupplyChainTradeLineItem>
      <ram:AssociatedDocumentLineDocument>
        <ram:LineID>1</ram:LineID>
      </ram:AssociatedDocumentLineDocument>
      <ram:SpecifiedTradeProduct>
        <ram:Name>Service on demand</ram:Name>
      </ram:SpecifiedTradeProduct>
      <ram:SpecifiedLineTradeAgreement>
        <ram:GrossPriceProductTradePrice>
          <ram:ChargeAmount>75.00</ram:ChargeAmount>
        </ram:GrossPriceProductTradePrice>
        <ram:NetPriceProductTradePrice>
          <ram:ChargeAmount>75.00</ram:ChargeAmount>
        </ram:NetPriceProductTradePrice>
      </ram:SpecifiedLineTradeAgreement>
      <ram:SpecifiedLineTradeDelivery>
        <ram:BilledQuantity unitCode="HUR">24.000</ram:BilledQuantity>
      </ram:SpecifiedLineTradeDelivery>
      <ram:SpecifiedLineTradeSettlement>
        <ram:SpecifiedTradeSettlementLineMonetarySummation>
          <ram:LineTotalAmount>1800.00</ram:LineTotalAmount>
        </ram:SpecifiedTradeSettlementLineMonetarySummation>
      </ram:SpecifiedLineTradeSettlement>
    </ram:IncludedSupplyChainTradeLineItem>
    <ram:IncludedSupplyChainTradeLineItem>
      <ram:AssociatedDocumentLineDocument>
        <ram:LineID>2</ram:LineID>
      </ram:AssociatedDocumentLineDocument>
      <ram:SpecifiedTradeProduct>
        <ram:Name>On Site Assistance</ram:Name>
      </ram:SpecifiedTradeProduct>
      <ram:SpecifiedLineTradeAgreement>
        <ram:GrossPriceProductTradePrice>
          <ram:ChargeAmount>38.25</ram:ChargeAmount>
        </ram:GrossPriceProductTradePrice>
        <ram:NetPriceProductTradePrice>
          <ram:ChargeAmount>38.25</ram:ChargeAmount>
        </ram:NetPriceProductTradePrice>
      </ram:SpecifiedLineTradeAgreement>
      <ram:SpecifiedLineTradeDelivery>
        <ram:BilledQuantity unitCode="HUR">30.000</ram:BilledQuantity>
      </ram:SpecifiedLineTradeDelivery>
      <ram:SpecifiedLineTradeSettlement>
        <ram:SpecifiedTradeSettlementLineMonetarySummation>
          <ram:LineTotalAmount>1147.50</ram:LineTotalAmount>
        </ram:SpecifiedTradeSettlementLineMonetarySummation>
      </ram:SpecifiedLineTradeSettlement>
    </ram:IncludedSupplyChainTradeLineItem>
    <ram:ApplicableHeaderTradeAgreement>
      <ram:SellerTradeParty>
        <ram:Name>YourCompany</ram:Name>
        <ram:DefinedTradeContact>
          <ram:PersonName>Mitchell Admin</ram:PersonName>
          <ram:TelephoneUniversalCommunication>
            <ram:CompleteNumber>+1 555-555-5555</ram:CompleteNumber>
          </ram:TelephoneUniversalCommunication>
          <ram:EmailURIUniversalCommunication>
            <ram:URIID schemeID="SMTP">niklastom.hucke@metronom.com</ram:URIID>
          </ram:EmailURIUniversalCommunication>
        </ram:DefinedTradeContact>
        <ram:PostalTradeAddress>
          <ram:PostcodeCode>18540</ram:PostcodeCode>
          <ram:LineOne>1725 Slough Ave.</ram:LineOne>
          <ram:CityName>Scranton</ram:CityName>
          <ram:CountryID>DE</ram:CountryID>
        </ram:PostalTradeAddress>
      </ram:SellerTradeParty>
      <ram:BuyerTradeParty>
        <ram:Name>Joel Willis</ram:Name>
        <ram:PostalTradeAddress>
          <ram:PostcodeCode>07002</ram:PostcodeCode>
          <ram:LineOne>858 Lynn Street</ram:LineOne>
          <ram:CityName>Bayonne</ram:CityName>
          <ram:CountryID>US</ram:CountryID>
        </ram:PostalTradeAddress>
      </ram:BuyerTradeParty>
    </ram:ApplicableHeaderTradeAgreement>
    <ram:ApplicableHeaderTradeDelivery>
      <ram:ShipToTradeParty>
        <ram:PostalTradeAddress>
          <ram:PostcodeCode>07002</ram:PostcodeCode>
          <ram:LineOne>858 Lynn Street</ram:LineOne>
          <ram:CityName>Bayonne</ram:CityName>
          <ram:CountryID>US</ram:CountryID>
        </ram:PostalTradeAddress>
      </ram:ShipToTradeParty>
    </ram:ApplicableHeaderTradeDelivery>
    <ram:ApplicableHeaderTradeSettlement>
      <ram:PaymentReference>INV/2020/0002</ram:PaymentReference>
      <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
      <ram:SpecifiedTradeSettlementPaymentMeans>
        <ram:TypeCode>30</ram:TypeCode>
        <ram:Information>Direct Debit of customers</ram:Information>
      </ram:SpecifiedTradeSettlementPaymentMeans>
      <ram:SpecifiedTradePaymentTerms>
        <ram:Description>15 Days</ram:Description>
        <ram:DueDateDateTime>
          <udt:DateTimeString format="102">20200512</udt:DateTimeString>
        </ram:DueDateDateTime>
      </ram:SpecifiedTradePaymentTerms>
      <ram:SpecifiedTradeSettlementHeaderMonetarySummation>
        <ram:LineTotalAmount>2947.50</ram:LineTotalAmount>
        <ram:TaxBasisTotalAmount>0.00</ram:TaxBasisTotalAmount>
        <ram:TaxTotalAmount currencyID="EUR">0.00</ram:TaxTotalAmount>
        <ram:GrandTotalAmount>2947.50</ram:GrandTotalAmount>
        <ram:TotalPrepaidAmount>0.00</ram:TotalPrepaidAmount>
        <ram:DuePayableAmount>2947.50</ram:DuePayableAmount>
      </ram:SpecifiedTradeSettlementHeaderMonetarySummation>
    </ram:ApplicableHeaderTradeSettlement>
  </rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>

Expected behaviour:
The PDF file with the embedded XML should be downloaded.

@BT-aestebanez
Copy link

Hello,

The problem is you need to define at least a tax.
#204

Best,
Alvaro

@github-actions
Copy link

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 13, 2022
@nitohu nitohu closed this as completed Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

2 participants