Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extraction of XRechnung xml files #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions facturx/facturx.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
FACTURX_FILENAME = 'factur-x.xml'
ZUGFERD_FILENAMES = ['zugferd-invoice.xml', 'ZUGFeRD-invoice.xml']
ORDERX_FILENAME = 'order-x.xml'
ALL_FILENAMES = [FACTURX_FILENAME] + ZUGFERD_FILENAMES + [ORDERX_FILENAME]
XRECHNUNG_FILENAME = 'xrechnung.xml'
ALL_FILENAMES = [FACTURX_FILENAME] + ZUGFERD_FILENAMES + [ORDERX_FILENAME] + [XRECHNUNG_FILENAME]
FACTURX_LEVEL2xsd = {
'minimum': 'facturx-minimum/Factur-X_1.07.2_MINIMUM.xsd',
'basicwl': 'facturx-basicwl/Factur-X_1.07.2_BASICWL.xsd',
Expand Down Expand Up @@ -295,7 +296,7 @@ def _get_embeddedfiles(embeddedfiles_node):


def get_facturx_xml_from_pdf(pdf_file, check_xsd=True):
filenames = [FACTURX_FILENAME] + ZUGFERD_FILENAMES
filenames = [FACTURX_FILENAME] + ZUGFERD_FILENAMES + [XRECHNUNG_FILENAME]
return get_xml_from_pdf(pdf_file, check_xsd=check_xsd, filenames=filenames)


Expand Down Expand Up @@ -846,9 +847,10 @@ def get_flavor(xml_etree):
def get_orderx_type(xml_etree):
if not isinstance(xml_etree, type(etree.Element('pouet'))):
raise ValueError('xml_etree must be an etree.Element() object')
namespaces = get_xml_namespaces('order-x')
type_code_xpath = \
"/rsm:SCRDMCCBDACIOMessageStructure/rsm:ExchangedDocument/ram:TypeCode"
xpath_res = xml_etree.xpath(type_code_xpath, namespaces=XML_NAMESPACES['order-x'])
xpath_res = xml_etree.xpath(type_code_xpath, namespaces=namespaces)
code = xpath_res and xpath_res[0].text and xpath_res[0].text.strip() or None
if code not in ORDERX_code2type:
raise Exception(
Expand Down