-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrechnung.sty
49 lines (45 loc) · 1.56 KB
/
rechnung.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rechnung}
\RequirePackage{fp}
\RequirePackage{calc}
\RequirePackage{array}
\RequirePackage{booktabs}
\newcounter{invoice@cost}
\newcounter{invoice@vat}
\newcommand*{\format@float}[1]{\FPround{\invoice@t}{#1}{2}$\invoice@t$}
\newcommand*{\format@int}[1]{$#1$}
\newcommand*{\total}[1]{\FPdiv{\invoice@t}{\arabic{#1}}{1000}\format@float{\invoice@t}}
\newcommand*\textPosten{Description}
\newcommand*\textPreis{Unit Price}
\newcommand*\textAnzahl{Quantity}
\newcommand*\textBetrag{Total Price}
\newcommand*\textWaehrung{CHF}
\newenvironment*{invoice}[1]{
\setcounter{invoice@cost}{0}
\setcounter{invoice@vat}{0}
\def\invoice@VATval{#1}%
%
\newcommand*{\Fee}[3]{%
\addtocounter{invoice@cost}{1000 * \real{##2} * \real{##3}}%
\addtocounter{invoice@vat}{10 * \real{#1} * \real{##2} * \real{##3}}%
{##1} & \format@float{##2} & \format@int{##3} & \FPmul{\invoice@cost}{##2}{##3}\format@float{\invoice@cost} \cr%
}%
%
~\par\noindent
\begin{tabular}{p{\dimexpr0.49\linewidth-2\tabcolsep}*{3}{>{\hfill}p{\dimexpr0.17\linewidth-2\tabcolsep}}}%
\toprule%
{\textPosten} & {\textPreis} & {\textAnzahl} & {\textBetrag} \cr%
\midrule%
}{%
\if\invoice@VATval0\else%
\midrule%
{Subtotal} & & & {\total{invoice@cost}} \cr%
{VAT (\invoice@VATval\,\%)} & & & {\total{invoice@vat}} \cr%
\fi%
\midrule%
\setcounter{invoice@cost}{\theinvoice@cost + \theinvoice@vat}%
{\bfseries Total} & & & {\bfseries\boldmath \textWaehrung~\total{invoice@cost}} \cr%
\bottomrule%
\end{tabular}%
\par~%
}