Ordering TaxPointDate before CreditNoteTypeCode in credit-note output - #101
Closed
CarlosMari wants to merge 2 commits into
Closed
Ordering TaxPointDate before CreditNoteTypeCode in credit-note output#101CarlosMari wants to merge 2 commits into
CarlosMari wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #101 +/- ##
==========================================
+ Coverage 80.91% 80.96% +0.05%
==========================================
Files 28 28
Lines 2117 2165 +48
==========================================
+ Hits 1713 1753 +40
- Misses 267 274 +7
- Partials 137 138 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3 tasks
Contributor
Author
|
Addressed in #102 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BUG — credit notes with a
TaxPointDateare XSD-invalidSymptom
Any UBL credit note that carries a
cbc:TaxPointDate(mapped from GOBLinv.ValueDate) is generated with the element in the wrong position and fails UBL XSD validation. This affects all contexts that emit credit notes (Peppol, EN 16931, …) — it is not context-specific.Root cause
InvoiceandCreditNoteshare a single Go struct, whose field order is fixed. In that structCreditNoteTypeCodeprecedesTaxPointDate, which is correct for the Invoice XSD but wrong for the CreditNote XSD:InvoiceTypeCode→TaxPointDateTaxPointDate→CreditNoteTypeCodeencoding/xmlemits fields in the single struct order, so a credit note placesTaxPointDateafterCreditNoteTypeCode— violating the CreditNote sequence.Proof (on
main, before this change)Generating a standard Peppol/EN 16931 credit note with a
value_dateand validating via phive (eu.peppol.bis3:creditnote:2025.5):The CEN-EN16931 and PEPPOL-EN16931 schematron layers pass — the failure is purely the XSD sequence.
Fix
Bytes/BytesCompactpost-process the marshaled output: when the document is a credit note carrying aTaxPointDate, move that element ahead ofCreditNoteTypeCodeto match the CreditNote XSD sequence. The reorder edits bytes directly becauseencoding/xmlcan neither vary field order per struct nor survive a decode/re-encode (it mangles thecac:/cbc:prefixes).After the fix the same document is phive-green (
TaxPointDateon the line beforeCreditNoteTypeCode).Test
Adds
test/data/convert/peppol/credit-note-taxpoint.json(+ golden), a standard Peppol/EN 16931 credit note with avalue_date, which is phive-valid with the fix and reproduces the failure without it.Notes
mainsince the bug pre-dates and is independent of OIOUBL.