1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
|