发票包添加总金额到总行

发票包添加总金额到总行

我正在使用发票包目前我开具发票。我是一名自由职业者,因此每个 \Fee 都是我完成的某项任务,计数指的是我花在这项任务上的小时数。例如:

\documentclass{letter}
\usepackage{invoice}
\address{...}
\signature{...}
\date{...}

\begin{document}
  \begin{letter}{...}
    \opening{Invoice XX 2023}
    \begin{invoice}{Dollar}{0}
      \ProjectTitle{My Project}%
      \Fee{Task 1} {60} {2}
      \Fee{Task 2} {60} {5}
      \Fee{Task 3} {60} {4}
    \end{invoice}
  \end{letter}
\end{document}

有没有办法将总小时数(即总计数)添加到金额总和和总数中?那么对于上面的例子,它会在总金额 660 旁边显示总小时数 11 吗?

答案1

Invoice包不对Count值求和,因此您应该修改包的一些内部命令。

\documentclass{letter}
\usepackage{invoice}
\address{...}
\signature{...}
\date{...}
    
\newcounter{Count}  <---------- Declare counter

\makeatletter
\renewcommand{\Fee@Line}[3]{%
    \gdef\Flag{3}%
    #1          &   &#2 &#3 &
        \FPmul\r{100}{#2}% added 2006-01-04
        \setcounter{One@Fee}{1 *\real{\r} * \real{#3} }%
        \addtocounter{ST@Fee}{\theOne@Fee}%
        \addtocounter{Fee}{\theOne@Fee}%
        \addtocounter{Fee@ctr}{1}%
        \addtocounter{Count}{#3}%     <-------- Add value to counter
        \Print@Value{\theOne@Fee}\\%
}
\renewcommand{\Tot@l}{%
    \\\hline
    \ifnum\theFee>0 \SumFees&   &   &%
                \theCount &%             <-------- Print the sum of Count field
                \Print@Value{\theFee}\\ 
        \ifVATnonzero%
            \Total@VAT@Printout%
        \fi%
    \fi%
    \ifnum\theExpenses>0 \SumExpenses&  &   & &%
                \Print@Value{\theExpenses}\\ 
    \fi%
    \ifnum\theDiscount<0 \Discount@Contents&    &   &   &%
                \Print@Value{\theDiscount}\\ 
    \fi%
    \hline\hline
    \textbf{\Total} &   &   &%
        \theCount &%                     <-------- Print the sum of Count field
        \message{^^J\Currency: \BC}%
        \message{^^J\VAT: \VAT@rate}%
        \addtocounter{Total}{\theFee}%
        \message{^^J\SumFees: }\Message@Value{\theFee}%
        \addtocounter{Total}{\theVAT}%
        \message{^^J\SumVAT: }\Message@Value{\theVAT}%
        \addtocounter{Total}{\theExpenses}%
        \message{^^J\SumExpenses: }\Message@Value{\theExpenses}%
        \ifnum\theDiscount<0 %
        \addtocounter{Total}{\theDiscount}%
        \message{^^J\Discount@Contents: }\Message@Value{\theDiscount}%
        \fi %
        \textbf{\Print@Value{\theTotal}}%
        \message{^^J\Total: }%
            \Message@Value{\theTotal}\message{^^J^^J}\\%
    \end{longtable}
    \gdef\Flag{8}%
}
\makeatother

\begin{document}
  \begin{letter}{...}
    \opening{Invoice XX 2023}
    \begin{invoice}{Dollar}{0}
      \ProjectTitle{My Project}%
      \Fee{Task 1} {60} {2}
      \Fee{Task 2} {60} {5}
      \Fee{Task 3} {60} {4}
    \end{invoice}
  \end{letter}
\end{document}

在此处输入图片描述

相关内容