From e347785142ae5ae34c4b4dfad0d989c74bc1a842 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Wed, 12 Jan 2011 08:10:56 -0800 Subject: [PATCH] Added initial class and example tex file --- invoice.cls | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++ invoice.tex | 34 ++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 invoice.cls create mode 100644 invoice.tex diff --git a/invoice.cls b/invoice.cls new file mode 100644 index 0000000..7df4828 --- /dev/null +++ b/invoice.cls @@ -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} +} diff --git a/invoice.tex b/invoice.tex new file mode 100644 index 0000000..168e618 --- /dev/null +++ b/invoice.tex @@ -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}