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

\setkomavar*{date}{\datum}
\setkomavar{date}{<%dodate%>}

\setkomavar{fromname}{<%employee_name%>}
\setkomavar{fromphone}{<%employee_tel%>}
\setkomavar{fromemail}{<%employee_email%>}
\setkomavar{title}{
	\einkaufslieferschein~\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}

<%if shiptoname%>%
\makeatletter
\begin{lrbox}\shippingAddressBox
	\parbox{\useplength{toaddrwidth}}{
		\backaddr@format{\scriptsize\usekomafont{backaddress}%
			\strut\abweichendeLieferadresse
		}
		\par\smallskip
		\setlength{\parskip}{\z@}
		\par
		\normalsize
		<%shiptoname%>\par
		<%if shiptocontact%> <%shiptocontact%><%end if%>\par
		<%shiptodepartment_1%>\par
		<%shiptodepartment_2%>\par
		<%shiptostreet%>\par
		<%shiptozipcode%> <%shiptocity%>%
	}
\end{lrbox}
\makeatother
<%end if%>%


\begin{document}


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


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

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