marei: switch to dtx generated files
[kivitendo-erp.git] / templates / print / marei / kiviletter.sty
index eba9b6f..7ed1d09 100644 (file)
@@ -193,6 +193,7 @@ contents={\usebox\shippingAddressBox}
 
 \newcolumntype{P}[1]{>{\raggedleft\arraybackslash}p{#1}<{\__kivi_tab_column_currency:}}
 
+
 \RequirePackage{tcolorbox}
 \tcbuselibrary{breakable, skins}
 
@@ -205,6 +206,7 @@ contents={\usebox\shippingAddressBox}
        },
        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,
@@ -242,6 +244,7 @@ contents={\usebox\shippingAddressBox}
        \seq_set_split:Nnn \l_kivi_PricingTable_seq {\tabularnewline} {#1}
        \seq_remove_all:Nn \l_kivi_PricingTable_seq {}
        \begingroup
+       \let\ExtraDescription\__kivi_addExtraDescription:n
        \setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
        \seq_map_inline:Nn \l_kivi_PricingTable_seq {
                \seq_set_split:Nnn  \l_kivi_columns_seq {&} {##1}
@@ -255,10 +258,11 @@ contents={\usebox\shippingAddressBox}
        \endtabular
        \seq_if_empty:NTF \g_kivi_extraDescription_seq
        {\par}
-       {\par
+       {\par\nopagebreak
        \begingroup
        \setlength{\hsize}{\dimexpr\l_kivi_tab_desc_dim+\l_kivi_tab_desc_leftskip_dim}
        \setlength{\leftskip}{\l_kivi_tab_desc_leftskip_dim}
+       \usekomafont{extraDescription}
        \seq_use:Nn \g_kivi_extraDescription_seq {\\}
        \par\nointerlineskip
        \endgroup
@@ -291,6 +295,7 @@ contents={\usebox\shippingAddressBox}
 }
 
 \cs_new:Nn \__kivi_tab_column_currency: {\,\currency}
+\def\tabcurrency{\__kivi_tab_column_currency:}
 \cs_set:Nn \__kivi_tab_column_header_currency: {}
 \cs_set_eq:NN \__kivi_tab_column_body_currency:  \__kivi_tab_column_currency:
 
@@ -316,6 +321,13 @@ contents={\usebox\shippingAddressBox}
                        \end{tabular*}
                }
        }
+       \hbox_gset:Nn \g_kivi_LT@lastfoot_box {
+               \raisebox{\dimexpr\depth+\baselineskip}[0pt][0pt]{
+                       \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}r@{}}
+                               \bottomrule
+                       \end{tabular*}
+               }
+       }
 }
 
 
@@ -327,13 +339,20 @@ contents={\usebox\shippingAddressBox}
        \tabular[t]{@{}p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-2\tabcolsep}}P{\l_kivi_tab_pricetotal_dim}@{}}
        \midrule
 }{
-       \bottomrule\endtabular
+       \endtabular
 }
 
-\newcommand{\ExtraDescription}[1]{\seq_gput_right:Nn \g_kivi_extraDescription_seq {#1}}
+
+\newcommand*\ExtraDescription{
+       \PackageError{kiviletter}{The~command~\string\ExtraDescription\space~may~be~only~used~inside~the~\string\FakeTable\space~environment.}{See~documentation~for~details}
+}
+
+
+\cs_new:Nn \__kivi_addExtraDescription:n {\seq_gput_right:Nn \g_kivi_extraDescription_seq {#1}}
 
 \newenvironment{PricingTabular}[1][]{
        \begingroup
+       \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
@@ -341,8 +360,10 @@ contents={\usebox\shippingAddressBox}
        \__kivi_PricingTabular_header:
        \endhead
        \midrule
-       \multicolumn{6}{@{}r@{}}{\weiteraufnaechsterseite}\\
+       \rlap{\makebox[\textwidth][r]{\weiteraufnaechsterseite}}\\
        \endfoot
+       \bottomrule
+       \endlastfoot
 }{
        \endlongtable
        \endgroup
@@ -367,18 +388,31 @@ contents={\usebox\shippingAddressBox}
 
 \RequirePackage{xltabular}
 
+\keys_define:nn {kivi/SimpleTabular} {
+       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 = {\bfseries\position & \bfseries\menge & \bfseries\bezeichnung},
+}
 
-\newenvironment{SimpleTabular}[1][\bfseries\position & \bfseries\menge & \bfseries\bezeichnung]
+\newenvironment{SimpleTabular}[1][]
 {
+       \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}
-       \xltabular{\linewidth}{@{}rrX@{}}
-       \toprule
-       #1\\
-       \midrule\\\endhead
-       \midrule
-       \multicolumn{3}{@{}>{\raggedright}p{\linewidth}@{}}{\weiteraufnaechsterseite}\\
+       \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
-       \bottomrule
+               \bottomrule
        \endlastfoot
        \ignorespaces
 }{
@@ -392,7 +426,6 @@ contents={\usebox\shippingAddressBox}
 % analog ist dies für pos, amount, price, pricetotal möglich.
 % Die Spalte der Bezeichnung ist nicht deaktivierbar
 \newenvironment{PricingTabular*}[1][]{
-       \bool_gset_true:N \g_kivi_inTable_bool
        \tl_if_empty:nF {#1} {\keys_set:nn {kivi/PricingTable} {#1}}
        \__kivi_setup_LT_boxes:
        \__kivi_setup_FakeTable:
@@ -447,4 +480,6 @@ contents={\usebox\shippingAddressBox}
 
 \renewcommand*{\raggedsignature}{\raggedright}
 
+\newkomafont{extraDescription}{}
+
 \endinput