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

Example code fails with AssertionError #41

Open
nyov opened this issue Dec 18, 2019 · 0 comments
Open

Example code fails with AssertionError #41

nyov opened this issue Dec 18, 2019 · 0 comments

Comments

@nyov
Copy link

nyov commented Dec 18, 2019

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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant