CSV output columns order
Could you implement a way to set the columns order in the CSV output ?
Especially in the lines. If we ask for a csv file, the lines column contains Json it should be csv.
In a CSV the file should look like
desc,vat,amount,lines,issuer,date,amount_untaxed,currency,invoice_number
with 'lines' replaced by the tags defined in the regex.
For example in my template line regex is :
line: '(\d{6}\s+(?P<Name>.{30,38}\s)\s+(?P<Quant>\d{1,3})\s+(|\w{2})\s+(|\-)(GRATUIT|PROMO|\d{1,4}\.\d{2})\s+\w{2}\s+\d\s+(Nt|(\d{2}\.\d{2}))\s+(|\-)(?P<Unit>\d{1,4}\.\d{2})\s+(|\-)(?P<Tot>\d{1,4}\.\d{2}))
so the CSV should be
desc,vat,amount,Name, Quant,Unit,Tot,issuer,date,amount_untaxed,currency,invoice_number
Only the first row would be complete, other lines (the ones containing the lines rows) would have invoice infos empty.
More, I should be able to tell invoice2data in which order to output the columns.
So to be fully precise, I would like to be able to make my output to be
issuer , invoice_number, date , desc, vat, amount_untaxed, amount, currency,Name, Quant,Unit,Tot
SomeFirm, 123456, 2019-09-22, SomeDescription, 200.00, 1000.00, EUR, Ice cream, 10, 2.31, 23.10
,,,,,,,Donuts, 5.00, 10.00, 50.00
,,,,,,,T5 screw driver, 2.23, 1.00, 2.23
This is easier to handle outside of invoice2data. Every user may want a different output format, which would be impossible for this project to accommodate.
Well, CSV clearly isn't a good choice for storing tree structured data.
Your proposed solution is one way of handling that. Or maybe the first row shouldn't have the first lines row? Please also mind this gets more complicated with mutliple fields containing multiple lines. I'm not sure how much worth it is it to extend CSV output support for such cases.
As for order I think it's natural to have them ordered the way they got specified in the template. Your tool reading CSV should easily handle that.