From 658acda9147c089d497d8d768acd2dbb3d168f8b Mon Sep 17 00:00:00 2001 From: Martin Kroll Date: Wed, 21 Jan 2026 14:35:52 +0100 Subject: [PATCH 1/2] Add tmp test to demo LineDeliveryNoteReferencedDocument missing LineID --- ...-DeliveryNoteReferencedDocument-LineID.xml | 569 ++++++++++++++++++ tests/test_roundtrip.py | 20 + 2 files changed, 589 insertions(+) create mode 100644 tests/samples/zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml diff --git a/tests/samples/zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml b/tests/samples/zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml new file mode 100644 index 0000000..974711f --- /dev/null +++ b/tests/samples/zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml @@ -0,0 +1,569 @@ + + + + + + + + + + true + + + urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended + + + + R87654321012345 + WARENRECHNUNG + 380 + + 20241115 + + + ST3 + Es bestehen Rabatt- oder Bonusvereinbarungen. + AAK + + + EEV + Der Verkäufer bleibt Eigentümer der Waren bis zu vollständigen Erfüllung der Kaufpreisforderung. + AAJ + + + MUSTERLIEFERANT GMBH +BAHNHOFSTRASSE 99 +99199 MUSTERHAUSEN +Geschäftsführung: +Max Mustermann +USt-IdNr: DE123456789 +Telefon: +49 932 431 0 +www.musterlieferant.de +HRB Nr. 372876 +Amtsgericht Musterstadt +GLN 4304171000002 +WEEE-Reg-Nr.: DE87654321 + + REG + + + Leergutwert: 46,50 + + + Wichtige Information: Bei Bestellungen bis zum 19.12. ist die Auslieferung bis spätestens 23.12. garantiert. + + + + + + 1 + + + 4123456000014 + ZS997 + Zitronensäure 100ml + + Verpackungsart + BO + + + + + 1.0000 + + + 1.0000 + + + + 100.0000 + 4.0000 + + L87654321012345 + 1 + + + + + VAT + S + 19.00 + + + 100.00 + + + + + + 2 + + + 4123456000021 + GZ250 + Gelierzucker Extra 250g + + + + 1.5000 + + + false + + 0.03 + Artikelrabatt 1 + + + + false + + 0.02 + Artikelrabatt 2 + + + + 1.4500 + + + + 50.0000 + 1.0000 + + + + VAT + S + 7.00 + + + 72.50 + + + + + + 3 + + + 4123456000021 + GZ250 + Gelierzucker Extra 250g + Artikel wie vereinbart ohne Berechnung + + + + 0.0000 + + + 0.0000 + + + + 10.0000 + 1.0000 + + + + VAT + S + 7.00 + + + 0.00 + + + + + + 4 + + + 4100130013294 + 2031 + Bierbrau Pils 20/0500 + EAN-VKE: 4100130913297 + + Verpackung + Kiste + + + + + 12.0000 + + + 12.0000 + + + + 15.0000 + 20.0000 + + + + VAT + S + 19.00 + + + 180.00 + + + + + + 5 + + + 2001015001325 + 1805 + Leergutpfand 20 x 0,5l + + Verpackung + unverpackt + + + + + 3.1000 + + + 3.1000 + + + + 15.0000 + 1.0000 + + + + VAT + S + 19.00 + + + 46.50 + + + + + + 6 + + + 4123456000038 + MP107 + Mischpalette Joghurt Karton 3 x 20 + + Verpackung + Karton + + + 4123456001035 + JOG103 + Erdbeer 20 x 150g Becher + 20.0000 + + + 4123456002032 + JOG203 + Banane 20 x 150g Becher + 20.0000 + + + 4123456003039 + JOG303 + Schoko 20 x 150g Becher + 20.0000 + + + + + 30.0000 + + + false + + 0.90 + Artikelrabatt 1 + + + + 29.1000 + + + + 2.0000 + 1.0000 + + + + VAT + S + 7.00 + + + 58.20 + + + + + + 549910 + 4333741000005 + MUSTERLIEFERANT GMBH + + + +49 932 431 500 + + + max.mustermann@musterlieferant.de + + + + 99199 + BAHNHOFSTRASSE 99 + MUSTERHAUSEN + DE + + + DE123456789 + + + + 009420 + 4304171000002 + MUSTER-KUNDE GMBH + + 40235 + KUNDENWEG 88 + DUESSELDORF + DE + + + + B123456789 + + + A456123 + 130 + + + + + 4304171088093 + MUSTER-MARKT + + 8211 + + + 31157 + HAUPTSTRASSE 44 + SARSTEDT + DE + + + + + 20180805 + + + + L87654321012345 + + + + EUR + + 009420 + 4304171000002 + MUSTER-KUNDE GMBH + + 40235 + KUNDENWEG 88 + DUESSELDORF + DE + + + + 61.07 + VAT + 321.40 + 326.50 + -5.10 + S + 19.00 + + + 8.93 + VAT + 127.59 + 130.70 + -3.11 + S + 7.00 + + + + false + + 2.00 + 280.00 + 5.60 + Rechnungsrabatt 1 + + VAT + S + 19.00 + + + + + false + + 2.00 + 130.70 + 2.61 + Rechnungsrabatt 1 + + VAT + S + 7.00 + + + + + false + + 280.00 + 2.50 + Rechnungsrabatt 2 + + VAT + S + 19.00 + + + + + false + + 130.70 + 0.50 + Rechnungsrabatt 2 + + VAT + S + 7.00 + + + + Transportkosten + 3.00 + + VAT + S + 19.00 + + + + Bei Zahlung innerhalb 14 Tagen gewähren wir 2,0% Skonto. + + 14 + 2.00 + + + + 457.20 + 3.00 + 11.21 + 448.99 + 70.00 + 518.99 + 0.00 + 518.99 + + + + \ No newline at end of file diff --git a/tests/test_roundtrip.py b/tests/test_roundtrip.py index d745cca..3fedcf2 100644 --- a/tests/test_roundtrip.py +++ b/tests/test_roundtrip.py @@ -35,6 +35,11 @@ def prettify(xml, **kwargs): @pytest.mark.parametrize("filename", samples) def test_sample_roundtrip(filename): + # FIXME: Skip test until LineDeliveryNoteReferencedDocument.line_id field is implemented + # Will be dropped in the next commit + if filename == "zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml": + pytest.skip("Skipping until LineDeliveryNoteReferencedDocument.line_id is implemented") + origxml = prettify( open(os.path.join(os.path.dirname(__file__), "samples", filename), "rb").read(), remove_comments=True, @@ -78,3 +83,18 @@ def test_sample_roundtrip(filename): # Compare output XML assert origxml == generatedxml + + +# This test will be dropped in the next commit +def test_delivery_note_line_id_error(): + """Test that demonstrates the TypeError when parsing DeliveryNoteReferencedDocument with LineID.""" + filename = "zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml" + filepath = os.path.join(os.path.dirname(__file__), "samples", filename) + + origxml = prettify( + open(filepath, "rb").read(), + remove_comments=True, + ) + + with pytest.raises(TypeError, match=r"Unknown element.*LineID"): + Document.parse(origxml) From 31708cb381aab7ad11ed7c6213476fcec599cbbd Mon Sep 17 00:00:00 2001 From: Martin Kroll Date: Wed, 21 Jan 2026 14:39:08 +0100 Subject: [PATCH 2/2] Add LineID to LineDeliveryNoteReferencedDocument also removes tmp test_delivery_note_line_id_error (LineDeliveryNoteReferencedDocument.LineID is handled by test_sample_roundtrip) --- drafthorse/models/references.py | 2 ++ tests/test_roundtrip.py | 20 -------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/drafthorse/models/references.py b/drafthorse/models/references.py index bed7df2..e3081b4 100644 --- a/drafthorse/models/references.py +++ b/drafthorse/models/references.py @@ -154,6 +154,8 @@ class Meta: class LineDeliveryNoteReferencedDocument(ReferencedDocument): + line_id = StringField(NS_RAM, "LineID", required=False, profile=COMFORT) + class Meta: namespace = NS_RAM tag = "DeliveryNoteReferencedDocument" diff --git a/tests/test_roundtrip.py b/tests/test_roundtrip.py index 3fedcf2..d745cca 100644 --- a/tests/test_roundtrip.py +++ b/tests/test_roundtrip.py @@ -35,11 +35,6 @@ def prettify(xml, **kwargs): @pytest.mark.parametrize("filename", samples) def test_sample_roundtrip(filename): - # FIXME: Skip test until LineDeliveryNoteReferencedDocument.line_id field is implemented - # Will be dropped in the next commit - if filename == "zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml": - pytest.skip("Skipping until LineDeliveryNoteReferencedDocument.line_id is implemented") - origxml = prettify( open(os.path.join(os.path.dirname(__file__), "samples", filename), "rb").read(), remove_comments=True, @@ -83,18 +78,3 @@ def test_sample_roundtrip(filename): # Compare output XML assert origxml == generatedxml - - -# This test will be dropped in the next commit -def test_delivery_note_line_id_error(): - """Test that demonstrates the TypeError when parsing DeliveryNoteReferencedDocument with LineID.""" - filename = "zugferd_2p3_EXTENDED_Warenrechnung-DeliveryNoteReferencedDocument-LineID.xml" - filepath = os.path.join(os.path.dirname(__file__), "samples", filename) - - origxml = prettify( - open(filepath, "rb").read(), - remove_comments=True, - ) - - with pytest.raises(TypeError, match=r"Unknown element.*LineID"): - Document.parse(origxml)