Projekt

Allgemein

Profil

Herunterladen (22,6 KB) Statistiken
| Zweig: | Markierung: | Revision:
4987cdc7 Jan Büren
\NeedsTeXFormat{LaTeX2e}
9d8ef337 Marei Peischl
\ProvidesPackage{kiviletter}[2022/04/23 Letter Layouts for Kivitendo]
33c815ee Jan Büren
8cb0bc13 Marei Peischl
\RequirePackage{l3keys2e}

95eab00b Marei Peischl
%Optionen vor den eigenen Paketoptionen hinzufügen, damit spätere diese ggf. überschreiben
\PassOptionsToPackage{
fromlogo,
fromalign=right,
firstfoot=false,%Für einheitliche Randeinstellungen
refline=nodate,
}{scrletter}

8cb0bc13 Marei Peischl
\ExplSyntaxOn
4987cdc7 Jan Büren
\newif\if@kivi@infobox
77d85523 Marei Peischl
\newif\if@kivi@footer
8cb0bc13 Marei Peischl
\keys_define:nn {kiviletter} {
95eab00b Marei Peischl
infobox .choices:nn = {true,false} {\use:c {@kivi@infobox\l_keys_choice_tl}},
infobox .default:n = true,
infobox .initial:n = true,
reffields .meta:n = {infobox=false},
footer .choices:nn = {true,false} {\use:c {@kivi@footer\l_keys_choice_tl}},
footer .default:n = true,
footer .initial:n = true,
nofooter .meta:n = {footer=false},
unknown .code:n = \PassOptionsToPackage{\l_keys_key_str=#1}{scrletter},
8cb0bc13 Marei Peischl
}
\ExplSyntaxOff
4987cdc7 Jan Büren
8cb0bc13 Marei Peischl
\ProcessKeysOptions{kiviletter}
4987cdc7 Jan Büren
ef0a9dc8 Marei Peischl
\RequirePackage{xparse}
4987cdc7 Jan Büren
\RequirePackage{iftex}
8cb0bc13 Marei Peischl
4987cdc7 Jan Büren
% Schriftart, Eingabelayout der Tastatur
\ifPDFTeX
3d229eb9 Marei Peischl
\RequirePackage[utf8]{inputenc}% Nur notwendig, wenn Basis älter als TL2018
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}
ef0a9dc8 Marei Peischl
3d229eb9 Marei Peischl
\RequirePackage{eurosym}
\DeclareUnicodeCharacter{20AC}{\euro}
4987cdc7 Jan Büren
\else
3d229eb9 Marei Peischl
\RequirePackage{fontspec}
4987cdc7 Jan Büren
\fi

5ffa2173 Marei Peischl
\RequirePackage{xltabular}
4987cdc7 Jan Büren
\RequirePackage{booktabs}
\RequirePackage{graphicx}

88fc44c8 Marei Peischl
\RequirePackage{scrletter}
4987cdc7 Jan Büren
\LoadLetterOption{DIN}

6974d60c Jan Büren
\newkomavar{taxpoint}
4987cdc7 Jan Büren
\newkomavar{transaction}
\newkomavar[\lieferschein{}~\nr]{delivery}
\newkomavar[\angebot{}~\nr]{quote}
2e0414b5 Marei Peischl
\newkomavar[\auftragsnummer]{orderID}
\newkomavar[\projektnummer]{projectID}
\setkomavar*{fromphone}{\textTelefon}
\setkomavar*{fromemail}{\textEmail}
\setkomavar*{fromfax}{\textFax}
\setkomavar*{customer}{\kundennummer}

4987cdc7 Jan Büren
\usepackage{geometry}

\ExplSyntaxOn
\dim_new:N \g_kivi_margin_dim
\dim_gset:Nn \g_kivi_margin_dim {\useplength{toaddrhpos}}
\geometry{a4paper,margin=\g_kivi_margin_dim,heightrounded}
%Scratch variables
\int_new:N \l_kivi_tmp_int
\bool_new:N \l_kivi_tmp_bool
\bool_new:N \g_kivi_TableFoot_bool
\dim_new:N \g_kivi_orig@textheight_dim
\ExplSyntaxOff

\newsavebox{\shippingAddressBox}


\DeclareNewLayer[
3d229eb9 Marei Peischl
foreground,
hoffset=\useplength{toaddrhpos},
voffset=\dimexpr\useplength{toaddrvpos}+\useplength{toaddrheight}+4\baselineskip,%sep to shippingaddressbox
contents={\usebox\shippingAddressBox}
4987cdc7 Jan Büren
]{kivitendo.shippingaddress}

\newpairofpagestyles{kivitendo.letter}{}
7a3c31d4 Marei Peischl
4987cdc7 Jan Büren
\renewcommand*{\letterpagestyle}{kivitendo.letter}

\DeclareNewPageStyleByLayers{kivitendo.letter.first}{
3d229eb9 Marei Peischl
kivitendo.shippingaddress,
plain.kivitendo.letter.head.odd,plain.kivitendo.letter.head.even,plain.kivitendo.letter.head.oneside,%
plain.kivitendo.letter.foot.odd,plain.kivitendo.letter.foot.even,plain.kivitendo.letter.foot.oneside,%
4987cdc7 Jan Büren
}

\setkomavar{backaddress}{\firma\ $\cdot$ \strasse\ $\cdot$ \ort}

\setkomavar{firsthead}{
3d229eb9 Marei Peischl
\if@logo
\rlap{\usekomavar{fromlogo}}%
\fi
4987cdc7 Jan Büren
}

\@setplength{locwidth}{6cm}

\ExplSyntaxOn
2a3b6b54 Marei Peischl
\dim_new:N \l_kivi_tab_desc_leftskip_dim
9bbfe2cb Marei Peischl


\cs_new:Nn \__kivi_set_colwidth:nn {
3d229eb9 Marei Peischl
\dim_set:cn {l_kivi_tab_#1_dim} {#2}
9bbfe2cb Marei Peischl
}


\cs_new:Nn \__kivi_initialize_columns: {
3d229eb9 Marei Peischl
\clist_map_inline:Nn \g_kivi_pricingtable_col_clist {
\bool_if_exist:cF {l_kivi_col_##1_bool}
{
\bool_new:c {l_kivi_col_##1_bool}
\dim_new:c {l_kivi_tab_##1_dim}
\keys_define:nn {kivi/PricingTable} {
##1 .choice:,
##1 / true .code:n = \bool_set_true:c {l_kivi_col_##1_bool},
##1 / false .code:n = \bool_set_false:c {l_kivi_col_##1_bool},
##1 / unknown .code:n = {
\bool_set_true:c {l_kivi_col_##1_bool}
\dim_set:cn {l_kivi_tab_##1_dim} {####1}
},
##1 .default:n = true,
##1 .initial:n = true,
##1 / header .prop_put:c = {l_kivi_col_##1_prop},
##1 / colspec .prop_put:c = {l_kivi_col_##1_prop},
}
}
}
c05124af Marei Peischl
}

9bbfe2cb Marei Peischl
\clist_new:N \g_kivi_pricingtable_col_clist

\keys_define:nn {kivi/PricingTable} {
3d229eb9 Marei Peischl
columns .code:n =
\clist_gset:Nn \g_kivi_pricingtable_col_clist {#1}
\__kivi_initialize_columns:,
columns .initial:n = {pos, id, desc, amount, price, pricetotal},
unknown .code:n = \keys_set:no {kivi/Tabular} {\l_keys_key_str=#1}
9bbfe2cb Marei Peischl
}

c05124af Marei Peischl
% set default values for colwidth
9bbfe2cb Marei Peischl
\keys_set:nn {kivi/PricingTable} {
3d229eb9 Marei Peischl
pos=5ex,
id=4em,
amount=5em,
price=7em,
pricetotal=7em,
95eab00b Marei Peischl
% desc=auto,
3d229eb9 Marei Peischl
pos/header=\position,
id/header=\artikelnummer,
desc/header=\bezeichnung,
amount/header=\menge,
price/header=\einzelpreis,
pricetotal/header=\gesamtpreis,
price / colspec = Price,
pricetotal / colspec = Price ,
9bbfe2cb Marei Peischl
}
4987cdc7 Jan Büren
\dim_new:N \g_kivi_tabcolsep_dim
\dim_gset:Nn \g_kivi_tabcolsep_dim {.5\tabcolsep}
4ec81d44 Marei Peischl
\setlength\tabcolsep{.5\tabcolsep}
c05124af Marei Peischl
bd4648bf Marei Peischl
\prg_new_conditional:Nnn \kivi_if_Price_col:n {T, TF} {
3d229eb9 Marei Peischl
\prop_get:cnN {l_kivi_col_#1_prop} {colspec} \l_tmpa_tl
\exp_args:NV \tl_if_eq:nnTF \l_tmpa_tl {Price}
{\prg_return_true:}
{\prg_return_false:}
c659bf51 Marei Peischl
}


c05124af Marei Peischl
\cs_new:Nn \__kivi_calc_desc_column: {
3d229eb9 Marei Peischl
\bool_if:NTF \g__kivi_Tabular_rowcolor_bool
{\dim_set:Nn \l_kivi_tab_desc_leftskip_dim {2\g_kivi_tabcolsep_dim}}
{\dim_zero:N \l_kivi_tab_desc_leftskip_dim}
\dim_zero:N \l_kivi_tab_desc_dim
\bool_set_false:N \l_tmpa_bool
\tl_gclear:N \g_kivi_Pricing_colspec_tl
\clist_map_inline:Nn \g_kivi_pricingtable_col_clist {
\tl_if_eq:nnTF {##1} {desc} {
\dim_set:Nn \l_kivi_tab_desc_dim {
\textwidth-\l_kivi_tab_desc_leftskip_dim
}
\bool_set_true:N \l_tmpa_bool
\tl_gput_right:Nn \g_kivi_Pricing_colspec_tl {p{\l_kivi_tab_desc_dim}}
}{
\bool_if:cT {l_kivi_col_##1_bool} {
\bool_if:NTF \l_tmpa_bool {
\dim_sub:Nn \l_kivi_tab_desc_dim {
\dim_use:c {l_kivi_tab_##1_dim}+2\g_kivi_tabcolsep_dim
}
}{
\dim_add:Nn \l_kivi_tab_desc_leftskip_dim {
\dim_use:c {l_kivi_tab_##1_dim}+2\g_kivi_tabcolsep_dim
}
}
bd4648bf Marei Peischl
\prop_if_in:cnTF {l_kivi_col_##1_prop} {colspec} {
\kivi_if_Price_col:nTF {##1} {
\tl_gput_right:Nn \g_kivi_Pricing_colspec_tl {K}
}{
\tl_gput_right:Nx \g_kivi_Pricing_colspec_tl {\prop_item:cn {l_kivi_col_##1_prop} {colspec}}
}
\tl_gput_right:Nn \g_kivi_Pricing_colspec_tl {{\dim_use:c {l_kivi_tab_##1_dim}}}
} {
\tl_gput_right:Nn \g_kivi_Pricing_colspec_tl {K{\dim_use:c {l_kivi_tab_##1_dim}}}
}
3d229eb9 Marei Peischl
\kivi_if_Price_col:nT {##1} {\tl_gput_right:Nn \g_kivi_Pricing_colspec_tl {<{\__kivi_tab_column_currency:}}}
}
}
}
\bool_if:NF \g__kivi_Tabular_rowcolor_bool {
\tl_gput_left:Nn \g_kivi_Pricing_colspec_tl {@{}}
\tl_gput_right:Nn \g_kivi_Pricing_colspec_tl {@{}}
}
4987cdc7 Jan Büren
}

661febc7 Marei Peischl
\newcolumntype{K}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{P}[1]{K{#1}<{\__kivi_tab_column_currency:}}
4987cdc7 Jan Büren
\RequirePackage{tcolorbox}
\tcbuselibrary{breakable, skins}
01b1d8ff Marei Peischl
\tcb@new@skin{kivi@LT}{base@unbroken,%
e6518ce7 Marei Peischl
frame~engine=empty,interior~titled~engine=empty,interior~engine=empty,segmentation~engine=empty,title~engine=empty,%
skin~first=kivi@LT@first,skin~middle=kivi@LT@middle,skin~last=kivi@LT@last,
underlay~first~and~middle={
\node[anchor=north] at (interior.north) {\csname box_use:c\endcsname {g_kivi_LT@head_box}};
\node[anchor=south] at (interior.south) {\csname box_use:c\endcsname {g_kivi_LT@foot_box}};
3d229eb9 Marei Peischl
},
e6518ce7 Marei Peischl
underlay~unbroken~and~last={
\node[anchor=north] at (interior.north) {\csname box_use:c\endcsname {g_kivi_LT@head_box}};
\node[anchor=south] at (interior.south) {\csname box_use:c\endcsname {g_kivi_LT@lastfoot_box}};
},
boxsep=0pt,
boxrule=0pt,
left=0pt,
right=0pt,
bottom=\box_ht:N \g_kivi_LT@foot_box+\box_dp:N \g_kivi_LT@foot_box + \aboverulesep,
top=\box_ht:N \g_kivi_LT@head_box+\box_dp:N \g_kivi_LT@head_box +\belowrulesep,
parbox=false,
01b1d8ff Marei Peischl
}

\tcb@new@skin{kivi@LT@first}{base@first,%
3d229eb9 Marei Peischl
frame~engine=empty,interior~titled~engine=empty,interior~engine=empty,segmentation~engine=empty,title~engine=empty,%
skin~first=kivi@LT@first,skin~middle=kivi@LT@middle,skin~last=kivi@LT@middle,
01b1d8ff Marei Peischl
}

\tcb@new@skin{kivi@LT@middle}{base@middle,%
3d229eb9 Marei Peischl
frame~engine=empty,interior~titled~engine=empty,interior~engine=empty,segmentation~engine=empty,title~engine=empty,%
skin~first=kivi@LT@middle,skin~middle=kivi@LT@middle,skin~last=kivi@LT@middle,
01b1d8ff Marei Peischl
}

\tcb@new@skin{kivi@LT@last}{base@last,%
3d229eb9 Marei Peischl
frame~engine=empty,interior~titled~engine=empty,interior~engine=empty,segmentation~engine=empty,title~engine=empty,%
skin~first=kivi@LT@middle,skin~middle=kivi@LT@middle,skin~last=kivi@LT@last,
01b1d8ff Marei Peischl
}

\tcbset{kivi@LT/.style={skin=kivi@LT}}%

4987cdc7 Jan Büren
\seq_new:N \l_kivi_PricingTable_seq
c05124af Marei Peischl
\seq_new:N \l_kivi_columns_seq
4987cdc7 Jan Büren
\seq_new:N \g_kivi_extraDescription_seq
4ec81d44 Marei Peischl
424ee46d Marei Peischl
\int_new:N \g__kivi_PricingTable_rowcolor_int
3d229eb9 Marei Peischl
\dim_new:N \l__kivi_fboxsep_dim
1057b87c Marei Peischl
\dim_set:Nn \l__kivi_fboxsep_dim {\g_kivi_tabcolsep_dim}

%colorbox variant to only add vertical spacing
%based on colorbox definition from xcolor.sty
%% ----------------------------------------------------------------
%% Copyright (C) 2003-2016 by Dr. Uwe Kern <xcolor at ukern dot de>
%% ----------------------------------------------------------------
%% This variant of colorbox adds a space of \l__kivi_fboxsep_dim along the vertical axes but no horizontal space
\def\kivi@tabcolorbox#1#{\protect\kivi@tabcolor@box{#1}}

\def\kivi@tabcolor@box#1#2{
3d229eb9 Marei Peischl
\tl_if_empty:oTF {#2}
\kivi@nocolor@b@x
\kivi@color@b@x
\relax{\color#1{#2}}
1057b87c Marei Peischl
}
\long\def\kivi@color@b@x#1#2#3%
{\leavevmode
3d229eb9 Marei Peischl
\setbox\z@\hbox{{\set@color#3}}%
\dimen@\ht\z@\advance\dimen@\l__kivi_fboxsep_dim\ht\z@\dimen@
\dimen@\dp\z@\advance\dimen@\l__kivi_fboxsep_dim\dp\z@\dimen@
{#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}\box\z@}}}
1057b87c Marei Peischl
\long\def\kivi@nocolor@b@x#1#2#3%
{\leavevmode
3d229eb9 Marei Peischl
\setbox\z@\hbox{#3}%
\dimen@\ht\z@\advance\dimen@\l__kivi_fboxsep_dim\ht\z@\dimen@
\dimen@\dp\z@\advance\dimen@\l__kivi_fboxsep_dim\dp\z@\dimen@
{\box\z@}}
1057b87c Marei Peischl
%%%

4987cdc7 Jan Büren
\newcommand{\FakeTable}[1]{
3d229eb9 Marei Peischl
\par
\seq_set_split:Nnn \l_kivi_PricingTable_seq {\tabularnewline} {#1}
\seq_remove_all:Nn \l_kivi_PricingTable_seq {}
\begingroup
\setlength{\parskip}{\c_zero_dim}
\let\ExtraDescription\__kivi_addExtraDescription:n
\setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
\seq_map_inline:Nn \l_kivi_PricingTable_seq {
40dae6b8 Marei Peischl
\if_mode_horizontal: \par \fi
3d229eb9 Marei Peischl
\bool_if:NT \g__kivi_Tabular_rowcolor_bool {
\int_gincr:N \g__kivi_PricingTable_rowcolor_int
\int_if_odd:nTF {\g__kivi_PricingTable_rowcolor_int}
{\nointerlineskip\kivi@tabcolorbox{\g__kivi_Tabular_rowcolor_odd_tl}}
{\nointerlineskip\kivi@tabcolorbox{\g__kivi_Tabular_rowcolor_even_tl}}
}
{\parbox{\linewidth}{
\seq_set_split:Nnn \l_kivi_columns_seq {&} {##1}
\seq_gclear:N \g_kivi_extraDescription_seq
\exp_args:Nnx \use:n {\tabular[t]}\g_kivi_Pricing_colspec_tl
\seq_pop_left:NN \__l_FakeTable_columns_seq \l_tmpa_tl
\seq_item:Nn \l_kivi_columns_seq {\l_tmpa_tl}
\seq_map_inline:Nn \__l_FakeTable_columns_seq {
&\seq_item:Nn \l_kivi_columns_seq {####1}
}
\endtabular
98d4a3a7 Marei Peischl
}
3d229eb9 Marei Peischl
\seq_if_empty:NTF \g_kivi_extraDescription_seq
{\par}
{\par\nopagebreak
\begingroup
\setlength{\leftskip}{\dim_eval:n {\bool_if:NT \g__kivi_Tabular_rowcolor_bool {-\tabcolsep} +\l_kivi_tab_desc_leftskip_dim}}
\setlength{\hsize}{\dim_eval:n {\l_kivi_tab_desc_dim+\leftskip}}
98d4a3a7 Marei Peischl
\setlength{\linewidth}{\hsize}
\addtolength{\leftmargini}{\l_kivi_tab_desc_leftskip_dim}
3d229eb9 Marei Peischl
\usekomafont{extraDescription}
\seq_use:Nn \g_kivi_extraDescription_seq {\\}
\par
\endgroup
}
98d4a3a7 Marei Peischl
}
c583fd97 Marei Peischl
\par
0204812c Marei Peischl
\tl_if_empty:NF \l__kivi_Tabular_rowsep_tl {\nointerlineskip\l__kivi_Tabular_rowsep_tl}
3d229eb9 Marei Peischl
}
c583fd97 Marei Peischl
\endgroup
\par
4987cdc7 Jan Büren
}


c05124af Marei Peischl
\seq_new:N \__l_FakeTable_columns_seq
\cs_new:Nn \__kivi_setup_FakeTable: {
3d229eb9 Marei Peischl
\seq_clear:N \__l_FakeTable_columns_seq
\int_zero:N \l_tmpa_int
\clist_map_inline:Nn \g_kivi_pricingtable_col_clist {
\int_incr:N \l_tmpa_int
\bool_if:cT {l_kivi_col_##1_bool} {\seq_put_right:Nx \__l_FakeTable_columns_seq {\int_use:N \l_tmpa_int}}
}
c05124af Marei Peischl
}

4987cdc7 Jan Büren
\tl_new:N \g_kivi_Pricing_colspec_tl
c05124af Marei Peischl
\tl_gset:Nn \g_kivi_Pricing_colspec_tl {
e6518ce7 Marei Peischl
\bool_if:NF \g__kivi_Tabular_rowcolor_bool {@{}}
\bool_if:NT \l_kivi_col_pos_bool {p{\l_kivi_tab_pos_dim}}
\bool_if:NT \l_kivi_col_id_bool {p{\l_kivi_tab_id_dim}}
p{\l_kivi_tab_desc_dim}
\bool_if:NT \l_kivi_col_amount_bool {\exp_not:n {>{\raggedleft\arraybackslash}p{\l_kivi_tab_amount_dim}}}
\bool_if:NT \l_kivi_col_price_bool {\exp_not:n {>{\raggedleft\arraybackslash}p{\l_kivi_tab_price_dim}<{\__kivi_tab_column_currency:}}}
\bool_if:NT \l_kivi_col_pricetotal_bool {\exp_not:n {>{\raggedleft\arraybackslash}p{\l_kivi_tab_pricetotal_dim}<{\__kivi_tab_column_currency:}}}
\bool_if:NF \g__kivi_Tabular_rowcolor_bool {@{}}
c05124af Marei Peischl
}
4987cdc7 Jan Büren
ef0a9dc8 Marei Peischl
\cs_new_protected:Nn \__kivi_tab_column_currency: {\,\currency}
736bde4c Marei Peischl
\def\tabcurrency{\__kivi_tab_column_currency:}
9bbfe2cb Marei Peischl
\cs_set:Nn \__kivi_tab_column_header_currency: {}
\cs_set_eq:NN \__kivi_tab_column_body_currency: \__kivi_tab_column_currency:
4987cdc7 Jan Büren
\clist_map_inline:nn {head, foot, firsthead, lastfoot} {%TODO reduce
3d229eb9 Marei Peischl
\box_new:c {g_kivi_LT@#1_box}
4987cdc7 Jan Büren
}

9bbfe2cb Marei Peischl
\newkomafont{PricingTableHeader}{\bfseries}

c05124af Marei Peischl
\cs_new:Nn \__kivi_setup_LT_boxes: {
3d229eb9 Marei Peischl
\__kivi_calc_desc_column:
\hbox_gset:Nn \g_kivi_LT@head_box {
\setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
\bool_if:NT \g__kivi_Tabular_rowcolor_bool {\kivi@tabcolorbox{\g__kivi_Tabular_rowcolor_header_tl}}%
{
\exp_args:Nnx \use:n {\tabular[b]}\g_kivi_Pricing_colspec_tl
\__kivi_PricingTabular_header:
\endtabular
}
}
\hbox_gset:Nn \g_kivi_LT@foot_box {
\begin{tabular*}{\textwidth}[t]{@{\extracolsep{\fill}}r@{\bool_if:NT \g__kivi_Tabular_rowcolor_bool {\hskip\tabcolsep}}}
\bool_if:NTF \g__kivi_Tabular_rowcolor_bool
88fc44c8 Marei Peischl
{\hline\noalign{\vskip1pt}}
3d229eb9 Marei Peischl
\midrule
\strut\weiteraufnaechsterseite
\end{tabular*}
}
\hbox_gset:Nn \g_kivi_LT@lastfoot_box {
\raisebox{\dimexpr\depth+\baselineskip}[0pt][0pt]{
\begin{tabular*}{\textwidth}{@{\bool_if:NT \g__kivi_Tabular_rowcolor_bool {\hskip\tabcolsep}\extracolsep{\fill}}r@{\bool_if:NT \g__kivi_Tabular_rowcolor_bool {\hskip\tabcolsep}}}
\bool_if:NF \g__kivi_Tabular_rowcolor_bool \bottomrule
\end{tabular*}
}
}
4987cdc7 Jan Büren
}


%Macht es sinn hier eine Variante zu machen, in der alle Spalten Belegbar sind?
4ec81d44 Marei Peischl
\NewDocumentEnvironment{PricingTotal}{+b}{
e6518ce7 Marei Peischl
\par\nointerlineskip
4987cdc7 Jan Büren
}{
95eab00b Marei Peischl
\bool_if:NT \g__kivi_Tabular_rowcolor_bool {\nointerlineskip\kivi@tabcolorbox{\g__kivi_Tabular_rowcolor_PricingTotal_tl}}
e6518ce7 Marei Peischl
{
\tabular[t]{
@{\bool_if:NT \g__kivi_Tabular_rowcolor_bool {\hskip\tabcolsep}}
p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-\bool_if:NTF \g__kivi_Tabular_rowcolor_bool {4}{2}\tabcolsep}}P{\l_kivi_tab_pricetotal_dim}@{\bool_if:NT \g__kivi_Tabular_rowcolor_bool {\hskip\tabcolsep}}
}
\l__kivi_Tabular_PricingTotal_topsep_tl
#1
\endtabular
}
4987cdc7 Jan Büren
}

4ec81d44 Marei Peischl
\tl_new:N \l__kivi_Tabular_PricingTotal_topsep_tl
%TODO
\tl_set:Nn \l__kivi_Tabular_PricingTotal_topsep_tl {\bool_if:NF \g__kivi_Tabular_rowcolor_bool \midrule}
bd3479e4 Marei Peischl
\newcommand*\ExtraDescription{
3d229eb9 Marei Peischl
\PackageError{kiviletter}{The~command~\string\ExtraDescription\space~may~be~only~used~inside~the~\string\FakeTable\space~environment.}{See~documentation~for~details}
bd3479e4 Marei Peischl
}


\cs_new:Nn \__kivi_addExtraDescription:n {\seq_gput_right:Nn \g_kivi_extraDescription_seq {#1}}
c05124af Marei Peischl
4987cdc7 Jan Büren
\newenvironment{PricingTabular}[1][]{
3d229eb9 Marei Peischl
\begingroup
\dim_set:Nn \parskip {\c_zero_dim}
\tl_if_empty:nF {#1} {\keys_set:nn {kivi/PricingTable} {#1}}
\setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
\__kivi_calc_desc_column:
\exp_args:Nx \longtable \g_kivi_Pricing_colspec_tl
% Tabellenkopf
\__kivi_PricingTabular_header:
\endhead
\midrule
\rlap{\makebox[\textwidth][r]{\weiteraufnaechsterseite}}\\
\endfoot
\bool_if:NF \g__kivi_Tabular_rowcolor_bool \bottomrule
\endlastfoot
4987cdc7 Jan Büren
}{
3d229eb9 Marei Peischl
\endlongtable
\endgroup
4987cdc7 Jan Büren
}

a89ea81f Marei Peischl
\cs_set:Nn \__kivi_PricingTabular_header: {
3d229eb9 Marei Peischl
\bool_if:NTF \g__kivi_Tabular_rowcolor_bool {\noalign{\skip_vertical:n {\dp\strutbox}}}\toprule
\cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_header_currency:
\bool_set_false:N \l_tmpa_bool
95eab00b Marei Peischl
\clist_map_inline:Nn \g_kivi_pricingtable_col_clist {
3d229eb9 Marei Peischl
\bool_if:cT {l_kivi_col_##1_bool} {
\bool_if:NT \l_tmpa_bool {&}
\bool_set_true:N \l_tmpa_bool
\usekomafont{PricingTableHeader}
\prop_item:cn {l_kivi_col_##1_prop} {header}
}
}
\cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_body_currency:
\\
\bool_if:NF \g__kivi_Tabular_rowcolor_bool \midrule
a89ea81f Marei Peischl
}

4ec81d44 Marei Peischl
\newkomafont{tablehead}{\bfseries}
4987cdc7 Jan Büren
374086f0 Marei Peischl
\keys_define:nn {kivi/SimpleTabular} {
3d229eb9 Marei Peischl
colspec .tl_set:N =\l_kivi_SimpleTabular_colspec_tl,
colspec .initial:n = {rrX},
headline .tl_set:N = \l_kivi_SimpleTabular_headline_tl,
headline .initial:n = {\usekomafont{tablehead}\position & \usekomafont{tablehead}\menge & \usekomafont{tablehead}\bezeichnung},
4ec81d44 Marei Peischl
}

a47d662b Marei Peischl
\keys_define:nn {kivi/Tabular} {
3d229eb9 Marei Peischl
color-rows .bool_gset:N = \g__kivi_Tabular_rowcolor_bool ,
color-rows .initial:n = false,
color-rows .default:n = true,
rowcolor-odd .tl_gset:N = \g__kivi_Tabular_rowcolor_odd_tl,
rowcolor-odd .initial:n = black!10,
rowcolor-even .tl_gset:N = \g__kivi_Tabular_rowcolor_even_tl,
rowcolor-even .initial:n =,
rowcolor-header .tl_gset:N = \g__kivi_Tabular_rowcolor_header_tl,
rowcolor-header .initial:n = black!35,
rowcolor-total .tl_gset:N = \g__kivi_Tabular_rowcolor_PricingTotal_tl,
rowcolor-total .initial:n = black!35,
526ed9a1 Marei Peischl
rowsep .tl_set:N =\l__kivi_Tabular_rowsep_tl,
rowsep .initial:n = ,
hrule .meta:n = {
rowsep={
\vskip\aboverulesep
\leavevmode\hrule\@height\lightrulewidth
\vskip\belowrulesep}},
374086f0 Marei Peischl
}
4987cdc7 Jan Büren
0ea3d7bd Marei Peischl
\newcommand*{\SetupSimpleTabular}[1]{\keys_set:nn {kivi/SimpleTabular} {#1}}
\newcommand*{\SetupPricingTabular}[1]{\keys_set:nn {kivi/PricingTable} {#1}}

374086f0 Marei Peischl
\newenvironment{SimpleTabular}[1][]
4987cdc7 Jan Büren
{
3d229eb9 Marei Peischl
\tl_if_in:nnTF {#1} {=} {\keys_set:nn {kivi/SimpleTabular} {#1}} {\tl_if_empty:nF {#1} {\tl_set:Nn \l_kivi_SimpleTabular_headline_tl {#1}}}
\setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
\dim_set:Nn \parskip {\c_zero_dim}
95eab00b Marei Peischl
\bool_if:NF \g__kivi_Tabular_rowcolor_bool {
3d229eb9 Marei Peischl
\tl_put_right:Nn \l_kivi_SimpleTabular_colspec_tl {@{}}
\tl_put_left:Nn \l_kivi_SimpleTabular_colspec_tl {@{}}
}
\exp_args:NnV \xltabular{\linewidth}\l_kivi_SimpleTabular_colspec_tl
\toprule
\cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_header_currency:
\l_kivi_SimpleTabular_headline_tl
\\
\noalign{\cs_gset_eq:NN \__kivi_tab_column_currency: \__kivi_tab_column_body_currency:}
\midrule
\endhead
\midrule
\rlap{\makebox[\textwidth][r]{\weiteraufnaechsterseite}}\\
\endfoot
\bool_if:NF \g__kivi_Tabular_rowcolor_bool \bottomrule
\endlastfoot
\ignorespaces
4987cdc7 Jan Büren
}{
3d229eb9 Marei Peischl
\def\@currenvir{tabularx}
\endxltabular
4987cdc7 Jan Büren
}

662d2792 Marei Peischl
%PricingTabular* kann automatisch spalten ignorieren
% \begin{PricingTabular*}[id=false]
% deaktiviert damit die Spalte der Produktnummer
% analog ist dies für pos, amount, price, pricetotal möglich.
% Die Spalte der Bezeichnung ist nicht deaktivierbar
01b1d8ff Marei Peischl
\newenvironment{PricingTabular*}[1][]{
3d229eb9 Marei Peischl
\int_gzero:N \g__kivi_PricingTable_rowcolor_int
\tl_if_empty:nF {#1} {\keys_set:nn {kivi/PricingTable} {#1}}
\__kivi_setup_LT_boxes:
\__kivi_setup_FakeTable:
\dim_set:Nn \parskip {\c_zero_dim}
\PricingTabularBox\ignorespaces
4ec81d44 Marei Peischl
}{\endPricingTabularBox
3d229eb9 Marei Peischl
%compensate footer spacing
\skip_vertical:n {-\box_ht:N \g_kivi_LT@foot_box-\box_dp:N \g_kivi_LT@foot_box}
4ec81d44 Marei Peischl
}
4987cdc7 Jan Büren
01b1d8ff Marei Peischl
\newtcolorbox{PricingTabularBox}{breakable,skin=kivi@LT}
4987cdc7 Jan Büren
2e0414b5 Marei Peischl
\if@kivi@infobox

3d229eb9 Marei Peischl
\def\locationsep{:}

\NewDocumentCommand{\locationentry}{som}{
\Ifkomavarempty{#3}{}{
\IfBooleanTF {#1} {
\strut
\IfNoValueTF {#2}
{\usekomavar*{#3}}
{#2}
\locationsep
\hfill\strut\space
\hbox_set:Nn \l_tmpa_box {\usekomavar{#3}}
\dim_compare:nTF {\box_wd:N \l_tmpa_box>\linewidth}
{\newline\hspace*{\fill}\llap}
{\hspace*{\fill}}
{\box_use:N \l_tmpa_box\strut}
}{
\@hangfrom{\strut
\IfNoValueTF {#2}
{\usekomavar*{#3}}
{#2}\locationsep~
}{
\parbox[t]{\dimexpr\linewidth-\hangindent}{
\raggedleft
\usekomavar{#3}\strut
}
}
}
}
\par
}

\newkomafont{transaction}{\bfseries}

\setkomavar{location}{
\Ifkomavarempty{transaction}{}{{
\usekomafont{transaction}
\usekomavar{transaction}
}
}
\par
\medskip
\parbox{\useplength{locwidth}}{
\locationentry{date}
\locationentry{myref}
\locationentry{customer}
\locationentry{yourref}
\locationentry{delivery}
\locationentry{quote}
\locationentry{orderID}
\locationentry{projectID}
296840e6 Jan Büren
\locationentry{taxpoint}
3d229eb9 Marei Peischl
\locationentry[\ansprechpartner]{fromname}
\locationentry{fromphone}
\locationentry*{fromemail}
}
}
\removereffields
\AtBeginLetter{
\ifdim\ht\shippingAddressBox>\z@
\@addtoplength{refvpos}{\dimexpr\ht\shippingAddressBox+\dp\shippingAddressBox}
\@addtoplength{refvpos}{4\baselineskip}%sep between address boxes
\fi
}
736bde4c Marei Peischl
4987cdc7 Jan Büren
\fi

71650e02 Marei Peischl
%Fallback for older KOMA-Script-Versions
\cs_if_exist:NF \Ifstr {\let\Ifstr\ifstr}
\cs_if_exist:NF \Ifkomavarempty {\let\Ifkomavarempty\ifkomavarempty}

%Definitionen für die insettings.tex

736bde4c Marei Peischl
\newcommand*{\setupIdentpath}[1]{
3d229eb9 Marei Peischl
\int_set:Nn \l_kivi_tmp_int {1}
\bool_set_true:N \l_kivi_tmp_bool
\bool_while_do:Nn \l_kivi_tmp_bool {
\file_if_exist:nTF {firma\int_use:N \l_kivi_tmp_int/ident.tex}
{
\exp_args:Nf \str_if_in:nnTF {#1} {Firma\int_use:N \l_kivi_tmp_int}
{
\newcommand*{\identpath}{firma\int_use:N \l_kivi_tmpa_int}
\bool_set_false:N \l_kivi_tmp_bool
}
{\int_incr:N \l_kivi_tmp_int}
}
{
\bool_set_false:N \l_kivi_tmp_bool
\newcommand*{\identpath}{firma}
}
}
736bde4c Marei Peischl
}

9d8ef337 Marei Peischl
\newcommand*{\setupCurrencyConfig}[3][euro]{
3d229eb9 Marei Peischl
\tl_new:N \g_kivi_currency_tl
9d8ef337 Marei Peischl
\exp_args:Nf \str_if_in:nnT {#3} {USD} {\tl_gset:Nn \g_kivi_currency_tl {usd}}
\exp_args:Nf \str_if_in:nnT {#3} {CHF} {\tl_gset:Nn \g_kivi_currency_tl {chf}}
\exp_args:Nf \str_if_in:nnT {#3} {EUR} {\tl_gset:Nn \g_kivi_currency_tl {euro}}
3d229eb9 Marei Peischl
\tl_if_empty:NT \g_kivi_currency_tl {
b5c4dac8 Marei Peischl
\tl_if_empty:oTF {#3} {
9d8ef337 Marei Peischl
\tl_gset:Nn \g_kivi_currency_tl {#1}
} {
\tl_gset:Nn \g_kivi_currency_tl {#3}
}
3d229eb9 Marei Peischl
}
9d8ef337 Marei Peischl
\input{#2/\g_kivi_currency_tl _account.tex}
\let\setupCurrencyConfig\_kivi_currency_already_configured:w
}

\newcommand*{\_kivi_currency_already_configured:w}[3][euro]{
\msg_error:nnx {kiviletter} {currency-already-configured} {\g_kivi_currency_tl}
736bde4c Marei Peischl
}

9d8ef337 Marei Peischl
\msg_new:nnn {kiviletter} {currency-already-configured} {
The~currency~configuration~is~a~global~setting~for~each~document.\\
It's~already~set~to~#1,~please~remove~the~second~call~of~\string\setupCurrencyConfig.
}
736bde4c Marei Peischl
\ExplSyntaxOff
4987cdc7 Jan Büren

\renewcommand*{\raggedsignature}{\raggedright}

b06bdb41 Marei Peischl
\newkomafont{extraDescription}{}
526ed9a1 Marei Peischl
\newkomafont{subtotal}{}
\newkomafont{total}{}
b06bdb41 Marei Peischl
4987cdc7 Jan Büren
\endinput