Skip to content

[Bug]: xRechnung/ZUGFeRD export missing TaxExemptionReason and unsupported VATEX codes#29904

Open
miljance wants to merge 3 commits intomicrosoft:mainfrom
miljance:EDocVATEXCodes
Open

[Bug]: xRechnung/ZUGFeRD export missing TaxExemptionReason and unsupported VATEX codes#29904
miljance wants to merge 3 commits intomicrosoft:mainfrom
miljance:EDocVATEXCodes

Conversation

@miljance
Copy link
Copy Markdown
Contributor

@miljance miljance commented Apr 8, 2026

Summary

E-Document for Germany - XRechnung/ZUGFeRD VATEX compliance and BR-DE rule fixes

VATEX Implementation:

  • Export dynamic VATEX code and tax exemption reason from VAT Posting Setup
  • Support 'Not Subject to VAT' (Category O) via VAT Clause integration
  • Added comprehensive test coverage for XRechnung and ZUGFeRD with all VATEX codes

EN16931 & BR-DE Compliance Fixes:

  • BR-O-02: Skip Seller/Buyer VAT ID only when ALL invoice lines are category 'O' (fixed critical bug: previously skipped if ANY line was 'O', breaking mixed invoices)
  • BR-O-05: Remove tax percent from line-level 'O' category elements
  • BR-DE-14: Always include tax percent at document level

Code Architecture:

  • Split tax category insertion into line-level and document-level procedures
  • Separated AllowanceCharge handling by context (6-param line-level, 11-param document-level)
  • Thread document language code to GetVATClauseInfo for localized exemption descriptions

Files Changed:

  • XRechnung: Export logic refactored for UBL compliance
  • ZUGFeRD: CII format aligned with EN16931 requirements
  • Tests: Added VATEX scenarios for all supported exemption categories

Work Item(s)

Fixes #29863

Fixes AB#630660

… rule fixes

**VATEX Implementation:**
- Export dynamic VATEX code and tax exemption reason from VAT Posting Setup
- Support 'Not Subject to VAT' (Category O) via VAT Clause integration
- Added comprehensive test coverage for XRechnung and ZUGFeRD with all VATEX codes

**EN16931 & BR-DE Compliance Fixes:**
- BR-O-02: Skip Seller/Buyer VAT ID only when ALL invoice lines are category 'O'
  (fixed critical bug: previously skipped if ANY line was 'O', breaking mixed invoices)
- BR-O-05: Remove tax percent from line-level 'O' category elements
- BR-DE-14: Always include tax percent at document level

**Code Architecture:**
- Split tax category insertion into line-level and document-level procedures
- Separated AllowanceCharge handling by context (6-param line-level, 11-param document-level)
- Thread document language code to GetVATClauseInfo for localized exemption descriptions

**Files Changed:**
- XRechnung: Export logic refactored for UBL compliance
- ZUGFeRD: CII format aligned with EN16931 requirements
- Tests: Added VATEX scenarios for all supported exemption categories
@miljance miljance requested a review from a team as a code owner April 8, 2026 09:26
@miljance miljance requested a review from PhDuck April 8, 2026 09:26
@miljance
Copy link
Copy Markdown
Contributor Author

miljance commented Apr 8, 2026

@pri-kise Could you take a look please?

@JesperSchulz
Copy link
Copy Markdown
Contributor

@miljance, could you resolve the merge conflict?

…nto EDocVATEXCodes

# Conflicts:
#	Apps/DE/EDocumentDE/app/src/XRechnung/ExportXRechnungDocument.Codeunit.al
…nto helper procedure

Replace hardcoded comparisons to 'O' (Not Subject to VAT) with a named helper procedure
for better maintainability and code clarity.

- Add IsTaxCategoryNotSubjectToVAT() helper procedure
- Update InsertClassifiedTaxCategory to use the helper
- Update both DetectNotSubjectToVATLines overloads to use the helper
- Centralizes the 'O' value in one location for easier future maintenance
@JesperSchulz JesperSchulz self-assigned this Apr 10, 2026
@JesperSchulz JesperSchulz added Finance GitHub request for Finance area linked Issue is linked to a Azure Boards work item processing-PR The PR is currently being reviewed labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Processing this PR. The branch is now locked 🔒 Please don't push updates unless otherwise agreed.

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

Labels

Finance GitHub request for Finance area linked Issue is linked to a Azure Boards work item processing-PR The PR is currently being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: xRechnung/ZUGFeRD export missing TaxExemptionReason and unsupported VATEX codes

3 participants