Closed m3nu closed 6 years ago
I don't recommend using another library here. It should be simple enough to just iterate over all the fields and fields.yml
and build a dict. The XML has too many empty and unused fields. It will be too confusing.
One of the Xpath is this: '//rsm:ExchangedDocumentContext/ram:GuidelineSpecifiedDocumentContextParameter/ram:ID',
Then the corresponding dict will be like this?
{
"ExchangedDocumentContext": {
"GuidelineSpecifiedDocumentContextParameter": {
"ID": "A1"
}
}
}
No. The json should be universal and not specific to an XML standard. So the json uses my simplified field names.
{
tax_amount: 99,
total_amount: 120,
...
}
The script for json export is ready. This is how the dict looks like:
{
"amount_tax": "3195.37",
"amount_total": "19172.24",
"amount_untaxed": null,
"buyer": "CLIENT 1",
"currency": "EUR",
"date": "20171031",
"invoice_number": "2017-TEST-04",
"name": null,
"seller": "FOURNISSEUR F",
"type": "380",
"version": "urn:factur-x.eu:1p0:minimum"
}
As I mentioned in #27 two required fields are not present, so have assigned them None
.
Looks great. Will check it out and merge.
Over the next weeks I'll be traveling and may not respond instantly.
No problem.
For the json-export I'd loop over all the valid fields defined in
fields.yml
and save them as json via a Python dict.