Skip to content

Commit

Permalink
Added initial class and example tex file
Browse files Browse the repository at this point in the history
  • Loading branch information
treyhunner committed Jan 12, 2011
0 parents commit e347785
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
110 changes: 110 additions & 0 deletions invoice.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2011 Trey Hunner %
% %
% Permission is hereby granted, free of charge, to any person obtaining %
% a copy of this software and associated documentation files (the %
% "Software"), to deal in the Software without restriction, including %
% without limitation the rights to use, copy, modify, merge, publish, %
% distribute, sublicense, and/or sell copies of the Software, and to %
% permit persons to whom the Software is furnished to do so, subject to %
% the following conditions: %
% %
% The above copyright notice and this permission notice shall be %
% included in all copies or substantial portions of the Software. %
% %
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, %
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF %
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND %
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE %
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION %
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION %
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ProvidesClass{invoice}

\LoadClass[12pt]{article}

\usepackage[letterpaper,hmargin=0.79in,vmargin=0.79in]{geometry}
\usepackage[parfill]{parskip} % Do not indent paragraphs
\usepackage{fp} % Fixed-point arithmetic
\usepackage{calc} % Counters for totaling hours and cost
\usepackage{longtable}

\pagestyle{empty} % No page numbers
\linespread{1.5}

\setlength{\doublerulesep}{\arrayrulewidth} % Double rules look like one thick one

% Command for setting a default hourly rate
\newcommand{\hourlyrate}[1]{\def \@hourlyrate {#1}}
\hourlyrate{1}
\newcommand{\feetype}[1]{
\textbf{#1}
\\
}

% Counters for totaling up hours and dollars
\newcounter{hours} \newcounter{cost} \newcounter{subcost}
\setcounter{hours}{0} \setcounter{cost}{0} \setcounter{subcost}{0}

% Formats inputed number with 2 digits after the decimal place
\newcommand*{\formatNumber}[1]{\FPround{\cost}{#1}{2}\cost} %

% Returns the total of counter
\newcommand*{\total}[1]{\FPdiv{\t}{\arabic{#1}}{1000}\formatNumber{\t}}

% Create an invoice table
\newenvironment{invoiceTable}{
% Create a new row from title, unit quantity, unit rate, and unit name
\newcommand*{\unitrow}[4]{%
\addtocounter{cost}{1000 * \real{##2} * \real{##3}}%
\addtocounter{subcost}{1000 * \real{##2} * \real{##3}}%
##1 & \formatNumber{##2} ##4 & \$\formatNumber{##3} & \$\FPmul{\cost}{##2}{##3}\formatNumber{\cost}%
\\
}
% Create a new row from title and expense amount
\newcommand*{\feerow}[2]{%
\addtocounter{cost}{1000 * \real{##2}}%
\addtocounter{subcost}{1000 * \real{##2}}%
##1 & & \$\formatNumber{##2} & \$\FPmul{\cost}{##2}{1}\formatNumber{\cost}%
\\
}

\newcommand{\subtotalNoStar}{
{\bf Subtotal} & {\bf \total{hours} hours} & & {\bf \$\total{subcost}}
\setcounter{subcost}{0}
\\*[1.5ex]
}
\newcommand{\subtotalStar}{
{\bf Subtotal} & & & {\bf \$\total{subcost}}
\setcounter{subcost}{0}
\\*[1.5ex]
}
\newcommand{\subtotal}{
\hline
\@ifstar
\subtotalStar%
\subtotalNoStar%
}


% Create a new row from date and hours worked (use stored fee type and hourly rate)
\newcommand*{\hourrow}[2]{%
\addtocounter{hours}{1000 * \real{##2}}%
\unitrow{##1}{##2}{\@hourlyrate}{hours}%
}
\renewcommand{\tabcolsep}{0.8ex}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}\hspace{\tabcolsep}} l r r r }
\hline
{\bf Description of Services} & \multicolumn{1}{c}{\bf Quantity} & \multicolumn{1}{c}{\bf Unit Price} & \multicolumn{1}{c}{\bf Amount} \\*
\hline\hline
\endhead
}{
\hline\hline\hline
{\bf Balance Due} & & & {\bf \$\total{cost}} \\
\end{longtable}
}
34 changes: 34 additions & 0 deletions invoice.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
\documentclass{invoice}

\def \tab {\hspace*{3ex}}

\begin{document}

\hfil{\Huge\bf Joe Shmoe}\hfil
\bigskip\break
\hrule
5555 Front St. \hfill 555~.~356~.~7936 \\
Toledo, OH 43602 \hfill shmoe@example.com
\\ \\
{\bf Invoice To:} \\
\tab John Doe \\
\tab ACME Corporation \\

{\bf Date:} \\
\tab \today \\

\hourlyrate{12.51}

\begin{invoiceTable}
\feetype{Consulting Services}
\hourrow{January 3, 2011}{8}
\hourrow{January 4, 2011}{6.5}
\hourrow{January 5, 2011}{5.25}
\hourrow{January 6, 2011}{9.75}
\hourrow{January 7, 2011}{4}
\subtotal
\feetype{Hosting Expenses}
\feerow{Ajax Hosting: January 8, 2011}{60}
\end{invoiceTable}

\end{document}

0 comments on commit e347785

Please sign in to comment.