From: Ben Dangelmayr Date: Tue, 19 Jul 2022 12:11:17 +0000 (+0200) Subject: Field correction and updated pdf.py to zugferd2.2 X-Git-Tag: 2.2.0~1^2~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07a5cf27454724019cc6b3e4bce264fa4b21ab51;p=thirdparty%2Fpython-drafthorse.git Field correction and updated pdf.py to zugferd2.2 --- diff --git a/drafthorse/models/accounting.py b/drafthorse/models/accounting.py index 3c99549..640556f 100644 --- a/drafthorse/models/accounting.py +++ b/drafthorse/models/accounting.py @@ -177,7 +177,7 @@ class MonetarySummation(Element): profile=BASIC, _d="Steuerbasisbetrag", ) - tax_total = MultiDecimalField( + tax_total = DecimalField( NS_RAM, "TaxTotalAmount", required=True, profile=BASIC, _d="Steuergesamtbetrag" ) grand_total = DecimalField( diff --git a/drafthorse/models/document.py b/drafthorse/models/document.py index 7017036..1796a89 100644 --- a/drafthorse/models/document.py +++ b/drafthorse/models/document.py @@ -33,7 +33,7 @@ class BusinessDocumentContextParameter(Element): class DocumentContext(Element): test_indicator = IndicatorField( - NS_RAM, "TestIndicator", required=False, profile=BASIC, _d="Testkennzeichen" + NS_RAM, "TestIndicator", required=False, profile=EXTENDED, _d="Testkennzeichen" ) business_parameter = Field( BusinessDocumentContextParameter, diff --git a/drafthorse/models/payment.py b/drafthorse/models/payment.py index e41ec9e..353aa97 100644 --- a/drafthorse/models/payment.py +++ b/drafthorse/models/payment.py @@ -49,7 +49,7 @@ class PayeeFinancialInstitution(Element): class PaymentMeans(Element): - type_code = StringField(NS_RAM, "TypeCode", required=False, profile=COMFORT) + type_code = StringField(NS_RAM, "TypeCode", required=True, profile=COMFORT) information = MultiStringField( NS_RAM, "Information", required=False, profile=COMFORT ) diff --git a/drafthorse/pdf.py b/drafthorse/pdf.py index e72d3f0..027f0b3 100644 --- a/drafthorse/pdf.py +++ b/drafthorse/pdf.py @@ -158,7 +158,7 @@ def _prepare_pdf_metadata_xml(level, pdf_metadata): fx_doc_filename = etree.SubElement( zugferd_desc, ns_zf + "DocumentFileName", nsmap=nsmap_zf ) - fx_doc_filename.text = "ZUGFeRD-invoice.xml" + fx_doc_filename.text = "{}.xml".format(level) fx_doc_version = etree.SubElement(zugferd_desc, ns_zf + "Version", nsmap=nsmap_zf) fx_doc_version.text = "1.0" fx_conformance_level = etree.SubElement( @@ -167,7 +167,7 @@ def _prepare_pdf_metadata_xml(level, pdf_metadata): fx_conformance_level.text = level xmp_file = os.path.join( - os.path.dirname(__file__), "schema", "ZUGFeRD1p0_extension_schema.xmp" + os.path.dirname(__file__), "schema", "ZUGFeRD2p2_extension_schema_{}.xmp".format(level) ) # Reason for defining a parser below: # http://lxml.de/FAQ.html#why-doesn-t-the-pretty-print-option-reformat-my-xml-output @@ -219,7 +219,7 @@ def _facturx_update_metadata_add_attachment( {NameObject("/F"): file_entry_obj, NameObject("/UF"): file_entry_obj} ) - fname_obj = createStringObject("ZUGFeRD-invoice.xml") + fname_obj = createStringObject(facturx_level + ".xml") filespec_dict = DictionaryObject( { NameObject("/AFRelationship"): NameObject("/Alternative"), diff --git a/drafthorse/schema/ZUGFeRD2p2_extension_schema_BASIC.xmp b/drafthorse/schema/ZUGFeRD2p2_extension_schema_BASIC.xmp new file mode 100644 index 0000000..4e968d8 --- /dev/null +++ b/drafthorse/schema/ZUGFeRD2p2_extension_schema_BASIC.xmp @@ -0,0 +1,87 @@ + + + + + + BASIC + BASIC.xml + INVOICE + 1.0 + + + + + + + + + ZUGFeRD PDFA Extension Schema + urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0# + zf + + + + DocumentFileName + Text + external + name of the embedded XML invoice file + + + DocumentType + Text + external + INVOICE + + + Version + Text + external + The actual version of the ZUGFeRD XML schema + + + ConformanceLevel + Text + external + The conformance level of the embedded ZUGFeRD data + + + + + + + + diff --git a/drafthorse/schema/ZUGFeRD2p2_extension_schema_EN16931.xmp b/drafthorse/schema/ZUGFeRD2p2_extension_schema_EN16931.xmp new file mode 100644 index 0000000..633782d --- /dev/null +++ b/drafthorse/schema/ZUGFeRD2p2_extension_schema_EN16931.xmp @@ -0,0 +1,87 @@ + + + + + + EN16931 + EN16931.xml + INVOICE + 1.0 + + + + + + + + + ZUGFeRD PDFA Extension Schema + urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0# + zf + + + + DocumentFileName + Text + external + name of the embedded XML invoice file + + + DocumentType + Text + external + INVOICE + + + Version + Text + external + The actual version of the ZUGFeRD XML schema + + + ConformanceLevel + Text + external + The conformance level of the embedded ZUGFeRD data + + + + + + + + diff --git a/drafthorse/schema/ZUGFeRD2p2_extension_schema_EXTENDED.xmp b/drafthorse/schema/ZUGFeRD2p2_extension_schema_EXTENDED.xmp new file mode 100644 index 0000000..0e28b17 --- /dev/null +++ b/drafthorse/schema/ZUGFeRD2p2_extension_schema_EXTENDED.xmp @@ -0,0 +1,87 @@ + + + + + + EXTENDED + EXTENDED.xml + INVOICE + 1.0 + + + + + + + + + ZUGFeRD PDFA Extension Schema + urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0# + zf + + + + DocumentFileName + Text + external + name of the embedded XML invoice file + + + DocumentType + Text + external + INVOICE + + + Version + Text + external + The actual version of the ZUGFeRD XML schema + + + ConformanceLevel + Text + external + The conformance level of the embedded ZUGFeRD data + + + + + + + + diff --git a/drafthorse/schema/ZUGFeRD2p2_extension_schema_MINIMUM.xmp b/drafthorse/schema/ZUGFeRD2p2_extension_schema_MINIMUM.xmp new file mode 100644 index 0000000..a01351a --- /dev/null +++ b/drafthorse/schema/ZUGFeRD2p2_extension_schema_MINIMUM.xmp @@ -0,0 +1,87 @@ + + + + + + MINIMUM + MINIMUM.xml + INVOICE + 1.0 + + + + + + + + + ZUGFeRD PDFA Extension Schema + urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0# + zf + + + + DocumentFileName + Text + external + name of the embedded XML invoice file + + + DocumentType + Text + external + INVOICE + + + Version + Text + external + The actual version of the ZUGFeRD XML schema + + + ConformanceLevel + Text + external + The conformance level of the embedded ZUGFeRD data + + + + + + + +