-
Notifications
You must be signed in to change notification settings - Fork 14
/
simpleinvoice.sty
248 lines (216 loc) · 10.1 KB
/
simpleinvoice.sty
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
% Package for creating invoices.
% Implemented by Mathias Lohne (mathialo@ifi.uio.no).
% (c) 2017 Mathias Lohne
% Version 2023-03-21.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{simpleinvoice}[2017/11/03 package simpleinvoice]
% Fall back to english if option parsing fails
\def \INV@lang {eng}
% Language options
\DeclareOption{american}{\def \INV@lang {eng}}
\DeclareOption{english}{\def \INV@lang {eng}}
\DeclareOption{UKenglish}{\def \INV@lang {eng}}
\DeclareOption{USenglish}{\def \INV@lang {eng}}
\DeclareOption{french}{\def \INV@lang {fr}}
\DeclareOption{francais}{\def \INV@lang {fr}}
\DeclareOption{norsk}{\def \INV@lang {nobm}}
\DeclareOption{norwegian}{\def \INV@lang {nobm}}
\DeclareOption{bokmaal}{\def \INV@lang {nobm}}
\DeclareOption{german}{\def \INV@lang {deu}}
\DeclareOption{deutsch}{\def \INV@lang {deu}}
\ProcessOptions
% Translations
\def \INV@text@invoice@eng {Invoice}
\def \INV@text@ourref@eng {Our ref}
\def \INV@text@yourref@eng {Your ref}
\def \INV@text@invnum@eng {Invoice number}
\def \INV@text@invdate@eng {Invoice date}
\def \INV@text@deadline@eng {Deadline}
\def \INV@text@description@eng {Description}
\def \INV@text@itemprice@eng {Item price}
\def \INV@text@vat@eng {VAT}
\def \INV@text@itemtotal@eng {Sum}
\def \INV@text@subtotal@eng {Subtotal}
\def \INV@text@total@eng {Total}
\def \INV@text@paymentinfo@eng {Payment info}
\def \INV@text@totallong@eng {Total}
\def \INV@text@accountnum@eng {Account number}
\def \INV@text@warning@eng {By paying after deadline, additional interest and fees may apply.}
\def \INV@text@invoice@fr {Facture}
\def \INV@text@ourref@fr {Notre référent}
\def \INV@text@yourref@fr {Votre référent}
\def \INV@text@invnum@fr {Numéro de facture}
\def \INV@text@invdate@fr {Date de facturation}
\def \INV@text@deadline@fr {Date limite de paiement}
\def \INV@text@description@fr {Description}
\def \INV@text@itemprice@fr {Prix unitaire}
\def \INV@text@vat@fr {TVA}
\def \INV@text@itemtotal@fr {Montant}
\def \INV@text@subtotal@fr {Sous-total}
\def \INV@text@total@fr {Total}
\def \INV@text@paymentinfo@fr {Informations de paiement}
\def \INV@text@totallong@fr {Total}
\def \INV@text@accountnum@fr {Numéro de compte}
\def \INV@text@warning@fr {En payant après la date limite, des intérêts et des frais peuvent être appliqués.}
\def \INV@text@invoice@nobm {Faktura}
\def \INV@text@ourref@nobm {Vår ref}
\def \INV@text@yourref@nobm {Deres ref}
\def \INV@text@invnum@nobm {Fakturanummer}
\def \INV@text@invdate@nobm {Fakturadato}
\def \INV@text@deadline@nobm {Forfallsdato}
\def \INV@text@description@nobm {Beskrivelse}
\def \INV@text@itemprice@nobm {Enhetspris}
\def \INV@text@vat@nobm {MVA}
\def \INV@text@itemtotal@nobm {Sum}
\def \INV@text@subtotal@nobm {MVA-grunnlag}
\def \INV@text@total@nobm {Å betale}
\def \INV@text@paymentinfo@nobm {Betalingsinformasjon}
\def \INV@text@totallong@nobm {Sum å betale}
\def \INV@text@accountnum@nobm {Kontonummer}
\def \INV@text@warning@nobm {Ved betaling etter forfall kan det påløpe renter og gebyr etter statens satser. Ved innsigelse vil kravet kunne bli sendt til forliksrådet, jf. tvistelovens § 5-2.}
\def \INV@text@invoice@deu {Rechnung}
\def \INV@text@ourref@deu {Unser Zeichen}
\def \INV@text@yourref@deu {Ihr Zeichen}
\def \INV@text@invnum@deu {Rechnungsnummer}
\def \INV@text@invdate@deu {Rechnungsdatum}
\def \INV@text@deadline@deu {Fälligkeitsdatum}
\def \INV@text@description@deu {Beschreibung}
\def \INV@text@itemprice@deu {Einzelpreis}
\def \INV@text@vat@deu {Mwst.}
\def \INV@text@itemtotal@deu {Gesamt}
\def \INV@text@subtotal@deu {Netto}
\def \INV@text@total@deu {Brutto}
\def \INV@text@paymentinfo@deu {Zahlungsinformationen}
\def \INV@text@totallong@deu {Rechnungsbetrag}
\def \INV@text@accountnum@deu {IBAN}
\def \INV@text@warning@deu {Bei Zahlungsverzug können weitere Kosten entstehen.}
%% Set the values
\def \INV@text@invoice {\csname INV@text@invoice@\INV@lang \endcsname}
\def \INV@text@ourref {\csname INV@text@ourref@\INV@lang \endcsname}
\def \INV@text@yourref {\csname INV@text@yourref@\INV@lang \endcsname}
\def \INV@text@invnum {\csname INV@text@invnum@\INV@lang \endcsname}
\def \INV@text@invdate {\csname INV@text@invdate@\INV@lang \endcsname}
\def \INV@text@deadline {\csname INV@text@deadline@\INV@lang \endcsname}
\def \INV@text@description {\csname INV@text@description@\INV@lang \endcsname}
\def \INV@text@itemprice {\csname INV@text@itemprice@\INV@lang \endcsname}
\def \INV@text@vat {\csname INV@text@vat@\INV@lang \endcsname}
\def \INV@text@itemtotal {\csname INV@text@itemtotal@\INV@lang \endcsname}
\def \INV@text@subtotal {\csname INV@text@subtotal@\INV@lang \endcsname}
\def \INV@text@total {\csname INV@text@total@\INV@lang \endcsname}
\def \INV@text@paymentinfo {\csname INV@text@paymentinfo@\INV@lang \endcsname}
\def \INV@text@totallong {\csname INV@text@totallong@\INV@lang \endcsname}
\def \INV@text@accountnum {\csname INV@text@accountnum@\INV@lang \endcsname}
\def \INV@text@warning {\csname INV@text@warning@\INV@lang \endcsname}
\def \INV@text@currency {}
% Import neccesary libraries
\RequirePackage{advdate}
\RequirePackage{hyperref}
\RequirePackage{url}
\RequirePackage{tabularx}
\RequirePackage{etoolbox}
\RequirePackage{xcolor}
\RequirePackage{colortbl}
\RequirePackage{babel}
% Define colors
\definecolor{linecolor}{HTML}{b2b2b2}
% Miscellanous styling
\setlength{\tabcolsep}{0em}
\setlength{\parskip}{0pt}
\setlength{\parindent}{0pt}
% Links
\RequirePackage{hyperref}
\RequirePackage{url}
% Table
\RequirePackage{tabularx}
% Commands
\RequirePackage{etoolbox}
% Line seperator
\newcommand{\linesep}{\vspace{6pt} {\color{linecolor}\hrule} \vspace{6pt}}
% Standard values
\def \INV@content@num {{\color{red} No number}}
\def \INV@content@title {\csname INV@text@invoice\endcsname}
\def \INV@content@date {\today}
\def \INV@content@deadline {\DayAfter[14]}
\def \INV@content@name {{\color{red} Your name}}
\def \INV@content@addr {{\color{red} Address line 1 \\ Address line 2}}
\def \INV@content@addroneline {{\color{red} Address line 1 / Address line 2}}
\def \INV@content@toname {{\color{red} Company}}
\def \INV@content@toaddr {{\color{red} Address line 1 \\ Address line 2}}
\def \INV@content@subtotal {{\color{red} Subtotal}}
\def \INV@content@vat {{\color{red} VAT}}
\def \INV@content@total {{\color{red} Total}}
\def \INV@content@accountnum {{\color{red} Bank account}}
\def \INV@content@summary {}
% Functions for overriding standard values
\newcommand{\setinvoicetitle}[1]{\def \INV@content@title {#1}}
\newcommand{\setinvoicenumber}[1]{\def \INV@content@num {#1}}
\newcommand{\setreceivername}[1]{\def \INV@content@toname {#1}}
\newcommand{\setreceiveraddress}[1]{\def \INV@content@toaddr {#1}}
\newcommand{\setname}[1]{\def \INV@content@name {#1}}
\newcommand{\setaddress}[2]{\def \INV@content@addr {#1}
\def \INV@content@addroneline {#2}
}
\newcommand{\setphonenumber}[1]{\def \INV@content@phonenum {#1}}
\newcommand{\setemail}[1]{\def \INV@content@email {\href{mailto:#1}{#1}}}
\newcommand{\setyourref}[1]{\def \INV@content@yourref {#1}}
\newcommand{\setourref}[1]{\def \INV@content@ourref {#1}}
\newcommand{\setinvoicedate}[1]{\def \INV@content@date {#1}}
\newcommand{\setdeadline}[1]{\def \INV@content@deadline {\DayAfter[#1]}}
\newcommand{\additem}[4]{\ifdef{\INV@content@list}{\appto \INV@content@list {\\ #1 & #2 \INV@text@currency & #3 \% & #4 \INV@text@currency}}{\def \INV@content@list {#1 & #2 \INV@text@currency& #3 \% & #4 \INV@text@currency}}}
\newcommand{\setsubtotal}[1]{\def \INV@content@subtotal {#1}}
\newcommand{\setvat}[1]{\def \INV@content@vat {#1}}
\newcommand{\settotal}[1]{\def \INV@content@total {#1}}
\newcommand{\setaccountnumber}[1]{\def \INV@content@accountnum {#1}}
\newcommand{\setsummary}[1]{\def \INV@content@summary {#1}}
\newcommand{\setcurrency}[1]{\def \INV@text@currency {\ #1}}
\newcommand{\setvattext}[1]{\def \INV@text@vat {#1}}
\newcommand{\setaccounttext}[1]{\def \INV@text@accountnum {#1}}
% Make invoice function
\def \makeinvoice {
\begin{minipage}[b]{0.5\textwidth}
{\large \textbf{\INV@content@toname}} \\
\INV@content@toaddr
\end{minipage}
\begin{minipage}[b]{0.5\textwidth}
\hfill {\Huge \INV@content@title}
\linesep
{\large \textbf{\INV@content@name}} \\
\INV@content@addr \ifdef{\INV@content@phonenum}{\\ \INV@content@phonenum}{} \ifdef{\INV@content@email}{\\ \INV@content@email}{}
\linesep
{ \footnotesize
\ifdef{\INV@content@ourref}{\csname INV@text@ourref\endcsname: \INV@content@ourref \\}{}
\ifdef{\INV@content@yourref}{\csname INV@text@yourref\endcsname: \INV@content@yourref \\}{}
\csname INV@text@invnum\endcsname: \INV@content@num \\
\csname INV@text@invdate\endcsname: \INV@content@date \\
\csname INV@text@deadline\endcsname: \INV@content@deadline
}
\end{minipage}
\vspace{1.5cm}
\INV@content@summary
\vspace{1cm}
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}{X c c r}
\textbf{\csname INV@text@description\endcsname} & \textbf{\csname INV@text@itemprice\endcsname} & \hspace{10pt}\textbf{\csname INV@text@vat\endcsname}\hspace{10pt} & \textbf{\csname INV@text@itemtotal\endcsname} \\ \arrayrulecolor{linecolor}\hline
\ifdef{\INV@content@list}{\INV@content@list}{{\color{red} No Items yet} & & &}
\end{tabularx}
\vspace{1.5cm}
\hfill
\renewcommand{\arraystretch}{1}
\begin{tabular}{r r}
\csname INV@text@subtotal\endcsname: \hspace{10pt} & \INV@content@subtotal \INV@text@currency\\
\csname INV@text@vat\endcsname: \hspace{10pt} & \INV@content@vat \INV@text@currency\\
{\Large \csname INV@text@total\endcsname: \hspace{10pt}} & {\Large \INV@content@total \INV@text@currency}
\end{tabular}
\vfill
{{\color{gray} \itshape \csname INV@text@warning\endcsname} \vspace{10pt} \\
{\huge \csname INV@text@paymentinfo\endcsname}
\linesep
\begin{tabularx}{\textwidth}{X r}
\csname INV@text@invnum\endcsname: & \INV@content@num \\
\csname INV@text@totallong\endcsname: & \INV@content@total \INV@text@currency\\
\csname INV@text@accountnum\endcsname: & \INV@content@accountnum
\end{tabularx}
\vspace{1 cm}
\linesep
{\footnotesize \color{gray} \INV@content@name \hfill \INV@content@addroneline \ifdef{\INV@content@phonenum}{\hfill \INV@content@phonenum}{} \ifdef{\INV@content@email}{\hfill \INV@content@email}{}}}
}