Skip to content

[Bug][E-Document DE] XRechnung credit memo export omits PayeeFinancialAccount, failing BR-61 and BR-DE-23-a validation #11057

Description

Describe the issue

When a posted sales credit memo or service credit memo is exported as an XRechnung e-document, the resulting XML declares SEPA credit transfer as the payment means but does not include the seller's bank account (IBAN/BIC). The XRechnung standard requires the payment account whenever a credit transfer is announced, so every exported credit memo fails validation against the official XRechnung rules. Recipients that validate incoming e-documents — in particular German public-sector customers, for whom XRechnung is mandatory — reject these credit memos.

Invoices exported from the same setup include the bank account and validate fine; only credit memos are affected.

There is no setup or master data workaround: the company bank account is configured and is used correctly for invoices, but the credit memo export never reads it, regardless of configuration.

Expected behavior

The credit memo export should write the PayeeFinancialAccount block (IBAN, plus FinancialInstitutionBranch/BIC when available) exactly like the invoice export does. EN 16931 rule BR-61 and XRechnung CIUS rule BR-DE-23-a apply to CreditNote documents the same as to Invoice documents:

  • BR-61 (error): if the Payment means type code (BT-81) means SEPA credit transfer, the Payment account identifier (BT-84) shall be present.
  • BR-DE-23-a (error): if BT-81 contains a credit-transfer key (30, 58), group BG-17 "CREDIT TRANSFER" must be transmitted.

Where it breaks, in codeunit 13916 Export XRechnung Document (src/Apps/DE/EDocumentDE/app/src/XRechnung/ExportXRechnungDocument.Codeunit.al):

  • The invoice paths pass the element name (lines 178 and 285):

    InsertPaymentMeans(RootXMLNode, '58', 'PayeeFinancialAccount', SalesInvoiceHeader."Company Bank Account Code");
  • The sales and service credit memo paths pass an empty string instead (lines 226 and 343):

    InsertPaymentMeans(RootXMLNode, '58', '', SalesCrMemoHeader."Company Bank Account Code");
  • InsertPaymentMeans (line 587) skips InsertPayeeFinancialAccount entirely when the PayeeFinancialAccount parameter is empty, so PaymentMeansCode 58 is written without the account — the exact combination BR-61 and BR-DE-23-a forbid.

Proposed fix: pass 'PayeeFinancialAccount' in the two credit memo call sites (sales and service), same as the invoice call sites. InsertPayeeFinancialAccount already handles IBAN and optional BIC via GetBankAccountPaymentDetails, so no further change is needed.

The ZUGFeRD export in the same app is not affected — its payment method insertion always writes the IBAN when present. The bug is XRechnung-only.

Steps to reproduce

Prerequisites: DE localization with the E-Document for Germany app; an E-Document Service configured with the XRechnung format; a customer set up to receive e-documents via that service; Company Information / company bank account with IBAN (and SWIFT/BIC) filled in.

  1. Post a sales invoice for the customer and let the e-document be created and exported.
  2. Validate the resulting XML against the official XRechnung validator (e.g. the KoSIT validator).
    → Expected: valid. Actual: valid — the PaymentMeans block contains PayeeFinancialAccount with the IBAN.
  3. Post a sales credit memo for the same customer (e.g. Corrective Credit Memo for the invoice) and let the e-document be created and exported.
  4. Open the exported CreditNote XML.
    → Expected: cac:PaymentMeans contains cac:PayeeFinancialAccount with the IBAN, as in the invoice. Actual: cac:PaymentMeans contains only cbc:PaymentMeansCode = 58; no bank account element.
  5. Validate the credit memo XML against the official XRechnung validator.
    → Expected: valid. Actual: validation fails with error BR-61 ("If the Payment means type code (BT-81) means SEPA credit transfer ... the Payment account identifier (BT-84) shall be present.") and error BR-DE-23-a (group BG-17 "CREDIT TRANSFER" must be transmitted for payment means keys 30/58), plus warning BR-DE-19 as a follow-on.

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApprovedThe issue is approvedTeam: FinanceGitHub request for Finance area

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions