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 nested attributes for FacturX class #7

Closed m3nu closed 6 years ago

m3nu commented 6 years ago

Some invoice attributes, like buyer and seller would benefit from a nested structures. Like seller->country. I suggest to user a dot as separator to add "fake" nesting. I didn't find a good way to nest it natively without too many changes.

Example: factx['seller.country']

Steps to implement:

duskybomb commented 6 years ago

How I am implementing it:

if '.' in field_name:
    field_name = field_name.replace('.', '_')

Then in fields.yml

seller_name:  # for seller.name
    _path:
    ...

I have made nested attributes for seller.name, seller.country and similarly for buyer. What else should I add?

duskybomb commented 6 years ago

@m3nu should I add more fields in the similar manner as mentioned above, or should this be done differently?

m3nu commented 6 years ago

We could simply call our nested fields seller_name, seller_country, etc. So use the underscore directly instead of the dot. This would save the trouble of replacing it.