Creating invoice iterating over a database with datatool

I'm trying use datatool to iterate over a CSV file in order to create an invoice.

This is what I have:

\documentclass[12pt]{letter}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage[a4paper]{geometry}
\usepackage[british]{babel}

\usepackage{datatool}

\usepackage{invoice}

\begin{document}

\begin{letter} TEST

\opening{}

\begin{invoice}{\euro}{21}
\ProjectTitle{Rekening January}%
\DTLforeach*{jan}%
{%
\Date=date,%
\Price=price,%
\Quantity=quantity%
}%
{%
\Fee{\Date}{\Price}{\Quantity}%
}%
\end{invoice}

\end{letter}

\end{document}


When I compile, I get two "undefined control sequence" about the lines

}%
\end{invoice}


What I'm doing wrong?

• Well you don't show your csv so one can't test your code. But don't use \euro (or some other fragile command) in the first argument of invoice. It is fed to a \message and will explode. Use better "EUR" or something like this. – Ulrike Fischer Dec 29 '18 at 15:51
• Thank you so much! that \euro was indeed the problem! With just euro it works as I wanted. The code was taken from the internet: may I ask why the original author placed so many % here and there? I removed them and the file did not compile anymore. What is the meaning/function of those empty comments (%)? – matteo-gambarutti Dec 29 '18 at 16:01
• The % suppress the space you would insert by the end-of-line. Datatool doesn't like them. – Ulrike Fischer Dec 29 '18 at 16:03

Don't use \euro (or some other fragile command) in the first argument of invoice. It is fed (quite unnecessarly) to a \message and will explode. Use better "EUR" or something like this.