\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%>}


\begin{document}

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

\setkomavar{transaction}{<%transaction_description%>}

\setkomafont{extraDescription}{\scriptsize}

\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{}%muss existieren, damit seitenstil erzeugt wird.

\begin{PricingTabular*}[columns={pos, id, desc, amount}]
% eigentliche Tabelle
\FakeTable{
<%foreach number%>%
          <%runningnumber%> &
          <%number%> &
          \textbf{<%description%>}&
          <%qty%> <%unit%>%
          <%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%>%
		  \tabularnewline
<%end number%>%
}
\end{PricingTabular*}





\vspace{0.2cm}

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


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

\end{letter}

\end{document}
