\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%>}{\lieferschein}{<%donumber%>}{<%dodate%>}

\setkomavar*{date}{\datum}
\setkomavar{date}{<%dodate%>}
\setkomavar{fromname}{<%employee_name%>}
\setkomavar{fromphone}{<%employee_tel%>}
\setkomavar{fromemail}{<%employee_email%>}
\setkomavar{title}{
	\lieferschein~
	\nr~<%donumber%>%
}
<%if ordnumber%>
	\setkomavar{orderID}{<%ordnumber%>}
<%end if%>%
<%if cusordnumber%>%
	\setkomavar*{yourref}{\unsereBestellnummer}
	\setkomavar{yourref}{<%cusordnumber%>}
<%end if%>%
\setkomavar{transaction}{<%transaction_description%>}

<%if globalprojectnumber%>%
	\setkomavar{projectID}{<%globalprojectnumber%>}
<%end globalprojectnumber%>%

\setkomavar{transaction}{<%transaction_description%>}
\setkomafont{extraDescription}{\scriptsize}

\begin{document}

\begin{letter}{
  \Ifstr{<%shiptoname%>}{}{ % KEINE ABWEICHENDE LIEFERADRESSE
	<%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
  }{ % ABWEICHENDE LIEFERADRESSE (Aus Stammdaten oder Beleg)
	<%shiptoname%>\strut\\
	<%if shiptocontact%> <%shiptocontact%><%end if%>\strut\\
	<%shiptodepartment_1%>\strut\\
	<%shiptodepartment_2%>\strut\\
	<%shiptostreet%>\strut\\
	<%shiptozipcode%> <%shiptocity%>\strut
	} % ende ifthenelse LIEFERADRESSE
}

\opening{}
\thispagestyle{kivitendo.letter.first}

\begin{PricingTabular*}[columns={pos, id, desc, amount}]
% eigentliche Tabelle
\FakeTable{
<%foreach number%>%
	<%runningnumber%> &
	<%number%> &
	\textbf{<%description%>}
		<%if longdescription%>\ExtraDescription{<%longdescription%>}<%end longdescription%>%
		<%if reqdate%>\ExtraDescription{\lieferdatum: <%reqdate%>}<%end reqdate%>%
		<%if serialnumber%>\ExtraDescription{\seriennummer: <%serialnumber%>}<%end serialnumber%>%
		<%if ean%>\ExtraDescription{\ean: <%ean%>}<%end ean%>%
		<%if projectnumber%>\ExtraDescription{\projektnummer: <%projectnumber%>}<%end projectnumber%>%
		<%foreach si_number%>%
			<%if si_chargenumber%>\ExtraDescription{\charge: <%si_chargenumber%> <%if si_bestbefore%> \mhd: <%si_bestbefore%><%end if%><%si_qty%>~<%si_unit%><%end si_chargenumber%>}%
		<%end si_number%>%
	&
		<%qty%> <%unit%>%
	\tabularnewline
<%end number%>%
}
\end{PricingTabular*}

\medskip

<%if notes%>%
<%notes%>%
\medskip
<%end if%>%

<%if delivery_term%>%
  \lieferung ~<%delivery_term.description_long%>\\
<%end delivery_term%>%

\end{letter}

\end{document}
