All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
   1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
   4 %      Contact: corff@zedat.fu-berlin.de, oliver.corff@email.de
 
   5 %        Datum: December 16, 2003
 
   7 %    Copyright: Ulaanbaatar, Beijing, Berlin, Zagreb, Shenyang, Shanghai
 
   8 %  Description: This collection of macros provides
 
   9 %               tools for generating complex invoices
 
  11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  13 % Corrections, suggestions and contributions by:
 
  18 %   Contributed labels in Italian.
 
  23 %   fixed one nasty spacing bug, simplified internal table 
 
  24 %   construction (table now has five instead of six columns,
 
  25 %   the second of which was never used).
 
  28 % Johann Spies, January 21, 2002
 
  29 % e-mail: jspies@sun.ac.za
 
  31 %   Hinted that \Subtotal Project should show the project name
 
  32 %   rather than just `Project'.
 
  34 %   Contributed labels in Afrikaans.
 
  37 % Robin Fairbairns, December 6, 2001
 
  39 %   Hinted that the dollar sign can also be printed by saying
 
  43 % Vincent Tougait, France, November 27, 2001
 
  45 %   Pointed out that fractions of VAT percents were not allowed.
 
  46 %   Bugfix on December 06, 2001
 
  49 % Fred Donck, The Hague, The Netherlands, October, 2001
 
  50 % e-mail: fd0@donck.com
 
  55 % Ian Wormsbecker, October 31, 2001
 
  57 %   Skips the VAT lines if VAT=0
 
  58 %   Noticed that the terminal message will not accept a Dollar sign.
 
  59 %   The only workaround is to say \char`$ in \begin{invoice}{}
 
  62 % Fred Donck, The Hague, The Netherlands, Sept 18, 2001
 
  63 % e-mail: fd0@donck.com
 
  65 % fixed some minor issues:
 
  66 %   real arithmetic will use integer intermediate values, so
 
  67 %   some calculations failed with the \Fee{title}{rate}{amount}
 
  68 %   where \rate is not an integer
 
  70 %   another fix is that in my opinion the VAT line should be 
 
  71 %   printed also even though only one project is specified
 
  73 %   third fix is that the subtotal-line should not be printed 
 
  74 %   on a project with only one \Fee line
 
  77 % Jacco Kok (fixed some labels),
 
  80 % Thilo Barth (discussed alternative names and command clashes
 
  81 %       with KOMA Script class scrlettr.cls),
 
  84 % Robert Inder (discussed general issues)
 
  86 % were gladly and gratefully received and accepted.
 
  88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  89 % -------------------     identification     -------------------
 
  91 \NeedsTeXFormat{LaTeX2e}
 
  92 \ProvidesPackage{invoice}[2003/12/16]
 
  94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  95 % -------------------    language options    -------------------
 
  98 \newcount\invoice@language
 
  99 \let\invoice@language=\language
 
 101 \ifx\l@english\undefined        \newlanguage\l@english \fi
 
 102 \ifx\l@german\undefined         \newlanguage\l@german \fi
 
 103 \ifx\l@dutch\undefined          \newlanguage\l@dutch \fi
 
 104 \ifx\l@french\undefined         \newlanguage\l@french \fi
 
 105 \ifx\l@afrikaans\undefined      \newlanguage\l@afrikaans \fi
 
 106 \ifx\l@italian\undefined        \newlanguage\l@italian \fi
 
 108 \DeclareOption{english}{\invoice@language=\number\l@english}
 
 109 \DeclareOption{german}{\invoice@language=\number\l@german}
 
 110 \DeclareOption{dutch}{\invoice@language=\number\l@dutch}
 
 111 \DeclareOption{french}{\invoice@language=\number\l@french}
 
 112 \DeclareOption{afrikaans}{\invoice@language=\number\l@afrikaans}
 
 113 \DeclareOption{italian}{\invoice@language=\number\l@italian}
 
 117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 118 % -------------------      initial code      -------------------
 
 120 \RequirePackage{ifthen}
 
 121 \RequirePackage{longtable}
 
 122 \RequirePackage{calc}
 
 126 \newcommand{\InvoiceVersion}{0.7}%
 
 129 %\newcounter{VAT@rate}          %
 
 130 \newcounter{Expenses}           %
 
 131 \newcounter{Discount}           % Discount item
 
 133 \newcounter{Project}            %
 
 135 \newcounter{Fee@ctr}            % Number of fees per project
 
 136                                 % no subtotal will be printed in case of
 
 139 \newcounter{Expense@ctr}        % Number of expense items per project
 
 140                                 % no subtotal will be printed in case of
 
 143 \newcounter{One@Fee}            % Individual Fee
 
 144 \newcounter{One@VAT}            % Individual VAT
 
 145 \newcounter{One@Expense}        % Individual Expense
 
 147 \newcounter{ST@Fee}             % Subtotal Fee
 
 148 \newcounter{ST@VAT}             % Subtotal VAT
 
 149 \newcounter{ST@Expenses}        % Subtotal Expenses
 
 150 \newcounter{ST@Project}         % Subtotal Project
 
 152 \gdef\Flag{0}%                  % State 0: Invoice not started yet
 
 153                                 % State 1: Start invoice
 
 154                                 % State 2: Start project, print title
 
 156                                 % State 4: Print Subtotal Fee
 
 157                                 % State 5: Expense Item
 
 158                                 % State 6: Print Subtotal Expenses
 
 159                                 % State 7: Print Subtotal Project
 
 160                                 % State 8: Print Total, Close invoice
 
 162 \gdef\Project{}%                % Empty Project Name
 
 166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 167 %\newcommand{\my@message}[1]{\message{^^J#1^^J^^J}}
 
 168 \newcommand{\error@message}[1]{\errmessage{^^J\Error: #1^^J^^J}}
 
 169 \newcommand{\warning@message}[1]{\message{^^J\Warning: #1^^J^^J}}
 
 170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 171 \ifx\invoice\undefined                  % False if KOMA Script scrlettr.cls
 
 172         \def\my@invoice{invoice}        % loaded. In this case one may say
 
 173 \else                                   % "invoice". If true, the environ-
 
 174         \def\my@invoice{invoiceenv}     % ment is renamed to "invoiceenv"
 
 175         \let\invoiceno\invoice          % and the scrlettr macro is renamed
 
 176         \def\invoice#1{%                % to "invoiceno". Thank you, Thilo,
 
 177                 \error@message{\KOMA}}  % for this hint!
 
 179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 180 \newenvironment{\my@invoice}[2]{%
 
 181         \setcounter{Fee@ctr}{0}%                % reset counter
 
 182         \setcounter{Expense@ctr}{0}%            % reset counter
 
 184         \setcounter{Project}{0}%
 
 185         \ST@Reset\Total@Reset%
 
 188         \ifx\VAT@rate\Null\VATnonzerofalse\else\VATnonzerotrue\fi%
 
 190                 \message{^^J^^JVAT is not zero!^^J^^J}%
 
 192                 \message{^^J^^JVAT is zero!^^J^^J}%
 
 194         % The VAT is: \the\VAT@rate % Debugging Diagnostics only
 
 196         \ifcase\Flag % 0: Invoice not started yet
 
 200                 \begin{longtable}{p{5cm}lrrr}%
 
 202         \else \error@message{\NoInvoiceNesting}%
 
 204 % At the end of environment: 
 
 205 % Yields state 8->0, Close and complete invoice, finish tables, etc.
 
 207         \ifcase\Flag % 0: Invoice not started yet
 
 209                 \error@message{\MissingOpening}%
 
 211         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 212         \or     % 1: Start invoice
 
 214                 \error@message{\MissingProject}%
 
 216         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 217         \or     % 2: Start project, print title
 
 219                 \error@message{\MissingInputData}%
 
 221         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 222         \or     % 3: Print remuneration item
 
 224                 \ifnum\theProject>0 \ST@Fee\ST@Project\fi%
 
 227         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 228         \or     % 4: Print subtotal remuneration
 
 230                 \ifnum\theProject>1 \ST@Project\fi%
 
 233         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 234         \or     % 5: Expense item
 
 236                 \ifnum\theProject>1 \ST@Expenses\ST@Project\fi%
 
 239         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 240         \or     % 6: Print subtotal expenses
 
 242                 \ifnum\theProject>1 \ST@Project\fi%
 
 245         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 246         \or     % 7: Print subtotal project
 
 250         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 251         \or     % 8: Print total, close invoice
 
 253                 \warning@message{\InvoiceCompleted}%
 
 255         \else \error@message{\InternalError}%
 
 259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 260 \newcommand{\ProjectTitle}[1]{% Yields state 2: Start Project
 
 261         %\gdef\NewProject{#1}
 
 263         \ifcase\Flag% 0: Invoice not started yet
 
 265         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 266         \or     % 1: Start invoice
 
 270         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 271         \or     % 2: Start project, print title
 
 273                 \error@message{\NoProjectNesting}%
 
 275         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 276         \or     % 3: Print remuneration item
 
 282         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 283         \or     % 4: Print subtotal remuneration
 
 288         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 289         \or     % 5: Expense item
 
 295         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 296         \or     % 6: Print subtotal expenses
 
 301         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 302         \or     % 7: Print subtotal project
 
 306         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 307         \or     % 8: Print total, close invoice
 
 309                 \error@message{\InvoiceCompletedNoProject}%
 
 311         \else \error@message{\InternalError}%
 
 313         \setcounter{Fee@ctr}{0}%                % reset counter
 
 314         \setcounter{Expense@ctr}{0}%            % reset counter
 
 316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 317 \newcommand{\Fee}[3]{% Yields state 3, Print Fee Item
 
 323         \ifcase\Flag % 0: Invoice not started yet
 
 324                 \error@message{\MissingOpening}%
 
 326         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 327         \or     % 1: Start invoice
 
 329                 \error@message{\MissingProject}%
 
 331         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 332         \or     % 2: Start project, print title
 
 335                 \Fee@Line{#1}{#2}{#3}%
 
 337         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 338         \or     % 3: Print remuneration item
 
 340                 \Fee@Line{#1}{#2}{#3}%
 
 342         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 343         \or     % 4: Print subtotal remuneration
 
 345                 \warning@message{\FeeSTExists}%
 
 347         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 348         \or     % 5: Expense item
 
 350                 \error@message{\FeeBeforeExpense}%
 
 352         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 353         \or     % 6: Print subtotal expenses
 
 355                 \error@message{\FeeBeforeExpense}%
 
 357         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 358         \or     % 7: Print subtotal project
 
 360                 \error@message{\ProjectCompletedNoFee}%
 
 362         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 363         \or     % 8: Print total, close invoice
 
 365                 \error@message{\InvoiceCompletedNoFee}%
 
 368         \else \error@message{\InternalError}%
 
 371 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 372 \newcommand{\STFee}{% Yields state 4, print subtotal remuneration
 
 374         \ifcase\Flag % 0: Invoice not started yet
 
 376                 \error@message{\MissingOpening}%
 
 378         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 379         \or     % 1: Start invoice
 
 381                 \error@message{\MissingProject}%
 
 383         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 384         \or     % 2: Start project, print title
 
 386                 \error@message{\MissingFee}%
 
 388         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 389         \or     % 3: Print remuneration item
 
 393         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 394         \or     % 4: Print subtotal remuneration
 
 396                 \warning@message{\FeeSTExists}%
 
 398         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 399         \or     % 5: Expense item
 
 401                 \error@message{\FeeBeforeExpense}%
 
 403         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 404         \or     % 6: Print subtotal expenses
 
 406                 \error@message{\FeeBeforeExpense}%
 
 408         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 409         \or     % 7: Print subtotal project
 
 411                 \error@message{\ProjectCompletedNoFee}%
 
 413         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 414         \or     % 8: Print total, close invoice
 
 416                 \error@message{\ProjectCompletedNoFee}%
 
 418         \else \error@message{\InternalError}%
 
 421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 422 \newcommand{\EBC}[2]{% Yields state 5: Expenses in BaseCurrency 
 
 424         % #1 Contents und Datum
 
 425         % #2 Amount in BaseCurrency
 
 427         \ifcase\Flag % 0: Invoice not started yet
 
 429                 \error@message{\MissingOpening}%
 
 431         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 432         \or     % 1: Start invoice
 
 434                 \error@message{\MissingProject}%
 
 436         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 437         \or     % 2: Start project, print title
 
 440                 \Expense@BaseCurrency{#1}{#2}%
 
 442         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 443         \or     % 3: Print remuneration item
 
 447                 \Expense@BaseCurrency{#1}{#2}%
 
 449         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 450         \or     % 4: Print subtotal remuneration
 
 453                 \Expense@BaseCurrency{#1}{#2}%
 
 455         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 456         \or     % 5: Expense item
 
 458                 \Expense@BaseCurrency{#1}{#2}%
 
 460         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 461         \or     % 6: Print subtotal expenses
 
 463         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 464         \or     % 7: Print subtotal project
 
 466         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 467         \or     % 8: Print total, close invoice
 
 469                 \error@message{\InvoiceCompletedNoExpense}%
 
 471         \else \error@message{\InternalError}%
 
 474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 475 \newcommand{\EBCi}[2]{% Yields state 5: Expenses in BaseCurrency 
 
 476         %                               But, unlike base form (no
 
 477         %                               'invisible') this version does
 
 478         %                               not state the item, it only
 
 479         %                               the total amount of expenses. 
 
 481         % #1 Contents und Datum
 
 482         % #2 Amount in BaseCurrency
 
 484         \ifcase\Flag % 0: Invoice not started yet
 
 486                 \error@message{\MissingOpening}%
 
 488         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 489         \or     % 1: Start invoice
 
 491                 \error@message{\MissingProject}%
 
 493         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 494         \or     % 2: Start project, print title
 
 497                 \Expense@Base@Currency{#1}{#2}%
 
 499         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 500         \or     % 3: Print remuneration item
 
 504                 \Expense@Base@Currency{#1}{#2}%
 
 506         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 507         \or     % 4: Print subtotal remuneration
 
 510                 \Expense@Base@Currency{#1}{#2}%
 
 512         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 513         \or     % 5: Expense item
 
 515                 \Expense@Base@Currency{#1}{#2}%
 
 517         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 518         \or     % 6: Print subtotal expenses
 
 520         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 521         \or     % 7: Print subtotal project
 
 523         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 524         \or     % 8: Print total, close invoice
 
 526                 \error@message{\InvoiceCompletedNoExpense}%
 
 528         \else \error@message{\InternalError}%
 
 531 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 532 \newcommand{\EFC}[5]{% Yields state 5: Expenses in ForeignCurrency
 
 534         % #1 Contents und Datum
 
 538         % #5 Amount Zielwaehrung
 
 541         % 1. {Contents}{ForeignCurrency}{ExchangeRate}{}
 
 542         % 2. {Contents}{ForeignCurrency}{}{BaseCurrency}
 
 543         % 3. {Contents}{ForeignCurrency}{ExchangeRate}{BaseCurrency}
 
 545         \ifcase\Flag % 0: Invoice not started yet
 
 547                 \error@message{\MissingOpening}%
 
 549         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 550         \or     % 1: Start invoice
 
 552                 \error@message{\MissingProject}%
 
 554         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 555         \or     % 2: Start project, print title
 
 558                 \Expense@ForeignCurrency{#1}{#2}{#3}{#4}{#5}%
 
 560         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 561         \or     % 3: Print remuneration item
 
 565                 \Expense@ForeignCurrency{#1}{#2}{#3}{#4}{#5}%
 
 567         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 568         \or     % 4: Print subtotal remuneration
 
 571                 \Expense@ForeignCurrency{#1}{#2}{#3}{#4}{#5}%
 
 573         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 574         \or     % 5: Expense item
 
 576                 \Expense@ForeignCurrency{#1}{#2}{#3}{#4}{#5}%
 
 578         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 579         \or     % 6: Print subtotal expenses
 
 581                 \error@message{\ProjectCompletedNoExpense}%
 
 583         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 584         \or     % 7: Print subtotal project
 
 586                 \error@message{\ProjectCompletedNoExpense}%
 
 588         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 589         \or     % 8: Print total, close invoice
 
 591                 \error@message{\InvoiceCompletedNoExpense}%
 
 593         \else \error@message{\InternalError}%
 
 596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 597 \newcommand{\EFCi}[5]{% Yields state 5: Expenses in ForeignCurrency
 
 598         %                               But, unlike base form (no
 
 599         %                               'invisible') this version does
 
 600         %                               not state the item, it only
 
 601         %                               the total amount of expenses. 
 
 603         % #1 Contents und Datum
 
 607         % #5 Amount Zielwaehrung
 
 610         % 1. {Contents}{ForeignCurrency}{ExchangeRate}{}
 
 611         % 2. {Contents}{ForeignCurrency}{}{BaseCurrency}
 
 612         % 3. {Contents}{ForeignCurrency}{ExchangeRate}{BaseCurrency}
 
 614         \ifcase\Flag % 0: Invoice not started yet
 
 616                 \error@message{\MissingOpening}%
 
 618         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 619         \or     % 1: Start invoice
 
 621                 \error@message{\MissingProject}%
 
 623         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 624         \or     % 2: Start project, print title
 
 627                 \Expense@Foreign@Currency{#1}{#2}{#3}{#4}{#5}%
 
 629         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 630         \or     % 3: Print remuneration item
 
 634                 \Expense@Foreign@Currency{#1}{#2}{#3}{#4}{#5}%
 
 636         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 637         \or     % 4: Print subtotal remuneration
 
 640                 \Expense@Foreign@Currency{#1}{#2}{#3}{#4}{#5}%
 
 642         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 643         \or     % 5: Expense item
 
 645                 \Expense@Foreign@Currency{#1}{#2}{#3}{#4}{#5}%
 
 647         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 648         \or     % 6: Print subtotal expenses
 
 650                 \error@message{\ProjectCompletedNoExpense}%
 
 652         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 653         \or     % 7: Print subtotal project
 
 655                 \error@message{\ProjectCompletedNoExpense}%
 
 657         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 658         \or     % 8: Print total, close invoice
 
 660                 \error@message{\InvoiceCompletedNoExpense}%
 
 662         \else \error@message{\InternalError}%
 
 665 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 666 \newcommand{\STExpenses}{% Yields state 6: Ausgabe der ST Expenses
 
 668         \ifcase\Flag % 0: Invoice not started yet
 
 670                 \error@message{\MissingOpening}%
 
 672         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 673         \or     % 1: Start invoice
 
 675                 \error@message{\MissingProject}%
 
 677         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 679         \or     % 2: Start project, print title
 
 681         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 683         \or     % 3: Print remuneration item
 
 685         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 687         \or     % 4: Print subtotal remuneration
 
 689         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 690         \or     % 5: Expense item
 
 694         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 695         \or     % 6: Print subtotal expenses
 
 697                 \warning@message{\ProjectCompletedNoExpense}%
 
 699         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 700         \or     % 7: Print subtotal project
 
 702         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 703         \or     % 8: Print total, close invoice
 
 705                 \error@message{\InvoiceCompletedNoExpense}%
 
 707         \else \error@message{\InternalError}%
 
 710 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 711 \newcommand{\STProject}{% Yields state 7: Ausgabe der ST Project
 
 713         \ifcase\Flag % 0: Invoice not started yet
 
 715                 \error@message{\MissingOpening}%
 
 717         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 718         \or     % 1: Start invoice
 
 720                 \error@message{\MissingProject}%
 
 722         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 723         \or     % 2: Start project, print title
 
 725                 \warning@message{\ProjectEmpty}%
 
 727         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 728         \or     % 3: Print remuneration item
 
 733         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 734         \or     % 4: Print subtotal remuneration
 
 738         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 739         \or     % 5: Expense item
 
 744         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 745         \or     % 6: Print subtotal expenses
 
 749         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 750         \or     % 7: Print subtotal project
 
 752                 \warning@message{\ProjectSTExists}%
 
 754         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 755         \or     % 8: Print total, close invoice
 
 757                 \error@message{\InvoiceCompletedNoProjectST}%
 
 759         \else \error@message{\InternalError}%
 
 762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 763 \newcommand{\Discount}[2]{%     Yields no particular state.
 
 764         %                       Inserts discount in project total,
 
 765         %                       names discount reason
 
 766         %                       and amount of discount
 
 768         \gdef\Discount@Contents{#1}%
 
 769         \setcounter{Discount}{100 * \real{-#2}}%
 
 771 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 772 \newcommand{\Total@Reset}{%
 
 775         \setcounter{Expenses}{0}%
 
 776         \setcounter{Total}{0}%
 
 778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 779 \newcommand{\ST@Reset}{%
 
 780         \setcounter{ST@Fee}{0}%
 
 781         \setcounter{ST@VAT}{0}%
 
 782         \setcounter{ST@Expenses}{0}%
 
 783         \setcounter{ST@Project}{0}%
 
 785 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 786 \newcommand{\Print@Value}[1]{%
 
 787         \Rmul\r#1{0.01}%% <- Reduce to BaseCurrency
 
 788         \Rtrunc\r{2}\r% % <- Truncate to two digits
 
 789         \r%             % <- Output data!
 
 791 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 792 \newcommand{\Message@Value}[1]{%
 
 793         \Rmul\r#1{0.01}%% <- Reduce to BaseCurrency
 
 794         \Rtrunc\r{2}\r% % <- Truncate to two digits
 
 795         \message{\r}%   % <- Output data!
 
 797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 798 \newcommand{\Project@Title}[1]{%
 
 799         % Internal command called by \ProjectTitle.
 
 803         \ST@Reset\addtocounter{Project}{1}%
 
 804         \ifnum\theProject>1 \\\\\else\\\fi%
 
 805         \multicolumn{5}{c}{\textbf{\large#1}}\\%
 
 807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 808 \newcommand{\Fee@Title}{%
 
 810         \noindent\textbf{\Activity}&&\UnitRate&\Count&\Amount\ (\BC)\\
 
 813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 814 \newcommand{\Fee@Line}[3]{%
 
 817         % #2 Charged Fee per Unit
 
 820         % Internal command, called by \Fee.
 
 826 %   next is reversed to allow real arithmetic.
 
 827 %   intermediate results are stored in integer format, so calculations are
 
 828 %   incorrect in case #2 is a real.
 
 829 %   fixed by exchanging the 1 and the 100
 
 831                 \setcounter{One@Fee}{100 * \real{#2} * \real{#3} * 1}%
 
 833                 \addtocounter{ST@Fee}{\theOne@Fee}%
 
 834                 \addtocounter{Fee}{\theOne@Fee}%
 
 835                 \addtocounter{Fee@ctr}{1}%          increase counter with 1
 
 836                 \Print@Value{\theOne@Fee}\\%
 
 838 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 839 \newcommand{\ST@Fee}{%
 
 842             \ifthenelse{\theFee@ctr>1} %            % if more than 1 \Fee line
 
 843                 {\Print@ST@Fees%                                        % print it, else
 
 846                 \ifVATnonzero\ST@VAT@Printout\fi%
 
 849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 850 \newcommand{\Print@ST@Fees}{%
 
 852         \SubtotalFee &  &       &       &%      print the subtotal of fees
 
 853                 \Print@Value{\theST@Fee}\\%
 
 855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 856 \newcommand{\ST@VAT@Printout}{%
 
 857                 \VAT\ (\VAT@rate\%)      &      &       &       &%
 
 858                         \setcounter{ST@VAT}{\theST@Fee * \real{\VAT@rate} / 100}%
 
 859                                 \Print@Value{\theST@VAT}\\%
 
 861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 862 \newcommand{\Expense@BaseCurrency}[2]{%
 
 866         \setcounter{One@Expense}{1*\real{\r}}%
 
 867         \addtocounter{ST@Expenses}{\theOne@Expense}%
 
 868         \addtocounter{Expenses}{\theOne@Expense}%
 
 869         \addtocounter{Expense@ctr}{1}%advance counter
 
 870                                 \Print@Value{\theOne@Expense}\\%
 
 872 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 873 \newcommand{\Expense@Base@Currency}[2]{%
 
 876         \setcounter{One@Expense}{1*\real{\r}}%
 
 877         \addtocounter{ST@Expenses}{\theOne@Expense}%
 
 878         \addtocounter{Expenses}{\theOne@Expense}%
 
 879         \addtocounter{Expense@ctr}{1}%advance counter
 
 880                 &       &       &       &       \\[-1.2em]% This is an ugly kludge:
 
 881                                                                   %     Inserting an empty line
 
 882                                                                   % which rolls backwards
 
 883                                                                   % makes disappear the spurious
 
 884                                                                   % spaces caused by external
 
 887 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 888 \newcommand{\Expense@ForeignCurrency}[5]{%
 
 891         % Folgende Angaben sind moeglich:
 
 892         % 1. {Contents}{Currency}{Amount}{Umrechnung}{  }
 
 893         % 2. {Contents}{Currency}{Amount}{          }{BaseCurrency}
 
 894         % 3. {Contents}{Currency}{Amount}{Umrechnung}{BaseCurrency}
 
 897         \ifthenelse{\equal{#5}{}}% Target in BaseCurrency or not?
 
 898                 {% Target not in BaseCurrency
 
 902                 {% Target in BaseCurrency
 
 905         \setcounter{One@Expense}{1*\real{\r}}%
 
 906         \addtocounter{ST@Expenses}{\theOne@Expense}%
 
 907         \addtocounter{Expenses}{\theOne@Expense}%
 
 908         \addtocounter{Expense@ctr}{1}%advance counter
 
 909         \Print@Value{\theOne@Expense}%
 
 912 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 913 \newcommand{\Expense@Foreign@Currency}[5]{%
 
 916         % Folgende Angaben sind moeglich:
 
 917         % 1. {Contents}{Currency}{Amount}{Umrechnung}{  }
 
 918         % 2. {Contents}{Currency}{Amount}{          }{BaseCurrency}
 
 919         % 3. {Contents}{Currency}{Amount}{Umrechnung}{BaseCurrency}
 
 921         \ifthenelse{\equal{#5}{}}% Target in BaseCurrency or not?
 
 922                 {% Target not in BaseCurrency
 
 926                 {% Target in BaseCurrency
 
 929         \setcounter{One@Expense}{1*\real{\r}}%
 
 930         \addtocounter{ST@Expenses}{\theOne@Expense}%
 
 931         \addtocounter{Expenses}{\theOne@Expense}%
 
 932         \addtocounter{Expense@ctr}{1}%advance counter
 
 933                 &       &       &       &       \\[-1.2em]% ugly kludge as above
 
 935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 936 \newcommand{\Expense@Title}{%
 
 938         \textbf{\Expense}&\Currency&\Amount&\Factor &\BC\\%
 
 941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 942 \newcommand{\ST@Expenses}{%
 
 944         \ifnum\theST@Expenses>0%
 
 945             \ifthenelse{\theExpense@ctr>1}%         % if more than 1 Expense line
 
 946                 {\Print@ST@Expenses}%                           % print it, else
 
 950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 951 \newcommand{\Print@ST@Expenses}{%
 
 953                 &       &       &       &       \\[-1.2em]% ugly kludge as above
 
 954         \SubtotalExpenses &     &       &       &%      print the subtotal of expenses
 
 955                 \Print@Value{\theST@Expenses}\\%
 
 957 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 958 \newcommand{\ST@Project}{%
 
 961         %\multicolumn{4}{l}{\SubtotalProject}%
 
 962         %\let\Project\NewProject%
 
 964         \SubtotalProject &      &       &       & 
 
 965                         \addtocounter{ST@Project}{\theST@Fee}%
 
 966                         \addtocounter{ST@Project}{\theST@VAT}%
 
 967                         \addtocounter{ST@Project}{\theST@Expenses}%
 
 968                         \Print@Value{\theST@Project}\\
 
 970 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 971 \newcommand{\Total@VAT@Printout}{%
 
 972                 \setcounter{VAT}{\theFee*\real{\VAT@rate}/100}%
 
 973                         \SumVAT &       &       &       &\Print@Value{\theVAT}\\%
 
 975 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 976 \newcommand{\Tot@l}{%
 
 978         \ifnum\theFee>0 \SumFees&       &       &       &%
 
 979                                 \Print@Value{\theFee}\\ 
 
 984         \ifnum\theExpenses>0 \SumExpenses&      &       &       &%
 
 985                                 \Print@Value{\theExpenses}\\ 
 
 987         \ifnum\theDiscount=0 \else \Discount@Contents&  &       &       &%
 
 988                                 \Print@Value{\theDiscount}\\ 
 
 991         \textbf{\Total} &       &       &       &%
 
 992                 \message{^^J\Currency: \BC}%
 
 993                 \message{^^J\VAT: \VAT@rate}%
 
 994                 \addtocounter{Total}{\theFee}%
 
 995                 \message{^^J\SumFees: }\Message@Value{\theFee}%
 
 996                 \addtocounter{Total}{\theVAT}%
 
 997                 \message{^^J\SumVAT: }\Message@Value{\theVAT}%
 
 998                 \addtocounter{Total}{\theExpenses}%
 
 999                 \message{^^J\SumExpenses: }\Message@Value{\theExpenses}%
 
1000                 \ifnum\theDiscount=0 \else %
 
1001                 \addtocounter{Total}{\theDiscount}%
 
1002                 \message{^^J\Discount@Contents: }\Message@Value{\theDiscount}%
 
1004                 \textbf{\Print@Value{\theTotal}}%
 
1005                 \message{^^J\Total: }%
 
1006                         \Message@Value{\theTotal}\message{^^J^^J}\\%