invoice-x / factur-x-ng

Python lib for Factur-X, the e-invoicing standard for France and Germany
Other
34 stars 8 forks source link

Example code fails with AssertionError #41

Open nyov opened 4 years ago

nyov commented 4 years ago

Trying the README sample again, now that my install works, I get this assertion error:

$ python3 test.py
2019-12-18 20:40:36,951 [INFO] No existing XML file found.
2019-12-18 20:40:36,951 [INFO] Factur-X flavor is factur-x (autodetected)
2019-12-18 20:40:36,951 [INFO] Factur-X level is minimum (autodetected)
2019-12-18 20:40:36,951 [INFO] PDF does not have XML embedded. Adding from template.
2019-12-18 20:40:36,953 [INFO] XML file successfully validated against XSD
Traceback (most recent call last):
  File "./fx-test.py", line 8, in <module>
    inv['due_date'] = datetime(2018, 10, 10)
  File "/home/testlab/.local/lib/python3.7/site-packages/facturx/facturx.py", line 107, in __setitem__
    path = self.flavor._get_xml_path(field_name)
  File "/home/testlab/.local/lib/python3.7/site-packages/facturx/flavors/xml_flavor.py", line 114, in _get_xml_path
    assert field_name in FIELDS.keys(), 'Field not specified. Try working directly on the XML tree.'
AssertionError: Field not specified. Try working directly on the XML tree.

This is the file

$ cat test.py 
#!/usr/bin/python3

from facturx import FacturX
from datetime import datetime

inv = FacturX('test.pdf')
inv['due_date'] = datetime(2018, 10, 10)
inv['seller.name'] = 'Smith Ltd.'
inv['buyer.country'] = 'France'