Commit | Line | Data |
---|---|---|
38e062db MW |
1 | \newif\ifpo@colour |
2 | \DeclareOption{colour}{\po@colourtrue} | |
3 | \DeclareOption{color}{\po@colourtrue} | |
4 | \DeclareOption{nocolour}{\po@colourfalse} | |
5 | \DeclareOption{nocolor}{\po@colourfalse} | |
6 | \ExecuteOptions{colour} | |
7 | \ProcessOptions\relax | |
8 | ||
9 | \RequirePackage{mdwtab} | |
10 | \ifpo@colour | |
11 | \RequirePackage{colour, mtcolour} | |
12 | \fi | |
13 | ||
14 | \newcount\po@total | |
15 | \newcount\po@unit | |
16 | \newcount\po@qty | |
17 | ||
18 | \def\poinit{\global\po@total\z@} | |
19 | \def\poline{\global\po@qty\@ne\global\po@unit\z@} | |
20 | \def\poqty#1{\global\po@qty#1\relax} | |
21 | \def\pounit#1{\po@split\pounit@i#1..\q@delim} | |
22 | \def\po@split#1#2.#3.#4\q@delim{% | |
23 | \count@#2% | |
24 | \multiply\count@100% | |
25 | \ifx.#3.\else% | |
26 | \count\tw@#3% | |
27 | \advance\count@\count\tw@% | |
28 | \fi% | |
29 | #1% | |
30 | } | |
31 | \def\pounit@i{\global\po@unit\count@} | |
32 | \def\po@@tot{% | |
33 | \count@\po@unit% | |
34 | \multiply\count@\po@qty% | |
35 | } | |
36 | \def\po@@vat{% | |
37 | \count@\po@total% | |
38 | \multiply\count@175% | |
39 | \advance\count@500% | |
40 | \divide\count@1000% | |
41 | } | |
42 | \def\poadd#1{% | |
43 | \csname po@@#1\endcsname% | |
44 | \global\advance\po@total\count@% | |
45 | } | |
46 | \def\po@@unit{\count@\po@unit} | |
47 | \def\po@@total{\count@\po@total} | |
48 | \def\q@delim{\q@delim} | |
49 | \def\pocash#1{% | |
50 | \csname po@@#1\endcsname% | |
51 | \count\tw@\count@% | |
52 | \divide\count\tw@100% | |
53 | \multiply\count\tw@100% | |
54 | \advance\count@-\count\tw@% | |
55 | \divide\count\tw@100% | |
56 | \relax\the\count\tw@% | |
57 | .% | |
58 | \expandafter\po@lead\the\count@\q@delim% | |
59 | } | |
60 | \def\po@lead#1#2\q@delim{\ifx\q@delim#2\q@delim0#1\else#1#2\fi} | |
61 | \ifpo@colour | |
62 | \def\altcolour{% | |
63 | \ifmod{\value{tabrow}}{2}{0}{\rowcolour{white}}{\rowcolour[grey]{0.95}}% | |
64 | } | |
65 | \else | |
66 | \let\altcolour\@empty | |
67 | \fi | |
68 | \def\po{% | |
69 | \small% | |
70 | \poinit% | |
71 | \begin{tabular}[C]{|?>{\altcolour}l|>{\raggedright}m{1.6in}|r|r|r|}% | |
72 | \hlx{hv}% | |
73 | \bfseries Part&% | |
74 | \bfseries Description&% | |
75 | $\vcenter{\bfseries\halign | |
76 | {&\strut\hfil##\cr Unit\cr price (\textsterling)\cr}}$&% | |
77 | \bfseries Qty&% | |
78 | $\vcenter{\bfseries\halign | |
79 | {&\strut\hfil##\cr Total\cr price (\textsterling)\cr}}$\\% | |
80 | \hlx{vh}% | |
81 | } | |
82 | \def\poitem{\hlx{v}\@testopt\poitem@i\@ne} | |
83 | \def\poitem@i[#1]#2#3#4{% | |
84 | #2&% | |
85 | #3&% | |
86 | \pounit{#4}\pocash{unit}&% | |
87 | \poqty{#1}\the\po@qty&% | |
88 | \pocash{tot}\poadd{tot}% | |
89 | \\% | |
90 | \hlx{v+}% | |
91 | } | |
92 | \def\posep{\hlx{hv}} | |
93 | \def\endpo{% | |
94 | \hlx{h?{\global\c@tabrow\z@}v[1-3]}% | |
95 | \multicolumn{4}{|l|}{Total excl. VAT}&\pocash{total}\\% | |
96 | \hlx{v[1-3]v[1-3]}% | |
97 | \multicolumn{4}{|l|}{VAT (@17.5\%)}&\pocash{vat}\poadd{vat}\\% | |
98 | \hlx{v[1-3]hv[1-3]}% | |
99 | \multicolumn{4}{|l|}{Total incl. VAT}&\pocash{total}\\% | |
100 | \hlx{v[1-3]h}% | |
101 | \end{tabular}% | |
102 | } | |
103 | \endinput |