Skip to content

[Bug]: XRechnung: Embedded PDF attachment embeds wrong invoice (first posted sales invoice instead of current) #29665

@miljance

Description

@miljance

Describe the issue

When generating a XRechnung electronic document with an embedded PDF attachment for a posted sales invoice, the embedded PDF is always the one belonging to the first posted sales invoice in the database (in the standard demo database this is invoice 103001), regardless of which invoice is being processed.

For example, when processing posted sales invoice 103300, the generated XML contains an <cac:AdditionalDocumentReference> with:

  • <cbc:ID>Invoice_103001.pdf</cbc:ID>
  • Filename "Invoice_103001.pdf"
  • Embedded binary content of invoice 103001

This behavior has been introduced with the issue #29414.

XML snippet example (partial):

<cac:AdditionalDocumentReference>
    <cbc:ID>Invoice_103001.pdf</cbc:ID>
    <cac:Attachment>
        <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="Invoice_103001.pdf">
            JVBERi0xLjgNCi...
        </cbc:EmbeddedDocumentBinaryObject>
    </cac:Attachment>
</cac:AdditionalDocumentReference>

Expected behavior

The embedded PDF attachment should always correspond to the current posted sales invoice being processed:

  • Filename should be Invoice_<CurrentInvoiceNo>.pdf (e.g., Invoice_103300.pdf)
  • The embedded binary content should be the PDF report generated for the current invoice

Steps to reproduce

  1. Open E-Document Service and select XRechnung.
  2. Set “Embed PDF in export” = Yes.
  3. Select a customer and assign a Sending Profile using the E-Documents workflow (DE: E-BELEGE).
  4. Make sure that Workflow uses XRechnung and is enabled.
  5. Create and post a Sales Invoice, open the E-Document, and export the XML.
  6. Current result: The XML does contain cbc:EmbeddedDocumentBinaryObject holding the PDF with the name Invoice_103001.pdf.
  7. Expected: The XML should contain cbc:EmbeddedDocumentBinaryObject holding the PDF with the name Invoice_103300.pdf.

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaapprovedThe issue is approved

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions