\documentclass[paper=a4,fontsize=10pt]{scrartcl}
\usepackage{kiviletter}


% Variablen, die in settings verwendet werden
\newcommand{\lxlangcode} {<%template_meta.language.template_code%>}
\newcommand{\lxmedia} {<%media%>}
\newcommand{\lxcurrency} {<%currency%>}
\newcommand{\kivicompany} {<%employee_company%>}

% settings: Einstellungen, Logo, Briefpapier, Kopfzeile, Fusszeile
\input{insettings.tex}


% laufende Kopfzeile:
\ourhead{\kundennummer}{<%customernumber%>}{\mahnung}{<%dunning_id%>}{<%dunning%>}


\begin{document}

\setkomavar*{date}{\datum}

\setkomavar{date}{<%dunning_date%>}
\setkomavar{customer}{<%customernumber%>}
\setkomavar{fromname}{<%employee_name%>}
\setkomavar{fromphone}{<%employee_tel%>}
\setkomavar{fromemail}{<%employee_email%>}
\setkomavar{title}{
	\mahnung
	<%if dunning_id%>~\nr~<%dunning_id%>}}<%end if%>
}
\setkomavar{transaction}{<%transaction_description%>}

\begin{letter}{
		<%name%>\strut\\
		<%if department_1%><%department_1%>\\<%end if%>
		<%if department_2%><%department_2%>\\<%end if%>
		<%cp_givenname%> <%cp_name%>\strut\\
		<%street%>\strut\\
		<%zipcode%> <%city%>\strut\\
		<%country%> \strut
	}

% Anrede nach Geschlecht unterscheiden
\opening{
	\ifstr{<%cp_name%>}{}
		{\anrede}
		{
			\ifstr{<%cp_gender%>}{f}
				{\anredefrau}
				{\anredeherr}
				<%cp_title%> <%cp_name%>,
		}
}
\thispagestyle{kivitendo.letter.first}

\mahnungsformel

\begin{SimpleTabular}[\bfseries\rechnung~\nr&\bfseries\datum&\bfseries\betrag]
% eigentliche Tabelle
<%foreach dn_invnumber%>
    <%dn_invnumber%> & <%dn_transdate%> & <%dn_amount%> \currency \\[0.1cm]
<%end dn_invnumber%>
\end{SimpleTabular}

\vspace{0.2cm}

\bitteZahlenBis~<%dunning_duedate%>.


\beruecksichtigtBis~<%dunning_date%>.


\schonGezahlt

\closing{\gruesse}

\end{letter}

\end{document}
