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

Implement JSON export #4

Closed m3nu closed 6 years ago

m3nu commented 6 years ago

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.

duskybomb commented 6 years ago

We can use this?

m3nu commented 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.

duskybomb commented 6 years ago

One of the Xpath is this: '//rsm:ExchangedDocumentContext/ram:GuidelineSpecifiedDocumentContextParameter/ram:ID',

Then the corresponding dict will be like this?

{ 
    "ExchangedDocumentContext": {
        "GuidelineSpecifiedDocumentContextParameter": {
            "ID": "A1"
        }
    }
} 
m3nu commented 6 years ago

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,
 ...
}
duskybomb commented 6 years ago

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.

m3nu commented 6 years ago

Looks great. Will check it out and merge.

Over the next weeks I'll be traveling and may not respond instantly.

duskybomb commented 6 years ago

No problem.