使用 siunitx 和 scrlttr2 将 invoice2 中的货币四舍五入为 5 或 10

使用 siunitx 和 scrlttr2 将 invoice2 中的货币四舍五入为 5 或 10

我创建了发票invoice2(内部使用siunitx)和scrlttr2

现在我计算出的货币值为 286.34,但实际应为 286.35。由于该数字由 内部计算invoice2,因此我无法控制打印本身。我需要一种以全局(文档范围)方式配置舍入的方法。

\documentclass[
  SN,% lco file for swiss letters (SN 010 130))
  german,
  refline=dateleft,
  firstfoot=false,
  enlargefirstpage,
  backaddress=false,
  foldmarks=false,
  parskip=half-
  ]{scrlttr2}
\newcommand\myTab[1][5cm]{\hspace*{#1}}
\usepackage[swissgerman]{babel}
\usepackage{tabto}
\usepackage{invoice2}
\usepackage{eurosym}
\usepackage{translations}
\usepackage[german]{isodate}
\usepackage{scrdate}% <- added
\usepackage{advdate}

% Save dd/mm/yyyy for today
\newcommand*\invoicedate{}
\SaveDate[\invoicedate]

\setkomavar{date}{{\SetDate[\invoicedate]\today}}
\newkomavar{paymentdate}
\setkomavar{paymentdate}{{% <- changed
  \SetDate[\invoicedate]%
  \ifnum\todaysnumber=6\DayAfter[30]% Saturday -> Monday
    \else\ifnum\todaysnumber=0\DayAfter[29]% Sunday -> Monday
      \else\DayAfter[28]
  \fi\fi
}}

% should be possible to use a different invoicedate
\newcommand*\setinvoicedate[1]{%
  \ifstr{#1}{today}
    {\SaveDate[\invoicedate]}%
    {\renewcommand*\invoicedate{#1}}%
}


\TabPositions{5cm, 8.5cm}

\makeatletter
  \@setplength{firstheadwidth}{\textwidth}
  \@addtoplength{firstheadvpos}{2cm}% <- shift the head with your address down
\makeatother

\renewcommand\raggedsignature{\raggedright}

%Ersetze Stückpreis
\DeclareTranslation{swissgerman}{invoice2-unit-price}{Preis ohne MwSt.}    

% set a different invoice date
% syntax: \setinvoicedate{dd/mm/yyyy}
% if it should be reset to \today use \setinvoicedate{today}
\setinvoicedate{today}

\setkomavar{fromname}{A Company}
\setkomavar{fromaddress}{A Street 7 \\ Duckburg}
\setkomavar{fromemail}{[email protected]}
\setkomavar{date}{}
\setkomavar{subject}{}
\setkomafont{title}{\bfseries\normalsize\raggedright}

\begin{document}
  \begin{letter}{Bilbo\\Bag End\\1 Bagshot Row\\Hobbiton}
    \opening{}
      Rechnungs-Nummer \tab \textbf{1234455} \\ 
      Rechnungs-Datum \tab \textbf{\printdate{\invoicedate}} \\
      Zahlbarbis \tab \textbf{\usekomavar{paymentdate}} \\

    \invoiceoptions{vat=.077}
    \invoiceoptions{colorize=true}
    \invoiceoptions{title-color=white}
    \invoiceoptions{even-color=white}
    \invoiceoptions{odd-color=white}                
    \setlength\LTleft{0pt} % forces the table to be left aligned
    \setlength\LTright{0pt}
    \LTcapwidth=\textwidth
    \begin{invoice}[currency-symbol={}]
        \invoicesingleitem{Harte Arbeit \hspace*{6.7cm}}{100.15}
    \end{invoice}
  \end{letter}
\end{document}

相关内容