Skip to content

Ensure LineItem tax Exemption fields only written for Extended & XRechnung#1069

Open
rjsmith wants to merge 1 commit intoZUGFeRD:masterfrom
rjsmith:bugfix/996
Open

Ensure LineItem tax Exemption fields only written for Extended & XRechnung#1069
rjsmith wants to merge 1 commit intoZUGFeRD:masterfrom
rjsmith:bugfix/996

Conversation

@rjsmith
Copy link
Copy Markdown

@rjsmith rjsmith commented Mar 19, 2026

This pull request fixes a bug in the ZUGFeRD2PullProvider generateXML() method that causes Mustang to generate invalid EN16931 - profile documents.

If a Mustang Product has a defined ExemptionReason and / or ExemptionReasonCode, the ZUGFeRD2PullProvider generateXML() currently adds ram:ExemptionReason and /or ram:ExemptionReasonCode to SpecifiedLineTradeSettlement ApplicableTradeTax, for any Profile.

However, these line item fields are only defined for Extended profile (and possibly XRechnung, there are existing unit tests that appear to expect these for Xrechnung profile, although the documented Xrechnung standard does not). This discrepancy is causing our test ZUGFeRD invoices generated by Mustang to fail third-party validation for non-standard tax cases that have an exemption reason that should appear in the document-level VAT Breakdown section.

Note that the referred bug ticket was recently closed by @jstaerk without explanation, and without an apparent fix, so I am contributing a fix here for review.

Closes #996

…e only written for Extended & XRechnung - profile documents

Closes ZUGFeRD#996
@rjsmith
Copy link
Copy Markdown
Author

rjsmith commented Mar 19, 2026

Also please note that I branched off master (commit 56b9099 ) to create my fork and bugfix branch, however, master branch has two failing tests, one of which is in the ZF2PushTest class to which I have also added a new test, but the previous failure is not related to changes I have made in this PR (so please don't blame me!)

@IsThatUniqueEnough
Copy link
Copy Markdown

ExemptionReasonCode and ExemptionReason are also not allowed in XRechnung.

@rjsmith
Copy link
Copy Markdown
Author

rjsmith commented Apr 13, 2026

ExemptionReasonCode and ExemptionReason are also not allowed in XRechnung.

Yes, I checked https://xeinkauf.de/app/uploads/2024/07/302-XRechnung-2024-06-20.pdf and it only shows the ExemptionReason in the VAT Breakdown section. However, the Mustang unit test suite appears to have tests that assert that Exemption Reason is included the Xrechnung line VAT section.

I guess we really need a Mustang maintainer to help us out here, I am happy to modify my PR to exclude Exemption for Xrechnug profile also (which would also need to modify those unit tests also).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ExemptionReason written to line item level violates EN16931 profile

2 participants