summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/invoice-class
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/invoice-class
Initial commit
Diffstat (limited to 'macros/latex/contrib/invoice-class')
-rw-r--r--macros/latex/contrib/invoice-class/README.md6
-rw-r--r--macros/latex/contrib/invoice-class/doc/duck-invoice.cfg10
-rw-r--r--macros/latex/contrib/invoice-class/doc/duck-invoice.csv31
-rw-r--r--macros/latex/contrib/invoice-class/doc/duck-invoice.pdfbin0 -> 37543 bytes
-rw-r--r--macros/latex/contrib/invoice-class/doc/duck-invoice.tex16
-rw-r--r--macros/latex/contrib/invoice-class/doc/ducks.csv1
-rw-r--r--macros/latex/contrib/invoice-class/doc/ducks.pdfbin0 -> 34447 bytes
-rw-r--r--macros/latex/contrib/invoice-class/doc/ducks.tex15
-rw-r--r--macros/latex/contrib/invoice-class/doc/invoice-class.pdfbin0 -> 76876 bytes
-rw-r--r--macros/latex/contrib/invoice-class/doc/invoice-class.tex132
-rw-r--r--macros/latex/contrib/invoice-class/invoice-class.cls168
11 files changed, 379 insertions, 0 deletions
diff --git a/macros/latex/contrib/invoice-class/README.md b/macros/latex/contrib/invoice-class/README.md
new file mode 100644
index 0000000000..1a94843072
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/README.md
@@ -0,0 +1,6 @@
+# invoice-class
+The `invoice-class` produces a standard US commercial invoice using data from a CSV file. Invoices can span multiple pages. The class is configurable for different shipping addresses.
+
+The class is released under the LPPL 1.3 licence.
+
+
diff --git a/macros/latex/contrib/invoice-class/doc/duck-invoice.cfg b/macros/latex/contrib/invoice-class/doc/duck-invoice.cfg
new file mode 100644
index 0000000000..05acf7197b
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/duck-invoice.cfg
@@ -0,0 +1,10 @@
+% Sample configuration file
+\fromaddress{%
+The Duck Company\\
+Some Avenue\\
+Somewhere MI 48823\\
+USA\\
+Tel. 555-555-5555\\
+}
+\shipper{Prof. van Duck}
+\location{Somewhere, MI}
diff --git a/macros/latex/contrib/invoice-class/doc/duck-invoice.csv b/macros/latex/contrib/invoice-class/doc/duck-invoice.csv
new file mode 100644
index 0000000000..6c849f3856
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/duck-invoice.csv
@@ -0,0 +1,31 @@
+Description, Country, Quantity, UnitValue, Amount
+Yellow Ducks, USA,5,2.00,10.00
+Pink Ducks, USA,4,15.00,60.00
+Blue Ducks, USA,6,5.00,30.00
+Orange Ducks, USA,1,4.00,4.00
+Red Ducks, USA,30,2.00,60.00
+Yellow Ducks, USA,5,2.00,10.00
+Pink Ducks, USA,4,15.00,60.00
+Blue Ducks, USA,6,5.00,30.00
+Orange Ducks, USA,1,4.00,4.00
+Red Ducks, USA,30,2.00,60.00
+Yellow Ducks, USA,5,2.00,10.00
+Pink Ducks, USA,4,15.00,60.00
+Blue Ducks, USA,6,5.00,30.00
+Orange Ducks, USA,1,4.00,4.00
+Red Ducks, USA,30,2.00,60.00
+Yellow Ducks, USA,5,2.00,10.00
+Pink Ducks, USA,4,15.00,60.00
+Blue Ducks, USA,6,5.00,30.00
+Orange Ducks, USA,1,4.00,4.00
+Red Ducks, USA,30,2.00,60.00
+Yellow Ducks, USA,5,2.00,10.00
+Pink Ducks, USA,4,15.00,60.00
+Blue Ducks, USA,6,5.00,30.00
+Orange Ducks, USA,1,4.00,4.00
+Red Ducks, USA,30,2.00,60.00
+Yellow Ducks, USA,5,2.00,10.00
+Pink Ducks, USA,4,15.00,60.00
+Blue Ducks, USA,6,5.00,30.00
+Orange Ducks, USA,1,4.00,4.00
+Red Ducks, USA,30,2.00,60.00 \ No newline at end of file
diff --git a/macros/latex/contrib/invoice-class/doc/duck-invoice.pdf b/macros/latex/contrib/invoice-class/doc/duck-invoice.pdf
new file mode 100644
index 0000000000..49a247b270
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/duck-invoice.pdf
Binary files differ
diff --git a/macros/latex/contrib/invoice-class/doc/duck-invoice.tex b/macros/latex/contrib/invoice-class/doc/duck-invoice.tex
new file mode 100644
index 0000000000..01d54398d6
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/duck-invoice.tex
@@ -0,0 +1,16 @@
+\documentclass{invoice-class}
+\ConfigPrefix{duck-}
+\InputFile{duck-invoice.csv}
+\waybill{8273205776}
+\carrier{FedEx}
+\destination{Brazil}
+\toaddress{Paulo Cereda\\Rua Bonita\\Cidade de Patos\\SP\\Brazil}
+\weight{1}{1}
+\packages{1}
+\shippingcost{40.00}
+\packingcost{0.00}
+\insurancecost{10.00}
+\begin{document}
+\printinvoice
+\end{document}
+
diff --git a/macros/latex/contrib/invoice-class/doc/ducks.csv b/macros/latex/contrib/invoice-class/doc/ducks.csv
new file mode 100644
index 0000000000..06e3318a27
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/ducks.csv
@@ -0,0 +1 @@
+Description, Country, Quantity, UnitValue, Amount Yellow Ducks, USA,5,2.00,10.00 Pink Ducks, USA,4,15.00,60.00 Blue Ducks, USA,6,5.00,30.00 Orange Ducks, USA,1,4.00,4.00 Red Ducks, USA,30,2.00,60.00 \ No newline at end of file
diff --git a/macros/latex/contrib/invoice-class/doc/ducks.pdf b/macros/latex/contrib/invoice-class/doc/ducks.pdf
new file mode 100644
index 0000000000..c837f2eaee
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/ducks.pdf
Binary files differ
diff --git a/macros/latex/contrib/invoice-class/doc/ducks.tex b/macros/latex/contrib/invoice-class/doc/ducks.tex
new file mode 100644
index 0000000000..eb938fca2b
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/ducks.tex
@@ -0,0 +1,15 @@
+\documentclass{invoice-class}
+\InputFile{ducks.csv}
+\waybill{8273205776}
+\carrier{FedEx}
+\destination{Brazil}
+\toaddress{Paulo Cereda\\Rua Bonita\\Cidade de Patos\\SP\\Brazil}
+\weight{1}{1}
+\packages{1}
+\shippingcost{40.00}
+\packingcost{0.00}
+\insurancecost{10.00}
+\begin{document}
+\printinvoice
+\end{document}
+
diff --git a/macros/latex/contrib/invoice-class/doc/invoice-class.pdf b/macros/latex/contrib/invoice-class/doc/invoice-class.pdf
new file mode 100644
index 0000000000..40271306b3
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/invoice-class.pdf
Binary files differ
diff --git a/macros/latex/contrib/invoice-class/doc/invoice-class.tex b/macros/latex/contrib/invoice-class/doc/invoice-class.tex
new file mode 100644
index 0000000000..4e1e09ad7b
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/doc/invoice-class.tex
@@ -0,0 +1,132 @@
+\documentclass[11pt]{article}
+\title{\textbf{Using the Invoice Class}}
+\author{\textbf{Alan Munn}\\Department of Linguistics and Languages\\\texttt{\href{mailto:amunn@msu.edu}{amunn@msu.edu}}}
+\date{Version 1.0\\January 17, 2019}
+\usepackage{fontspec}
+\setmainfont[]{Linux Libertine O}
+\setsansfont[]{Linux Biolinum O}
+\setmonofont[Scale=MatchLowercase]{Linux Libertine Mono O}
+\usepackage[lmargin=1in,rmargin=1in,tmargin=1.25in,bmargin=1in]{geometry}
+\usepackage{titling}
+\usepackage{array, booktabs, multicol, xspace,tabularx}
+\usepackage{enumitem}
+\usepackage{caption}
+\usepackage{fancyvrb,listings,url}
+\usepackage{pdfpages}
+\usepackage[sf]{titlesec}
+\usepackage{titleps}
+\newpagestyle{main}{%
+\setfoot{\itshape Invoice Class}{}{\thepage}}
+\pagestyle{main}
+
+\usepackage[colorlinks=true]{hyperref}
+
+\DefineShortVerb{\|}
+\newcommand*\bs{\textbackslash}
+
+\lstset{%
+ basicstyle=\ttfamily\small,
+ commentstyle=\itshape\ttfamily\small,
+ showspaces=false,
+ showstringspaces=false,
+ breaklines=true,
+ breakautoindent=true,
+ frame=single
+ captionpos=t
+ language=TeX
+}
+
+\newcommand*{\pkg}[1]{\texttt{#1}\xspace}
+\setitemize[1]{label={}}
+\setitemize[2]{label={}}
+\setdescription{font={\normalfont}}
+\setlength{\droptitle}{-1in}
+
+
+
+\begin{document}
+\maketitle
+\thispagestyle{empty}
+\section{Introduction}
+The \pkg{invoice-class} class allows printing of a standard US commercial invoice using invoice data from a CSV spreadsheet. Invoices can span multiple pages.
+
+\section{Class document commands}
+The main class commands specify the parts of the form that need to be filled in. Each command except |\weight| takes a single argument.
+
+\begin{center}
+\begin{tabularx}{.8\textwidth}{>{\ttfamily\bs}l<{\{\}}X}
+\toprule
+\multicolumn{1}{c}{Command name} & \multicolumn{1}{l}{Description}\\
+\midrule
+{waybill}& waybill number\\
+{shippingdate}& shipping date (default is \texttt{\bs today})\\
+{carrier}& name of the freight carrier\\
+{destination}& destination country\\
+{toaddress}& Destination address\\
+\multicolumn{1}{>{\ttfamily\bs}l}{weight\{<lbs>\}\{<oz>\}} & weight in pounds and ounces\\
+{packages}{1} & number of packages in the shipment\\
+{shippingcost}& total cost of shipping (default = 0.00)\\
+{packingcost} & total cost of packing (default = 0.00)\\
+{insurancecost} & total cost of insurance (default is 0.00)\\
+{InputFile} & name of the CSV file for item date\\
+\bottomrule
+\end{tabularx}
+\captionof{table}{Invoice document commands}\label{commands}
+\end{center}
+
+\subsection{Producing the invoice}
+Once all the required elements are specified (which can be done in the preamble), there is a single command to produce the invoice:
+\begin{center}
+\begin{tabularx}{.8\textwidth}{>{\ttfamily\bs}lX}
+{printinvoice} & Prints the invoice\\
+\end{tabularx}
+\end{center}
+
+\section{Class configuration commands}
+Since an invoice will generally have a fixed From address, shipper and location, these values are best set in a separate configuration file (although they can also be set within the document.) The class will look for the file |invoice.cfg| or, |<prefix>invoice.cfg| where |<prefix>| is specified using the document command |\ConfigPrefix|. This allows multiple configuration files with different information within them.
+Each configuration file should contain an instance of |\fromaddress|, |\shipper|, and |\location|.
+\begin{center}
+\begin{tabularx}{.8\textwidth}{>{\ttfamily\bs}l<{\{\}}X}
+\toprule
+\multicolumn{1}{c}{Command name} & \multicolumn{1}{l}{Description}\\
+\midrule
+{fromaddresss}& shipper's address\\
+{shipper}& name of shipper\\
+{location}& location\\
+{ConfigPrefix} & configuration file prefix (default is none)\\
+\bottomrule
+\end{tabularx}
+\captionof{table}{Invoice configuration commands}\label{config-commands}
+\end{center}
+
+
+\section{\pkg{datatool} details}
+The uses the \pkg{datatool} package to produce the invoice using a CSV file. The CSV file requires the following column headings to be present. All other columns are ignored. (Heading names are case-sensitive.)
+\begin{center}
+\begin{tabularx}{.8\textwidth}{>{\ttfamily}lX}
+\toprule
+\multicolumn{1}{c}{Column name} & \multicolumn{1}{l}{Description}\\
+\midrule
+{Description} & Item description\\
+{Country} & Country of origin\\
+{Quantity} & unit quantity\\
+{UnitValue} & per unit value\\
+{Amount} & total value for item\\
+\bottomrule
+\end{tabularx}
+\captionof{table}{Required CSV Column labels}\label{CSV}
+\end{center}
+\subsection{Sample CSV file}
+\lstinputlisting{ducks.csv}
+\clearpage
+\section{Sample Configuration file}
+\lstinputlisting{duck-invoice.cfg}
+
+\section{Sample document}
+\lstinputlisting{ducks.tex}
+\section{Bugs and support}
+This package is released as is, and although I will accept bug reports, fixing them may not be a priority. You're free to fork the project to modify it as you wish.
+
+
+\includepdf[]{ducks.pdf}
+\end{document}
diff --git a/macros/latex/contrib/invoice-class/invoice-class.cls b/macros/latex/contrib/invoice-class/invoice-class.cls
new file mode 100644
index 0000000000..d7fc6cc16b
--- /dev/null
+++ b/macros/latex/contrib/invoice-class/invoice-class.cls
@@ -0,0 +1,168 @@
+% US Commercial Invoice Class
+% Copyright 2008-2019 by Alan Munn amunn@msu.edu
+%
+% This class may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This package has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this package is Alan Munn amunn@msu.edu
+%
+\def\invc@date{2019/01/17}
+\def\invc@version{1.0}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{invoice-class}[\invc@date\space Commercial Invoice \invc@version]
+\LoadClass[11pt]{article}
+\RequirePackage[margin=1in]{geometry}
+\RequirePackage{datatool}
+\RequirePackage{multicol}
+\RequirePackage{array}
+\RequirePackage{tabularx}
+\RequirePackage{longtable}
+\RequirePackage{dcolumn}
+\RequirePackage{fancyhdr}
+% internal commands
+\renewcommand{\rmdefault}{\sfdefault}
+\newcommand*{\invc@BL}[1]{\rule{#1}{.5pt}} % signature rule
+\newcommand*\invc@NL{\tabularnewline}
+\newcolumntype{d}{D{.}{.}{6.2}} % decimal columns for amounts
+\newcommand*{\invc@mc}{\multicolumn{1}{c|}} % column header
+\newcommand*{\invc@waybill}{% format waybill in a box
+\fbox{\textbf{Waybill Number:} \invc@waybillnum}}
+%
+% user commands
+%
+\newcommand*{\ConfigPrefix}[1]{\gdef\invc@configprefix{#1}}
+\newcommand*{\InputFile}[1]{\gdef\invc@inputfile{#1}}
+\newcommand*{\waybill}[1]{\gdef\invc@waybillnum{#1}}
+\newcommand*{\shippingdate}[1]{\gdef\invc@shippingdate{#1}}
+\newcommand{\toaddress}[1]{\gdef\invc@toaddress{#1}}
+\newcommand*{\destination}[1]{\gdef\invc@destination{#1}}
+\newcommand*{\carrier}[1]{\gdef\invc@carrier{#1}}
+\newcommand*{\weight}[2]{\gdef\invc@pounds{#1}\gdef\invc@oz{#2}}
+\newcommand*{\packages}[1]{\gdef\invc@packages{#1}}
+\newcommand*{\packingcost}[1]{\gdef\invc@packingcost{#1}}
+\newcommand*{\shippingcost}[1]{\gdef\invc@shippingcost{#1}}
+\newcommand*{\insurancecost}[1]{\gdef\invc@insurancecost{#1}}
+\newcommand{\fromaddress}[1]{\long\gdef\invc@fromaddress{#1}}
+\newcommand*{\shipper}[1]{\gdef\invc@shipper{#1}}
+\newcommand*{\location}[1]{\gdef\invc@location{#1}}
+%
+% defaults
+%
+\packingcost{0}
+\shippingcost{0}
+\insurancecost{0}
+\shippingdate{\today}
+\ConfigPrefix{}
+%
+% Configuration file scheme:
+% \ConfigPrefix{} sets a prefix for config files and allows multiple configuration files
+% invoice.cfg should contain the commands \fromaddress, \shipper and \location
+% these will generally be fixed values, but can be set on a per document basis too.
+%
+\AtBeginDocument{
+\InputIfFileExists{\invc@configprefix invoice.cfg}{\ClassInfo{invoice-class}{Loading configuration file \invc@configprefix invoice.cfg }\typeout{Loading configuration file \invc@configprefix invoice.cfg}}
+{\ClassInfo{invoice-class}{Config file not loaded. Using class default}\typeout{Config file not loaded. Using class default}
+\fromaddress{%
+The Duck Company\\
+Some Avenue\\
+Somewhere MI 48823\\
+USA\\
+Tel. 555-555-5555\\
+}
+\shipper{Prof. van Duck}
+\location{Somewhere, MI}
+}}
+%
+\pagestyle{fancy}
+\parindent=0pt
+\lhead{}
+\chead{\Large \sffamily \bfseries Commercial Invoice }
+\rhead{}
+\lfoot{}
+\cfoot{\sffamily\thepage}
+\rfoot{}
+\renewcommand{\headrulewidth}{0.4pt}
+\renewcommand{\footrulewidth}{0pt}
+\setlength{\headheight}{18pt}
+\thispagestyle{fancy}
+\sffamily
+\newcommand{\printinvoice}{%
+\invc@waybill
+\begin{multicols}{2}
+
+{\Large\bfseries From:}
+
+\invc@fromaddress
+
+\columnbreak
+
+{\Large\bfseries To:}
+
+\invc@toaddress
+\end{multicols}
+
+\setlength{\extrarowheight}{9pt}
+\begin{tabularx}{\linewidth}{|*{4}{>{\centering}X|}}
+\hline
+\textbf{\scriptsize Country of ultimate destination:} & \textbf{\scriptsize Exporting Carrier} & \textbf{\scriptsize Total number of packages} & \textbf{\scriptsize Gross Weight} \invc@NL
+\invc@destination & \invc@carrier &
+\invc@packages & \invc@pounds~lb \invc@oz~oz \invc@NL
+\hline
+\end{tabularx}
+%
+\DTLloaddb{invoice}{\invc@inputfile}
+\DTLsumcolumn{invoice}{Amount}{\invc@total}
+\setlength{\extrarowheight}{3pt}
+\begin{longtable}{|p{2.1381in}|>{\centering}p{1in}|r|d|d|}
+\hline
+\centering\bfseries Description & \centering\bfseries Country of Origin & \centering \bfseries Quantity &\invc@mc{\bfseries Unit Value\$} & \invc@mc{\bfseries Amount (USD)}\invc@NL
+\hline
+\endhead
+\hline
+\endfoot
+\DTLforeach{invoice}{%
+\description=Description,\country=Country,\quantity=Quantity,\unitvalue=UnitValue,\amount=Amount}{%
+\description & \country & \quantity & \unitvalue & \amount \invc@NL} & & & & \invc@NL
+\hline
+\multicolumn{4}{|r|}{\bfseries Currency type and amount}& \DTLdecimaltocurrency{\invc@total}{\invc@subtotal}\invc@subtotal \invc@NL
+\multicolumn{4}{|r|}{\bfseries Packing cost} & \DTLdecimaltocurrency{\invc@packingcost}{\invc@pcost}\invc@pcost\invc@NL
+\multicolumn{4}{|r|}{\bfseries Shipping cost} & \DTLdecimaltocurrency{\invc@shippingcost}{\invc@scost}\invc@scost\invc@NL
+\multicolumn{4}{|r|}{\bfseries Insurance cost} & \DTLdecimaltocurrency{\invc@insurancecost}{\invc@icost}\invc@icost\invc@NL
+\hline\hline
+\multicolumn{4}{|r|}{\bfseries Total Invoice Value} &\DTLaddall{\invc@grandtotal}{\invc@total,\invc@packingcost,\invc@shippingcost,\invc@insurancecost}
+\DTLconverttodecimal{\invc@grandtotal}{\invc@gtotal}
+\DTLdecimaltocurrency{\invc@gtotal}{\invc@ctotal}\invc@ctotal \invc@NL
+\hline
+\end{longtable}
+\vskip 5ex
+{\Large\bfseries Notes:}
+
+{\footnotesize These commodities, technologies, or software were exported from the United States of
+America in accordance with the Export Administration regulations. Diversion contrary to
+U.S. law is prohibited.
+
+It is hereby certified that this invoice shows: (1) the actual price of the goods described,
+(2) that no other invoice has been or will be issued, and (3) that all particulars are true
+and correct.}
+
+\bigskip
+\setlength{\extrarowheight}{18pt}
+\begin{tabular}{|p{3in}|p{1.75in}|}
+\hline
+\textbf{\scriptsize Name:} \hskip 2em \invc@shipper & \textbf{\scriptsize Date:} \invc@shippingdate \invc@NL
+
+\hline
+\multicolumn{2}{|l|}{\textbf{\scriptsize Location:} \hskip 1em \invc@location}\invc@NL
+\hline
+\multicolumn{2}{|l|}{ \textbf{\scriptsize Signature:}}\invc@NL
+\hline
+\end{tabular}
+}
+\endinput \ No newline at end of file