marei: cleanup
[kivitendo-erp.git] / templates / print / marei / kiviletter.sty
index 829b83a..6aedf1b 100644 (file)
@@ -2,9 +2,15 @@
 \ProvidesPackage{kiviletter}[2020/04/24 Letter Layouts for Kivitendo]
 
 \newif\if@kivi@infobox
+\newif\if@kivi@footer
 \DeclareOption{reffields}{\@kivi@infoboxfalse}
 \DeclareOption{infobox}{\@kivi@infoboxtrue}
+\DeclareOption{nofooter}{\@kivi@footerfalse}
+\DeclareOption{footer}{\@kivi@footertrue}
 \@kivi@infoboxtrue
+\@kivi@footertrue
+
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{scrletter}}
 
 \ProcessOptions\relax
 
@@ -21,9 +27,7 @@
 \RequirePackage{fontspec}
 \fi
 
-%\RequirePackage{xltabular}
-\RequirePackage{tabularx}
-\RequirePackage{longtable}
+\RequirePackage{xltabular}
 \RequirePackage{booktabs}
 \RequirePackage{graphicx}
 
@@ -252,7 +256,7 @@ contents={\usebox\shippingAddressBox}
        \setlength{\leftskip}{\l_kivi_tab_desc_leftskip_dim}
        \usekomafont{extraDescription}
        \seq_use:Nn \g_kivi_extraDescription_seq {\\}
-       \par\nointerlineskip
+       \par
        \endgroup
        }
        }
@@ -283,6 +287,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:
 
@@ -320,8 +325,7 @@ contents={\usebox\shippingAddressBox}
 
 %Macht es sinn hier eine Variante zu machen, in der alle Spalten Belegbar sind?
 \newenvironment{PricingTotal}{
-       \par
-       \vspace{-\ht\strutbox}
+       \par\nointerlineskip
        \unskip
        \tabular[t]{@{}p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-2\tabcolsep}}P{\l_kivi_tab_pricetotal_dim}@{}}
        \midrule
@@ -339,6 +343,7 @@ contents={\usebox\shippingAddressBox}
 
 \newenvironment{PricingTabular}[1][]{
        \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:
@@ -373,7 +378,6 @@ contents={\usebox\shippingAddressBox}
        \midrule
 }
 
-\RequirePackage{xltabular}
 
 \keys_define:nn {kivi/SimpleTabular} {
        colspec .tl_set:N =\l_kivi_SimpleTabular_colspec_tl,
@@ -382,21 +386,28 @@ contents={\usebox\shippingAddressBox}
        headline .initial:n = {\bfseries\position & \bfseries\menge & \bfseries\bezeichnung},
 }
 
+\newcommand*{\SetupSimpleTabular}[1]{\keys_set:nn {kivi/SimpleTabular} {#1}}
+\newcommand*{\SetupPricingTabular}[1]{\keys_set:nn {kivi/PricingTable} {#1}}
+
 \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}
+       \dim_set:Nn \parskip {\c_zero_dim}
        \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
-       \l_kivi_SimpleTabular_headline_tl\\
-       \midrule
+               \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}}\\
+               \midrule
+               \rlap{\makebox[\textwidth][r]{\weiteraufnaechsterseite}}\\
        \endfoot
-       \bottomrule
+               \bottomrule
        \endlastfoot
        \ignorespaces
 }{
@@ -413,6 +424,7 @@ contents={\usebox\shippingAddressBox}
        \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
 }{\endPricingTabularBox}
 
@@ -422,7 +434,7 @@ contents={\usebox\shippingAddressBox}
 
 \if@kivi@infobox
 \setkomavar{location}{
-       \ifkomavarempty{transaction}{}{
+       \Ifkomavarempty{transaction}{}{
        \bfseries
        \usekomavar{transaction}
        }
@@ -430,24 +442,24 @@ contents={\usebox\shippingAddressBox}
        \medskip
        \begin{tabularx}{\useplength{locwidth}}{@{}l<{:}>{\raggedleft\arraybackslash}X@{}}
                \usekomavar*{date}&\usekomavar{date}\\
-               \ifkomavarempty{myref}{}{
+               \Ifkomavarempty{myref}{}{
                        \usekomavar*{myref}&\usekomavar{myref}\\
                }
                \kundennummer&\usekomavar{customer}\\
-               \ifkomavarempty{yourref}{}{
+               \Ifkomavarempty{yourref}{}{
                        \usekomavar*{yourref}&\usekomavar{yourref}\\
                }
-               \ifkomavarempty{delivery}{}{
+               \Ifkomavarempty{delivery}{}{
                        \usekomavar*{delivery}&\usekomavar{delivery}\\
                }
-               \ifkomavarempty{quote}{}{
+               \Ifkomavarempty{quote}{}{
                        \usekomavar*{quote}&\usekomavar{quote}\\
                }
-               \ifkomavarempty{orderID}{}{\auftragsnummer&\usekomavar{orderID}\\}
-               \ifkomavarempty{projectID}{}{\projektnummer&\usekomavar{projectID}\\}
+               \Ifkomavarempty{orderID}{}{\auftragsnummer&\usekomavar{orderID}\\}
+               \Ifkomavarempty{projectID}{}{\projektnummer&\usekomavar{projectID}\\}
                \ansprechpartner&\usekomavar{fromname}
-               \ifkomavarempty{fromphone}{}{\\\textTelefon&\usekomavar{fromphone}}
-               \ifkomavarempty{fromemail}{}{\\\textEmail&\usekomavar{fromemail}}
+               \Ifkomavarempty{fromphone}{}{\\\textTelefon&\usekomavar{fromphone}}
+               \Ifkomavarempty{fromemail}{}{\\\textEmail&\usekomavar{fromemail}}
        \end{tabularx}
 }
 \removereffields
@@ -457,9 +469,48 @@ contents={\usebox\shippingAddressBox}
        \@addtoplength{refvpos}{4\baselineskip}%sep between address boxes
        \fi
 }
-\ExplSyntaxOff
+
 \fi
 
+%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
+
+\newcommand*{\setupIdentpath}[1]{
+       \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}
+               }
+       }
+}
+
+\newcommand*{\setupCurrencyConfig}[2]{
+       \tl_new:N \g_kivi_currency_tl
+       \exp_args:Nf \str_if_in:nnT {#2} {USD} {\tl_gset:Nn \g_kivi_currency_tl {usd}}
+       \exp_args:Nf \str_if_in:nnT {#2} {CHF} {\tl_gset:Nn \g_kivi_currency_tl {chf}}
+       \exp_args:Nf \str_if_in:nnT {#2} {EUR} {\tl_gset:Nn \g_kivi_currency_tl {euro}}
+       \tl_if_empty:NT  \g_kivi_currency_tl {
+               \tl_gset:Nn \g_kivi_currency_tl {default}
+               \edef \currency {\tl_to_str:N \lxcurrency}
+       }
+       \input{#1/\g_kivi_currency_tl _account.tex}
+}
+
+\ExplSyntaxOff
 
 
 \renewcommand*{\raggedsignature}{\raggedright}