I want to generate invoices based on a CSV table. My approach looks like this:
\documentclass{letter}
\usepackage{invoice}
\usepackage{datatool}
\address{ABC AG \\
Nonamestreet 4 \\
1100 Vienna \\
bill@example.com}
\date{16. September 2013}
\begin{document}
\DTLloaddb{bills}{billdata.csv}
\DTLforeach{bills}
{\firstname=firstname}
{\lastname=lastname}
{\caddress=customeraddress}
{\tariffname=tariffname}
{\service=service}
{\rateperunit=rateperunit}
{\unitcount=unitcount}
{
\begin{letter}{\firstname~ \lastname \\ \caddress}
\opening{Invoice} Dear customer \lastname! This is your current bill.
\begin{invoice}{Euro}{20}
\ProjectTitle{\tariffname}
\Fee{Regular charge} {\rateperunit} {\unitcount}
\end{invoice}
\closing{Best regards, ABC AG}
\end{letter}
\clearpage
}
\end{document}
The CSV file has the following structure:
firstname lastname customeraddress tariffname service rateperunit unitcount
John Doe Musterstraße 4 Tariff1 Call 0.04 4
...
I then compile the .tex file with PDFLaTeX.
But I'm always getting this error:
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.36 \NeedsTeXFormat{LaTeX2e}[
1995/12/01]
?
and
! Emergency stop.
...
l.36 \NeedsTeXFormat{LaTeX2e}[
1995/12/01]
You're in trouble here. Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
I am using the texlive package of Ubuntu 13.04, and I also tried that with csvsimple, ending up with the exact same error.

\inputinstead of\RequirePackageand this disturbs datatool as it doesn't realize that fp has already been loaded. Try if it works if you load datatool before invoice. Or correct invoice.sty. – Ulrike Fischer Sep 16 '13 at 09:56\RequirePackageworks (with the other modifications I post in my answer) – Red Sep 16 '13 at 09:59