X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/424ee46d4d1c360cc86e05a43d14c02c71db15e2..53593baa211863fbf66540cf1bcc36c8fb37257f:/templates/print/marei/kiviletter.sty

diff --git a/templates/print/marei/kiviletter.sty b/templates/print/marei/kiviletter.sty
index d4a02c288..79b33a818 100644
--- a/templates/print/marei/kiviletter.sty
+++ b/templates/print/marei/kiviletter.sty
@@ -1,24 +1,37 @@
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{kiviletter}[2020/04/24 Letter Layouts for Kivitendo]
+\ProvidesPackage{kiviletter}[2022/04/23 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
+\RequirePackage{l3keys2e}
 
-\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{scrletter}}
+%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}
 
-\ProcessOptions\relax
+\ExplSyntaxOn
+\newif\if@kivi@infobox
+\newif\if@kivi@footer
+\keys_define:nn {kiviletter} {
+  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},
+}
+\ExplSyntaxOff
 
+\ProcessKeysOptions{kiviletter}
 
-\RequirePackage{expl3}
 \RequirePackage{xparse}
 \RequirePackage{iftex}
-\KOMAoptions{fontsize=12pt}
+
 % Schriftart, Eingabelayout der Tastatur
 \ifPDFTeX
   \RequirePackage[utf8]{inputenc}% Nur notwendig, wenn Basis Ã¤lter als TL2018
@@ -35,14 +48,10 @@
 \RequirePackage{booktabs}
 \RequirePackage{graphicx}
 
-
-
-\RequirePackage[fromlogo,fromalign=right,
-  firstfoot=false,%FÃ¼r einheitliche Randeinstellungen
-  refline=nodate,
-]{scrletter}
+\RequirePackage{scrletter}
 \LoadLetterOption{DIN}
 
+\newkomavar{taxpoint}
 \newkomavar{transaction}
 \newkomavar[\lieferschein{}~\nr]{delivery}
 \newkomavar[\angebot{}~\nr]{quote}
@@ -147,7 +156,7 @@
   amount=5em,
   price=7em,
   pricetotal=7em,
-  %	desc=auto,
+  %  desc=auto,
   pos/header=\position,
   id/header=\artikelnummer,
   desc/header=\bezeichnung,
@@ -213,23 +222,23 @@
 \tcbuselibrary{breakable, skins}
 
 \tcb@new@skin{kivi@LT}{base@unbroken,%
-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}};
-},
-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}};
+  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}};
 },
-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,
+  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,
 }
 
 \tcb@new@skin{kivi@LT@first}{base@first,%
@@ -249,8 +258,6 @@ parbox=false,
 
 \tcbset{kivi@LT/.style={skin=kivi@LT}}%
 
-
-
 \seq_new:N \l_kivi_PricingTable_seq
 \seq_new:N \l_kivi_columns_seq
 \seq_new:N \g_kivi_extraDescription_seq
@@ -299,6 +306,7 @@ parbox=false,
   \let\ExtraDescription\__kivi_addExtraDescription:n
   \setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
   \seq_map_inline:Nn \l_kivi_PricingTable_seq {
+    \if_mode_horizontal: \par \fi
     \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}
@@ -329,6 +337,7 @@ parbox=false,
       }}
   }
   \endgroup\par
+  \l__kivi_Tabular_rowsep_tl
 }
 
 
@@ -344,14 +353,14 @@ parbox=false,
 
 \tl_new:N \g_kivi_Pricing_colspec_tl
 \tl_gset:Nn \g_kivi_Pricing_colspec_tl {
-\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 {@{}}
+  \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 {@{}}
 }
 
 \cs_new_protected:Nn \__kivi_tab_column_currency: {\,\currency}
@@ -366,7 +375,6 @@ p{\l_kivi_tab_desc_dim}
 \newkomafont{PricingTableHeader}{\bfseries}
 
 \cs_new:Nn \__kivi_setup_LT_boxes: {
-  %	\bool_show:N  \g__kivi_Tabular_rowcolor_bool
   \__kivi_calc_desc_column:
   \hbox_gset:Nn \g_kivi_LT@head_box {
     \setlength{\tabcolsep}{\g_kivi_tabcolsep_dim}
@@ -378,18 +386,12 @@ p{\l_kivi_tab_desc_dim}
     }
   }
   \hbox_gset:Nn \g_kivi_LT@foot_box {
-    %		\parbox{\linewidth}{
-    %		\leavevmode\color{red}\rule{\linewidth}{1pt}\par\nointerlineskip
-    %		\leavevmode\color{blue}\rule{\linewidth}{1cm}
-    %		}
-    %		\raisebox{\depth}{
     \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
-      {\hline\noalign{\vskip1pt}}%\noalign{\nointerlineskip\vskip\z@}\noalign{\nointerlineskip\rule{\linewidth}{\arrayrulewidth}}}%\leavevmode\rule{\linewidth}{\arrayrulewidth}}} 
+      {\hline\noalign{\vskip1pt}}
       \midrule
       \strut\weiteraufnaechsterseite
     \end{tabular*}
-    %		}
   }
   \hbox_gset:Nn \g_kivi_LT@lastfoot_box {
     \raisebox{\dimexpr\depth+\baselineskip}[0pt][0pt]{
@@ -403,17 +405,18 @@ p{\l_kivi_tab_desc_dim}
 
 %Macht es sinn hier eine Variante zu machen, in der alle Spalten Belegbar sind?
 \NewDocumentEnvironment{PricingTotal}{+b}{
-\par\nointerlineskip
-%	\unskip
+  \par\nointerlineskip
 }{
-\bool_if:NT \g__kivi_Tabular_rowcolor_bool 	{\nointerlineskip\kivi@tabcolorbox{\g__kivi_Tabular_rowcolor_PricingTotal_tl}}
-{
-\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
-}
+  \bool_if:NT \g__kivi_Tabular_rowcolor_bool   {\nointerlineskip\kivi@tabcolorbox{\g__kivi_Tabular_rowcolor_PricingTotal_tl}}
+  {
+    \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
+  }
 }
 
 \tl_new:N \l__kivi_Tabular_PricingTotal_topsep_tl
@@ -451,7 +454,7 @@ p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-\bool_if:NTF \g__kivi_Tabul
   \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
-  \clist_map_inline:Nn \g_kivi_pricingtable_col_clist	{
+  \clist_map_inline:Nn \g_kivi_pricingtable_col_clist  {
     \bool_if:cT {l_kivi_col_##1_bool} {
       \bool_if:NT \l_tmpa_bool {&}
       \bool_set_true:N \l_tmpa_bool
@@ -485,8 +488,13 @@ p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-\bool_if:NTF \g__kivi_Tabul
   rowcolor-header .initial:n = black!35,
   rowcolor-total .tl_gset:N = \g__kivi_Tabular_rowcolor_PricingTotal_tl,
   rowcolor-total .initial:n = black!35,
-  rowsep .tl_set:N =\g__kivi_Tabular_rowsep_tl,
-  hrule .meta:n = {rowsep=\midrule}
+  rowsep .tl_set:N =\l__kivi_Tabular_rowsep_tl,
+  rowsep .initial:n = ,
+  hrule .meta:n = {
+    rowsep={
+      \vskip\aboverulesep
+      \leavevmode\hrule\@height\lightrulewidth
+      \vskip\belowrulesep}},
 }
 
 \newcommand*{\SetupSimpleTabular}[1]{\keys_set:nn {kivi/SimpleTabular} {#1}}
@@ -497,7 +505,7 @@ p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-\bool_if:NTF \g__kivi_Tabul
   \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}
-  \bool_if:NF	\g__kivi_Tabular_rowcolor_bool {
+  \bool_if:NF \g__kivi_Tabular_rowcolor_bool {
     \tl_put_right:Nn \l_kivi_SimpleTabular_colspec_tl {@{}}
     \tl_put_left:Nn \l_kivi_SimpleTabular_colspec_tl {@{}}
   }
@@ -592,6 +600,7 @@ p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-\bool_if:NTF \g__kivi_Tabul
       \locationentry{quote}
       \locationentry{orderID}
       \locationentry{projectID}
+      \locationentry{taxpoint}
       \locationentry[\ansprechpartner]{fromname}
       \locationentry{fromphone}
       \locationentry*{fromemail}
@@ -633,23 +642,37 @@ p{\dim_eval:n {\linewidth-\l_kivi_tab_pricetotal_dim-\bool_if:NTF \g__kivi_Tabul
   }
 }
 
-\newcommand*{\setupCurrencyConfig}[2]{
+\newcommand*{\setupCurrencyConfig}[3][euro]{
   \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}}
+  \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}}
   \tl_if_empty:NT  \g_kivi_currency_tl {
-    \tl_gset:Nn \g_kivi_currency_tl {default}
-    \edef \currency {\tl_to_str:N \lxcurrency}
+    \tl_if_empty:oTF {#3} {
+      \tl_gset:Nn \g_kivi_currency_tl {#1}
+    } {
+      \tl_gset:Nn \g_kivi_currency_tl {#3}
+    }
   }
-  \input{#1/\g_kivi_currency_tl _account.tex}
+  \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}
+}
+
+\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.
+}
 \ExplSyntaxOff
 
 
 \renewcommand*{\raggedsignature}{\raggedright}
 
 \newkomafont{extraDescription}{}
+\newkomafont{subtotal}{}
+\newkomafont{total}{}
 
 \endinput
