I am trying to build an invoice generation system in LaTeX which will be easy and maintainable. Right now we are using longtable and a preprocessing layer. I would like to change this to a .sty and a set of macros so that templates can be more heavily separated from the data entered into them.
What I would like is an API like:
\begin{invoicetable}{r|llrr|r}{runningnumber,description,qty,sellprice,linetotal}
\heading{runningnumber=\#,partnumber=Partnumber,description=Description,qty=Qty,sellprice=Price,linetotal=Total}
\line{runningnumber=1,partnumber=A-12232,description={Test part, some data},qty=4,sellprice=14.99,linetotal=59.96}
\end{invoicetable}
This would be a macro for something like (pretty formatting added here for clarity):
\begin{longtable}{r|llrr|r}
\# & Partnumber & Description & Qty & Sellprice & linetotal \\
\endhead
1 & A-12232 & Test part, some data & 4 & 14.99 & 59.96 \\
\end{longtable}
A few reasons for doing this is that it would allow me to drop columns in the environment declaration and have relevant keys ignored in the line items, and it would free up key ordering in the addition of lines themselves (partnumber=A-12232,qty=4 would be the same regardless of ordering).
At this point I have a pretty good idea of how the \line macro would work in that case (I may name it \invoiceline) and if I have trouble I can ask more questions there, but my immediate question is with the argument to the \begin macro. I need to be able to figure out roughly how to internally take the comma separated values in, break them up into an ordered list and a counter, something like a counter of \invoice@cols as a counter, and \invoice@col@current as another one. I figure there would need to be a macro for each col, like \invoice@col1 returning the name of the column.
