-
-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathE001_invoice.php
More file actions
371 lines (345 loc) · 16.4 KB
/
E001_invoice.php
File metadata and controls
371 lines (345 loc) · 16.4 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<?php
/**
* E001_invoice.php
*
* @since 2017-05-08
* @category Library
* @package Pdf
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2002-2026 Nicola Asuni - Tecnick.com LTD
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf
*
* This file is part of tc-lib-pdf software library.
*/
// NOTE: run make deps fonts in the project root to generate the dependencies and example fonts.
// autoloader when using Composer
require(__DIR__ . '/../vendor/autoload.php');
// define fonts directory
\define('K_PATH_FONTS', \realpath(__DIR__ . '/../vendor/tecnickcom/tc-lib-pdf-font/target/fonts'));
// autoloader when using RPM or DEB package installation
//require ('/usr/share/php/Com/Tecnick/Pdf/autoload.php');
// main TCPDF object
$pdf = new \Com\Tecnick\Pdf\Tcpdf(
'mm', // string $unit = 'mm',
true, // bool $isunicode = true,
false, // bool $subsetfont = false,
true, // bool $compress = true,
'pdfa3', // string $mode = '',
null, // ?ObjEncrypt $objEncrypt = null,
);
// ----------
$pdf->setCreator('tc-lib-pdf');
$pdf->setAuthor('Nicola Asuni');
$pdf->setSubject('tc-lib-pdf example: 001');
$pdf->setTitle('Example Invoice Factur-X 1.07 / ZUGFeRD 2.3');
$pdf->setKeywords('TCPDF tc-lib-pdf example');
$pdf->setPDFFilename('001_invoice.pdf');
$pdf->setViewerPreferences(['DisplayDocTitle' => true]);
$pdf->enableDefaultPageContent();
// ----------
// Insert fonts
$bfont1 = $pdf->font->insert($pdf->pon, 'dejavusans', '', 10);
// ----------
// Factur-X 1.07 / ZUGFeRD 2.3
$pageF01 = $pdf->addPage();
$pdf->setBookmark('Factur', '', 0, -1, 0, 0, 'B', '');
$pdf->page->addContent($bfont1['out']);
$invoiceHTML = '
<h2 style="color:#003366;">INVOICE EXAMPLE</h2>
<table border="0" cellspacing="0" cellpadding="2" style="width:100%;">
<tr>
<td style="width:50%; vertical-align:top;">
<b>Seller</b><br/>
ELEKTRON Industrieservice GmbH<br/>
Geschäftsführer Egon Schrempp Amtsgericht Stuttgart HRB 1234<br/>
Erfurter Strasse 13<br/>
74465 Demoort, DE<br/>
VAT: DE136695976
</td>
<td style="width:50%; vertical-align:top; text-align:right;">
<b>Invoice No.:</b> 181301674<br/>
<b>Invoice Date:</b> 15.11.2024<br/>
<b>Delivery Date:</b> 01.11.2024<br/>
<b>Order Ref.:</b> per Mail vom 01.09.2024<br/>
<b>Project:</b> 13130162
</td>
</tr>
</table>
<br/>
<b>Bill To:</b><br/>
ConsultingService GmbH<br/>
Attn: Liselotte Müller-Lüdenscheidt<br/>
Musterstr. 18<br/>
76138 Karlsruhe, DE<br/>
<br/>
<table border="1" cellspacing="0" cellpadding="3" style="width:100%; text-align:right;">
<tr style="background-color:#003366; color:#ffffff;">
<th style="text-align:left; width:8%;">Pos.</th>
<th style="text-align:left; width:40%;">Description</th>
<th style="width:12%;">Qty</th>
<th style="width:10%;">Unit</th>
<th style="width:15%;">Unit Price</th>
<th style="width:15%;">Amount</th>
</tr>
<tr>
<td style="text-align:left;">01</td>
<td style="text-align:left;">TGA Obermonteur/Monteur<br/><i>Beamermontage</i></td>
<td>3</td>
<td>HUR</td>
<td>43.20</td>
<td>129.60</td>
</tr>
<tr>
<td style="text-align:left;">02</td>
<td style="text-align:left;">Beamer-Deckenhalterung<br/><i>Außerhalb Angebot</i></td>
<td>1</td>
<td>H87</td>
<td>122.50</td>
<td>122.50</td>
</tr>
</table>
<br/>
<table border="0" cellspacing="0" cellpadding="2" style="width:100%;">
<tr>
<td style="width:60%;"></td>
<td style="width:40%;">
<table border="1" cellspacing="0" cellpadding="3" style="width:100%; text-align:right;">
<tr><td style="text-align:left;">Net Total</td><td>EUR 252.10</td></tr>
<tr><td style="text-align:left;">VAT 19%</td><td>EUR 47.90</td></tr>
<tr><td style="text-align:left;"><b>Grand Total</b></td><td><b>EUR 300.00</b></td></tr>
<tr><td style="text-align:left;">Prepaid</td><td>EUR 0.00</td></tr>
<tr><td style="text-align:left;"><b>Due Amount</b></td><td><b>EUR 300.00</b></td></tr>
</table>
</td>
</tr>
</table>
<br/>
<b>Payment Terms:</b> Zahlbar sofort rein netto<br/>
<b>Bank:</b> IBAN DE91100000000123456789<br/>
<b>Payment Reference:</b> Rechnung 181301674<br/>
<br/>
<i>Factur-X 1.07 / ZUGFeRD 2.3 — embedded XML attachment: factur-x.xml</i>
';
$pdf->page->addContent($pdf->getHTMLCell($invoiceHTML, 15, 15, 180));
$invoiceXML = <<<XML
<?xml version='1.0' encoding='UTF-8' ?>
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
<rsm:ExchangedDocumentContext>
<ram:BusinessProcessSpecifiedDocumentContextParameter>
<ram:ID>Baurechnung</ram:ID>
</ram:BusinessProcessSpecifiedDocumentContextParameter>
<ram:GuidelineSpecifiedDocumentContextParameter>
<ram:ID>urn:cen.eu:en16931:2017</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument>
<ram:ID>181301674</ram:ID>
<ram:TypeCode>204</ram:TypeCode>
<ram:IssueDateTime>
<udt:DateTimeString format="102">20241115</udt:DateTimeString>
</ram:IssueDateTime>
<ram:IncludedNote>
<ram:Content>Rapport-Nr.: 42389 vom 01.11.2024
Im 2. OG BT1 Besprechungsraum eine Beamerhalterung an die Decke montiert. Dafür eine Deckenplatte ausgesägt. Beamerhalterung zur Montage auseinander gebaut. Ein Stromkabel für den Beamer, ein HDMI Kabel und ein VGA Kabel durch die Halterung gezogen. Beamerhalterung wieder zusammengebaut und Beamer montiert. Beamer verkabelt und ausgerichtet. Decke geschlossen.</ram:Content>
</ram:IncludedNote>
</rsm:ExchangedDocument>
<rsm:SupplyChainTradeTransaction>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>01</ram:LineID>
<ram:IncludedNote>
<ram:Content>01 Beamermontage
Für die doppelte Verlegung, falls erforderlich.</ram:Content>
</ram:IncludedNote>
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:Name>TGA Obermonteur/Monteur</ram:Name>
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:GrossPriceProductTradePrice>
<ram:ChargeAmount>43.2</ram:ChargeAmount>
</ram:GrossPriceProductTradePrice>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>43.2</ram:ChargeAmount>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="HUR">3</ram:BilledQuantity>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<ram:LineTotalAmount>129.6</ram:LineTotalAmount>
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>02</ram:LineID>
<ram:IncludedNote>
<ram:Content>02 Außerhalb Angebot</ram:Content>
</ram:IncludedNote>
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:Name>Beamer-Deckenhalterung</ram:Name>
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:GrossPriceProductTradePrice>
<ram:ChargeAmount>122.5</ram:ChargeAmount>
</ram:GrossPriceProductTradePrice>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>122.5</ram:ChargeAmount>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="H87">1</ram:BilledQuantity>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<ram:LineTotalAmount>122.5</ram:LineTotalAmount>
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>Liselotte Müller-Lüdenscheidt</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:ID>549910</ram:ID>
<ram:Name>ELEKTRON Industrieservice GmbH</ram:Name>
<ram:Description>Geschäftsführer Egon Schrempp Amtsgericht Stuttgart HRB 1234</ram:Description>
<ram:PostalTradeAddress>
<ram:PostcodeCode>74465</ram:PostcodeCode>
<ram:LineOne>Erfurter Strasse 13</ram:LineOne>
<ram:CityName>Demoort</ram:CityName>
<ram:CountryID>DE</ram:CountryID>
</ram:PostalTradeAddress>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">DE136695976</ram:ID>
</ram:SpecifiedTaxRegistration>
</ram:SellerTradeParty>
<ram:BuyerTradeParty>
<ram:ID>16259</ram:ID>
<ram:Name>ConsultingService GmbH</ram:Name>
<ram:PostalTradeAddress>
<ram:PostcodeCode>76138</ram:PostcodeCode>
<ram:LineOne>Musterstr. 18</ram:LineOne>
<ram:CityName>Karlsruhe</ram:CityName>
<ram:CountryID>DE</ram:CountryID>
</ram:PostalTradeAddress>
</ram:BuyerTradeParty>
<ram:SellerOrderReferencedDocument>
<ram:IssuerAssignedID>per Mail vom 01.09.2024</ram:IssuerAssignedID>
</ram:SellerOrderReferencedDocument>
<ram:AdditionalReferencedDocument>
<ram:IssuerAssignedID>13130162</ram:IssuerAssignedID>
<ram:URIID>#ef=Aufmass.png</ram:URIID>
<ram:TypeCode>916</ram:TypeCode>
</ram:AdditionalReferencedDocument>
<ram:AdditionalReferencedDocument>
<ram:IssuerAssignedID>42389</ram:IssuerAssignedID>
<ram:URIID>#ef=ElektronRapport_neu-red.pdf</ram:URIID>
<ram:TypeCode>916</ram:TypeCode>
</ram:AdditionalReferencedDocument>
<ram:SpecifiedProcuringProject>
<ram:ID>13130162</ram:ID>
<ram:Name>Projekt</ram:Name>
</ram:SpecifiedProcuringProject>
</ram:ApplicableHeaderTradeAgreement>
<ram:ApplicableHeaderTradeDelivery>
<ram:ActualDeliverySupplyChainEvent>
<ram:OccurrenceDateTime>
<udt:DateTimeString format="102">20241101</udt:DateTimeString>
</ram:OccurrenceDateTime>
</ram:ActualDeliverySupplyChainEvent>
</ram:ApplicableHeaderTradeDelivery>
<ram:ApplicableHeaderTradeSettlement>
<ram:PaymentReference>Rechnung 181301674</ram:PaymentReference>
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>58</ram:TypeCode>
<ram:PayeePartyCreditorFinancialAccount>
<ram:IBANID>DE91100000000123456789</ram:IBANID>
</ram:PayeePartyCreditorFinancialAccount>
</ram:SpecifiedTradeSettlementPaymentMeans>
<ram:ApplicableTradeTax>
<ram:CalculatedAmount>47.9</ram:CalculatedAmount>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:BasisAmount>252.1</ram:BasisAmount>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradePaymentTerms>
<ram:Description>Zahlbar sofort rein netto</ram:Description>
</ram:SpecifiedTradePaymentTerms>
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<ram:LineTotalAmount>252.1</ram:LineTotalAmount>
<ram:ChargeTotalAmount>0</ram:ChargeTotalAmount>
<ram:AllowanceTotalAmount>0</ram:AllowanceTotalAmount>
<ram:TaxBasisTotalAmount>252.1</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="EUR">47.9</ram:TaxTotalAmount>
<ram:GrandTotalAmount>300</ram:GrandTotalAmount>
<ram:TotalPrepaidAmount>0</ram:TotalPrepaidAmount>
<ram:DuePayableAmount>300</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<ram:ReceivableSpecifiedTradeAccountingAccount>
<ram:ID>420</ram:ID>
</ram:ReceivableSpecifiedTradeAccountingAccount>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>
XML;
$pdf->addContentAsEmbeddedFile('factur-x.xml', $invoiceXML);
$pdf->setCustomXMP('x:xmpmeta.rdf:RDF.rdf:Description.pdfaExtension:schemas.rdf:Bag',
'<rdf:li rdf:parseType="Resource">
<pdfaSchema:schema>Factur-X PDFA Extension Schema</pdfaSchema:schema>
<pdfaSchema:namespaceURI>urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>
<pdfaSchema:prefix>fx</pdfaSchema:prefix>
<pdfaSchema:property>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:name>DocumentFileName</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
<pdfaProperty:category>external</pdfaProperty:category>
<pdfaProperty:description>The name of the embedded XML document</pdfaProperty:description>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:name>DocumentType</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
<pdfaProperty:category>external</pdfaProperty:category>
<pdfaProperty:description>The type of the hybrid document in capital letters, e.g. INVOICE or ORDER</pdfaProperty:description>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:name>Version</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
<pdfaProperty:category>external</pdfaProperty:category>
<pdfaProperty:description>The actual version of the standard applying to the embedded XML document</pdfaProperty:description>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<pdfaProperty:name>ConformanceLevel</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType>
<pdfaProperty:category>external</pdfaProperty:category>
<pdfaProperty:description>The conformance level of the embedded XML document</pdfaProperty:description>
</rdf:li>
</rdf:Seq>
</pdfaSchema:property>
</rdf:li>'
);
$pdf->setCustomXMP('x:xmpmeta.rdf:RDF',
'<rdf:Description xmlns:fx="urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#" rdf:about="">
<fx:DocumentType>INVOICE</fx:DocumentType>
<fx:DocumentFileName>factur-x.xml</fx:DocumentFileName>
<fx:Version>1.0</fx:Version>
<fx:ConformanceLevel>EN 16931</fx:ConformanceLevel>
</rdf:Description>');
// =============================================================
$rawpdf = $pdf->getOutPDFString();
$pdf->renderPDF($rawpdf);