1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\NFe; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Classe a construção do xml da NFe modelo 55 e modelo 65 |
7
|
|
|
* Esta classe basica está estruturada para montar XML da NFe para o |
8
|
|
|
* layout versão 4.00, os demais modelos serão derivados deste |
9
|
|
|
* |
10
|
|
|
* @category API |
11
|
|
|
* @package NFePHP\NFe\ |
12
|
|
|
* @copyright Copyright (c) 2008-2019 |
13
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPLv3+ |
14
|
|
|
* @license https://opensource.org/licenses/MIT MIT |
15
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+ |
16
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
17
|
|
|
* @link http://github.com/nfephp-org/sped-nfe for the canonical source repository |
18
|
|
|
*/ |
19
|
|
|
use NFePHP\Common\Keys; |
20
|
|
|
use NFePHP\Common\DOMImproved as Dom; |
21
|
|
|
use NFePHP\Common\Strings; |
22
|
|
|
use NFePHP\NFe\Common\Gtin; |
23
|
|
|
use stdClass; |
24
|
|
|
use RuntimeException; |
25
|
|
|
use InvalidArgumentException; |
26
|
|
|
use DOMElement; |
27
|
|
|
use DateTime; |
28
|
|
|
|
29
|
|
|
class Make |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
public $errors = []; |
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
public $chNFe; |
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
public $xml; |
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $version; |
48
|
|
|
/** |
49
|
|
|
* @var integer |
50
|
|
|
*/ |
51
|
|
|
protected $mod = 55; |
52
|
|
|
/** |
53
|
|
|
* @var \NFePHP\Common\DOMImproved |
54
|
|
|
*/ |
55
|
|
|
public $dom; |
56
|
|
|
/** |
57
|
|
|
* @var integer |
58
|
|
|
*/ |
59
|
|
|
protected $tpAmb = 2; |
60
|
|
|
/** |
61
|
|
|
* @var DOMElement |
62
|
|
|
*/ |
63
|
|
|
protected $NFe; |
64
|
|
|
/** |
65
|
|
|
* @var DOMElement |
66
|
|
|
*/ |
67
|
|
|
protected $infNFe; |
68
|
|
|
/** |
69
|
|
|
* @var DOMElement |
70
|
|
|
*/ |
71
|
|
|
protected $ide; |
72
|
|
|
/** |
73
|
|
|
* @var DOMElement |
74
|
|
|
*/ |
75
|
|
|
protected $emit; |
76
|
|
|
/** |
77
|
|
|
* @var DOMElement |
78
|
|
|
*/ |
79
|
|
|
protected $enderEmit; |
80
|
|
|
/** |
81
|
|
|
* @var DOMElement |
82
|
|
|
*/ |
83
|
|
|
protected $dest; |
84
|
|
|
/** |
85
|
|
|
* @var DOMElement |
86
|
|
|
*/ |
87
|
|
|
protected $enderDest; |
88
|
|
|
/** |
89
|
|
|
* @var DOMElement |
90
|
|
|
*/ |
91
|
|
|
protected $retirada; |
92
|
|
|
/** |
93
|
|
|
* @var DOMElement |
94
|
|
|
*/ |
95
|
|
|
protected $entrega; |
96
|
|
|
/** |
97
|
|
|
* @var DOMElement |
98
|
|
|
*/ |
99
|
|
|
protected $total; |
100
|
|
|
/** |
101
|
|
|
* @var DOMElement |
102
|
|
|
*/ |
103
|
|
|
protected $cobr; |
104
|
|
|
/** |
105
|
|
|
* @var DOMElement |
106
|
|
|
*/ |
107
|
|
|
protected $transp; |
108
|
|
|
/** |
109
|
|
|
* @var DOMElement |
110
|
|
|
*/ |
111
|
|
|
protected $infAdic; |
112
|
|
|
/** |
113
|
|
|
* @var DOMElement |
114
|
|
|
*/ |
115
|
|
|
protected $exporta; |
116
|
|
|
/** |
117
|
|
|
* @var DOMElement |
118
|
|
|
*/ |
119
|
|
|
protected $compra; |
120
|
|
|
/** |
121
|
|
|
* @var DOMElement |
122
|
|
|
*/ |
123
|
|
|
protected $cana; |
124
|
|
|
/** |
125
|
|
|
* @var DOMElement |
126
|
|
|
*/ |
127
|
|
|
protected $infNFeSupl; |
128
|
|
|
/** |
129
|
|
|
* @var array of DOMElements |
130
|
|
|
*/ |
131
|
|
|
protected $aNFref = []; |
132
|
|
|
/** |
133
|
|
|
* @var array of DOMElements |
134
|
|
|
*/ |
135
|
|
|
protected $aDup = []; |
136
|
|
|
/** |
137
|
|
|
* @var DOMElement |
138
|
|
|
*/ |
139
|
|
|
protected $pag; |
140
|
|
|
/** |
141
|
|
|
* @var array of DOMElements |
142
|
|
|
*/ |
143
|
|
|
protected $aDetPag = []; |
144
|
|
|
/** |
145
|
|
|
* @var array of DOMElements |
146
|
|
|
*/ |
147
|
|
|
protected $aReboque = []; |
148
|
|
|
/** |
149
|
|
|
* @var array of DOMElements |
150
|
|
|
*/ |
151
|
|
|
protected $aVol = []; |
152
|
|
|
/** |
153
|
|
|
* @var array of DOMElements |
154
|
|
|
*/ |
155
|
|
|
protected $aAutXML = []; |
156
|
|
|
/** |
157
|
|
|
* @var array of DOMElements |
158
|
|
|
*/ |
159
|
|
|
protected $aDet = []; |
160
|
|
|
/** |
161
|
|
|
* @var array of DOMElements |
162
|
|
|
*/ |
163
|
|
|
protected $aProd = []; |
164
|
|
|
/** |
165
|
|
|
* @var array of DOMElements |
166
|
|
|
*/ |
167
|
|
|
protected $aRastro = []; |
168
|
|
|
/** |
169
|
|
|
* @var array of DOMElements |
170
|
|
|
*/ |
171
|
|
|
protected $aNVE = []; |
172
|
|
|
/** |
173
|
|
|
* @var array of DOMElements |
174
|
|
|
*/ |
175
|
|
|
protected $aCest = []; |
176
|
|
|
/** |
177
|
|
|
* @var array of DOMElements |
178
|
|
|
*/ |
179
|
|
|
protected $aRECOPI = []; |
180
|
|
|
/** |
181
|
|
|
* @var array of DOMElements |
182
|
|
|
*/ |
183
|
|
|
protected $aDetExport = []; |
184
|
|
|
/** |
185
|
|
|
* @var array of DOMElements |
186
|
|
|
*/ |
187
|
|
|
protected $aDI = []; |
188
|
|
|
/** |
189
|
|
|
* @var array of DOMElements |
190
|
|
|
*/ |
191
|
|
|
protected $aAdi = []; |
192
|
|
|
/** |
193
|
|
|
* @var array of DOMElements |
194
|
|
|
*/ |
195
|
|
|
protected $aVeicProd = []; |
196
|
|
|
/** |
197
|
|
|
* @var array of DOMElements |
198
|
|
|
*/ |
199
|
|
|
protected $aMed = []; |
200
|
|
|
/** |
201
|
|
|
* @var array of DOMElements |
202
|
|
|
*/ |
203
|
|
|
protected $aArma = []; |
204
|
|
|
/** |
205
|
|
|
* @var array of DOMElements |
206
|
|
|
*/ |
207
|
|
|
protected $aComb = []; |
208
|
|
|
/** |
209
|
|
|
* @var array of DOMElements |
210
|
|
|
*/ |
211
|
|
|
protected $aEncerrante = []; |
212
|
|
|
/** |
213
|
|
|
* @var array of DOMElements |
214
|
|
|
*/ |
215
|
|
|
protected $aImposto = []; |
216
|
|
|
/** |
217
|
|
|
* @var array of DOMElements |
218
|
|
|
*/ |
219
|
|
|
protected $aICMS = []; |
220
|
|
|
/** |
221
|
|
|
* @var array of DOMElements |
222
|
|
|
*/ |
223
|
|
|
protected $aICMSUFDest = []; |
224
|
|
|
/** |
225
|
|
|
* @var array of DOMElements |
226
|
|
|
*/ |
227
|
|
|
protected $aIPI = []; |
228
|
|
|
/** |
229
|
|
|
* @var array of DOMElements |
230
|
|
|
*/ |
231
|
|
|
protected $aII = []; |
232
|
|
|
/** |
233
|
|
|
* @var array of DOMElements |
234
|
|
|
*/ |
235
|
|
|
protected $aISSQN = []; |
236
|
|
|
/** |
237
|
|
|
* @var array |
238
|
|
|
*/ |
239
|
|
|
protected $aPIS = []; |
240
|
|
|
/** |
241
|
|
|
* @var array of DOMElements |
242
|
|
|
*/ |
243
|
|
|
protected $aPISST = []; |
244
|
|
|
/** |
245
|
|
|
* @var array of DOMElements |
246
|
|
|
*/ |
247
|
|
|
protected $aCOFINS = []; |
248
|
|
|
/** |
249
|
|
|
* @var array of DOMElements |
250
|
|
|
*/ |
251
|
|
|
protected $aCOFINSST = []; |
252
|
|
|
/** |
253
|
|
|
* @var array of DOMElements |
254
|
|
|
*/ |
255
|
|
|
protected $aImpostoDevol = []; |
256
|
|
|
/** |
257
|
|
|
* @var array of DOMElements |
258
|
|
|
*/ |
259
|
|
|
protected $aInfAdProd = []; |
260
|
|
|
/** |
261
|
|
|
* @var array of DOMElements |
262
|
|
|
*/ |
263
|
|
|
protected $aObsCont = []; |
264
|
|
|
/** |
265
|
|
|
* @var array of DOMElements |
266
|
|
|
*/ |
267
|
|
|
protected $aObsFisco = []; |
268
|
|
|
/** |
269
|
|
|
* @var array of DOMElements |
270
|
|
|
*/ |
271
|
|
|
protected $aProcRef = []; |
272
|
|
|
/** |
273
|
|
|
* @var stdClass |
274
|
|
|
*/ |
275
|
|
|
protected $stdTot; |
276
|
|
|
/** |
277
|
|
|
* @var DOMElement |
278
|
|
|
*/ |
279
|
|
|
protected $infRespTec; |
280
|
|
|
/** |
281
|
|
|
* @var string |
282
|
|
|
*/ |
283
|
|
|
protected $csrt; |
284
|
|
|
/** |
285
|
|
|
* @var boolean |
286
|
|
|
*/ |
287
|
|
|
protected $replaceAccentedChars = false; |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* Função construtora cria um objeto DOMDocument |
291
|
|
|
* que será carregado com o documento fiscal |
292
|
|
|
*/ |
293
|
7 |
|
public function __construct() |
294
|
|
|
{ |
295
|
7 |
|
$this->dom = new Dom('1.0', 'UTF-8'); |
296
|
7 |
|
$this->dom->preserveWhiteSpace = false; |
297
|
7 |
|
$this->dom->formatOutput = false; |
298
|
|
|
//elemento totalizador |
299
|
7 |
|
$this->stdTot = new \stdClass(); |
300
|
7 |
|
$this->stdTot->vBC = 0; |
301
|
7 |
|
$this->stdTot->vICMS = 0; |
302
|
7 |
|
$this->stdTot->vICMSDeson = 0; |
303
|
7 |
|
$this->stdTot->vFCP = 0; |
304
|
7 |
|
$this->stdTot->vFCPUFDest = 0; |
305
|
7 |
|
$this->stdTot->vICMSUFDest = 0; |
306
|
7 |
|
$this->stdTot->vICMSUFRemet = 0; |
307
|
7 |
|
$this->stdTot->vBCST = 0; |
308
|
7 |
|
$this->stdTot->vST = 0; |
309
|
7 |
|
$this->stdTot->vFCPST = 0; |
310
|
7 |
|
$this->stdTot->vFCPSTRet = 0; |
311
|
7 |
|
$this->stdTot->vProd = 0; |
312
|
7 |
|
$this->stdTot->vFrete = 0; |
313
|
7 |
|
$this->stdTot->vSeg = 0; |
314
|
7 |
|
$this->stdTot->vDesc = 0; |
315
|
7 |
|
$this->stdTot->vII = 0; |
316
|
7 |
|
$this->stdTot->vIPI = 0; |
317
|
7 |
|
$this->stdTot->vIPIDevol = 0; |
318
|
7 |
|
$this->stdTot->vPIS = 0; |
319
|
7 |
|
$this->stdTot->vCOFINS = 0; |
320
|
7 |
|
$this->stdTot->vOutro = 0; |
321
|
7 |
|
$this->stdTot->vNF = 0; |
322
|
7 |
|
$this->stdTot->vTotTrib = 0; |
323
|
7 |
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* Set character convertion to ASCII only ou not |
327
|
|
|
* @param bool $option |
328
|
|
|
*/ |
329
|
|
|
public function setOnlyAscii($option = false) |
330
|
|
|
{ |
331
|
|
|
$this->replaceAccentedChars = $option; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Returns xml string and assembly it is necessary |
336
|
|
|
* @return string |
337
|
|
|
*/ |
338
|
|
|
public function getXML() |
339
|
|
|
{ |
340
|
|
|
if (empty($this->xml)) { |
341
|
|
|
$this->montaNFe(); |
342
|
|
|
} |
343
|
|
|
return $this->xml; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Retorns the key number of NFe (44 digits) |
348
|
|
|
* @return string |
349
|
|
|
*/ |
350
|
1 |
|
public function getChave() |
351
|
|
|
{ |
352
|
1 |
|
return $this->chNFe; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* Returns the model of NFe 55 or 65 |
357
|
|
|
* @return int |
358
|
|
|
*/ |
359
|
|
|
public function getModelo() |
360
|
|
|
{ |
361
|
|
|
return $this->mod; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* Call method of xml assembly. For compatibility only. |
366
|
|
|
* @return string |
367
|
|
|
*/ |
368
|
|
|
public function montaNFe() |
369
|
|
|
{ |
370
|
|
|
return $this->monta(); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* NFe xml mount method |
375
|
|
|
* this function returns TRUE on success or FALSE on error |
376
|
|
|
* The xml of the NFe must be retrieved by the getXML() function or |
377
|
|
|
* directly by the public property $xml |
378
|
|
|
* |
379
|
|
|
* @return string |
380
|
|
|
* @throws RuntimeException |
381
|
|
|
*/ |
382
|
|
|
public function monta() |
383
|
|
|
{ |
384
|
|
|
$this->errors = $this->dom->errors; |
385
|
|
|
//cria a tag raiz da Nfe |
386
|
|
|
$this->buildNFe(); |
387
|
|
|
//processa nfeRef e coloca as tags na tag ide |
388
|
|
|
foreach ($this->aNFref as $nfeRef) { |
389
|
|
|
$this->dom->appChild($this->ide, $nfeRef, 'Falta tag "ide"'); |
390
|
|
|
} |
391
|
|
|
//monta as tags det e coloca no array $this->aDet com os detalhes dos produtos |
392
|
|
|
$this->buildDet(); |
393
|
|
|
//[2] tag ide (5 B01) |
394
|
|
|
$this->dom->appChild($this->infNFe, $this->ide, 'Falta tag "infNFe"'); |
395
|
|
|
//[8] tag emit (30 C01) |
396
|
|
|
$this->dom->appChild($this->infNFe, $this->emit, 'Falta tag "infNFe"'); |
397
|
|
|
//[10] tag dest (62 E01) |
398
|
|
|
$this->dom->appChild($this->infNFe, $this->dest, 'Falta tag "infNFe"'); |
399
|
|
|
//[12] tag retirada (80 F01) |
400
|
|
|
$this->dom->appChild($this->infNFe, $this->retirada, 'Falta tag "infNFe"'); |
401
|
|
|
//[13] tag entrega (89 G01) |
402
|
|
|
$this->dom->appChild($this->infNFe, $this->entrega, 'Falta tag "infNFe"'); |
403
|
|
|
//[14] tag autXML (97a.1 G50) |
404
|
|
|
foreach ($this->aAutXML as $aut) { |
405
|
|
|
$this->dom->appChild($this->infNFe, $aut, 'Falta tag "infNFe"'); |
406
|
|
|
} |
407
|
|
|
//[14a] tag det (98 H01) |
408
|
|
|
foreach ($this->aDet as $det) { |
409
|
|
|
$this->dom->appChild($this->infNFe, $det, 'Falta tag "infNFe"'); |
410
|
|
|
} |
411
|
|
|
//[28a] tag total (326 W01) |
412
|
|
|
$this->dom->appChild($this->infNFe, $this->total, 'Falta tag "infNFe"'); |
413
|
|
|
//mota a tag vol |
414
|
|
|
$this->buildVol(); |
415
|
|
|
//[32] tag transp (356 X01) |
416
|
|
|
$this->dom->appChild($this->infNFe, $this->transp, 'Falta tag "infNFe"'); |
417
|
|
|
//[39a] tag cobr (389 Y01) |
418
|
|
|
$this->dom->appChild($this->infNFe, $this->cobr, 'Falta tag "infNFe"'); |
419
|
|
|
//[42] tag pag (398a YA01) |
420
|
|
|
//processa Pag e coloca as tags na tag pag |
421
|
|
|
$this->buildTagPag(); |
422
|
|
|
//[44] tag infAdic (399 Z01) |
423
|
|
|
$this->dom->appChild($this->infNFe, $this->infAdic, 'Falta tag "infNFe"'); |
424
|
|
|
//[48] tag exporta (402 ZA01) |
425
|
|
|
$this->dom->appChild($this->infNFe, $this->exporta, 'Falta tag "infNFe"'); |
426
|
|
|
//[49] tag compra (405 ZB01) |
427
|
|
|
$this->dom->appChild($this->infNFe, $this->compra, 'Falta tag "infNFe"'); |
428
|
|
|
//[50] tag cana (409 ZC01) |
429
|
|
|
$this->dom->appChild($this->infNFe, $this->cana, 'Falta tag "infNFe"'); |
430
|
|
|
//Responsável Técnico |
431
|
|
|
$this->dom->appChild($this->infNFe, $this->infRespTec, 'Falta tag "infNFe"'); |
432
|
|
|
//[1] tag infNFe (1 A01) |
433
|
|
|
$this->dom->appChild($this->NFe, $this->infNFe, 'Falta tag "NFe"'); |
434
|
|
|
//[0] tag NFe |
435
|
|
|
$this->dom->appendChild($this->NFe); |
436
|
|
|
// testa da chave |
437
|
|
|
$this->checkNFeKey($this->dom); |
438
|
|
|
$this->xml = $this->dom->saveXML(); |
439
|
|
|
if (count($this->errors) > 0) { |
440
|
|
|
throw new RuntimeException('Existem erros nas tags. Obtenha os erros com getErrors().'); |
441
|
|
|
} |
442
|
|
|
return $this->xml; |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
/** |
446
|
|
|
* Informações da NF-e A01 pai NFe |
447
|
|
|
* tag NFe/infNFe |
448
|
|
|
* @param stdClass $std |
449
|
|
|
* @return DOMElement |
450
|
|
|
*/ |
451
|
7 |
|
public function taginfNFe(stdClass $std) |
452
|
|
|
{ |
453
|
7 |
|
$possible = ['Id', 'versao', 'pk_nItem']; |
454
|
7 |
|
$std = $this->equilizeParameters($std, $possible); |
455
|
7 |
|
$chave = preg_replace('/[^0-9]/', '', $std->Id); |
456
|
7 |
|
$this->infNFe = $this->dom->createElement("infNFe"); |
457
|
7 |
|
$this->infNFe->setAttribute("Id", 'NFe' . $chave); |
458
|
7 |
|
$this->infNFe->setAttribute( |
459
|
7 |
|
"versao", |
460
|
7 |
|
$std->versao |
461
|
|
|
); |
462
|
7 |
|
$this->version = $std->versao; |
463
|
7 |
|
if (!empty($std->pk_nItem)) { |
464
|
1 |
|
$this->infNFe->setAttribute("pk_nItem", $std->pk_nItem); |
465
|
|
|
} |
466
|
7 |
|
$this->chNFe = $chave; |
467
|
7 |
|
return $this->infNFe; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* Informações de identificação da NF-e B01 pai A01 |
472
|
|
|
* NOTA: Ajustado para NT2016_002_v1.30 |
473
|
|
|
* tag NFe/infNFe/ide |
474
|
|
|
* @param stdClass $std |
475
|
|
|
* @return DOMElement |
476
|
|
|
*/ |
477
|
4 |
|
public function tagide(stdClass $std) |
478
|
|
|
{ |
479
|
|
|
$possible = [ |
480
|
4 |
|
'cUF', |
481
|
|
|
'cNF', |
482
|
|
|
'natOp', |
483
|
|
|
'indPag', |
484
|
|
|
'mod', |
485
|
|
|
'serie', |
486
|
|
|
'nNF', |
487
|
|
|
'dhEmi', |
488
|
|
|
'dhSaiEnt', |
489
|
|
|
'tpNF', |
490
|
|
|
'idDest', |
491
|
|
|
'cMunFG', |
492
|
|
|
'tpImp', |
493
|
|
|
'tpEmis', |
494
|
|
|
'cDV', |
495
|
|
|
'tpAmb', |
496
|
|
|
'finNFe', |
497
|
|
|
'indFinal', |
498
|
|
|
'indPres', |
499
|
|
|
'procEmi', |
500
|
|
|
'verProc', |
501
|
|
|
'dhCont', |
502
|
|
|
'xJust' |
503
|
|
|
]; |
504
|
4 |
|
$std = $this->equilizeParameters($std, $possible); |
505
|
|
|
|
506
|
4 |
|
if (empty($std->cNF)) { |
507
|
1 |
|
$std->cNF = Keys::random($std->nNF); |
508
|
|
|
} |
509
|
4 |
|
if (empty($std->cDV)) { |
510
|
2 |
|
$std->cDV = 0; |
511
|
|
|
} |
512
|
|
|
//validação conforme NT 2019.001 |
513
|
4 |
|
$std->cNF = str_pad($std->cNF, 8, '0', STR_PAD_LEFT); |
514
|
4 |
|
if (intval($std->cNF) == intval($std->nNF)) { |
515
|
|
|
throw new InvalidArgumentException("O valor [{$std->cNF}] não é " |
516
|
|
|
. "aceitável para cNF, não pode ser igual ao de nNF, vide NT2019.001"); |
517
|
|
|
} |
518
|
4 |
|
if (method_exists(Keys::class, 'cNFIsValid')) { |
519
|
4 |
|
if (!Keys::cNFIsValid($std->cNF)) { |
520
|
|
|
throw new InvalidArgumentException("O valor [{$std->cNF}] para cNF " |
521
|
|
|
. "é invalido, deve respeitar a NT2019.001"); |
522
|
|
|
} |
523
|
|
|
} |
524
|
4 |
|
$this->tpAmb = $std->tpAmb; |
525
|
4 |
|
$this->mod = $std->mod; |
526
|
4 |
|
$identificador = 'B01 <ide> - '; |
527
|
4 |
|
$ide = $this->dom->createElement("ide"); |
528
|
4 |
|
$this->dom->addChild( |
529
|
4 |
|
$ide, |
530
|
4 |
|
"cUF", |
531
|
4 |
|
$std->cUF, |
532
|
4 |
|
true, |
533
|
4 |
|
$identificador . "Código da UF do emitente do Documento Fiscal" |
534
|
|
|
); |
535
|
4 |
|
$this->dom->addChild( |
536
|
4 |
|
$ide, |
537
|
4 |
|
"cNF", |
538
|
4 |
|
$std->cNF, |
539
|
4 |
|
true, |
540
|
4 |
|
$identificador . "Código Numérico que compõe a Chave de Acesso" |
541
|
|
|
); |
542
|
4 |
|
$this->dom->addChild( |
543
|
4 |
|
$ide, |
544
|
4 |
|
"natOp", |
545
|
4 |
|
substr(trim($std->natOp), 0, 60), |
546
|
4 |
|
true, |
547
|
4 |
|
$identificador . "Descrição da Natureza da Operação" |
548
|
|
|
); |
549
|
4 |
|
$this->dom->addChild( |
550
|
4 |
|
$ide, |
551
|
4 |
|
"mod", |
552
|
4 |
|
$std->mod, |
553
|
4 |
|
true, |
554
|
4 |
|
$identificador . "Código do Modelo do Documento Fiscal" |
555
|
|
|
); |
556
|
4 |
|
$this->dom->addChild( |
557
|
4 |
|
$ide, |
558
|
4 |
|
"serie", |
559
|
4 |
|
$std->serie, |
560
|
4 |
|
true, |
561
|
4 |
|
$identificador . "Série do Documento Fiscal" |
562
|
|
|
); |
563
|
4 |
|
$this->dom->addChild( |
564
|
4 |
|
$ide, |
565
|
4 |
|
"nNF", |
566
|
4 |
|
$std->nNF, |
567
|
4 |
|
true, |
568
|
4 |
|
$identificador . "Número do Documento Fiscal" |
569
|
|
|
); |
570
|
4 |
|
$this->dom->addChild( |
571
|
4 |
|
$ide, |
572
|
4 |
|
"dhEmi", |
573
|
4 |
|
$std->dhEmi, |
574
|
4 |
|
true, |
575
|
4 |
|
$identificador . "Data e hora de emissão do Documento Fiscal" |
576
|
|
|
); |
577
|
4 |
|
if ($std->mod == '55' && !empty($std->dhSaiEnt)) { |
578
|
1 |
|
$this->dom->addChild( |
579
|
1 |
|
$ide, |
580
|
1 |
|
"dhSaiEnt", |
581
|
1 |
|
$std->dhSaiEnt, |
582
|
1 |
|
false, |
583
|
1 |
|
$identificador . "Data e hora de Saída ou da Entrada da Mercadoria/Produto" |
584
|
|
|
); |
585
|
|
|
} |
586
|
4 |
|
$this->dom->addChild( |
587
|
4 |
|
$ide, |
588
|
4 |
|
"tpNF", |
589
|
4 |
|
$std->tpNF, |
590
|
4 |
|
true, |
591
|
4 |
|
$identificador . "Tipo de Operação" |
592
|
|
|
); |
593
|
4 |
|
$this->dom->addChild( |
594
|
4 |
|
$ide, |
595
|
4 |
|
"idDest", |
596
|
4 |
|
$std->idDest, |
597
|
4 |
|
true, |
598
|
4 |
|
$identificador . "Identificador de local de destino da operação" |
599
|
|
|
); |
600
|
4 |
|
$this->dom->addChild( |
601
|
4 |
|
$ide, |
602
|
4 |
|
"cMunFG", |
603
|
4 |
|
$std->cMunFG, |
604
|
4 |
|
true, |
605
|
4 |
|
$identificador . "Código do Município de Ocorrência do Fato Gerador" |
606
|
|
|
); |
607
|
4 |
|
$this->dom->addChild( |
608
|
4 |
|
$ide, |
609
|
4 |
|
"tpImp", |
610
|
4 |
|
$std->tpImp, |
611
|
4 |
|
true, |
612
|
4 |
|
$identificador . "Formato de Impressão do DANFE" |
613
|
|
|
); |
614
|
4 |
|
$this->dom->addChild( |
615
|
4 |
|
$ide, |
616
|
4 |
|
"tpEmis", |
617
|
4 |
|
$std->tpEmis, |
618
|
4 |
|
true, |
619
|
4 |
|
$identificador . "Tipo de Emissão da NF-e" |
620
|
|
|
); |
621
|
4 |
|
$this->dom->addChild( |
622
|
4 |
|
$ide, |
623
|
4 |
|
"cDV", |
624
|
4 |
|
!empty($std->cDV) ? $std->cDV : '0', |
625
|
4 |
|
true, |
626
|
4 |
|
$identificador . "Dígito Verificador da Chave de Acesso da NF-e" |
627
|
|
|
); |
628
|
4 |
|
$this->dom->addChild( |
629
|
4 |
|
$ide, |
630
|
4 |
|
"tpAmb", |
631
|
4 |
|
$std->tpAmb, |
632
|
4 |
|
true, |
633
|
4 |
|
$identificador . "Identificação do Ambiente" |
634
|
|
|
); |
635
|
4 |
|
$this->dom->addChild( |
636
|
4 |
|
$ide, |
637
|
4 |
|
"finNFe", |
638
|
4 |
|
$std->finNFe, |
639
|
4 |
|
true, |
640
|
4 |
|
$identificador . "Finalidade de emissão da NF-e" |
641
|
|
|
); |
642
|
4 |
|
$this->dom->addChild( |
643
|
4 |
|
$ide, |
644
|
4 |
|
"indFinal", |
645
|
4 |
|
$std->indFinal, |
646
|
4 |
|
true, |
647
|
4 |
|
$identificador . "Indica operação com Consumidor final" |
648
|
|
|
); |
649
|
4 |
|
$this->dom->addChild( |
650
|
4 |
|
$ide, |
651
|
4 |
|
"indPres", |
652
|
4 |
|
$std->indPres, |
653
|
4 |
|
true, |
654
|
4 |
|
$identificador . "Indicador de presença do comprador no estabelecimento comercial no momento da operação" |
655
|
|
|
); |
656
|
4 |
|
$this->dom->addChild( |
657
|
4 |
|
$ide, |
658
|
4 |
|
"procEmi", |
659
|
4 |
|
$std->procEmi, |
660
|
4 |
|
true, |
661
|
4 |
|
$identificador . "Processo de emissão da NF-e" |
662
|
|
|
); |
663
|
4 |
|
$this->dom->addChild( |
664
|
4 |
|
$ide, |
665
|
4 |
|
"verProc", |
666
|
4 |
|
$std->verProc, |
667
|
4 |
|
true, |
668
|
4 |
|
$identificador . "Versão do Processo de emissão da NF-e" |
669
|
|
|
); |
670
|
4 |
|
if (!empty($std->dhCont) && !empty($std->xJust)) { |
671
|
1 |
|
$this->dom->addChild( |
672
|
1 |
|
$ide, |
673
|
1 |
|
"dhCont", |
674
|
1 |
|
$std->dhCont, |
675
|
1 |
|
true, |
676
|
1 |
|
$identificador . "Data e Hora da entrada em contingência" |
677
|
|
|
); |
678
|
1 |
|
$this->dom->addChild( |
679
|
1 |
|
$ide, |
680
|
1 |
|
"xJust", |
681
|
1 |
|
substr(trim($std->xJust), 0, 256), |
682
|
1 |
|
true, |
683
|
1 |
|
$identificador . "Justificativa da entrada em contingência" |
684
|
|
|
); |
685
|
|
|
} |
686
|
4 |
|
$this->ide = $ide; |
687
|
4 |
|
return $ide; |
688
|
|
|
} |
689
|
|
|
|
690
|
|
|
/** |
691
|
|
|
* Chave de acesso da NF-e referenciada BA02 pai BA01 |
692
|
|
|
* tag NFe/infNFe/ide/NFref/refNFe |
693
|
|
|
* @param stdClass $std |
694
|
|
|
* @return DOMElement |
695
|
|
|
*/ |
696
|
|
|
public function tagrefNFe(stdClass $std) |
697
|
|
|
{ |
698
|
|
|
$possible = ['refNFe']; |
699
|
|
|
$std = $this->equilizeParameters($std, $possible); |
700
|
|
|
|
701
|
|
|
$num = $this->buildNFref(); |
702
|
|
|
$refNFe = $this->dom->createElement("refNFe", $std->refNFe); |
703
|
|
|
$this->dom->appChild($this->aNFref[$num - 1], $refNFe); |
704
|
|
|
return $refNFe; |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
/** |
708
|
|
|
* Informação da NF modelo 1/1A referenciada BA03 pai BA01 |
709
|
|
|
* tag NFe/infNFe/ide/NFref/NF DOMNode |
710
|
|
|
* @param stdClass $std |
711
|
|
|
* @return DOMElement |
712
|
|
|
*/ |
713
|
|
|
public function tagrefNF(stdClass $std) |
714
|
|
|
{ |
715
|
|
|
$possible = ['cUF', 'AAMM', 'CNPJ', 'mod', 'serie', 'nNF']; |
716
|
|
|
$std = $this->equilizeParameters($std, $possible); |
717
|
|
|
|
718
|
|
|
$identificador = 'BA03 <refNF> - '; |
719
|
|
|
$num = $this->buildNFref(); |
720
|
|
|
$refNF = $this->dom->createElement("refNF"); |
721
|
|
|
$this->dom->addChild( |
722
|
|
|
$refNF, |
723
|
|
|
"cUF", |
724
|
|
|
$std->cUF, |
725
|
|
|
true, |
726
|
|
|
$identificador . "Código da UF do emitente" |
727
|
|
|
); |
728
|
|
|
$this->dom->addChild( |
729
|
|
|
$refNF, |
730
|
|
|
"AAMM", |
731
|
|
|
$std->AAMM, |
732
|
|
|
true, |
733
|
|
|
$identificador . "Ano e Mês de emissão da NF-e" |
734
|
|
|
); |
735
|
|
|
$this->dom->addChild( |
736
|
|
|
$refNF, |
737
|
|
|
"CNPJ", |
738
|
|
|
$std->CNPJ, |
739
|
|
|
true, |
740
|
|
|
$identificador . "CNPJ do emitente" |
741
|
|
|
); |
742
|
|
|
$this->dom->addChild( |
743
|
|
|
$refNF, |
744
|
|
|
"mod", |
745
|
|
|
$std->mod, |
746
|
|
|
true, |
747
|
|
|
$identificador . "Modelo do Documento Fiscal" |
748
|
|
|
); |
749
|
|
|
$this->dom->addChild( |
750
|
|
|
$refNF, |
751
|
|
|
"serie", |
752
|
|
|
$std->serie, |
753
|
|
|
true, |
754
|
|
|
$identificador . "Série do Documento Fiscal" |
755
|
|
|
); |
756
|
|
|
$this->dom->addChild( |
757
|
|
|
$refNF, |
758
|
|
|
"nNF", |
759
|
|
|
$std->nNF, |
760
|
|
|
true, |
761
|
|
|
$identificador . "Número do Documento Fiscal" |
762
|
|
|
); |
763
|
|
|
$this->dom->appChild($this->aNFref[$num - 1], $refNF); |
764
|
|
|
return $refNF; |
765
|
|
|
} |
766
|
|
|
|
767
|
|
|
/** |
768
|
|
|
* Informações da NF de produtor rural referenciada BA10 pai BA01 |
769
|
|
|
* tag NFe/infNFe/ide/NFref/refNFP |
770
|
|
|
* @param stdClass $std |
771
|
|
|
* @return DOMElement |
772
|
|
|
*/ |
773
|
|
|
public function tagrefNFP(stdClass $std) |
774
|
|
|
{ |
775
|
|
|
$possible = [ |
776
|
|
|
'cUF', |
777
|
|
|
'AAMM', |
778
|
|
|
'CNPJ', |
779
|
|
|
'CPF', |
780
|
|
|
'IE', |
781
|
|
|
'mod', |
782
|
|
|
'serie', |
783
|
|
|
'nNF' |
784
|
|
|
]; |
785
|
|
|
$std = $this->equilizeParameters($std, $possible); |
786
|
|
|
|
787
|
|
|
$identificador = 'BA10 <refNFP> - '; |
788
|
|
|
$num = $this->buildNFref(); |
789
|
|
|
$refNFP = $this->dom->createElement("refNFP"); |
790
|
|
|
$this->dom->addChild( |
791
|
|
|
$refNFP, |
792
|
|
|
"cUF", |
793
|
|
|
$std->cUF, |
794
|
|
|
true, |
795
|
|
|
$identificador . "Código da UF do emitente" |
796
|
|
|
); |
797
|
|
|
$this->dom->addChild( |
798
|
|
|
$refNFP, |
799
|
|
|
"AAMM", |
800
|
|
|
$std->AAMM, |
801
|
|
|
true, |
802
|
|
|
$identificador . "AAMM da emissão da NF de produtor" |
803
|
|
|
); |
804
|
|
|
$this->dom->addChild( |
805
|
|
|
$refNFP, |
806
|
|
|
"CNPJ", |
807
|
|
|
$std->CNPJ, |
808
|
|
|
false, |
809
|
|
|
$identificador . "Informar o CNPJ do emitente da NF de produtor" |
810
|
|
|
); |
811
|
|
|
$this->dom->addChild( |
812
|
|
|
$refNFP, |
813
|
|
|
"CPF", |
814
|
|
|
$std->CPF, |
815
|
|
|
false, |
816
|
|
|
$identificador . "Informar o CPF do emitente da NF de produtor" |
817
|
|
|
); |
818
|
|
|
$this->dom->addChild( |
819
|
|
|
$refNFP, |
820
|
|
|
"IE", |
821
|
|
|
$std->IE, |
822
|
|
|
true, |
823
|
|
|
$identificador . "Informar a IE do emitente da NF de Produtor ou o literal 'ISENTO'" |
824
|
|
|
); |
825
|
|
|
$this->dom->addChild( |
826
|
|
|
$refNFP, |
827
|
|
|
"mod", |
828
|
|
|
str_pad($std->mod, 2, '0', STR_PAD_LEFT), |
829
|
|
|
true, |
830
|
|
|
$identificador . "Modelo do Documento Fiscal" |
831
|
|
|
); |
832
|
|
|
$this->dom->addChild( |
833
|
|
|
$refNFP, |
834
|
|
|
"serie", |
835
|
|
|
$std->serie, |
836
|
|
|
true, |
837
|
|
|
$identificador . "Série do Documento Fiscal" |
838
|
|
|
); |
839
|
|
|
$this->dom->addChild( |
840
|
|
|
$refNFP, |
841
|
|
|
"nNF", |
842
|
|
|
$std->nNF, |
843
|
|
|
true, |
844
|
|
|
$identificador . "Número do Documento Fiscal" |
845
|
|
|
); |
846
|
|
|
$this->dom->appChild($this->aNFref[$num - 1], $refNFP); |
847
|
|
|
return $refNFP; |
848
|
|
|
} |
849
|
|
|
|
850
|
|
|
/** |
851
|
|
|
* Chave de acesso do CT-e referenciada BA19 pai BA01 |
852
|
|
|
* tag NFe/infNFe/ide/NFref/refCTe |
853
|
|
|
* @param stdClass $std |
854
|
|
|
* @return DOMElement |
855
|
|
|
*/ |
856
|
|
|
public function tagrefCTe(stdClass $std) |
857
|
|
|
{ |
858
|
|
|
$possible = ['refCTe']; |
859
|
|
|
$std = $this->equilizeParameters($std, $possible); |
860
|
|
|
|
861
|
|
|
$num = $this->buildNFref(); |
862
|
|
|
$refCTe = $this->dom->createElement("refCTe", $std->refCTe); |
863
|
|
|
$this->dom->appChild($this->aNFref[$num - 1], $refCTe); |
864
|
|
|
return $refCTe; |
865
|
|
|
} |
866
|
|
|
|
867
|
|
|
/** |
868
|
|
|
* Informações do Cupom Fiscal referenciado BA20 pai BA01 |
869
|
|
|
* tag NFe/infNFe/ide/NFref/refECF |
870
|
|
|
* @param stdClass $std |
871
|
|
|
* @return DOMElement |
872
|
|
|
*/ |
873
|
|
|
public function tagrefECF(stdClass $std) |
874
|
|
|
{ |
875
|
|
|
$possible = ['mod', 'nECF', 'nCOO']; |
876
|
|
|
$std = $this->equilizeParameters($std, $possible); |
877
|
|
|
|
878
|
|
|
$identificador = 'BA20 <refECF> - '; |
879
|
|
|
$num = $this->buildNFref(); |
880
|
|
|
$refECF = $this->dom->createElement("refECF"); |
881
|
|
|
$this->dom->addChild( |
882
|
|
|
$refECF, |
883
|
|
|
"mod", |
884
|
|
|
$std->mod, |
885
|
|
|
true, |
886
|
|
|
$identificador . "Modelo do Documento Fiscal" |
887
|
|
|
); |
888
|
|
|
$this->dom->addChild( |
889
|
|
|
$refECF, |
890
|
|
|
"nECF", |
891
|
|
|
str_pad($std->nECF, 3, '0', STR_PAD_LEFT), |
892
|
|
|
true, |
893
|
|
|
$identificador . "Número de ordem sequencial do ECF" |
894
|
|
|
); |
895
|
|
|
$this->dom->addChild( |
896
|
|
|
$refECF, |
897
|
|
|
"nCOO", |
898
|
|
|
str_pad($std->nCOO, 6, '0', STR_PAD_LEFT), |
899
|
|
|
true, |
900
|
|
|
$identificador . "Número do Contador de Ordem de Operação - COO" |
901
|
|
|
); |
902
|
|
|
$this->dom->appChild($this->aNFref[$num - 1], $refECF); |
903
|
|
|
return $refECF; |
904
|
|
|
} |
905
|
|
|
|
906
|
|
|
/** |
907
|
|
|
* Identificação do emitente da NF-e C01 pai A01 |
908
|
|
|
* tag NFe/infNFe/emit |
909
|
|
|
* @param stdClass $std |
910
|
|
|
* @return DOMElement |
911
|
|
|
*/ |
912
|
|
|
public function tagemit(stdClass $std) |
913
|
|
|
{ |
914
|
|
|
$possible = [ |
915
|
|
|
'xNome', |
916
|
|
|
'xFant', |
917
|
|
|
'IE', |
918
|
|
|
'IEST', |
919
|
|
|
'IM', |
920
|
|
|
'CNAE', |
921
|
|
|
'CRT', |
922
|
|
|
'CNPJ', |
923
|
|
|
'CPF' |
924
|
|
|
]; |
925
|
|
|
$std = $this->equilizeParameters($std, $possible); |
926
|
|
|
$identificador = 'C01 <emit> - '; |
927
|
|
|
$this->emit = $this->dom->createElement("emit"); |
928
|
|
|
$this->dom->addChild( |
929
|
|
|
$this->emit, |
930
|
|
|
"CNPJ", |
931
|
|
|
Strings::onlyNumbers($std->CNPJ), |
932
|
|
|
false, |
933
|
|
|
$identificador . "CNPJ do emitente" |
934
|
|
|
); |
935
|
|
|
$this->dom->addChild( |
936
|
|
|
$this->emit, |
937
|
|
|
"CPF", |
938
|
|
|
Strings::onlyNumbers($std->CPF), |
939
|
|
|
false, |
940
|
|
|
$identificador . "CPF do remetente" |
941
|
|
|
); |
942
|
|
|
$this->dom->addChild( |
943
|
|
|
$this->emit, |
944
|
|
|
"xNome", |
945
|
|
|
substr(trim($std->xNome), 0, 60), |
946
|
|
|
true, |
947
|
|
|
$identificador . "Razão Social ou Nome do emitente" |
948
|
|
|
); |
949
|
|
|
$this->dom->addChild( |
950
|
|
|
$this->emit, |
951
|
|
|
"xFant", |
952
|
|
|
substr(trim($std->xFant), 0, 60), |
953
|
|
|
false, |
954
|
|
|
$identificador . "Nome fantasia do emitente" |
955
|
|
|
); |
956
|
|
|
if ($std->IE != 'ISENTO') { |
957
|
|
|
$std->IE = Strings::onlyNumbers($std->IE); |
958
|
|
|
} |
959
|
|
|
$this->dom->addChild( |
960
|
|
|
$this->emit, |
961
|
|
|
"IE", |
962
|
|
|
$std->IE, |
963
|
|
|
true, |
964
|
|
|
$identificador . "Inscrição Estadual do emitente" |
965
|
|
|
); |
966
|
|
|
$this->dom->addChild( |
967
|
|
|
$this->emit, |
968
|
|
|
"IEST", |
969
|
|
|
Strings::onlyNumbers($std->IEST), |
970
|
|
|
false, |
971
|
|
|
$identificador . "IE do Substituto Tributário do emitente" |
972
|
|
|
); |
973
|
|
|
$this->dom->addChild( |
974
|
|
|
$this->emit, |
975
|
|
|
"IM", |
976
|
|
|
Strings::onlyNumbers($std->IM), |
977
|
|
|
false, |
978
|
|
|
$identificador . "Inscrição Municipal do Prestador de Serviço do emitente" |
979
|
|
|
); |
980
|
|
|
$this->dom->addChild( |
981
|
|
|
$this->emit, |
982
|
|
|
"CNAE", |
983
|
|
|
Strings::onlyNumbers($std->CNAE), |
984
|
|
|
false, |
985
|
|
|
$identificador . "CNAE fiscal do emitente" |
986
|
|
|
); |
987
|
|
|
$this->dom->addChild( |
988
|
|
|
$this->emit, |
989
|
|
|
"CRT", |
990
|
|
|
$std->CRT, |
991
|
|
|
true, |
992
|
|
|
$identificador . "Código de Regime Tributário do emitente" |
993
|
|
|
); |
994
|
|
|
return $this->emit; |
995
|
|
|
} |
996
|
|
|
|
997
|
|
|
/** |
998
|
|
|
* Endereço do emitente C05 pai C01 |
999
|
|
|
* tag NFe/infNFe/emit/endEmit |
1000
|
|
|
* @param stdClass $std |
1001
|
|
|
* @return DOMElement |
1002
|
|
|
*/ |
1003
|
|
|
public function tagenderEmit(stdClass $std) |
1004
|
|
|
{ |
1005
|
|
|
$possible = [ |
1006
|
|
|
'xLgr', |
1007
|
|
|
'nro', |
1008
|
|
|
'xCpl', |
1009
|
|
|
'xBairro', |
1010
|
|
|
'cMun', |
1011
|
|
|
'xMun', |
1012
|
|
|
'UF', |
1013
|
|
|
'CEP', |
1014
|
|
|
'cPais', |
1015
|
|
|
'xPais', |
1016
|
|
|
'fone' |
1017
|
|
|
]; |
1018
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1019
|
|
|
|
1020
|
|
|
$identificador = 'C05 <enderEmit> - '; |
1021
|
|
|
$this->enderEmit = $this->dom->createElement("enderEmit"); |
1022
|
|
|
$this->dom->addChild( |
1023
|
|
|
$this->enderEmit, |
1024
|
|
|
"xLgr", |
1025
|
|
|
substr(trim($std->xLgr), 0, 60), |
1026
|
|
|
true, |
1027
|
|
|
$identificador . "Logradouro do Endereço do emitente" |
1028
|
|
|
); |
1029
|
|
|
$this->dom->addChild( |
1030
|
|
|
$this->enderEmit, |
1031
|
|
|
"nro", |
1032
|
|
|
substr(trim($std->nro), 0, 60), |
1033
|
|
|
true, |
1034
|
|
|
$identificador . "Número do Endereço do emitente" |
1035
|
|
|
); |
1036
|
|
|
$this->dom->addChild( |
1037
|
|
|
$this->enderEmit, |
1038
|
|
|
"xCpl", |
1039
|
|
|
substr(trim($std->xCpl), 0, 60), |
1040
|
|
|
false, |
1041
|
|
|
$identificador . "Complemento do Endereço do emitente" |
1042
|
|
|
); |
1043
|
|
|
$this->dom->addChild( |
1044
|
|
|
$this->enderEmit, |
1045
|
|
|
"xBairro", |
1046
|
|
|
substr(trim($std->xBairro), 0, 60), |
1047
|
|
|
true, |
1048
|
|
|
$identificador . "Bairro do Endereço do emitente" |
1049
|
|
|
); |
1050
|
|
|
$this->dom->addChild( |
1051
|
|
|
$this->enderEmit, |
1052
|
|
|
"cMun", |
1053
|
|
|
Strings::onlyNumbers($std->cMun), |
1054
|
|
|
true, |
1055
|
|
|
$identificador . "Código do município do Endereço do emitente" |
1056
|
|
|
); |
1057
|
|
|
$this->dom->addChild( |
1058
|
|
|
$this->enderEmit, |
1059
|
|
|
"xMun", |
1060
|
|
|
substr(trim($std->xMun), 0, 60), |
1061
|
|
|
true, |
1062
|
|
|
$identificador . "Nome do município do Endereço do emitente" |
1063
|
|
|
); |
1064
|
|
|
$this->dom->addChild( |
1065
|
|
|
$this->enderEmit, |
1066
|
|
|
"UF", |
1067
|
|
|
strtoupper(trim($std->UF)), |
1068
|
|
|
true, |
1069
|
|
|
$identificador . "Sigla da UF do Endereço do emitente" |
1070
|
|
|
); |
1071
|
|
|
$this->dom->addChild( |
1072
|
|
|
$this->enderEmit, |
1073
|
|
|
"CEP", |
1074
|
|
|
Strings::onlyNumbers($std->CEP), |
1075
|
|
|
true, |
1076
|
|
|
$identificador . "Código do CEP do Endereço do emitente" |
1077
|
|
|
); |
1078
|
|
|
$this->dom->addChild( |
1079
|
|
|
$this->enderEmit, |
1080
|
|
|
"cPais", |
1081
|
|
|
Strings::onlyNumbers($std->cPais), |
1082
|
|
|
false, |
1083
|
|
|
$identificador . "Código do País do Endereço do emitente" |
1084
|
|
|
); |
1085
|
|
|
$this->dom->addChild( |
1086
|
|
|
$this->enderEmit, |
1087
|
|
|
"xPais", |
1088
|
|
|
substr(trim($std->xPais), 0, 60), |
1089
|
|
|
false, |
1090
|
|
|
$identificador . "Nome do País do Endereço do emitente" |
1091
|
|
|
); |
1092
|
|
|
$this->dom->addChild( |
1093
|
|
|
$this->enderEmit, |
1094
|
|
|
"fone", |
1095
|
|
|
trim($std->fone), |
1096
|
|
|
false, |
1097
|
|
|
$identificador . "Telefone do Endereço do emitente" |
1098
|
|
|
); |
1099
|
|
|
$node = $this->emit->getElementsByTagName("IE")->item(0); |
1100
|
|
|
$this->emit->insertBefore($this->enderEmit, $node); |
1101
|
|
|
return $this->enderEmit; |
1102
|
|
|
} |
1103
|
|
|
|
1104
|
|
|
/** |
1105
|
|
|
* Identificação do Destinatário da NF-e E01 pai A01 |
1106
|
|
|
* tag NFe/infNFe/dest (opcional para modelo 65) |
1107
|
|
|
* @param stdClass $std |
1108
|
|
|
* @return DOMElement |
1109
|
|
|
*/ |
1110
|
|
|
public function tagdest(stdClass $std) |
1111
|
|
|
{ |
1112
|
|
|
$possible = [ |
1113
|
|
|
'xNome', |
1114
|
|
|
'indIEDest', |
1115
|
|
|
'IE', |
1116
|
|
|
'ISUF', |
1117
|
|
|
'IM', |
1118
|
|
|
'email', |
1119
|
|
|
'CNPJ', |
1120
|
|
|
'CPF', |
1121
|
|
|
'idEstrangeiro' |
1122
|
|
|
]; |
1123
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1124
|
|
|
$identificador = 'E01 <dest> - '; |
1125
|
|
|
$flagNome = true; //marca se xNome é ou não obrigatório |
1126
|
|
|
$temIE = $std->IE != '' && $std->IE != 'ISENTO'; // Tem inscrição municipal |
1127
|
|
|
$this->dest = $this->dom->createElement("dest"); |
1128
|
|
|
if (!$temIE && $std->indIEDest == 1) { |
1129
|
|
|
$std->indIEDest = 2; |
1130
|
|
|
} |
1131
|
|
|
if ($this->mod == '65') { |
1132
|
|
|
$std->indIEDest = 9; |
1133
|
|
|
if ($std->xNome == '') { |
1134
|
|
|
$flagNome = false; //marca se xNome é ou não obrigatório |
1135
|
|
|
} |
1136
|
|
|
} |
1137
|
|
|
$xNome = $std->xNome; |
1138
|
|
|
if ($this->tpAmb == '2') { |
1139
|
|
|
$xNome = 'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
1140
|
|
|
//a exigência do CNPJ 99999999000191 não existe mais |
1141
|
|
|
} |
1142
|
|
|
if (!empty($std->CNPJ)) { |
1143
|
|
|
$this->dom->addChild( |
1144
|
|
|
$this->dest, |
1145
|
|
|
"CNPJ", |
1146
|
|
|
Strings::onlyNumbers($std->CNPJ), |
1147
|
|
|
true, |
1148
|
|
|
$identificador . "CNPJ do destinatário" |
1149
|
|
|
); |
1150
|
|
|
} elseif (!empty($std->CPF)) { |
1151
|
|
|
$this->dom->addChild( |
1152
|
|
|
$this->dest, |
1153
|
|
|
"CPF", |
1154
|
|
|
Strings::onlyNumbers($std->CPF), |
1155
|
|
|
true, |
1156
|
|
|
$identificador . "CPF do destinatário" |
1157
|
|
|
); |
1158
|
|
|
} elseif ($std->idEstrangeiro !== null) { |
1159
|
|
|
$this->dom->addChild( |
1160
|
|
|
$this->dest, |
1161
|
|
|
"idEstrangeiro", |
1162
|
|
|
$std->idEstrangeiro, |
1163
|
|
|
true, |
1164
|
|
|
$identificador . "Identificação do destinatário no caso de comprador estrangeiro", |
1165
|
|
|
true |
1166
|
|
|
); |
1167
|
|
|
$std->indIEDest = '9'; |
1168
|
|
|
} |
1169
|
|
|
$this->dom->addChild( |
1170
|
|
|
$this->dest, |
1171
|
|
|
"xNome", |
1172
|
|
|
substr(trim($xNome), 0, 60), |
1173
|
|
|
$flagNome, //se mod 55 true ou mod 65 false |
1174
|
|
|
$identificador . "Razão Social ou nome do destinatário" |
1175
|
|
|
); |
1176
|
|
|
$this->dom->addChild( |
1177
|
|
|
$this->dest, |
1178
|
|
|
"indIEDest", |
1179
|
|
|
Strings::onlyNumbers($std->indIEDest), |
1180
|
|
|
true, |
1181
|
|
|
$identificador . "Indicador da IE do Destinatário" |
1182
|
|
|
); |
1183
|
|
|
if ($temIE) { |
1184
|
|
|
$this->dom->addChild( |
1185
|
|
|
$this->dest, |
1186
|
|
|
"IE", |
1187
|
|
|
$std->IE, |
1188
|
|
|
true, |
1189
|
|
|
$identificador . "Inscrição Estadual do Destinatário" |
1190
|
|
|
); |
1191
|
|
|
} |
1192
|
|
|
$this->dom->addChild( |
1193
|
|
|
$this->dest, |
1194
|
|
|
"ISUF", |
1195
|
|
|
Strings::onlyNumbers($std->ISUF), |
1196
|
|
|
false, |
1197
|
|
|
$identificador . "Inscrição na SUFRAMA do destinatário" |
1198
|
|
|
); |
1199
|
|
|
$this->dom->addChild( |
1200
|
|
|
$this->dest, |
1201
|
|
|
"IM", |
1202
|
|
|
Strings::onlyNumbers($std->IM), |
1203
|
|
|
false, |
1204
|
|
|
$identificador . "Inscrição Municipal do Tomador do Serviço do destinatário" |
1205
|
|
|
); |
1206
|
|
|
$this->dom->addChild( |
1207
|
|
|
$this->dest, |
1208
|
|
|
"email", |
1209
|
|
|
substr(trim($std->email), 0, 60), |
1210
|
|
|
false, |
1211
|
|
|
$identificador . "Email do destinatário" |
1212
|
|
|
); |
1213
|
|
|
return $this->dest; |
1214
|
|
|
} |
1215
|
|
|
|
1216
|
|
|
/** |
1217
|
|
|
* Endereço do Destinatário da NF-e E05 pai E01 |
1218
|
|
|
* tag NFe/infNFe/dest/enderDest (opcional para modelo 65) |
1219
|
|
|
* Os dados do destinatário devem ser inseridos antes deste método |
1220
|
|
|
* @param stdClass $std |
1221
|
|
|
* @return DOMElement |
1222
|
|
|
*/ |
1223
|
|
|
public function tagenderDest(stdClass $std) |
1224
|
|
|
{ |
1225
|
|
|
$possible = [ |
1226
|
|
|
'xLgr', |
1227
|
|
|
'nro', |
1228
|
|
|
'xCpl', |
1229
|
|
|
'xBairro', |
1230
|
|
|
'cMun', |
1231
|
|
|
'xMun', |
1232
|
|
|
'UF', |
1233
|
|
|
'CEP', |
1234
|
|
|
'cPais', |
1235
|
|
|
'xPais', |
1236
|
|
|
'fone' |
1237
|
|
|
]; |
1238
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1239
|
|
|
|
1240
|
|
|
$identificador = 'E05 <enderDest> - '; |
1241
|
|
|
if (empty($this->dest)) { |
1242
|
|
|
throw new RuntimeException('A TAG dest deve ser criada antes do endereço do mesmo.'); |
1243
|
|
|
} |
1244
|
|
|
$this->enderDest = $this->dom->createElement("enderDest"); |
1245
|
|
|
$this->dom->addChild( |
1246
|
|
|
$this->enderDest, |
1247
|
|
|
"xLgr", |
1248
|
|
|
$std->xLgr, |
1249
|
|
|
true, |
1250
|
|
|
$identificador . "Logradouro do Endereço do Destinatário" |
1251
|
|
|
); |
1252
|
|
|
$this->dom->addChild( |
1253
|
|
|
$this->enderDest, |
1254
|
|
|
"nro", |
1255
|
|
|
$std->nro, |
1256
|
|
|
true, |
1257
|
|
|
$identificador . "Número do Endereço do Destinatário" |
1258
|
|
|
); |
1259
|
|
|
$this->dom->addChild( |
1260
|
|
|
$this->enderDest, |
1261
|
|
|
"xCpl", |
1262
|
|
|
$std->xCpl, |
1263
|
|
|
false, |
1264
|
|
|
$identificador . "Complemento do Endereço do Destinatário" |
1265
|
|
|
); |
1266
|
|
|
$this->dom->addChild( |
1267
|
|
|
$this->enderDest, |
1268
|
|
|
"xBairro", |
1269
|
|
|
$std->xBairro, |
1270
|
|
|
true, |
1271
|
|
|
$identificador . "Bairro do Endereço do Destinatário" |
1272
|
|
|
); |
1273
|
|
|
$this->dom->addChild( |
1274
|
|
|
$this->enderDest, |
1275
|
|
|
"cMun", |
1276
|
|
|
$std->cMun, |
1277
|
|
|
true, |
1278
|
|
|
$identificador . "Código do município do Endereço do Destinatário" |
1279
|
|
|
); |
1280
|
|
|
$this->dom->addChild( |
1281
|
|
|
$this->enderDest, |
1282
|
|
|
"xMun", |
1283
|
|
|
$std->xMun, |
1284
|
|
|
true, |
1285
|
|
|
$identificador . "Nome do município do Endereço do Destinatário" |
1286
|
|
|
); |
1287
|
|
|
$this->dom->addChild( |
1288
|
|
|
$this->enderDest, |
1289
|
|
|
"UF", |
1290
|
|
|
$std->UF, |
1291
|
|
|
true, |
1292
|
|
|
$identificador . "Sigla da UF do Endereço do Destinatário" |
1293
|
|
|
); |
1294
|
|
|
$this->dom->addChild( |
1295
|
|
|
$this->enderDest, |
1296
|
|
|
"CEP", |
1297
|
|
|
$std->CEP, |
1298
|
|
|
false, |
1299
|
|
|
$identificador . "Código do CEP do Endereço do Destinatário" |
1300
|
|
|
); |
1301
|
|
|
$this->dom->addChild( |
1302
|
|
|
$this->enderDest, |
1303
|
|
|
"cPais", |
1304
|
|
|
$std->cPais, |
1305
|
|
|
false, |
1306
|
|
|
$identificador . "Código do País do Endereço do Destinatário" |
1307
|
|
|
); |
1308
|
|
|
$this->dom->addChild( |
1309
|
|
|
$this->enderDest, |
1310
|
|
|
"xPais", |
1311
|
|
|
$std->xPais, |
1312
|
|
|
false, |
1313
|
|
|
$identificador . "Nome do País do Endereço do Destinatário" |
1314
|
|
|
); |
1315
|
|
|
$this->dom->addChild( |
1316
|
|
|
$this->enderDest, |
1317
|
|
|
"fone", |
1318
|
|
|
$std->fone, |
1319
|
|
|
false, |
1320
|
|
|
$identificador . "Telefone do Endereço do Destinatário" |
1321
|
|
|
); |
1322
|
|
|
$node = $this->dest->getElementsByTagName("indIEDest")->item(0); |
1323
|
|
|
if (!isset($node)) { |
1324
|
|
|
$node = $this->dest->getElementsByTagName("IE")->item(0); |
1325
|
|
|
} |
1326
|
|
|
$this->dest->insertBefore($this->enderDest, $node); |
1327
|
|
|
return $this->enderDest; |
1328
|
|
|
} |
1329
|
|
|
|
1330
|
|
|
/** |
1331
|
|
|
* Identificação do Local de retirada F01 pai A01 |
1332
|
|
|
* tag NFe/infNFe/retirada (opcional) |
1333
|
|
|
* NOTA: ajustado para NT 2018.005 |
1334
|
|
|
* @param stdClass $std |
1335
|
|
|
* @return DOMElement |
1336
|
|
|
*/ |
1337
|
|
|
public function tagretirada(stdClass $std) |
1338
|
|
|
{ |
1339
|
|
|
$possible = [ |
1340
|
|
|
'xLgr', |
1341
|
|
|
'nro', |
1342
|
|
|
'xCpl', |
1343
|
|
|
'xBairro', |
1344
|
|
|
'cMun', |
1345
|
|
|
'xMun', |
1346
|
|
|
'UF', |
1347
|
|
|
'CNPJ', |
1348
|
|
|
'CPF', |
1349
|
|
|
'xNome', |
1350
|
|
|
'CEP', |
1351
|
|
|
'cPais', |
1352
|
|
|
'xPais', |
1353
|
|
|
'fone', |
1354
|
|
|
'email', |
1355
|
|
|
'IE' |
1356
|
|
|
]; |
1357
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1358
|
|
|
$identificador = 'F01 <retirada> - '; |
1359
|
|
|
$this->retirada = $this->dom->createElement("retirada"); |
1360
|
|
|
$this->dom->addChild( |
1361
|
|
|
$this->retirada, |
1362
|
|
|
"CNPJ", |
1363
|
|
|
$std->CNPJ, |
1364
|
|
|
false, |
1365
|
|
|
$identificador . "CNPJ do Cliente da Retirada" |
1366
|
|
|
); |
1367
|
|
|
$this->dom->addChild( |
1368
|
|
|
$this->retirada, |
1369
|
|
|
"CPF", |
1370
|
|
|
$std->CPF, |
1371
|
|
|
false, |
1372
|
|
|
$identificador . "CPF do Cliente da Retirada" |
1373
|
|
|
); |
1374
|
|
|
$this->dom->addChild( |
1375
|
|
|
$this->retirada, |
1376
|
|
|
"xNome", |
1377
|
|
|
$std->xNome, |
1378
|
|
|
false, |
1379
|
|
|
$identificador . "Nome do Cliente da Retirada" |
1380
|
|
|
); |
1381
|
|
|
$this->dom->addChild( |
1382
|
|
|
$this->retirada, |
1383
|
|
|
"xLgr", |
1384
|
|
|
$std->xLgr, |
1385
|
|
|
true, |
1386
|
|
|
$identificador . "Logradouro do Endereco do Cliente da Retirada" |
1387
|
|
|
); |
1388
|
|
|
$this->dom->addChild( |
1389
|
|
|
$this->retirada, |
1390
|
|
|
"nro", |
1391
|
|
|
$std->nro, |
1392
|
|
|
true, |
1393
|
|
|
$identificador . "Número do Endereco do Cliente da Retirada" |
1394
|
|
|
); |
1395
|
|
|
$this->dom->addChild( |
1396
|
|
|
$this->retirada, |
1397
|
|
|
"xCpl", |
1398
|
|
|
$std->xCpl, |
1399
|
|
|
false, |
1400
|
|
|
$identificador . "Complemento do Endereco do Cliente da Retirada" |
1401
|
|
|
); |
1402
|
|
|
$this->dom->addChild( |
1403
|
|
|
$this->retirada, |
1404
|
|
|
"xBairro", |
1405
|
|
|
$std->xBairro, |
1406
|
|
|
true, |
1407
|
|
|
$identificador . "Bairro do Endereco do Cliente da Retirada" |
1408
|
|
|
); |
1409
|
|
|
$this->dom->addChild( |
1410
|
|
|
$this->retirada, |
1411
|
|
|
"cMun", |
1412
|
|
|
$std->cMun, |
1413
|
|
|
true, |
1414
|
|
|
$identificador . "Código do município do Endereco do Cliente da Retirada" |
1415
|
|
|
); |
1416
|
|
|
$this->dom->addChild( |
1417
|
|
|
$this->retirada, |
1418
|
|
|
"xMun", |
1419
|
|
|
$std->xMun, |
1420
|
|
|
true, |
1421
|
|
|
$identificador . "Nome do município do Endereco do Cliente da Retirada" |
1422
|
|
|
); |
1423
|
|
|
$this->dom->addChild( |
1424
|
|
|
$this->retirada, |
1425
|
|
|
"UF", |
1426
|
|
|
$std->UF, |
1427
|
|
|
true, |
1428
|
|
|
$identificador . "Sigla da UF do Endereco do Cliente da Retirada" |
1429
|
|
|
); |
1430
|
|
|
$this->dom->addChild( |
1431
|
|
|
$this->retirada, |
1432
|
|
|
"CEP", |
1433
|
|
|
$std->CEP, |
1434
|
|
|
false, |
1435
|
|
|
$identificador . "CEP do Endereco do Cliente da Retirada" |
1436
|
|
|
); |
1437
|
|
|
$this->dom->addChild( |
1438
|
|
|
$this->retirada, |
1439
|
|
|
"cPais", |
1440
|
|
|
$std->cPais, |
1441
|
|
|
false, |
1442
|
|
|
$identificador . "Codigo do Pais do Endereco do Cliente da Retirada" |
1443
|
|
|
); |
1444
|
|
|
$this->dom->addChild( |
1445
|
|
|
$this->retirada, |
1446
|
|
|
"xPais", |
1447
|
|
|
$std->xPais, |
1448
|
|
|
false, |
1449
|
|
|
$identificador . "Pais do Endereco do Cliente da Retirada" |
1450
|
|
|
); |
1451
|
|
|
$this->dom->addChild( |
1452
|
|
|
$this->retirada, |
1453
|
|
|
"fone", |
1454
|
|
|
$std->fone, |
1455
|
|
|
false, |
1456
|
|
|
$identificador . "Fone do Endereco do Cliente da Retirada" |
1457
|
|
|
); |
1458
|
|
|
$this->dom->addChild( |
1459
|
|
|
$this->retirada, |
1460
|
|
|
"email", |
1461
|
|
|
$std->email, |
1462
|
|
|
false, |
1463
|
|
|
$identificador . "Email do Endereco do Cliente da Retirada" |
1464
|
|
|
); |
1465
|
|
|
$this->dom->addChild( |
1466
|
|
|
$this->retirada, |
1467
|
|
|
"IE", |
1468
|
|
|
$std->IE, |
1469
|
|
|
false, |
1470
|
|
|
$identificador . "IE do Cliente da Retirada" |
1471
|
|
|
); |
1472
|
|
|
return $this->retirada; |
1473
|
|
|
} |
1474
|
|
|
|
1475
|
|
|
/** |
1476
|
|
|
* Identificação do Local de entrega G01 pai A01 |
1477
|
|
|
* tag NFe/infNFe/entrega (opcional) |
1478
|
|
|
* NOTA: ajustado para NT 2018.005 |
1479
|
|
|
* @param stdClass $std |
1480
|
|
|
* @return DOMElement |
1481
|
|
|
*/ |
1482
|
|
|
public function tagentrega(stdClass $std) |
1483
|
|
|
{ |
1484
|
|
|
$possible = [ |
1485
|
|
|
'xLgr', |
1486
|
|
|
'nro', |
1487
|
|
|
'xCpl', |
1488
|
|
|
'xBairro', |
1489
|
|
|
'cMun', |
1490
|
|
|
'xMun', |
1491
|
|
|
'UF', |
1492
|
|
|
'CNPJ', |
1493
|
|
|
'CPF', |
1494
|
|
|
'xNome', |
1495
|
|
|
'CEP', |
1496
|
|
|
'cPais', |
1497
|
|
|
'xPais', |
1498
|
|
|
'fone', |
1499
|
|
|
'email', |
1500
|
|
|
'IE' |
1501
|
|
|
]; |
1502
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1503
|
|
|
$identificador = 'G01 <entrega> - '; |
1504
|
|
|
$this->entrega = $this->dom->createElement("entrega"); |
1505
|
|
|
$this->dom->addChild( |
1506
|
|
|
$this->entrega, |
1507
|
|
|
"CNPJ", |
1508
|
|
|
$std->CNPJ, |
1509
|
|
|
false, |
1510
|
|
|
$identificador . "CNPJ do Cliente da Entrega" |
1511
|
|
|
); |
1512
|
|
|
$this->dom->addChild( |
1513
|
|
|
$this->entrega, |
1514
|
|
|
"CPF", |
1515
|
|
|
$std->CPF, |
1516
|
|
|
false, |
1517
|
|
|
$identificador . "CPF do Cliente da Entrega" |
1518
|
|
|
); |
1519
|
|
|
$this->dom->addChild( |
1520
|
|
|
$this->entrega, |
1521
|
|
|
"xNome", |
1522
|
|
|
$std->xNome, |
1523
|
|
|
false, |
1524
|
|
|
$identificador . "Nome do Cliente da Entrega" |
1525
|
|
|
); |
1526
|
|
|
$this->dom->addChild( |
1527
|
|
|
$this->entrega, |
1528
|
|
|
"xLgr", |
1529
|
|
|
$std->xLgr, |
1530
|
|
|
true, |
1531
|
|
|
$identificador . "Logradouro do Endereco do Cliente da Entrega" |
1532
|
|
|
); |
1533
|
|
|
$this->dom->addChild( |
1534
|
|
|
$this->entrega, |
1535
|
|
|
"nro", |
1536
|
|
|
$std->nro, |
1537
|
|
|
true, |
1538
|
|
|
$identificador . "Número do Endereco do Cliente da Entrega" |
1539
|
|
|
); |
1540
|
|
|
$this->dom->addChild( |
1541
|
|
|
$this->entrega, |
1542
|
|
|
"xCpl", |
1543
|
|
|
$std->xCpl, |
1544
|
|
|
false, |
1545
|
|
|
$identificador . "Complemento do Endereco do Cliente da Entrega" |
1546
|
|
|
); |
1547
|
|
|
$this->dom->addChild( |
1548
|
|
|
$this->entrega, |
1549
|
|
|
"xBairro", |
1550
|
|
|
$std->xBairro, |
1551
|
|
|
true, |
1552
|
|
|
$identificador . "Bairro do Endereco do Cliente da Entrega" |
1553
|
|
|
); |
1554
|
|
|
$this->dom->addChild( |
1555
|
|
|
$this->entrega, |
1556
|
|
|
"cMun", |
1557
|
|
|
$std->cMun, |
1558
|
|
|
true, |
1559
|
|
|
$identificador . "Código do município do Endereco do Cliente da Entrega" |
1560
|
|
|
); |
1561
|
|
|
$this->dom->addChild( |
1562
|
|
|
$this->entrega, |
1563
|
|
|
"xMun", |
1564
|
|
|
$std->xMun, |
1565
|
|
|
true, |
1566
|
|
|
$identificador . "Nome do município do Endereco do Cliente da Entrega" |
1567
|
|
|
); |
1568
|
|
|
$this->dom->addChild( |
1569
|
|
|
$this->entrega, |
1570
|
|
|
"UF", |
1571
|
|
|
$std->UF, |
1572
|
|
|
true, |
1573
|
|
|
$identificador . "Sigla da UF do Endereco do Cliente da Entrega" |
1574
|
|
|
); |
1575
|
|
|
$this->dom->addChild( |
1576
|
|
|
$this->entrega, |
1577
|
|
|
"CEP", |
1578
|
|
|
$std->CEP, |
1579
|
|
|
false, |
1580
|
|
|
$identificador . "CEP do Endereco do Cliente da Entrega" |
1581
|
|
|
); |
1582
|
|
|
$this->dom->addChild( |
1583
|
|
|
$this->entrega, |
1584
|
|
|
"cPais", |
1585
|
|
|
$std->cPais, |
1586
|
|
|
false, |
1587
|
|
|
$identificador . "Codigo do Pais do Endereco do Cliente da Entrega" |
1588
|
|
|
); |
1589
|
|
|
$this->dom->addChild( |
1590
|
|
|
$this->entrega, |
1591
|
|
|
"xPais", |
1592
|
|
|
$std->xPais, |
1593
|
|
|
false, |
1594
|
|
|
$identificador . "Pais do Endereco do Cliente da Entrega" |
1595
|
|
|
); |
1596
|
|
|
$this->dom->addChild( |
1597
|
|
|
$this->entrega, |
1598
|
|
|
"fone", |
1599
|
|
|
$std->fone, |
1600
|
|
|
false, |
1601
|
|
|
$identificador . "Fone do Endereco do Cliente da Entrega" |
1602
|
|
|
); |
1603
|
|
|
$this->dom->addChild( |
1604
|
|
|
$this->entrega, |
1605
|
|
|
"email", |
1606
|
|
|
$std->email, |
1607
|
|
|
false, |
1608
|
|
|
$identificador . "Email do Endereco do Cliente da Entrega" |
1609
|
|
|
); |
1610
|
|
|
$this->dom->addChild( |
1611
|
|
|
$this->entrega, |
1612
|
|
|
"IE", |
1613
|
|
|
$std->IE, |
1614
|
|
|
false, |
1615
|
|
|
$identificador . "IE do Cliente da Entrega" |
1616
|
|
|
); |
1617
|
|
|
return $this->entrega; |
1618
|
|
|
} |
1619
|
|
|
|
1620
|
|
|
/** |
1621
|
|
|
* Pessoas autorizadas para o download do XML da NF-e G50 pai A01 |
1622
|
|
|
* tag NFe/infNFe/autXML |
1623
|
|
|
* @param stdClass $std |
1624
|
|
|
* @return DOMElement |
1625
|
|
|
*/ |
1626
|
|
|
public function tagautXML(stdClass $std) |
1627
|
|
|
{ |
1628
|
|
|
$possible = ['CNPJ', 'CPF']; |
1629
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1630
|
|
|
$identificador = 'G50 <autXML> - '; |
1631
|
|
|
$std->CNPJ = !empty($std->CNPJ) ? $std->CNPJ : null; |
1632
|
|
|
$std->CPF = !empty($std->CPF) ? $std->CPF : null; |
1633
|
|
|
$autXML = $this->dom->createElement("autXML"); |
1634
|
|
|
$this->dom->addChild( |
1635
|
|
|
$autXML, |
1636
|
|
|
"CNPJ", |
1637
|
|
|
$std->CNPJ, |
1638
|
|
|
false, |
1639
|
|
|
$identificador . "CNPJ do Cliente Autorizado" |
1640
|
|
|
); |
1641
|
|
|
$this->dom->addChild( |
1642
|
|
|
$autXML, |
1643
|
|
|
"CPF", |
1644
|
|
|
$std->CPF, |
1645
|
|
|
false, |
1646
|
|
|
$identificador . "CPF do Cliente Autorizado" |
1647
|
|
|
); |
1648
|
|
|
$this->aAutXML[] = $autXML; |
1649
|
|
|
return $autXML; |
1650
|
|
|
} |
1651
|
|
|
|
1652
|
|
|
/** |
1653
|
|
|
* Informações adicionais do produto V01 pai H01 |
1654
|
|
|
* tag NFe/infNFe/det[]/infAdProd |
1655
|
|
|
* @param stdClass $std |
1656
|
|
|
* @return DOMElement |
1657
|
|
|
*/ |
1658
|
|
|
public function taginfAdProd(stdClass $std) |
1659
|
|
|
{ |
1660
|
|
|
$possible = ['item', 'infAdProd']; |
1661
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1662
|
|
|
$infAdProd = $this->dom->createElement( |
1663
|
|
|
"infAdProd", |
1664
|
|
|
substr(trim($std->infAdProd), 0, 500) |
1665
|
|
|
); |
1666
|
|
|
$this->aInfAdProd[$std->item] = $infAdProd; |
1667
|
|
|
return $infAdProd; |
1668
|
|
|
} |
1669
|
|
|
|
1670
|
|
|
/** |
1671
|
|
|
* Detalhamento de Produtos e Serviços I01 pai H01 |
1672
|
|
|
* tag NFe/infNFe/det[]/prod |
1673
|
|
|
* NOTA: Ajustado para NT2016_002_v1.30 |
1674
|
|
|
* @param stdClass $std |
1675
|
|
|
* @return DOMElement |
1676
|
|
|
*/ |
1677
|
|
|
public function tagprod(stdClass $std) |
1678
|
|
|
{ |
1679
|
|
|
$possible = [ |
1680
|
|
|
'item', |
1681
|
|
|
'cProd', |
1682
|
|
|
'cEAN', |
1683
|
|
|
'xProd', |
1684
|
|
|
'NCM', |
1685
|
|
|
'cBenef', |
1686
|
|
|
'EXTIPI', |
1687
|
|
|
'CFOP', |
1688
|
|
|
'uCom', |
1689
|
|
|
'qCom', |
1690
|
|
|
'vUnCom', |
1691
|
|
|
'vProd', |
1692
|
|
|
'cEANTrib', |
1693
|
|
|
'uTrib', |
1694
|
|
|
'qTrib', |
1695
|
|
|
'vUnTrib', |
1696
|
|
|
'vFrete', |
1697
|
|
|
'vSeg', |
1698
|
|
|
'vDesc', |
1699
|
|
|
'vOutro', |
1700
|
|
|
'indTot', |
1701
|
|
|
'xPed', |
1702
|
|
|
'nItemPed', |
1703
|
|
|
'nFCI' |
1704
|
|
|
]; |
1705
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1706
|
|
|
//totalizador |
1707
|
|
|
if ($std->indTot == 1) { |
1708
|
|
|
$this->stdTot->vProd += (float) $std->vProd; |
1709
|
|
|
} |
1710
|
|
|
$this->stdTot->vFrete += (float) $std->vFrete; |
1711
|
|
|
$this->stdTot->vSeg += (float) $std->vSeg; |
1712
|
|
|
$this->stdTot->vDesc += (float) $std->vDesc; |
1713
|
|
|
$this->stdTot->vOutro += (float) $std->vOutro; |
1714
|
|
|
|
1715
|
|
|
$cean = !empty($std->cEAN) ? trim(strtoupper($std->cEAN)) : ''; |
1716
|
|
|
$ceantrib = !empty($std->cEANTrib) ? trim(strtoupper($std->cEANTrib)) : ''; |
1717
|
|
|
//throw exception if not is Valid |
1718
|
|
|
Gtin::isValid($cean); |
1719
|
|
|
Gtin::isValid($ceantrib); |
1720
|
|
|
$identificador = 'I01 <prod> - '; |
1721
|
|
|
$prod = $this->dom->createElement("prod"); |
1722
|
|
|
$this->dom->addChild( |
1723
|
|
|
$prod, |
1724
|
|
|
"cProd", |
1725
|
|
|
$std->cProd, |
1726
|
|
|
true, |
1727
|
|
|
$identificador . "[item $std->item] Código do produto ou serviço" |
1728
|
|
|
); |
1729
|
|
|
$this->dom->addChild( |
1730
|
|
|
$prod, |
1731
|
|
|
"cEAN", |
1732
|
|
|
$cean, |
1733
|
|
|
true, |
1734
|
|
|
$identificador . "[item $std->item] GTIN (Global Trade Item Number) do produto, antigo " |
1735
|
|
|
. "código EAN ou código de barras", |
1736
|
|
|
true |
1737
|
|
|
); |
1738
|
|
|
$xProd = $std->xProd; |
1739
|
|
|
if ($this->tpAmb == '2' && $this->mod == '65' && $std->item === 1) { |
1740
|
|
|
$xProd = 'NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
1741
|
|
|
} |
1742
|
|
|
$this->dom->addChild( |
1743
|
|
|
$prod, |
1744
|
|
|
"xProd", |
1745
|
|
|
$xProd, |
1746
|
|
|
true, |
1747
|
|
|
$identificador . "[item $std->item] Descrição do produto ou serviço" |
1748
|
|
|
); |
1749
|
|
|
$this->dom->addChild( |
1750
|
|
|
$prod, |
1751
|
|
|
"NCM", |
1752
|
|
|
$std->NCM, |
1753
|
|
|
true, |
1754
|
|
|
$identificador . "[item $std->item] Código NCM com 8 dígitos ou 2 dígitos (gênero)" |
1755
|
|
|
); |
1756
|
|
|
//incluido no layout 4.00 |
1757
|
|
|
$this->dom->addChild( |
1758
|
|
|
$prod, |
1759
|
|
|
"cBenef", |
1760
|
|
|
$std->cBenef, |
1761
|
|
|
false, |
1762
|
|
|
$identificador . "[item $std->item] Código de Benefício Fiscal utilizado pela UF" |
1763
|
|
|
); |
1764
|
|
|
$this->dom->addChild( |
1765
|
|
|
$prod, |
1766
|
|
|
"EXTIPI", |
1767
|
|
|
$std->EXTIPI, |
1768
|
|
|
false, |
1769
|
|
|
$identificador . "[item $std->item] Preencher de acordo com o código EX da TIPI" |
1770
|
|
|
); |
1771
|
|
|
$this->dom->addChild( |
1772
|
|
|
$prod, |
1773
|
|
|
"CFOP", |
1774
|
|
|
$std->CFOP, |
1775
|
|
|
true, |
1776
|
|
|
$identificador . "[item $std->item] Código Fiscal de Operações e Prestações" |
1777
|
|
|
); |
1778
|
|
|
$this->dom->addChild( |
1779
|
|
|
$prod, |
1780
|
|
|
"uCom", |
1781
|
|
|
$std->uCom, |
1782
|
|
|
true, |
1783
|
|
|
$identificador . "[item $std->item] Unidade Comercial do produto" |
1784
|
|
|
); |
1785
|
|
|
$this->dom->addChild( |
1786
|
|
|
$prod, |
1787
|
|
|
"qCom", |
1788
|
|
|
$std->qCom, |
1789
|
|
|
true, |
1790
|
|
|
$identificador . "[item $std->item] Quantidade Comercial do produto" |
1791
|
|
|
); |
1792
|
|
|
$this->dom->addChild( |
1793
|
|
|
$prod, |
1794
|
|
|
"vUnCom", |
1795
|
|
|
$std->vUnCom, |
1796
|
|
|
true, |
1797
|
|
|
$identificador . "[item $std->item] Valor Unitário de Comercialização do produto" |
1798
|
|
|
); |
1799
|
|
|
$this->dom->addChild( |
1800
|
|
|
$prod, |
1801
|
|
|
"vProd", |
1802
|
|
|
$std->vProd, |
1803
|
|
|
true, |
1804
|
|
|
$identificador . "[item $std->item] Valor Total Bruto dos Produtos ou Serviços" |
1805
|
|
|
); |
1806
|
|
|
$this->dom->addChild( |
1807
|
|
|
$prod, |
1808
|
|
|
"cEANTrib", |
1809
|
|
|
$ceantrib, |
1810
|
|
|
true, |
1811
|
|
|
$identificador . "[item $std->item] GTIN (Global Trade Item Number) da unidade tributável, antigo " |
1812
|
|
|
. "código EAN ou código de barras", |
1813
|
|
|
true |
1814
|
|
|
); |
1815
|
|
|
$this->dom->addChild( |
1816
|
|
|
$prod, |
1817
|
|
|
"uTrib", |
1818
|
|
|
$std->uTrib, |
1819
|
|
|
true, |
1820
|
|
|
$identificador . "[item $std->item] Unidade Tributável do produto" |
1821
|
|
|
); |
1822
|
|
|
$this->dom->addChild( |
1823
|
|
|
$prod, |
1824
|
|
|
"qTrib", |
1825
|
|
|
$std->qTrib, |
1826
|
|
|
true, |
1827
|
|
|
$identificador . "[item $std->item] Quantidade Tributável do produto" |
1828
|
|
|
); |
1829
|
|
|
$this->dom->addChild( |
1830
|
|
|
$prod, |
1831
|
|
|
"vUnTrib", |
1832
|
|
|
$std->vUnTrib, |
1833
|
|
|
true, |
1834
|
|
|
$identificador . "[item $std->item] Valor Unitário de tributação do produto" |
1835
|
|
|
); |
1836
|
|
|
$this->dom->addChild( |
1837
|
|
|
$prod, |
1838
|
|
|
"vFrete", |
1839
|
|
|
$this->conditionalNumberFormatting($std->vFrete), |
1840
|
|
|
false, |
1841
|
|
|
$identificador . "[item $std->item] Valor Total do Frete" |
1842
|
|
|
); |
1843
|
|
|
$this->dom->addChild( |
1844
|
|
|
$prod, |
1845
|
|
|
"vSeg", |
1846
|
|
|
$this->conditionalNumberFormatting($std->vSeg), |
1847
|
|
|
false, |
1848
|
|
|
$identificador . "[item $std->item] Valor Total do Seguro" |
1849
|
|
|
); |
1850
|
|
|
$this->dom->addChild( |
1851
|
|
|
$prod, |
1852
|
|
|
"vDesc", |
1853
|
|
|
$this->conditionalNumberFormatting($std->vDesc), |
1854
|
|
|
false, |
1855
|
|
|
$identificador . "[item $std->item] Valor do Desconto" |
1856
|
|
|
); |
1857
|
|
|
$this->dom->addChild( |
1858
|
|
|
$prod, |
1859
|
|
|
"vOutro", |
1860
|
|
|
$this->conditionalNumberFormatting($std->vOutro), |
1861
|
|
|
false, |
1862
|
|
|
$identificador . "[item $std->item] Outras despesas acessórias" |
1863
|
|
|
); |
1864
|
|
|
$this->dom->addChild( |
1865
|
|
|
$prod, |
1866
|
|
|
"indTot", |
1867
|
|
|
$std->indTot, |
1868
|
|
|
true, |
1869
|
|
|
$identificador . "[item $std->item] Indica se valor do Item (vProd) entra no valor total da NF-e (vProd)" |
1870
|
|
|
); |
1871
|
|
|
$this->dom->addChild( |
1872
|
|
|
$prod, |
1873
|
|
|
"xPed", |
1874
|
|
|
$std->xPed, |
1875
|
|
|
false, |
1876
|
|
|
$identificador . "[item $std->item] Número do Pedido de Compra" |
1877
|
|
|
); |
1878
|
|
|
$this->dom->addChild( |
1879
|
|
|
$prod, |
1880
|
|
|
"nItemPed", |
1881
|
|
|
$std->nItemPed, |
1882
|
|
|
false, |
1883
|
|
|
$identificador . "[item $std->item] Item do Pedido de Compra" |
1884
|
|
|
); |
1885
|
|
|
$this->dom->addChild( |
1886
|
|
|
$prod, |
1887
|
|
|
"nFCI", |
1888
|
|
|
$std->nFCI, |
1889
|
|
|
false, |
1890
|
|
|
$identificador . "[item $std->item] Número de controle da FCI " |
1891
|
|
|
. "Ficha de Conteúdo de Importação" |
1892
|
|
|
); |
1893
|
|
|
$this->aProd[$std->item] = $prod; |
1894
|
|
|
return $prod; |
1895
|
|
|
} |
1896
|
|
|
|
1897
|
|
|
/** |
1898
|
|
|
* NVE NOMENCLATURA DE VALOR ADUANEIRO E ESTATÍSTICA |
1899
|
|
|
* Podem ser até 8 NVE's por item |
1900
|
|
|
* |
1901
|
|
|
* @param stdClass $std |
1902
|
|
|
* @return DOMElement|null |
1903
|
|
|
*/ |
1904
|
|
|
public function tagNVE(stdClass $std) |
1905
|
|
|
{ |
1906
|
|
|
$possible = ['item', 'NVE']; |
1907
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1908
|
|
|
|
1909
|
|
|
if ($std->NVE == '') { |
1910
|
|
|
return null; |
1911
|
|
|
} |
1912
|
|
|
$nve = $this->dom->createElement("NVE", $std->NVE); |
1913
|
|
|
$this->aNVE[$std->item][] = $nve; |
1914
|
|
|
return $nve; |
1915
|
|
|
} |
1916
|
|
|
|
1917
|
|
|
/** |
1918
|
|
|
* Código Especificador da Substituição Tributária – CEST, |
1919
|
|
|
* que identifica a mercadoria sujeita aos regimes de substituição |
1920
|
|
|
* tributária e de antecipação do recolhimento do imposto. |
1921
|
|
|
* vide NT2015.003 I05C pai |
1922
|
|
|
* tag NFe/infNFe/det[item]/prod/CEST (opcional) |
1923
|
|
|
* NOTA: Ajustado para NT2016_002_v1.30 |
1924
|
|
|
* @param stdClass $std |
1925
|
|
|
* @return DOMElement |
1926
|
|
|
*/ |
1927
|
|
|
public function tagCEST(stdClass $std) |
1928
|
|
|
{ |
1929
|
|
|
$possible = ['item', 'CEST', 'indEscala', 'CNPJFab']; |
1930
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1931
|
|
|
$identificador = 'I05b <ctrltST> - '; |
1932
|
|
|
$ctrltST = $this->dom->createElement("ctrltST"); |
1933
|
|
|
$this->dom->addChild( |
1934
|
|
|
$ctrltST, |
1935
|
|
|
"CEST", |
1936
|
|
|
Strings::onlyNumbers($std->CEST), |
1937
|
|
|
true, |
1938
|
|
|
"$identificador [item $std->item] Numero CEST" |
1939
|
|
|
); |
1940
|
|
|
//incluido no layout 4.00 |
1941
|
|
|
$this->dom->addChild( |
1942
|
|
|
$ctrltST, |
1943
|
|
|
"indEscala", |
1944
|
|
|
trim($std->indEscala), |
1945
|
|
|
false, |
1946
|
|
|
"$identificador [item $std->item] Indicador de Produção em escala relevante" |
1947
|
|
|
); |
1948
|
|
|
//incluido no layout 4.00 |
1949
|
|
|
$this->dom->addChild( |
1950
|
|
|
$ctrltST, |
1951
|
|
|
"CNPJFab", |
1952
|
|
|
Strings::onlyNumbers($std->CNPJFab), |
1953
|
|
|
false, |
1954
|
|
|
"$identificador [item $std->item] CNPJ do Fabricante da Mercadoria," |
1955
|
|
|
. "obrigatório para produto em escala NÃO relevante." |
1956
|
|
|
); |
1957
|
|
|
$this->aCest[$std->item][] = $ctrltST; |
1958
|
|
|
return $ctrltST; |
1959
|
|
|
} |
1960
|
|
|
|
1961
|
|
|
/** |
1962
|
|
|
* tag NFe/infNFe/det[item]/prod/nRECOPI |
1963
|
|
|
* @param stdClass $std |
1964
|
|
|
* @return DOMElement |
1965
|
|
|
*/ |
1966
|
|
|
public function tagRECOPI(stdClass $std) |
1967
|
|
|
{ |
1968
|
|
|
$possible = ['item', 'nRECOPI']; |
1969
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1970
|
|
|
$recopi = $this->dom->createElement("nRECOPI", $std->nRECOPI); |
1971
|
|
|
$this->aRECOPI[$std->item] = $recopi; |
1972
|
|
|
return $recopi; |
1973
|
|
|
} |
1974
|
|
|
|
1975
|
|
|
/** |
1976
|
|
|
* Declaração de Importação I8 pai I01 |
1977
|
|
|
* tag NFe/infNFe/det[]/prod/DI |
1978
|
|
|
* @param stdClass $std |
1979
|
|
|
* @return DOMElement |
1980
|
|
|
*/ |
1981
|
|
|
public function tagDI(stdClass $std) |
1982
|
|
|
{ |
1983
|
|
|
$possible = [ |
1984
|
|
|
'item', |
1985
|
|
|
'nDI', |
1986
|
|
|
'dDI', |
1987
|
|
|
'xLocDesemb', |
1988
|
|
|
'UFDesemb', |
1989
|
|
|
'dDesemb', |
1990
|
|
|
'tpViaTransp', |
1991
|
|
|
'vAFRMM', |
1992
|
|
|
'tpIntermedio', |
1993
|
|
|
'CNPJ', |
1994
|
|
|
'UFTerceiro', |
1995
|
|
|
'cExportador' |
1996
|
|
|
]; |
1997
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1998
|
|
|
$identificador = 'I8 <DI> - '; |
1999
|
|
|
$tDI = $this->dom->createElement("DI"); |
2000
|
|
|
$this->dom->addChild( |
2001
|
|
|
$tDI, |
2002
|
|
|
"nDI", |
2003
|
|
|
$std->nDI, |
2004
|
|
|
true, |
2005
|
|
|
$identificador . "[item $std->item] Número do Documento de Importação (DI, DSI, DIRE, ...)" |
2006
|
|
|
); |
2007
|
|
|
$this->dom->addChild( |
2008
|
|
|
$tDI, |
2009
|
|
|
"dDI", |
2010
|
|
|
$std->dDI, |
2011
|
|
|
true, |
2012
|
|
|
$identificador . "[item $std->item] Data de Registro do documento" |
2013
|
|
|
); |
2014
|
|
|
$this->dom->addChild( |
2015
|
|
|
$tDI, |
2016
|
|
|
"xLocDesemb", |
2017
|
|
|
$std->xLocDesemb, |
2018
|
|
|
true, |
2019
|
|
|
$identificador . "[item $std->item] Local de desembaraço" |
2020
|
|
|
); |
2021
|
|
|
$this->dom->addChild( |
2022
|
|
|
$tDI, |
2023
|
|
|
"UFDesemb", |
2024
|
|
|
$std->UFDesemb, |
2025
|
|
|
true, |
2026
|
|
|
$identificador . "[item $std->item] Sigla da UF onde ocorreu o Desembaraço Aduaneiro" |
2027
|
|
|
); |
2028
|
|
|
$this->dom->addChild( |
2029
|
|
|
$tDI, |
2030
|
|
|
"dDesemb", |
2031
|
|
|
$std->dDesemb, |
2032
|
|
|
true, |
2033
|
|
|
$identificador . "[item $std->item] Data do Desembaraço Aduaneiro" |
2034
|
|
|
); |
2035
|
|
|
$this->dom->addChild( |
2036
|
|
|
$tDI, |
2037
|
|
|
"tpViaTransp", |
2038
|
|
|
$std->tpViaTransp, |
2039
|
|
|
true, |
2040
|
|
|
$identificador . "[item $std->item] Via de transporte internacional " |
2041
|
|
|
. "informada na Declaração de Importação (DI)" |
2042
|
|
|
); |
2043
|
|
|
$this->dom->addChild( |
2044
|
|
|
$tDI, |
2045
|
|
|
"vAFRMM", |
2046
|
|
|
$this->conditionalNumberFormatting($std->vAFRMM), |
2047
|
|
|
false, |
2048
|
|
|
$identificador . "[item $std->item] Valor da AFRMM " |
2049
|
|
|
. "- Adicional ao Frete para Renovação da Marinha Mercante" |
2050
|
|
|
); |
2051
|
|
|
$this->dom->addChild( |
2052
|
|
|
$tDI, |
2053
|
|
|
"tpIntermedio", |
2054
|
|
|
$std->tpIntermedio, |
2055
|
|
|
true, |
2056
|
|
|
$identificador . "[item $std->item] Forma de importação quanto a intermediação" |
2057
|
|
|
); |
2058
|
|
|
$this->dom->addChild( |
2059
|
|
|
$tDI, |
2060
|
|
|
"CNPJ", |
2061
|
|
|
$std->CNPJ, |
2062
|
|
|
false, |
2063
|
|
|
$identificador . "[item $std->item] CNPJ do adquirente ou do encomendante" |
2064
|
|
|
); |
2065
|
|
|
$this->dom->addChild( |
2066
|
|
|
$tDI, |
2067
|
|
|
"UFTerceiro", |
2068
|
|
|
$std->UFTerceiro, |
2069
|
|
|
false, |
2070
|
|
|
$identificador . "[item $std->item] Sigla da UF do adquirente ou do encomendante" |
2071
|
|
|
); |
2072
|
|
|
$this->dom->addChild( |
2073
|
|
|
$tDI, |
2074
|
|
|
"cExportador", |
2075
|
|
|
$std->cExportador, |
2076
|
|
|
true, |
2077
|
|
|
$identificador . "[item $std->item] Código do Exportador" |
2078
|
|
|
); |
2079
|
|
|
$this->aDI[$std->item][$std->nDI] = $tDI; |
2080
|
|
|
return $tDI; |
2081
|
|
|
} |
2082
|
|
|
|
2083
|
|
|
/** |
2084
|
|
|
* Adições I25 pai I18 |
2085
|
|
|
* tag NFe/infNFe/det[]/prod/DI/adi |
2086
|
|
|
* @param stdClass $std |
2087
|
|
|
* @return DOMElement |
2088
|
|
|
*/ |
2089
|
|
|
public function tagadi(stdClass $std) |
2090
|
|
|
{ |
2091
|
|
|
$possible = [ |
2092
|
|
|
'item', |
2093
|
|
|
'nDI', |
2094
|
|
|
'nAdicao', |
2095
|
|
|
'nSeqAdic', |
2096
|
|
|
'cFabricante', |
2097
|
|
|
'vDescDI', |
2098
|
|
|
'nDraw' |
2099
|
|
|
]; |
2100
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2101
|
|
|
$identificador = 'I25 <adi> - '; |
2102
|
|
|
$adi = $this->dom->createElement("adi"); |
2103
|
|
|
$this->dom->addChild( |
2104
|
|
|
$adi, |
2105
|
|
|
"nAdicao", |
2106
|
|
|
$std->nAdicao, |
2107
|
|
|
true, |
2108
|
|
|
$identificador . "[item $std->item] Número da Adição" |
2109
|
|
|
); |
2110
|
|
|
$this->dom->addChild( |
2111
|
|
|
$adi, |
2112
|
|
|
"nSeqAdic", |
2113
|
|
|
$std->nSeqAdic, |
2114
|
|
|
true, |
2115
|
|
|
$identificador . "[item $std->item] Número sequencial do item dentro da Adição" |
2116
|
|
|
); |
2117
|
|
|
$this->dom->addChild( |
2118
|
|
|
$adi, |
2119
|
|
|
"cFabricante", |
2120
|
|
|
$std->cFabricante, |
2121
|
|
|
true, |
2122
|
|
|
$identificador . "[item $std->item] Código do fabricante estrangeiro" |
2123
|
|
|
); |
2124
|
|
|
$this->dom->addChild( |
2125
|
|
|
$adi, |
2126
|
|
|
"vDescDI", |
2127
|
|
|
$this->conditionalNumberFormatting($std->vDescDI), |
2128
|
|
|
false, |
2129
|
|
|
$identificador . "[item $std->item] Valor do desconto do item da DI Adição" |
2130
|
|
|
); |
2131
|
|
|
$this->dom->addChild( |
2132
|
|
|
$adi, |
2133
|
|
|
"nDraw", |
2134
|
|
|
$std->nDraw, |
2135
|
|
|
false, |
2136
|
|
|
$identificador . "[item $std->item] Número do ato concessório de Drawback" |
2137
|
|
|
); |
2138
|
|
|
$this->aAdi[$std->item][$std->nDI][] = $adi; |
2139
|
|
|
//colocar a adi em seu DI respectivo |
2140
|
|
|
$nodeDI = $this->aDI[$std->item][$std->nDI]; |
2141
|
|
|
$this->dom->appChild($nodeDI, $adi); |
2142
|
|
|
$this->aDI[$std->item][$std->nDI] = $nodeDI; |
2143
|
|
|
return $adi; |
2144
|
|
|
} |
2145
|
|
|
|
2146
|
|
|
/** |
2147
|
|
|
* Grupo de informações de exportação para o item I50 pai I01 |
2148
|
|
|
* tag NFe/infNFe/det[]/prod/detExport |
2149
|
|
|
* @param stdClass $std |
2150
|
|
|
* @return DOMElement |
2151
|
|
|
*/ |
2152
|
|
|
public function tagdetExport(stdClass $std) |
2153
|
|
|
{ |
2154
|
|
|
$possible = [ |
2155
|
|
|
'item', |
2156
|
|
|
'nDraw' |
2157
|
|
|
]; |
2158
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2159
|
|
|
$identificador = 'I50 <detExport> - '; |
2160
|
|
|
$detExport = $this->dom->createElement("detExport"); |
2161
|
|
|
$this->dom->addChild( |
2162
|
|
|
$detExport, |
2163
|
|
|
"nDraw", |
2164
|
|
|
Strings::onlyNumbers($std->nDraw), |
2165
|
|
|
false, |
2166
|
|
|
$identificador . "[item $std->item] Número do ato concessório de Drawback" |
2167
|
|
|
); |
2168
|
|
|
$this->aDetExport[$std->item][] = $detExport; |
2169
|
|
|
return $detExport; |
2170
|
|
|
} |
2171
|
|
|
|
2172
|
|
|
/** |
2173
|
|
|
* Grupo de informações de exportação para o item I52 pai I52 |
2174
|
|
|
* tag NFe/infNFe/det[]/prod/detExport |
2175
|
|
|
* @param stdClass $std |
2176
|
|
|
* @return DOMElement |
2177
|
|
|
*/ |
2178
|
|
|
public function tagdetExportInd(stdClass $std) |
2179
|
|
|
{ |
2180
|
|
|
$possible = [ |
2181
|
|
|
'item', |
2182
|
|
|
'nRE', |
2183
|
|
|
'chNFe', |
2184
|
|
|
'qExport' |
2185
|
|
|
]; |
2186
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2187
|
|
|
$identificador = 'I52 <exportInd> - '; |
2188
|
|
|
$exportInd = $this->dom->createElement("exportInd"); |
2189
|
|
|
$this->dom->addChild( |
2190
|
|
|
$exportInd, |
2191
|
|
|
"nRE", |
2192
|
|
|
Strings::onlyNumbers($std->nRE), |
2193
|
|
|
true, |
2194
|
|
|
$identificador . "[item $std->item] Número do Registro de Exportação" |
2195
|
|
|
); |
2196
|
|
|
$this->dom->addChild( |
2197
|
|
|
$exportInd, |
2198
|
|
|
"chNFe", |
2199
|
|
|
Strings::onlyNumbers($std->chNFe), |
2200
|
|
|
true, |
2201
|
|
|
$identificador . "[item $std->item] Chave de Acesso da NF-e recebida para exportação" |
2202
|
|
|
); |
2203
|
|
|
$this->dom->addChild( |
2204
|
|
|
$exportInd, |
2205
|
|
|
"qExport", |
2206
|
|
|
$this->conditionalNumberFormatting($std->qExport, 4), |
2207
|
|
|
true, |
2208
|
|
|
$identificador . "[item $std->item] Quantidade do item realmente exportado" |
2209
|
|
|
); |
2210
|
|
|
//obtem o ultimo detExport |
2211
|
|
|
$nDE = count($this->aDetExport[$std->item]) - 1; |
2212
|
|
|
if ($nDE < 0) { |
2213
|
|
|
throw new RuntimeException('A TAG detExportInd deve ser criada depois da detExport, pois pertence a ela.'); |
2214
|
|
|
} |
2215
|
|
|
//colocar a exportInd em seu DetExport respectivo |
2216
|
|
|
$nodeDetExport = $this->aDetExport[$std->item][$nDE]; |
2217
|
|
|
$this->dom->appChild($nodeDetExport, $exportInd); |
2218
|
|
|
$this->aDetExport[$std->item][$nDE] = $nodeDetExport; |
2219
|
|
|
return $exportInd; |
2220
|
|
|
} |
2221
|
|
|
|
2222
|
|
|
/** |
2223
|
|
|
* Rastreabilidade do produto podem ser até 500 por item TAG I80 pai I01 |
2224
|
|
|
* NOTA: Ajustado para NT2016_002_v1.00 |
2225
|
|
|
* tag NFe/infNFe/det[]/prod/rastro |
2226
|
|
|
* @param stdClass $std |
2227
|
|
|
* @return DOMElement |
2228
|
|
|
*/ |
2229
|
|
|
public function tagRastro(stdClass $std) |
2230
|
|
|
{ |
2231
|
|
|
$possible = [ |
2232
|
|
|
'item', |
2233
|
|
|
'nLote', |
2234
|
|
|
'qLote', |
2235
|
|
|
'dFab', |
2236
|
|
|
'dVal', |
2237
|
|
|
'cAgreg' |
2238
|
|
|
]; |
2239
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2240
|
|
|
$identificador = 'I80 <rastro> - '; |
2241
|
|
|
$rastro = $this->dom->createElement("rastro"); |
2242
|
|
|
$this->dom->addChild( |
2243
|
|
|
$rastro, |
2244
|
|
|
"nLote", |
2245
|
|
|
substr(trim($std->nLote), 0, 20), |
2246
|
|
|
true, |
2247
|
|
|
$identificador . "[item $std->item] Número do lote" |
2248
|
|
|
); |
2249
|
|
|
$this->dom->addChild( |
2250
|
|
|
$rastro, |
2251
|
|
|
"qLote", |
2252
|
|
|
$this->conditionalNumberFormatting($std->qLote, 3), |
2253
|
|
|
true, |
2254
|
|
|
$identificador . "[item $std->item] Quantidade do lote" |
2255
|
|
|
); |
2256
|
|
|
$this->dom->addChild( |
2257
|
|
|
$rastro, |
2258
|
|
|
"dFab", |
2259
|
|
|
trim($std->dFab), |
2260
|
|
|
true, |
2261
|
|
|
$identificador . "[item $std->item] Data de fabricação" |
2262
|
|
|
); |
2263
|
|
|
$this->dom->addChild( |
2264
|
|
|
$rastro, |
2265
|
|
|
"dVal", |
2266
|
|
|
trim($std->dVal), |
2267
|
|
|
true, |
2268
|
|
|
$identificador . "[item $std->item] Data da validade" |
2269
|
|
|
); |
2270
|
|
|
$this->dom->addChild( |
2271
|
|
|
$rastro, |
2272
|
|
|
"cAgreg", |
2273
|
|
|
Strings::onlyNumbers($std->cAgreg), |
2274
|
|
|
false, |
2275
|
|
|
$identificador . "[item $std->item] Código de Agregação" |
2276
|
|
|
); |
2277
|
|
|
$this->aRastro[$std->item][] = $rastro; |
2278
|
|
|
return $rastro; |
2279
|
|
|
} |
2280
|
|
|
|
2281
|
|
|
/** |
2282
|
|
|
* Detalhamento de Veículos novos J01 pai I90 |
2283
|
|
|
* tag NFe/infNFe/det[]/prod/veicProd (opcional) |
2284
|
|
|
* @param stdClass $std |
2285
|
|
|
* @return DOMElement |
2286
|
|
|
*/ |
2287
|
|
|
public function tagveicProd(stdClass $std) |
2288
|
|
|
{ |
2289
|
|
|
$possible = [ |
2290
|
|
|
'item', |
2291
|
|
|
'tpOp', |
2292
|
|
|
'chassi', |
2293
|
|
|
'cCor', |
2294
|
|
|
'xCor', |
2295
|
|
|
'pot', |
2296
|
|
|
'cilin', |
2297
|
|
|
'pesoL', |
2298
|
|
|
'pesoB', |
2299
|
|
|
'nSerie', |
2300
|
|
|
'tpComb', |
2301
|
|
|
'nMotor', |
2302
|
|
|
'CMT', |
2303
|
|
|
'dist', |
2304
|
|
|
'anoMod', |
2305
|
|
|
'anoFab', |
2306
|
|
|
'tpPint', |
2307
|
|
|
'tpVeic', |
2308
|
|
|
'espVeic', |
2309
|
|
|
'VIN', |
2310
|
|
|
'condVeic', |
2311
|
|
|
'cMod', |
2312
|
|
|
'cCorDENATRAN', |
2313
|
|
|
'lota', |
2314
|
|
|
'tpRest' |
2315
|
|
|
]; |
2316
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2317
|
|
|
$identificador = 'J01 <veicProd> - '; |
2318
|
|
|
$veicProd = $this->dom->createElement("veicProd"); |
2319
|
|
|
$this->dom->addChild( |
2320
|
|
|
$veicProd, |
2321
|
|
|
"tpOp", |
2322
|
|
|
$std->tpOp, |
2323
|
|
|
true, |
2324
|
|
|
"$identificador [item $std->item] Tipo da operação do veículo" |
2325
|
|
|
); |
2326
|
|
|
$this->dom->addChild( |
2327
|
|
|
$veicProd, |
2328
|
|
|
"chassi", |
2329
|
|
|
$std->chassi, |
2330
|
|
|
true, |
2331
|
|
|
"$identificador [item $std->item] Chassi do veículo" |
2332
|
|
|
); |
2333
|
|
|
$this->dom->addChild( |
2334
|
|
|
$veicProd, |
2335
|
|
|
"cCor", |
2336
|
|
|
$std->cCor, |
2337
|
|
|
true, |
2338
|
|
|
"$identificador [item $std->item] Cor do veículo" |
2339
|
|
|
); |
2340
|
|
|
$this->dom->addChild( |
2341
|
|
|
$veicProd, |
2342
|
|
|
"xCor", |
2343
|
|
|
$std->xCor, |
2344
|
|
|
true, |
2345
|
|
|
"$identificador [item $std->item] Descrição da Cor do veículo" |
2346
|
|
|
); |
2347
|
|
|
$this->dom->addChild( |
2348
|
|
|
$veicProd, |
2349
|
|
|
"pot", |
2350
|
|
|
$std->pot, |
2351
|
|
|
true, |
2352
|
|
|
"$identificador [item $std->item] Potência Motor (CV) do veículo" |
2353
|
|
|
); |
2354
|
|
|
$this->dom->addChild( |
2355
|
|
|
$veicProd, |
2356
|
|
|
"cilin", |
2357
|
|
|
$std->cilin, |
2358
|
|
|
true, |
2359
|
|
|
"$identificador [item $std->item] Cilindradas do veículo" |
2360
|
|
|
); |
2361
|
|
|
$this->dom->addChild( |
2362
|
|
|
$veicProd, |
2363
|
|
|
"pesoL", |
2364
|
|
|
$this->conditionalNumberFormatting($std->pesoL, 3), |
2365
|
|
|
true, |
2366
|
|
|
"$identificador [item $std->item] Peso Líquido do veículo" |
2367
|
|
|
); |
2368
|
|
|
$this->dom->addChild( |
2369
|
|
|
$veicProd, |
2370
|
|
|
"pesoB", |
2371
|
|
|
$this->conditionalNumberFormatting($std->pesoB, 3), |
2372
|
|
|
true, |
2373
|
|
|
"$identificador [item $std->item] Peso Bruto do veículo" |
2374
|
|
|
); |
2375
|
|
|
$this->dom->addChild( |
2376
|
|
|
$veicProd, |
2377
|
|
|
"nSerie", |
2378
|
|
|
$std->nSerie, |
2379
|
|
|
true, |
2380
|
|
|
"$identificador [item $std->item] Serial (série) do veículo" |
2381
|
|
|
); |
2382
|
|
|
$this->dom->addChild( |
2383
|
|
|
$veicProd, |
2384
|
|
|
"tpComb", |
2385
|
|
|
$std->tpComb, |
2386
|
|
|
true, |
2387
|
|
|
"$identificador [item $std->item] Tipo de combustível do veículo" |
2388
|
|
|
); |
2389
|
|
|
$this->dom->addChild( |
2390
|
|
|
$veicProd, |
2391
|
|
|
"nMotor", |
2392
|
|
|
$std->nMotor, |
2393
|
|
|
true, |
2394
|
|
|
"$identificador [item $std->item] Número de Motor do veículo" |
2395
|
|
|
); |
2396
|
|
|
$this->dom->addChild( |
2397
|
|
|
$veicProd, |
2398
|
|
|
"CMT", |
2399
|
|
|
$this->conditionalNumberFormatting($std->CMT, 4), |
2400
|
|
|
true, |
2401
|
|
|
"$identificador [item $std->item] Capacidade Máxima de Tração do veículo" |
2402
|
|
|
); |
2403
|
|
|
$this->dom->addChild( |
2404
|
|
|
$veicProd, |
2405
|
|
|
"dist", |
2406
|
|
|
$std->dist, |
2407
|
|
|
true, |
2408
|
|
|
"$identificador [item $std->item] Distância entre eixos do veículo" |
2409
|
|
|
); |
2410
|
|
|
$this->dom->addChild( |
2411
|
|
|
$veicProd, |
2412
|
|
|
"anoMod", |
2413
|
|
|
$std->anoMod, |
2414
|
|
|
true, |
2415
|
|
|
"$identificador [item $std->item] Ano Modelo de Fabricação do veículo" |
2416
|
|
|
); |
2417
|
|
|
$this->dom->addChild( |
2418
|
|
|
$veicProd, |
2419
|
|
|
"anoFab", |
2420
|
|
|
$std->anoFab, |
2421
|
|
|
true, |
2422
|
|
|
"$identificador [item $std->item] Ano de Fabricação do veículo" |
2423
|
|
|
); |
2424
|
|
|
$this->dom->addChild( |
2425
|
|
|
$veicProd, |
2426
|
|
|
"tpPint", |
2427
|
|
|
$std->tpPint, |
2428
|
|
|
true, |
2429
|
|
|
"$identificador [item $std->item] Tipo de Pintura do veículo" |
2430
|
|
|
); |
2431
|
|
|
$this->dom->addChild( |
2432
|
|
|
$veicProd, |
2433
|
|
|
"tpVeic", |
2434
|
|
|
$std->tpVeic, |
2435
|
|
|
true, |
2436
|
|
|
"$identificador [item $std->item] Tipo de Veículo" |
2437
|
|
|
); |
2438
|
|
|
$this->dom->addChild( |
2439
|
|
|
$veicProd, |
2440
|
|
|
"espVeic", |
2441
|
|
|
$std->espVeic, |
2442
|
|
|
true, |
2443
|
|
|
"$identificador [item $std->item] Espécie de Veículo" |
2444
|
|
|
); |
2445
|
|
|
$this->dom->addChild( |
2446
|
|
|
$veicProd, |
2447
|
|
|
"VIN", |
2448
|
|
|
$std->VIN, |
2449
|
|
|
true, |
2450
|
|
|
"$identificador [item $std->item] Condição do VIN do veículo" |
2451
|
|
|
); |
2452
|
|
|
$this->dom->addChild( |
2453
|
|
|
$veicProd, |
2454
|
|
|
"condVeic", |
2455
|
|
|
$std->condVeic, |
2456
|
|
|
true, |
2457
|
|
|
"$identificador [item $std->item] Condição do Veículo" |
2458
|
|
|
); |
2459
|
|
|
$this->dom->addChild( |
2460
|
|
|
$veicProd, |
2461
|
|
|
"cMod", |
2462
|
|
|
$std->cMod, |
2463
|
|
|
true, |
2464
|
|
|
"$identificador [item $std->item] Código Marca Modelo do veículo" |
2465
|
|
|
); |
2466
|
|
|
$this->dom->addChild( |
2467
|
|
|
$veicProd, |
2468
|
|
|
"cCorDENATRAN", |
2469
|
|
|
$std->cCorDENATRAN, |
2470
|
|
|
true, |
2471
|
|
|
"$identificador [item $std->item] Código da Cor do veículo" |
2472
|
|
|
); |
2473
|
|
|
$this->dom->addChild( |
2474
|
|
|
$veicProd, |
2475
|
|
|
"lota", |
2476
|
|
|
$std->lota, |
2477
|
|
|
true, |
2478
|
|
|
"$identificador [item $std->item] Capacidade máxima de lotação do veículo" |
2479
|
|
|
); |
2480
|
|
|
$this->dom->addChild( |
2481
|
|
|
$veicProd, |
2482
|
|
|
"tpRest", |
2483
|
|
|
$std->tpRest, |
2484
|
|
|
true, |
2485
|
|
|
"$identificador [item $std->item] Restrição do veículo" |
2486
|
|
|
); |
2487
|
|
|
$this->aVeicProd[$std->item] = $veicProd; |
2488
|
|
|
return $veicProd; |
2489
|
|
|
} |
2490
|
|
|
|
2491
|
|
|
/** |
2492
|
|
|
* Detalhamento de medicamentos K01 pai I90 |
2493
|
|
|
* NOTA: Ajustado para NT2018.005 |
2494
|
|
|
* tag NFe/infNFe/det[]/prod/med (opcional) |
2495
|
|
|
* @param stdClass $std |
2496
|
|
|
* @return DOMElement |
2497
|
|
|
*/ |
2498
|
|
|
public function tagmed(stdClass $std) |
2499
|
|
|
{ |
2500
|
|
|
$possible = [ |
2501
|
|
|
'item', |
2502
|
|
|
'vPMC', |
2503
|
|
|
'cProdANVISA', |
2504
|
|
|
'xMotivoIsencao' |
2505
|
|
|
]; |
2506
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2507
|
|
|
$identificador = 'K01 <med> - '; |
2508
|
|
|
$med = $this->dom->createElement("med"); |
2509
|
|
|
$this->dom->addChild( |
2510
|
|
|
$med, |
2511
|
|
|
"cProdANVISA", |
2512
|
|
|
$std->cProdANVISA, |
2513
|
|
|
false, |
2514
|
|
|
"$identificador [item $std->item] Numero ANVISA" |
2515
|
|
|
); |
2516
|
|
|
$this->dom->addChild( |
2517
|
|
|
$med, |
2518
|
|
|
"xMotivoIsencao", |
2519
|
|
|
$std->xMotivoIsencao, |
2520
|
|
|
false, |
2521
|
|
|
"$identificador [item $std->item] Motivo da isenção da ANVISA" |
2522
|
|
|
); |
2523
|
|
|
$this->dom->addChild( |
2524
|
|
|
$med, |
2525
|
|
|
"vPMC", |
2526
|
|
|
$this->conditionalNumberFormatting($std->vPMC), |
2527
|
|
|
true, |
2528
|
|
|
"$identificador [item $std->item] Preço máximo consumidor" |
2529
|
|
|
); |
2530
|
|
|
$this->aMed[$std->item] = $med; |
2531
|
|
|
return $med; |
2532
|
|
|
} |
2533
|
|
|
|
2534
|
|
|
/** |
2535
|
|
|
* Detalhamento de armas L01 pai I90 |
2536
|
|
|
* tag NFe/infNFe/det[]/prod/arma (opcional) |
2537
|
|
|
* @param stdClass $std |
2538
|
|
|
* @return DOMElement |
2539
|
|
|
*/ |
2540
|
|
|
public function tagarma(stdClass $std) |
2541
|
|
|
{ |
2542
|
|
|
$possible = [ |
2543
|
|
|
'item', |
2544
|
|
|
'nAR', |
2545
|
|
|
'tpArma', |
2546
|
|
|
'nSerie', |
2547
|
|
|
'nCano', |
2548
|
|
|
'descr' |
2549
|
|
|
]; |
2550
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2551
|
|
|
$identificador = 'L01 <arma> - '; |
2552
|
|
|
$arma = $this->dom->createElement("arma"); |
2553
|
|
|
$this->dom->addChild( |
2554
|
|
|
$arma, |
2555
|
|
|
"tpArma", |
2556
|
|
|
$std->tpArma, |
2557
|
|
|
true, |
2558
|
|
|
"$identificador [item $std->item] Indicador do tipo de arma de fogo" |
2559
|
|
|
); |
2560
|
|
|
$this->dom->addChild( |
2561
|
|
|
$arma, |
2562
|
|
|
"nSerie", |
2563
|
|
|
$std->nSerie, |
2564
|
|
|
true, |
2565
|
|
|
"$identificador [item $std->item] Número de série da arma" |
2566
|
|
|
); |
2567
|
|
|
$this->dom->addChild( |
2568
|
|
|
$arma, |
2569
|
|
|
"nCano", |
2570
|
|
|
$std->nCano, |
2571
|
|
|
true, |
2572
|
|
|
"$identificador [item $std->item] Número de série do cano" |
2573
|
|
|
); |
2574
|
|
|
$this->dom->addChild( |
2575
|
|
|
$arma, |
2576
|
|
|
"descr", |
2577
|
|
|
$std->descr, |
2578
|
|
|
true, |
2579
|
|
|
"$identificador [item $std->item] Descrição completa da arma, compreendendo: calibre, marca, capacidade, " |
2580
|
|
|
. "tipo de funcionamento, comprimento e demais elementos que " |
2581
|
|
|
. "permitam a sua perfeita identificação." |
2582
|
|
|
); |
2583
|
|
|
$this->aArma[$std->item][$std->nAR] = $arma; |
2584
|
|
|
return $arma; |
2585
|
|
|
} |
2586
|
|
|
|
2587
|
|
|
/** |
2588
|
|
|
* Detalhamento de combustiveis L101 pai I90 |
2589
|
|
|
* tag NFe/infNFe/det[]/prod/comb (opcional) |
2590
|
|
|
* LA|cProdANP|pMixGN|CODIF|qTemp|UFCons| |
2591
|
|
|
* |
2592
|
|
|
* NOTA: Ajustado para NT2016_002_v1.30 |
2593
|
|
|
* LA|cProdANP|descANP|pGLP|pGNn|pGNi|vPart|CODIF|qTemp|UFCons| |
2594
|
|
|
* @param stdClass $std |
2595
|
|
|
* @return DOMElement |
2596
|
|
|
*/ |
2597
|
|
|
public function tagcomb(stdClass $std) |
2598
|
|
|
{ |
2599
|
|
|
$possible = [ |
2600
|
|
|
'item', |
2601
|
|
|
'cProdANP', |
2602
|
|
|
'descANP', |
2603
|
|
|
'pGLP', |
2604
|
|
|
'pGNn', |
2605
|
|
|
'pGNi', |
2606
|
|
|
'vPart', |
2607
|
|
|
'CODIF', |
2608
|
|
|
'qTemp', |
2609
|
|
|
'UFCons', |
2610
|
|
|
'qBCProd', |
2611
|
|
|
'vAliqProd', |
2612
|
|
|
'vCIDE' |
2613
|
|
|
]; |
2614
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2615
|
|
|
|
2616
|
|
|
$identificador = 'L101 <comb> - '; |
2617
|
|
|
$comb = $this->dom->createElement("comb"); |
2618
|
|
|
$this->dom->addChild( |
2619
|
|
|
$comb, |
2620
|
|
|
"cProdANP", |
2621
|
|
|
$std->cProdANP, |
2622
|
|
|
true, |
2623
|
|
|
"$identificador [item $std->item] Código de produto da ANP" |
2624
|
|
|
); |
2625
|
|
|
//incluso no layout 4.00 |
2626
|
|
|
$this->dom->addChild( |
2627
|
|
|
$comb, |
2628
|
|
|
"descANP", |
2629
|
|
|
$std->descANP, |
2630
|
|
|
false, |
2631
|
|
|
"$identificador [item $std->item] Utilizar a descrição de produtos do " |
2632
|
|
|
. "Sistema de Informações de Movimentação de Produtos - " |
2633
|
|
|
. "SIMP (http://www.anp.gov.br/simp/" |
2634
|
|
|
); |
2635
|
|
|
//incluso no layout 4.00 |
2636
|
|
|
$this->dom->addChild( |
2637
|
|
|
$comb, |
2638
|
|
|
"pGLP", |
2639
|
|
|
$this->conditionalNumberFormatting($std->pGLP, 4), |
2640
|
|
|
false, |
2641
|
|
|
"$identificador [item $std->item] Percentual do GLP derivado do " |
2642
|
|
|
. "petróleo no produto GLP (cProdANP=210203001) 1v4" |
2643
|
|
|
); |
2644
|
|
|
//incluso no layout 4.00 |
2645
|
|
|
$this->dom->addChild( |
2646
|
|
|
$comb, |
2647
|
|
|
"pGNn", |
2648
|
|
|
$this->conditionalNumberFormatting($std->pGNn, 4), |
2649
|
|
|
false, |
2650
|
|
|
"$identificador [item $std->item] Percentual de Gás Natural Nacional" |
2651
|
|
|
. " – GLGNn para o produto GLP (cProdANP=210203001) 1v4" |
2652
|
|
|
); |
2653
|
|
|
//incluso no layout 4.00 |
2654
|
|
|
$this->dom->addChild( |
2655
|
|
|
$comb, |
2656
|
|
|
"pGNi", |
2657
|
|
|
$this->conditionalNumberFormatting($std->pGNi, 4), |
2658
|
|
|
false, |
2659
|
|
|
"$identificador [item $std->item] Percentual de Gás Natural Importado" |
2660
|
|
|
. " – GLGNi para o produto GLP (cProdANP=210203001) 1v4" |
2661
|
|
|
); |
2662
|
|
|
//incluso no layout 4.00 |
2663
|
|
|
$this->dom->addChild( |
2664
|
|
|
$comb, |
2665
|
|
|
"vPart", |
2666
|
|
|
$this->conditionalNumberFormatting($std->vPart), |
2667
|
|
|
false, |
2668
|
|
|
"$identificador [item $std->item] Valor de partida (cProdANP=210203001) " |
2669
|
|
|
); |
2670
|
|
|
$this->dom->addChild( |
2671
|
|
|
$comb, |
2672
|
|
|
"CODIF", |
2673
|
|
|
$std->CODIF, |
2674
|
|
|
false, |
2675
|
|
|
"[item $std->item] Código de autorização / registro do CODIF" |
2676
|
|
|
); |
2677
|
|
|
$this->dom->addChild( |
2678
|
|
|
$comb, |
2679
|
|
|
"qTemp", |
2680
|
|
|
$this->conditionalNumberFormatting($std->qTemp, 4), |
2681
|
|
|
false, |
2682
|
|
|
"$identificador [item $std->item] Quantidade de combustível faturada à temperatura ambiente." |
2683
|
|
|
); |
2684
|
|
|
$this->dom->addChild( |
2685
|
|
|
$comb, |
2686
|
|
|
"UFCons", |
2687
|
|
|
$std->UFCons, |
2688
|
|
|
true, |
2689
|
|
|
"[item $std->item] Sigla da UF de consumo" |
2690
|
|
|
); |
2691
|
|
|
if ($std->qBCProd != "") { |
2692
|
|
|
$tagCIDE = $this->dom->createElement("CIDE"); |
2693
|
|
|
$this->dom->addChild( |
2694
|
|
|
$tagCIDE, |
2695
|
|
|
"qBCProd", |
2696
|
|
|
$std->qBCProd, |
2697
|
|
|
true, |
2698
|
|
|
"$identificador [item $std->item] BC da CIDE" |
2699
|
|
|
); |
2700
|
|
|
$this->dom->addChild( |
2701
|
|
|
$tagCIDE, |
2702
|
|
|
"vAliqProd", |
2703
|
|
|
$this->conditionalNumberFormatting($std->vAliqProd, 4), |
2704
|
|
|
true, |
2705
|
|
|
"$identificador [item $std->item] Valor da alíquota da CIDE" |
2706
|
|
|
); |
2707
|
|
|
$this->dom->addChild( |
2708
|
|
|
$tagCIDE, |
2709
|
|
|
"vCIDE", |
2710
|
|
|
$this->conditionalNumberFormatting($std->vCIDE), |
2711
|
|
|
true, |
2712
|
|
|
"$identificador [item $std->item] Valor da CIDE" |
2713
|
|
|
); |
2714
|
|
|
$this->dom->appChild($comb, $tagCIDE); |
2715
|
|
|
} |
2716
|
|
|
$this->aComb[$std->item] = $comb; |
2717
|
|
|
return $comb; |
2718
|
|
|
} |
2719
|
|
|
|
2720
|
|
|
/** |
2721
|
|
|
* informações relacionadas com as operações de combustíveis, subgrupo de |
2722
|
|
|
* encerrante que permite o controle sobre as operações de venda de combustíveis |
2723
|
|
|
* LA11 pai LA01 |
2724
|
|
|
* tag NFe/infNFe/det[]/prod/comb/encerrante (opcional) |
2725
|
|
|
* @param stdClass $std |
2726
|
|
|
* @return DOMElement |
2727
|
|
|
*/ |
2728
|
|
|
public function tagencerrante(stdClass $std) |
2729
|
|
|
{ |
2730
|
|
|
$possible = [ |
2731
|
|
|
'item', |
2732
|
|
|
'nBico', |
2733
|
|
|
'nBomba', |
2734
|
|
|
'nTanque', |
2735
|
|
|
'vEncIni', |
2736
|
|
|
'vEncFin' |
2737
|
|
|
]; |
2738
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2739
|
|
|
$identificador = 'LA11 <encerrante> - '; |
2740
|
|
|
$encerrante = $this->dom->createElement("encerrante"); |
2741
|
|
|
$this->dom->addChild( |
2742
|
|
|
$encerrante, |
2743
|
|
|
"nBico", |
2744
|
|
|
$std->nBico, |
2745
|
|
|
true, |
2746
|
|
|
"$identificador [item $std->item] Número de identificação do bico utilizado no abastecimento" |
2747
|
|
|
); |
2748
|
|
|
$this->dom->addChild( |
2749
|
|
|
$encerrante, |
2750
|
|
|
"nBomba", |
2751
|
|
|
$std->nBomba, |
2752
|
|
|
false, |
2753
|
|
|
"$identificador [item $std->item] Número de identificação da bomba ao qual o bico está interligado" |
2754
|
|
|
); |
2755
|
|
|
$this->dom->addChild( |
2756
|
|
|
$encerrante, |
2757
|
|
|
"nTanque", |
2758
|
|
|
$std->nTanque, |
2759
|
|
|
true, |
2760
|
|
|
"$identificador [item $std->item] Número de identificação do tanque ao qual o bico está interligado" |
2761
|
|
|
); |
2762
|
|
|
$this->dom->addChild( |
2763
|
|
|
$encerrante, |
2764
|
|
|
"vEncIni", |
2765
|
|
|
$this->conditionalNumberFormatting($std->vEncIni), |
2766
|
|
|
true, |
2767
|
|
|
"$identificador [item $std->item] Valor do Encerrante no início do abastecimento" |
2768
|
|
|
); |
2769
|
|
|
$this->dom->addChild( |
2770
|
|
|
$encerrante, |
2771
|
|
|
"vEncFin", |
2772
|
|
|
$this->conditionalNumberFormatting($std->vEncFin), |
2773
|
|
|
true, |
2774
|
|
|
"$identificador [item $std->item] Valor do Encerrante no final do abastecimento" |
2775
|
|
|
); |
2776
|
|
|
$this->aEncerrante[$std->item] = $encerrante; |
2777
|
|
|
return $encerrante; |
2778
|
|
|
} |
2779
|
|
|
|
2780
|
|
|
/** |
2781
|
|
|
* Impostos com o valor total tributado M01 pai H01 |
2782
|
|
|
* tag NFe/infNFe/det[]/imposto |
2783
|
|
|
* @param stdClass $std |
2784
|
|
|
* @return DOMElement |
2785
|
|
|
*/ |
2786
|
|
|
public function tagimposto(stdClass $std) |
2787
|
|
|
{ |
2788
|
|
|
$possible = ['item', 'vTotTrib']; |
2789
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2790
|
|
|
//totalizador dos valores dos itens |
2791
|
|
|
$this->stdTot->vTotTrib += (float) $std->vTotTrib; |
2792
|
|
|
$identificador = 'M01 <imposto> - '; |
2793
|
|
|
$imposto = $this->dom->createElement("imposto"); |
2794
|
|
|
$this->dom->addChild( |
2795
|
|
|
$imposto, |
2796
|
|
|
"vTotTrib", |
2797
|
|
|
$this->conditionalNumberFormatting($std->vTotTrib), |
2798
|
|
|
false, |
2799
|
|
|
"$identificador [item $std->item] Valor aproximado total de tributos federais, estaduais e municipais." |
2800
|
|
|
); |
2801
|
|
|
$this->aImposto[$std->item] = $imposto; |
2802
|
|
|
return $imposto; |
2803
|
|
|
} |
2804
|
|
|
|
2805
|
|
|
/** |
2806
|
|
|
* Informações do ICMS da Operação própria e ST N01 pai M01 |
2807
|
|
|
* tag NFe/infNFe/det[]/imposto/ICMS |
2808
|
|
|
* @param stdClass $std |
2809
|
|
|
* @return DOMElement |
2810
|
|
|
*/ |
2811
|
|
|
public function tagICMS(stdClass $std) |
2812
|
|
|
{ |
2813
|
|
|
$possible = [ |
2814
|
|
|
'item', |
2815
|
|
|
'orig', |
2816
|
|
|
'CST', |
2817
|
|
|
'modBC', |
2818
|
|
|
'vBC', |
2819
|
|
|
'pICMS', |
2820
|
|
|
'vICMS', |
2821
|
|
|
'pFCP', |
2822
|
|
|
'vFCP', |
2823
|
|
|
'vBCFCP', |
2824
|
|
|
'modBCST', |
2825
|
|
|
'pMVAST', |
2826
|
|
|
'pRedBCST', |
2827
|
|
|
'vBCST', |
2828
|
|
|
'pICMSST', |
2829
|
|
|
'vICMSST', |
2830
|
|
|
'vBCFCPST', |
2831
|
|
|
'pFCPST', |
2832
|
|
|
'vFCPST', |
2833
|
|
|
'vICMSDeson', |
2834
|
|
|
'motDesICMS', |
2835
|
|
|
'pRedBC', |
2836
|
|
|
'vICMSOp', |
2837
|
|
|
'pDif', |
2838
|
|
|
'vICMSDif', |
2839
|
|
|
'vBCSTRet', |
2840
|
|
|
'pST', |
2841
|
|
|
'vICMSSTRet', |
2842
|
|
|
'vBCFCPSTRet', |
2843
|
|
|
'pFCPSTRet', |
2844
|
|
|
'vFCPSTRet', |
2845
|
|
|
'pRedBCEfet', |
2846
|
|
|
'vBCEfet', |
2847
|
|
|
'pICMSEfet', |
2848
|
|
|
'vICMSEfet', |
2849
|
|
|
'vICMSSubstituto' |
2850
|
|
|
]; |
2851
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2852
|
|
|
//totalização generica |
2853
|
|
|
$this->stdTot->vICMSDeson += (float) !empty($std->vICMSDeson) ? $std->vICMSDeson : 0; |
2854
|
|
|
$this->stdTot->vFCP += (float) !empty($std->vFCP) ? $std->vFCP : 0; |
2855
|
|
|
$this->stdTot->vFCPST += (float) !empty($std->vFCPST) ? $std->vFCPST : 0; |
2856
|
|
|
$this->stdTot->vFCPSTRet += (float) !empty($std->vFCPSTRet) ? $std->vFCPSTRet : 0; |
2857
|
|
|
$identificador = 'N01 <ICMSxx> - '; |
2858
|
|
|
switch ($std->CST) { |
2859
|
|
|
case '00': |
2860
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
2861
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
2862
|
|
|
|
2863
|
|
|
$icms = $this->dom->createElement("ICMS00"); |
2864
|
|
|
$this->dom->addChild( |
2865
|
|
|
$icms, |
2866
|
|
|
'orig', |
2867
|
|
|
$std->orig, |
2868
|
|
|
true, |
2869
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
2870
|
|
|
); |
2871
|
|
|
$this->dom->addChild( |
2872
|
|
|
$icms, |
2873
|
|
|
'CST', |
2874
|
|
|
$std->CST, |
2875
|
|
|
true, |
2876
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 00" |
2877
|
|
|
); |
2878
|
|
|
$this->dom->addChild( |
2879
|
|
|
$icms, |
2880
|
|
|
'modBC', |
2881
|
|
|
$std->modBC, |
2882
|
|
|
true, |
2883
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
2884
|
|
|
); |
2885
|
|
|
$this->dom->addChild( |
2886
|
|
|
$icms, |
2887
|
|
|
'vBC', |
2888
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
2889
|
|
|
true, |
2890
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS" |
2891
|
|
|
); |
2892
|
|
|
$this->dom->addChild( |
2893
|
|
|
$icms, |
2894
|
|
|
'pICMS', |
2895
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
2896
|
|
|
true, |
2897
|
|
|
"$identificador [item $std->item] Alíquota do imposto" |
2898
|
|
|
); |
2899
|
|
|
$this->dom->addChild( |
2900
|
|
|
$icms, |
2901
|
|
|
'vICMS', |
2902
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
2903
|
|
|
true, |
2904
|
|
|
"$identificador [item $std->item] Valor do ICMS" |
2905
|
|
|
); |
2906
|
|
|
$this->dom->addChild( |
2907
|
|
|
$icms, |
2908
|
|
|
'pFCP', |
2909
|
|
|
$this->conditionalNumberFormatting($std->pFCP, 4), |
2910
|
|
|
false, |
2911
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
2912
|
|
|
. "Combate à Pobreza (FCP)" |
2913
|
|
|
); |
2914
|
|
|
$this->dom->addChild( |
2915
|
|
|
$icms, |
2916
|
|
|
'vFCP', |
2917
|
|
|
$this->conditionalNumberFormatting($std->vFCP), |
2918
|
|
|
false, |
2919
|
|
|
"$identificador [item $std->item] Valor do Fundo de Combate " |
2920
|
|
|
. "à Pobreza (FCP)" |
2921
|
|
|
); |
2922
|
|
|
break; |
2923
|
|
|
case '10': |
2924
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
2925
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
2926
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
2927
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
2928
|
|
|
|
2929
|
|
|
$icms = $this->dom->createElement("ICMS10"); |
2930
|
|
|
$this->dom->addChild( |
2931
|
|
|
$icms, |
2932
|
|
|
'orig', |
2933
|
|
|
$std->orig, |
2934
|
|
|
true, |
2935
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
2936
|
|
|
); |
2937
|
|
|
$this->dom->addChild( |
2938
|
|
|
$icms, |
2939
|
|
|
'CST', |
2940
|
|
|
$std->CST, |
2941
|
|
|
true, |
2942
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 10" |
2943
|
|
|
); |
2944
|
|
|
$this->dom->addChild( |
2945
|
|
|
$icms, |
2946
|
|
|
'modBC', |
2947
|
|
|
$std->modBC, |
2948
|
|
|
true, |
2949
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
2950
|
|
|
); |
2951
|
|
|
$this->dom->addChild( |
2952
|
|
|
$icms, |
2953
|
|
|
'vBC', |
2954
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
2955
|
|
|
true, |
2956
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS" |
2957
|
|
|
); |
2958
|
|
|
$this->dom->addChild( |
2959
|
|
|
$icms, |
2960
|
|
|
'pICMS', |
2961
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
2962
|
|
|
true, |
2963
|
|
|
"$identificador [item $std->item] Alíquota do imposto" |
2964
|
|
|
); |
2965
|
|
|
$this->dom->addChild( |
2966
|
|
|
$icms, |
2967
|
|
|
'vICMS', |
2968
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
2969
|
|
|
true, |
2970
|
|
|
"$identificador [item $std->item] Valor do ICMS" |
2971
|
|
|
); |
2972
|
|
|
$this->dom->addChild( |
2973
|
|
|
$icms, |
2974
|
|
|
'vBCFCP', |
2975
|
|
|
$this->conditionalNumberFormatting($std->vBCFCP), |
2976
|
|
|
false, |
2977
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
2978
|
|
|
); |
2979
|
|
|
$this->dom->addChild( |
2980
|
|
|
$icms, |
2981
|
|
|
'pFCP', |
2982
|
|
|
$this->conditionalNumberFormatting($std->pFCP, 4), |
2983
|
|
|
false, |
2984
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
2985
|
|
|
. "Combate à Pobreza (FCP)" |
2986
|
|
|
); |
2987
|
|
|
$this->dom->addChild( |
2988
|
|
|
$icms, |
2989
|
|
|
'vFCP', |
2990
|
|
|
$this->conditionalNumberFormatting($std->vFCP), |
2991
|
|
|
false, |
2992
|
|
|
"$identificador [item $std->item] Valor do FCP" |
2993
|
|
|
); |
2994
|
|
|
$this->dom->addChild( |
2995
|
|
|
$icms, |
2996
|
|
|
'modBCST', |
2997
|
|
|
$std->modBCST, |
2998
|
|
|
true, |
2999
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
3000
|
|
|
); |
3001
|
|
|
$this->dom->addChild( |
3002
|
|
|
$icms, |
3003
|
|
|
'pMVAST', |
3004
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
3005
|
|
|
false, |
3006
|
|
|
"$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
3007
|
|
|
); |
3008
|
|
|
$this->dom->addChild( |
3009
|
|
|
$icms, |
3010
|
|
|
'pRedBCST', |
3011
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
3012
|
|
|
false, |
3013
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
3014
|
|
|
); |
3015
|
|
|
$this->dom->addChild( |
3016
|
|
|
$icms, |
3017
|
|
|
'vBCST', |
3018
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
3019
|
|
|
true, |
3020
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS ST" |
3021
|
|
|
); |
3022
|
|
|
$this->dom->addChild( |
3023
|
|
|
$icms, |
3024
|
|
|
'pICMSST', |
3025
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
3026
|
|
|
true, |
3027
|
|
|
"$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
3028
|
|
|
); |
3029
|
|
|
$this->dom->addChild( |
3030
|
|
|
$icms, |
3031
|
|
|
'vICMSST', |
3032
|
|
|
$this->conditionalNumberFormatting($std->vICMSST), |
3033
|
|
|
true, |
3034
|
|
|
"$identificador [item $std->item] Valor do ICMS ST" |
3035
|
|
|
); |
3036
|
|
|
$this->dom->addChild( |
3037
|
|
|
$icms, |
3038
|
|
|
'vBCFCPST', |
3039
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPST), |
3040
|
|
|
false, |
3041
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
3042
|
|
|
); |
3043
|
|
|
$this->dom->addChild( |
3044
|
|
|
$icms, |
3045
|
|
|
'pFCPST', |
3046
|
|
|
$this->conditionalNumberFormatting($std->pFCPST, 4), |
3047
|
|
|
false, |
3048
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3049
|
|
|
. "Combate à Pobreza (FCP) ST" |
3050
|
|
|
); |
3051
|
|
|
$this->dom->addChild( |
3052
|
|
|
$icms, |
3053
|
|
|
'vFCPST', |
3054
|
|
|
$this->conditionalNumberFormatting($std->vFCPST), |
3055
|
|
|
false, |
3056
|
|
|
"$identificador [item $std->item] Valor do FCP ST" |
3057
|
|
|
); |
3058
|
|
|
break; |
3059
|
|
|
case '20': |
3060
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
3061
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
3062
|
|
|
|
3063
|
|
|
$icms = $this->dom->createElement("ICMS20"); |
3064
|
|
|
$this->dom->addChild( |
3065
|
|
|
$icms, |
3066
|
|
|
'orig', |
3067
|
|
|
$std->orig, |
3068
|
|
|
true, |
3069
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
3070
|
|
|
); |
3071
|
|
|
$this->dom->addChild( |
3072
|
|
|
$icms, |
3073
|
|
|
'CST', |
3074
|
|
|
$std->CST, |
3075
|
|
|
true, |
3076
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 20" |
3077
|
|
|
); |
3078
|
|
|
$this->dom->addChild( |
3079
|
|
|
$icms, |
3080
|
|
|
'modBC', |
3081
|
|
|
$std->modBC, |
3082
|
|
|
true, |
3083
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
3084
|
|
|
); |
3085
|
|
|
$this->dom->addChild( |
3086
|
|
|
$icms, |
3087
|
|
|
'pRedBC', |
3088
|
|
|
$this->conditionalNumberFormatting($std->pRedBC, 4), |
3089
|
|
|
true, |
3090
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC" |
3091
|
|
|
); |
3092
|
|
|
$this->dom->addChild( |
3093
|
|
|
$icms, |
3094
|
|
|
'vBC', |
3095
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
3096
|
|
|
true, |
3097
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS" |
3098
|
|
|
); |
3099
|
|
|
$this->dom->addChild( |
3100
|
|
|
$icms, |
3101
|
|
|
'pICMS', |
3102
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
3103
|
|
|
true, |
3104
|
|
|
"$identificador [item $std->item] Alíquota do imposto" |
3105
|
|
|
); |
3106
|
|
|
$this->dom->addChild( |
3107
|
|
|
$icms, |
3108
|
|
|
'vICMS', |
3109
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
3110
|
|
|
true, |
3111
|
|
|
"$identificador [item $std->item] Valor do ICMS" |
3112
|
|
|
); |
3113
|
|
|
$this->dom->addChild( |
3114
|
|
|
$icms, |
3115
|
|
|
'vBCFCP', |
3116
|
|
|
$this->conditionalNumberFormatting($std->vBCFCP), |
3117
|
|
|
false, |
3118
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
3119
|
|
|
); |
3120
|
|
|
$this->dom->addChild( |
3121
|
|
|
$icms, |
3122
|
|
|
'pFCP', |
3123
|
|
|
$this->conditionalNumberFormatting($std->pFCP, 4), |
3124
|
|
|
false, |
3125
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3126
|
|
|
. "Combate à Pobreza (FCP)" |
3127
|
|
|
); |
3128
|
|
|
$this->dom->addChild( |
3129
|
|
|
$icms, |
3130
|
|
|
'vFCP', |
3131
|
|
|
$this->conditionalNumberFormatting($std->vFCP), |
3132
|
|
|
false, |
3133
|
|
|
"$identificador [item $std->item] Valor do FCP" |
3134
|
|
|
); |
3135
|
|
|
$this->dom->addChild( |
3136
|
|
|
$icms, |
3137
|
|
|
'vICMSDeson', |
3138
|
|
|
$this->conditionalNumberFormatting($std->vICMSDeson), |
3139
|
|
|
false, |
3140
|
|
|
"$identificador [item $std->item] Valor do ICMS desonerado" |
3141
|
|
|
); |
3142
|
|
|
$this->dom->addChild( |
3143
|
|
|
$icms, |
3144
|
|
|
'motDesICMS', |
3145
|
|
|
$std->motDesICMS, |
3146
|
|
|
false, |
3147
|
|
|
"$identificador [item $std->item] Motivo da desoneração do ICMS" |
3148
|
|
|
); |
3149
|
|
|
break; |
3150
|
|
|
case '30': |
3151
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
3152
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
3153
|
|
|
|
3154
|
|
|
$icms = $this->dom->createElement("ICMS30"); |
3155
|
|
|
$this->dom->addChild( |
3156
|
|
|
$icms, |
3157
|
|
|
'orig', |
3158
|
|
|
$std->orig, |
3159
|
|
|
true, |
3160
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
3161
|
|
|
); |
3162
|
|
|
$this->dom->addChild( |
3163
|
|
|
$icms, |
3164
|
|
|
'CST', |
3165
|
|
|
$std->CST, |
3166
|
|
|
true, |
3167
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 30" |
3168
|
|
|
); |
3169
|
|
|
$this->dom->addChild( |
3170
|
|
|
$icms, |
3171
|
|
|
'modBCST', |
3172
|
|
|
$std->modBCST, |
3173
|
|
|
true, |
3174
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
3175
|
|
|
); |
3176
|
|
|
$this->dom->addChild( |
3177
|
|
|
$icms, |
3178
|
|
|
'pMVAST', |
3179
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
3180
|
|
|
false, |
3181
|
|
|
"$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
3182
|
|
|
); |
3183
|
|
|
$this->dom->addChild( |
3184
|
|
|
$icms, |
3185
|
|
|
'pRedBCST', |
3186
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
3187
|
|
|
false, |
3188
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
3189
|
|
|
); |
3190
|
|
|
$this->dom->addChild( |
3191
|
|
|
$icms, |
3192
|
|
|
'vBCST', |
3193
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
3194
|
|
|
true, |
3195
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS ST" |
3196
|
|
|
); |
3197
|
|
|
$this->dom->addChild( |
3198
|
|
|
$icms, |
3199
|
|
|
'pICMSST', |
3200
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
3201
|
|
|
true, |
3202
|
|
|
"$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
3203
|
|
|
); |
3204
|
|
|
$this->dom->addChild( |
3205
|
|
|
$icms, |
3206
|
|
|
'vICMSST', |
3207
|
|
|
$this->conditionalNumberFormatting($std->vICMSST), |
3208
|
|
|
true, |
3209
|
|
|
"$identificador [item $std->item] Valor do ICMS ST" |
3210
|
|
|
); |
3211
|
|
|
$this->dom->addChild( |
3212
|
|
|
$icms, |
3213
|
|
|
'vBCFCPST', |
3214
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPST), |
3215
|
|
|
false, |
3216
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
3217
|
|
|
); |
3218
|
|
|
$this->dom->addChild( |
3219
|
|
|
$icms, |
3220
|
|
|
'pFCPST', |
3221
|
|
|
$this->conditionalNumberFormatting($std->pFCPST, 4), |
3222
|
|
|
false, |
3223
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3224
|
|
|
. "Combate à Pobreza (FCP) ST" |
3225
|
|
|
); |
3226
|
|
|
$this->dom->addChild( |
3227
|
|
|
$icms, |
3228
|
|
|
'vFCPST', |
3229
|
|
|
$this->conditionalNumberFormatting($std->vFCPST), |
3230
|
|
|
false, |
3231
|
|
|
"$identificador [item $std->item] Valor do FCP ST" |
3232
|
|
|
); |
3233
|
|
|
$this->dom->addChild( |
3234
|
|
|
$icms, |
3235
|
|
|
'vICMSDeson', |
3236
|
|
|
$this->conditionalNumberFormatting($std->vICMSDeson), |
3237
|
|
|
false, |
3238
|
|
|
"$identificador [item $std->item] Valor do ICMS desonerado" |
3239
|
|
|
); |
3240
|
|
|
$this->dom->addChild( |
3241
|
|
|
$icms, |
3242
|
|
|
'motDesICMS', |
3243
|
|
|
$std->motDesICMS, |
3244
|
|
|
false, |
3245
|
|
|
"$identificador [item $std->item] Motivo da desoneração do ICMS" |
3246
|
|
|
); |
3247
|
|
|
break; |
3248
|
|
|
case '40': |
3249
|
|
|
case '41': |
3250
|
|
|
case '50': |
3251
|
|
|
$icms = $this->dom->createElement("ICMS40"); |
3252
|
|
|
$this->dom->addChild( |
3253
|
|
|
$icms, |
3254
|
|
|
'orig', |
3255
|
|
|
$std->orig, |
3256
|
|
|
true, |
3257
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
3258
|
|
|
); |
3259
|
|
|
$this->dom->addChild( |
3260
|
|
|
$icms, |
3261
|
|
|
'CST', |
3262
|
|
|
$std->CST, |
3263
|
|
|
true, |
3264
|
|
|
"$identificador [item $std->item] Tributação do ICMS $std->CST" |
3265
|
|
|
); |
3266
|
|
|
$this->dom->addChild( |
3267
|
|
|
$icms, |
3268
|
|
|
'vICMSDeson', |
3269
|
|
|
$this->conditionalNumberFormatting($std->vICMSDeson), |
3270
|
|
|
false, |
3271
|
|
|
"$identificador [item $std->item] Valor do ICMS desonerado" |
3272
|
|
|
); |
3273
|
|
|
$this->dom->addChild( |
3274
|
|
|
$icms, |
3275
|
|
|
'motDesICMS', |
3276
|
|
|
$std->motDesICMS, |
3277
|
|
|
false, |
3278
|
|
|
"$identificador [item $std->item] Motivo da desoneração do ICMS" |
3279
|
|
|
); |
3280
|
|
|
break; |
3281
|
|
|
case '51': |
3282
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
3283
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
3284
|
|
|
|
3285
|
|
|
$icms = $this->dom->createElement("ICMS51"); |
3286
|
|
|
$this->dom->addChild( |
3287
|
|
|
$icms, |
3288
|
|
|
'orig', |
3289
|
|
|
$std->orig, |
3290
|
|
|
true, |
3291
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
3292
|
|
|
); |
3293
|
|
|
$this->dom->addChild( |
3294
|
|
|
$icms, |
3295
|
|
|
'CST', |
3296
|
|
|
$std->CST, |
3297
|
|
|
true, |
3298
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 51" |
3299
|
|
|
); |
3300
|
|
|
$this->dom->addChild( |
3301
|
|
|
$icms, |
3302
|
|
|
'modBC', |
3303
|
|
|
$std->modBC, |
3304
|
|
|
false, |
3305
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
3306
|
|
|
); |
3307
|
|
|
$this->dom->addChild( |
3308
|
|
|
$icms, |
3309
|
|
|
'pRedBC', |
3310
|
|
|
$this->conditionalNumberFormatting($std->pRedBC, 4), |
3311
|
|
|
false, |
3312
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC" |
3313
|
|
|
); |
3314
|
|
|
$this->dom->addChild( |
3315
|
|
|
$icms, |
3316
|
|
|
'vBC', |
3317
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
3318
|
|
|
false, |
3319
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS" |
3320
|
|
|
); |
3321
|
|
|
$this->dom->addChild( |
3322
|
|
|
$icms, |
3323
|
|
|
'pICMS', |
3324
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
3325
|
|
|
false, |
3326
|
|
|
"$identificador [item $std->item] Alíquota do imposto" |
3327
|
|
|
); |
3328
|
|
|
$this->dom->addChild( |
3329
|
|
|
$icms, |
3330
|
|
|
'vICMSOp', |
3331
|
|
|
$this->conditionalNumberFormatting($std->vICMSOp), |
3332
|
|
|
false, |
3333
|
|
|
"$identificador [item $std->item] Valor do ICMS da Operação" |
3334
|
|
|
); |
3335
|
|
|
$this->dom->addChild( |
3336
|
|
|
$icms, |
3337
|
|
|
'pDif', |
3338
|
|
|
$this->conditionalNumberFormatting($std->pDif, 4), |
3339
|
|
|
false, |
3340
|
|
|
"$identificador [item $std->item] Percentual do diferimento" |
3341
|
|
|
); |
3342
|
|
|
$this->dom->addChild( |
3343
|
|
|
$icms, |
3344
|
|
|
'vICMSDif', |
3345
|
|
|
$this->conditionalNumberFormatting($std->vICMSDif), |
3346
|
|
|
false, |
3347
|
|
|
"$identificador [item $std->item] Valor do ICMS diferido" |
3348
|
|
|
); |
3349
|
|
|
$this->dom->addChild( |
3350
|
|
|
$icms, |
3351
|
|
|
'vICMS', |
3352
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
3353
|
|
|
false, |
3354
|
|
|
"$identificador [item $std->item] Valor do ICMS realmente devido" |
3355
|
|
|
); |
3356
|
|
|
$this->dom->addChild( |
3357
|
|
|
$icms, |
3358
|
|
|
'vBCFCP', |
3359
|
|
|
$this->conditionalNumberFormatting($std->vBCFCP), |
3360
|
|
|
false, |
3361
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
3362
|
|
|
); |
3363
|
|
|
$this->dom->addChild( |
3364
|
|
|
$icms, |
3365
|
|
|
'pFCP', |
3366
|
|
|
$this->conditionalNumberFormatting($std->pFCP, 4), |
3367
|
|
|
false, |
3368
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3369
|
|
|
. "Combate à Pobreza (FCP)" |
3370
|
|
|
); |
3371
|
|
|
$this->dom->addChild( |
3372
|
|
|
$icms, |
3373
|
|
|
'vFCP', |
3374
|
|
|
$this->conditionalNumberFormatting($std->vFCP), |
3375
|
|
|
false, |
3376
|
|
|
"$identificador [item $std->item] Valor do FCP" |
3377
|
|
|
); |
3378
|
|
|
break; |
3379
|
|
|
case '60': |
3380
|
|
|
$icms = $this->dom->createElement("ICMS60"); |
3381
|
|
|
$this->dom->addChild( |
3382
|
|
|
$icms, |
3383
|
|
|
'orig', |
3384
|
|
|
$std->orig, |
3385
|
|
|
true, |
3386
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
3387
|
|
|
); |
3388
|
|
|
$this->dom->addChild( |
3389
|
|
|
$icms, |
3390
|
|
|
'CST', |
3391
|
|
|
$std->CST, |
3392
|
|
|
true, |
3393
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 60" |
3394
|
|
|
); |
3395
|
|
|
$this->dom->addChild( |
3396
|
|
|
$icms, |
3397
|
|
|
'vBCSTRet', |
3398
|
|
|
$this->conditionalNumberFormatting($std->vBCSTRet), |
3399
|
|
|
false, |
3400
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS ST retido" |
3401
|
|
|
); |
3402
|
|
|
$this->dom->addChild( |
3403
|
|
|
$icms, |
3404
|
|
|
'pST', |
3405
|
|
|
$this->conditionalNumberFormatting($std->pST, 4), |
3406
|
|
|
false, |
3407
|
|
|
"$identificador [item $std->item] Valor do ICMS ST retido" |
3408
|
|
|
); |
3409
|
|
|
$this->dom->addChild( |
3410
|
|
|
$icms, |
3411
|
|
|
'vICMSSubstituto', |
3412
|
|
|
$this->conditionalNumberFormatting($std->vICMSSubstituto), |
3413
|
|
|
false, |
3414
|
|
|
"$identificador [item $std->item] Valor do ICMS próprio do Substituto" |
3415
|
|
|
); |
3416
|
|
|
$this->dom->addChild( |
3417
|
|
|
$icms, |
3418
|
|
|
'vICMSSTRet', |
3419
|
|
|
$this->conditionalNumberFormatting($std->vICMSSTRet), |
3420
|
|
|
false, |
3421
|
|
|
"$identificador [item $std->item] Valor do ICMS ST retido" |
3422
|
|
|
); |
3423
|
|
|
$this->dom->addChild( |
3424
|
|
|
$icms, |
3425
|
|
|
'vBCFCPSTRet', |
3426
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPSTRet), |
3427
|
|
|
false, |
3428
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo " |
3429
|
|
|
. "do FCP retido anteriormente por ST" |
3430
|
|
|
); |
3431
|
|
|
$this->dom->addChild( |
3432
|
|
|
$icms, |
3433
|
|
|
'pFCPSTRet', |
3434
|
|
|
$this->conditionalNumberFormatting($std->pFCPSTRet, 4), |
3435
|
|
|
false, |
3436
|
|
|
"$identificador [item $std->item] Percentual do FCP retido " |
3437
|
|
|
. "anteriormente por Substituição Tributária" |
3438
|
|
|
); |
3439
|
|
|
$this->dom->addChild( |
3440
|
|
|
$icms, |
3441
|
|
|
'vFCPSTRet', |
3442
|
|
|
$this->conditionalNumberFormatting($std->vFCPSTRet), |
3443
|
|
|
false, |
3444
|
|
|
"$identificador [item $std->item] Valor do FCP retido por " |
3445
|
|
|
. "Substituição Tributária" |
3446
|
|
|
); |
3447
|
|
|
$this->dom->addChild( |
3448
|
|
|
$icms, |
3449
|
|
|
'pRedBCEfet', |
3450
|
|
|
$this->conditionalNumberFormatting($std->pRedBCEfet, 4), |
3451
|
|
|
false, |
3452
|
|
|
"$identificador [item $std->item] Percentual de redução " |
3453
|
|
|
. "para obtenção da base de cálculo efetiva (vBCEfet)" |
3454
|
|
|
); |
3455
|
|
|
$this->dom->addChild( |
3456
|
|
|
$icms, |
3457
|
|
|
'vBCEfet', |
3458
|
|
|
$this->conditionalNumberFormatting($std->vBCEfet), |
3459
|
|
|
false, |
3460
|
|
|
"$identificador [item $std->item] base de calculo efetiva" |
3461
|
|
|
); |
3462
|
|
|
$this->dom->addChild( |
3463
|
|
|
$icms, |
3464
|
|
|
'pICMSEfet', |
3465
|
|
|
$this->conditionalNumberFormatting($std->pICMSEfet, 4), |
3466
|
|
|
false, |
3467
|
|
|
"$identificador [item $std->item] Alíquota do ICMS na operação a consumidor final" |
3468
|
|
|
); |
3469
|
|
|
$this->dom->addChild( |
3470
|
|
|
$icms, |
3471
|
|
|
'vICMSEfet', |
3472
|
|
|
$this->conditionalNumberFormatting($std->vICMSEfet), |
3473
|
|
|
false, |
3474
|
|
|
"$identificador [item $std->item] Valor do ICMS efetivo" |
3475
|
|
|
); |
3476
|
|
|
break; |
3477
|
|
|
case '70': |
3478
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
3479
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
3480
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
3481
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
3482
|
|
|
|
3483
|
|
|
$icms = $this->dom->createElement("ICMS70"); |
3484
|
|
|
$this->dom->addChild( |
3485
|
|
|
$icms, |
3486
|
|
|
'orig', |
3487
|
|
|
$std->orig, |
3488
|
|
|
true, |
3489
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
3490
|
|
|
); |
3491
|
|
|
$this->dom->addChild( |
3492
|
|
|
$icms, |
3493
|
|
|
'CST', |
3494
|
|
|
$std->CST, |
3495
|
|
|
true, |
3496
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 70" |
3497
|
|
|
); |
3498
|
|
|
$this->dom->addChild( |
3499
|
|
|
$icms, |
3500
|
|
|
'modBC', |
3501
|
|
|
$std->modBC, |
3502
|
|
|
true, |
3503
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
3504
|
|
|
); |
3505
|
|
|
$this->dom->addChild( |
3506
|
|
|
$icms, |
3507
|
|
|
'pRedBC', |
3508
|
|
|
$this->conditionalNumberFormatting($std->pRedBC, 4), |
3509
|
|
|
true, |
3510
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC" |
3511
|
|
|
); |
3512
|
|
|
$this->dom->addChild( |
3513
|
|
|
$icms, |
3514
|
|
|
'vBC', |
3515
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
3516
|
|
|
true, |
3517
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS" |
3518
|
|
|
); |
3519
|
|
|
$this->dom->addChild( |
3520
|
|
|
$icms, |
3521
|
|
|
'pICMS', |
3522
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
3523
|
|
|
true, |
3524
|
|
|
"$identificador [item $std->item] Alíquota do imposto" |
3525
|
|
|
); |
3526
|
|
|
$this->dom->addChild( |
3527
|
|
|
$icms, |
3528
|
|
|
'vICMS', |
3529
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
3530
|
|
|
true, |
3531
|
|
|
"$identificador [item $std->item] Valor do ICMS" |
3532
|
|
|
); |
3533
|
|
|
$this->dom->addChild( |
3534
|
|
|
$icms, |
3535
|
|
|
'vBCFCP', |
3536
|
|
|
$this->conditionalNumberFormatting($std->vBCFCP), |
3537
|
|
|
false, |
3538
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
3539
|
|
|
); |
3540
|
|
|
$this->dom->addChild( |
3541
|
|
|
$icms, |
3542
|
|
|
'pFCP', |
3543
|
|
|
$this->conditionalNumberFormatting($std->pFCP, 4), |
3544
|
|
|
false, |
3545
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3546
|
|
|
. "Combate à Pobreza (FCP)" |
3547
|
|
|
); |
3548
|
|
|
$this->dom->addChild( |
3549
|
|
|
$icms, |
3550
|
|
|
'vFCP', |
3551
|
|
|
$std->vFCP, |
3552
|
|
|
false, |
3553
|
|
|
"$identificador [item $std->item] Valor do FCP" |
3554
|
|
|
); |
3555
|
|
|
$this->dom->addChild( |
3556
|
|
|
$icms, |
3557
|
|
|
'modBCST', |
3558
|
|
|
$std->modBCST, |
3559
|
|
|
true, |
3560
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
3561
|
|
|
); |
3562
|
|
|
$this->dom->addChild( |
3563
|
|
|
$icms, |
3564
|
|
|
'pMVAST', |
3565
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
3566
|
|
|
false, |
3567
|
|
|
"$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
3568
|
|
|
); |
3569
|
|
|
$this->dom->addChild( |
3570
|
|
|
$icms, |
3571
|
|
|
'pRedBCST', |
3572
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
3573
|
|
|
false, |
3574
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
3575
|
|
|
); |
3576
|
|
|
$this->dom->addChild( |
3577
|
|
|
$icms, |
3578
|
|
|
'vBCST', |
3579
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
3580
|
|
|
true, |
3581
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS ST" |
3582
|
|
|
); |
3583
|
|
|
$this->dom->addChild( |
3584
|
|
|
$icms, |
3585
|
|
|
'pICMSST', |
3586
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
3587
|
|
|
true, |
3588
|
|
|
"$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
3589
|
|
|
); |
3590
|
|
|
$this->dom->addChild( |
3591
|
|
|
$icms, |
3592
|
|
|
'vICMSST', |
3593
|
|
|
$this->conditionalNumberFormatting($std->vICMSST), |
3594
|
|
|
true, |
3595
|
|
|
"$identificador [item $std->item] Valor do ICMS ST" |
3596
|
|
|
); |
3597
|
|
|
$this->dom->addChild( |
3598
|
|
|
$icms, |
3599
|
|
|
'vBCFCPST', |
3600
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPST), |
3601
|
|
|
false, |
3602
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
3603
|
|
|
); |
3604
|
|
|
$this->dom->addChild( |
3605
|
|
|
$icms, |
3606
|
|
|
'pFCPST', |
3607
|
|
|
$this->conditionalNumberFormatting($std->pFCPST, 4), |
3608
|
|
|
false, |
3609
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3610
|
|
|
. "Combate à Pobreza (FCP) ST" |
3611
|
|
|
); |
3612
|
|
|
$this->dom->addChild( |
3613
|
|
|
$icms, |
3614
|
|
|
'vFCPST', |
3615
|
|
|
$this->conditionalNumberFormatting($std->vFCPST), |
3616
|
|
|
false, |
3617
|
|
|
"$identificador [item $std->item] Valor do FCP ST" |
3618
|
|
|
); |
3619
|
|
|
$this->dom->addChild( |
3620
|
|
|
$icms, |
3621
|
|
|
'vICMSDeson', |
3622
|
|
|
$this->conditionalNumberFormatting($std->vICMSDeson), |
3623
|
|
|
false, |
3624
|
|
|
"$identificador [item $std->item] Valor do ICMS desonerado" |
3625
|
|
|
); |
3626
|
|
|
$this->dom->addChild( |
3627
|
|
|
$icms, |
3628
|
|
|
'motDesICMS', |
3629
|
|
|
$std->motDesICMS, |
3630
|
|
|
false, |
3631
|
|
|
"$identificador [item $std->item] Motivo da desoneração do ICMS" |
3632
|
|
|
); |
3633
|
|
|
break; |
3634
|
|
|
case '90': |
3635
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
3636
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
3637
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
3638
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
3639
|
|
|
|
3640
|
|
|
$icms = $this->dom->createElement("ICMS90"); |
3641
|
|
|
$this->dom->addChild( |
3642
|
|
|
$icms, |
3643
|
|
|
'orig', |
3644
|
|
|
$std->orig, |
3645
|
|
|
true, |
3646
|
|
|
"$identificador [item $std->item] Origem da mercadoria" |
3647
|
|
|
); |
3648
|
|
|
$this->dom->addChild( |
3649
|
|
|
$icms, |
3650
|
|
|
'CST', |
3651
|
|
|
$std->CST, |
3652
|
|
|
true, |
3653
|
|
|
"$identificador [item $std->item] Tributação do ICMS = 90" |
3654
|
|
|
); |
3655
|
|
|
$this->dom->addChild( |
3656
|
|
|
$icms, |
3657
|
|
|
'modBC', |
3658
|
|
|
$std->modBC, |
3659
|
|
|
false, |
3660
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
3661
|
|
|
); |
3662
|
|
|
$this->dom->addChild( |
3663
|
|
|
$icms, |
3664
|
|
|
'vBC', |
3665
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
3666
|
|
|
false, |
3667
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS" |
3668
|
|
|
); |
3669
|
|
|
$this->dom->addChild( |
3670
|
|
|
$icms, |
3671
|
|
|
'pRedBC', |
3672
|
|
|
$this->conditionalNumberFormatting($std->pRedBC, 4), |
3673
|
|
|
false, |
3674
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC" |
3675
|
|
|
); |
3676
|
|
|
$this->dom->addChild( |
3677
|
|
|
$icms, |
3678
|
|
|
'pICMS', |
3679
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
3680
|
|
|
false, |
3681
|
|
|
"$identificador [item $std->item] Alíquota do imposto" |
3682
|
|
|
); |
3683
|
|
|
$this->dom->addChild( |
3684
|
|
|
$icms, |
3685
|
|
|
'vICMS', |
3686
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
3687
|
|
|
false, |
3688
|
|
|
"$identificador [item $std->item] Valor do ICMS" |
3689
|
|
|
); |
3690
|
|
|
$this->dom->addChild( |
3691
|
|
|
$icms, |
3692
|
|
|
'vBCFCP', |
3693
|
|
|
$this->conditionalNumberFormatting($std->vBCFCP), |
3694
|
|
|
false, |
3695
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
3696
|
|
|
); |
3697
|
|
|
$this->dom->addChild( |
3698
|
|
|
$icms, |
3699
|
|
|
'pFCP', |
3700
|
|
|
$this->conditionalNumberFormatting($std->pFCP, 4), |
3701
|
|
|
false, |
3702
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3703
|
|
|
. "Combate à Pobreza (FCP)" |
3704
|
|
|
); |
3705
|
|
|
$this->dom->addChild( |
3706
|
|
|
$icms, |
3707
|
|
|
'vFCP', |
3708
|
|
|
$this->conditionalNumberFormatting($std->vFCP), |
3709
|
|
|
false, |
3710
|
|
|
"$identificador [item $std->item] Valor do FCP" |
3711
|
|
|
); |
3712
|
|
|
$this->dom->addChild( |
3713
|
|
|
$icms, |
3714
|
|
|
'modBCST', |
3715
|
|
|
$std->modBCST, |
3716
|
|
|
false, |
3717
|
|
|
"$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
3718
|
|
|
); |
3719
|
|
|
$this->dom->addChild( |
3720
|
|
|
$icms, |
3721
|
|
|
'pMVAST', |
3722
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
3723
|
|
|
false, |
3724
|
|
|
"$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
3725
|
|
|
); |
3726
|
|
|
$this->dom->addChild( |
3727
|
|
|
$icms, |
3728
|
|
|
'pRedBCST', |
3729
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
3730
|
|
|
false, |
3731
|
|
|
"$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
3732
|
|
|
); |
3733
|
|
|
$this->dom->addChild( |
3734
|
|
|
$icms, |
3735
|
|
|
'vBCST', |
3736
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
3737
|
|
|
false, |
3738
|
|
|
"$identificador [item $std->item] Valor da BC do ICMS ST" |
3739
|
|
|
); |
3740
|
|
|
$this->dom->addChild( |
3741
|
|
|
$icms, |
3742
|
|
|
'pICMSST', |
3743
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
3744
|
|
|
false, |
3745
|
|
|
"$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
3746
|
|
|
); |
3747
|
|
|
$this->dom->addChild( |
3748
|
|
|
$icms, |
3749
|
|
|
'vICMSST', |
3750
|
|
|
$this->conditionalNumberFormatting($std->vICMSST), |
3751
|
|
|
false, |
3752
|
|
|
"$identificador [item $std->item] Valor do ICMS ST" |
3753
|
|
|
); |
3754
|
|
|
$this->dom->addChild( |
3755
|
|
|
$icms, |
3756
|
|
|
'vBCFCPST', |
3757
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPST), |
3758
|
|
|
false, |
3759
|
|
|
"$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
3760
|
|
|
); |
3761
|
|
|
$this->dom->addChild( |
3762
|
|
|
$icms, |
3763
|
|
|
'pFCPST', |
3764
|
|
|
$this->conditionalNumberFormatting($std->pFCPST, 4), |
3765
|
|
|
false, |
3766
|
|
|
"$identificador [item $std->item] Percentual do Fundo de " |
3767
|
|
|
. "Combate à Pobreza (FCP) ST" |
3768
|
|
|
); |
3769
|
|
|
$this->dom->addChild( |
3770
|
|
|
$icms, |
3771
|
|
|
'vFCPST', |
3772
|
|
|
$this->conditionalNumberFormatting($std->vFCPST), |
3773
|
|
|
false, |
3774
|
|
|
"$identificador [item $std->item] Valor do FCP ST" |
3775
|
|
|
); |
3776
|
|
|
$this->dom->addChild( |
3777
|
|
|
$icms, |
3778
|
|
|
'vICMSDeson', |
3779
|
|
|
$this->conditionalNumberFormatting($std->vICMSDeson), |
3780
|
|
|
false, |
3781
|
|
|
"$identificador [item $std->item] Valor do ICMS desonerado" |
3782
|
|
|
); |
3783
|
|
|
$this->dom->addChild( |
3784
|
|
|
$icms, |
3785
|
|
|
'motDesICMS', |
3786
|
|
|
$std->motDesICMS, |
3787
|
|
|
false, |
3788
|
|
|
"$identificador [item $std->item] Motivo da desoneração do ICMS" |
3789
|
|
|
); |
3790
|
|
|
break; |
3791
|
|
|
} |
3792
|
|
|
$tagIcms = $this->dom->createElement('ICMS'); |
3793
|
|
|
if (isset($icms)) { |
3794
|
|
|
$tagIcms->appendChild($icms); |
3795
|
|
|
} |
3796
|
|
|
$this->aICMS[$std->item] = $tagIcms; |
3797
|
|
|
return $tagIcms; |
3798
|
|
|
} |
3799
|
|
|
|
3800
|
|
|
/** |
3801
|
|
|
* Grupo de Partilha do ICMS entre a UF de origem e UF de destino ou |
3802
|
|
|
* a UF definida na legislação. N10a pai N01 |
3803
|
|
|
* tag NFe/infNFe/det[]/imposto/ICMS/ICMSPart |
3804
|
|
|
* @param stdClass $std |
3805
|
|
|
* @return DOMElement |
3806
|
|
|
*/ |
3807
|
|
|
public function tagICMSPart(stdClass $std) |
3808
|
|
|
{ |
3809
|
|
|
$possible = [ |
3810
|
|
|
'item', |
3811
|
|
|
'orig', |
3812
|
|
|
'CST', |
3813
|
|
|
'modBC', |
3814
|
|
|
'vBC', |
3815
|
|
|
'pRedBC', |
3816
|
|
|
'pICMS', |
3817
|
|
|
'vICMS', |
3818
|
|
|
'modBCST', |
3819
|
|
|
'pMVAST', |
3820
|
|
|
'pRedBCST', |
3821
|
|
|
'vBCST', |
3822
|
|
|
'pICMSST', |
3823
|
|
|
'vICMSST', |
3824
|
|
|
'pBCOp', |
3825
|
|
|
'UFST' |
3826
|
|
|
]; |
3827
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3828
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
3829
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
3830
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
3831
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
3832
|
|
|
$icmsPart = $this->dom->createElement("ICMSPart"); |
3833
|
|
|
$this->dom->addChild( |
3834
|
|
|
$icmsPart, |
3835
|
|
|
'orig', |
3836
|
|
|
$std->orig, |
3837
|
|
|
true, |
3838
|
|
|
"[item $std->item] Origem da mercadoria" |
3839
|
|
|
); |
3840
|
|
|
$this->dom->addChild( |
3841
|
|
|
$icmsPart, |
3842
|
|
|
'CST', |
3843
|
|
|
$std->CST, |
3844
|
|
|
true, |
3845
|
|
|
"[item $std->item] Tributação do ICMS 10 ou 90" |
3846
|
|
|
); |
3847
|
|
|
$this->dom->addChild( |
3848
|
|
|
$icmsPart, |
3849
|
|
|
'modBC', |
3850
|
|
|
$std->modBC, |
3851
|
|
|
true, |
3852
|
|
|
"[item $std->item] Modalidade de determinação da BC do ICMS" |
3853
|
|
|
); |
3854
|
|
|
$this->dom->addChild( |
3855
|
|
|
$icmsPart, |
3856
|
|
|
'vBC', |
3857
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
3858
|
|
|
true, |
3859
|
|
|
"[item $std->item] Valor da BC do ICMS" |
3860
|
|
|
); |
3861
|
|
|
$this->dom->addChild( |
3862
|
|
|
$icmsPart, |
3863
|
|
|
'pRedBC', |
3864
|
|
|
$this->conditionalNumberFormatting($std->pRedBC, 4), |
3865
|
|
|
false, |
3866
|
|
|
"[item $std->item] Percentual da Redução de BC" |
3867
|
|
|
); |
3868
|
|
|
$this->dom->addChild( |
3869
|
|
|
$icmsPart, |
3870
|
|
|
'pICMS', |
3871
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
3872
|
|
|
true, |
3873
|
|
|
"[item $std->item] Alíquota do imposto" |
3874
|
|
|
); |
3875
|
|
|
$this->dom->addChild( |
3876
|
|
|
$icmsPart, |
3877
|
|
|
'vICMS', |
3878
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
3879
|
|
|
true, |
3880
|
|
|
"[item $std->item] Valor do ICMS" |
3881
|
|
|
); |
3882
|
|
|
$this->dom->addChild( |
3883
|
|
|
$icmsPart, |
3884
|
|
|
'modBCST', |
3885
|
|
|
$std->modBCST, |
3886
|
|
|
true, |
3887
|
|
|
"[item $std->item] Modalidade de determinação da BC do ICMS ST" |
3888
|
|
|
); |
3889
|
|
|
$this->dom->addChild( |
3890
|
|
|
$icmsPart, |
3891
|
|
|
'pMVAST', |
3892
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
3893
|
|
|
false, |
3894
|
|
|
"[item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
3895
|
|
|
); |
3896
|
|
|
$this->dom->addChild( |
3897
|
|
|
$icmsPart, |
3898
|
|
|
'pRedBCST', |
3899
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
3900
|
|
|
false, |
3901
|
|
|
"[item $std->item] Percentual da Redução de BC do ICMS ST" |
3902
|
|
|
); |
3903
|
|
|
$this->dom->addChild( |
3904
|
|
|
$icmsPart, |
3905
|
|
|
'vBCST', |
3906
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
3907
|
|
|
true, |
3908
|
|
|
"[item $std->item] Valor da BC do ICMS ST" |
3909
|
|
|
); |
3910
|
|
|
$this->dom->addChild( |
3911
|
|
|
$icmsPart, |
3912
|
|
|
'pICMSST', |
3913
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
3914
|
|
|
true, |
3915
|
|
|
"[item $std->item] Alíquota do imposto do ICMS ST" |
3916
|
|
|
); |
3917
|
|
|
$this->dom->addChild( |
3918
|
|
|
$icmsPart, |
3919
|
|
|
'vICMSST', |
3920
|
|
|
$this->conditionalNumberFormatting($std->vICMSST), |
3921
|
|
|
true, |
3922
|
|
|
"[item $std->item] Valor do ICMS ST" |
3923
|
|
|
); |
3924
|
|
|
$this->dom->addChild( |
3925
|
|
|
$icmsPart, |
3926
|
|
|
'pBCOp', |
3927
|
|
|
$this->conditionalNumberFormatting($std->pBCOp, 4), |
3928
|
|
|
true, |
3929
|
|
|
"[item $std->item] Percentual da BC operação própria" |
3930
|
|
|
); |
3931
|
|
|
$this->dom->addChild( |
3932
|
|
|
$icmsPart, |
3933
|
|
|
'UFST', |
3934
|
|
|
$std->UFST, |
3935
|
|
|
true, |
3936
|
|
|
"[item $std->item] UF para qual é devido o ICMS ST" |
3937
|
|
|
); |
3938
|
|
|
//caso exista a tag aICMS[$std->item] inserir nela caso contrario criar |
3939
|
|
|
if (!empty($this->aICMS[$std->item])) { |
3940
|
|
|
$tagIcms = $this->aICMS[$std->item]; |
3941
|
|
|
} else { |
3942
|
|
|
$tagIcms = $this->dom->createElement('ICMS'); |
3943
|
|
|
} |
3944
|
|
|
$this->dom->appChild($tagIcms, $icmsPart, "Inserindo ICMSPart em ICMS[$std->item]"); |
3945
|
|
|
$this->aICMS[$std->item] = $tagIcms; |
3946
|
|
|
return $tagIcms; |
3947
|
|
|
} |
3948
|
|
|
|
3949
|
|
|
/** |
3950
|
|
|
* Grupo de Repasse de ICMSST retido anteriormente em operações |
3951
|
|
|
* interestaduais com repasses através do Substituto Tributário |
3952
|
|
|
* NOTA: ajustado NT 2018.005 |
3953
|
|
|
* tag NFe/infNFe/det[]/imposto/ICMS/ICMSST N10b pai N01 |
3954
|
|
|
* @param stdClass $std |
3955
|
|
|
* @return DOMElement |
3956
|
|
|
*/ |
3957
|
|
|
public function tagICMSST(stdClass $std) |
3958
|
|
|
{ |
3959
|
|
|
$possible = [ |
3960
|
|
|
'item', |
3961
|
|
|
'orig', |
3962
|
|
|
'CST', |
3963
|
|
|
'vBCSTRet', |
3964
|
|
|
'vICMSSTRet', |
3965
|
|
|
'vBCSTDest', |
3966
|
|
|
'vICMSSTDest', |
3967
|
|
|
'vBCFCPSTRet', |
3968
|
|
|
'pFCPSTRet', |
3969
|
|
|
'vFCPSTRet', |
3970
|
|
|
'pST', |
3971
|
|
|
'vICMSSubstituto', |
3972
|
|
|
'pRedBCEfet', |
3973
|
|
|
'vBCEfet', |
3974
|
|
|
'pICMSEfet', |
3975
|
|
|
'vICMSEfet' |
3976
|
|
|
]; |
3977
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3978
|
|
|
$icmsST = $this->dom->createElement("ICMSST"); |
3979
|
|
|
$this->dom->addChild( |
3980
|
|
|
$icmsST, |
3981
|
|
|
'orig', |
3982
|
|
|
$std->orig, |
3983
|
|
|
true, |
3984
|
|
|
"[item $std->item] Origem da mercadoria" |
3985
|
|
|
); |
3986
|
|
|
$this->dom->addChild( |
3987
|
|
|
$icmsST, |
3988
|
|
|
'CST', |
3989
|
|
|
$std->CST, |
3990
|
|
|
true, |
3991
|
|
|
"[item $std->item] Tributação do ICMS 41 ou 60" |
3992
|
|
|
); |
3993
|
|
|
$this->dom->addChild( |
3994
|
|
|
$icmsST, |
3995
|
|
|
'vBCSTRet', |
3996
|
|
|
$this->conditionalNumberFormatting($std->vBCSTRet), |
3997
|
|
|
true, |
3998
|
|
|
"[item $std->item] Valor do BC do ICMS ST retido na UF remetente" |
3999
|
|
|
); |
4000
|
|
|
$this->dom->addChild( |
4001
|
|
|
$icmsST, |
4002
|
|
|
'pST', |
4003
|
|
|
$this->conditionalNumberFormatting($std->pST, 4), |
4004
|
|
|
false, |
4005
|
|
|
"[item $std->item] Alíquota suportada pelo Consumidor Final" |
4006
|
|
|
); |
4007
|
|
|
$this->dom->addChild( |
4008
|
|
|
$icmsST, |
4009
|
|
|
'vICMSSubstituto', |
4010
|
|
|
$this->conditionalNumberFormatting($std->vICMSSubstituto), |
4011
|
|
|
false, |
4012
|
|
|
"[item $std->item] Valor do ICMS próprio do Substituto" |
4013
|
|
|
); |
4014
|
|
|
$this->dom->addChild( |
4015
|
|
|
$icmsST, |
4016
|
|
|
'vICMSSTRet', |
4017
|
|
|
$this->conditionalNumberFormatting($std->vICMSSTRet), |
4018
|
|
|
true, |
4019
|
|
|
"[item $std->item] Valor do ICMS ST retido na UF remetente" |
4020
|
|
|
); |
4021
|
|
|
$this->dom->addChild( |
4022
|
|
|
$icmsST, |
4023
|
|
|
'vBCFCPSTRet', |
4024
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPSTRet), |
4025
|
|
|
false, |
4026
|
|
|
"[item $std->item] Valor da Base de Cálculo do FCP" |
4027
|
|
|
); |
4028
|
|
|
$this->dom->addChild( |
4029
|
|
|
$icmsST, |
4030
|
|
|
'pFCPSTRet', |
4031
|
|
|
$this->conditionalNumberFormatting($std->pFCPSTRet, 4), |
4032
|
|
|
false, |
4033
|
|
|
"[item $std->item] Percentual do FCP retido" |
4034
|
|
|
); |
4035
|
|
|
$this->dom->addChild( |
4036
|
|
|
$icmsST, |
4037
|
|
|
'vFCPSTRet', |
4038
|
|
|
$this->conditionalNumberFormatting($std->vFCPSTRet), |
4039
|
|
|
false, |
4040
|
|
|
"[item $std->item] Valor do FCP retido" |
4041
|
|
|
); |
4042
|
|
|
$this->dom->addChild( |
4043
|
|
|
$icmsST, |
4044
|
|
|
'vBCSTDest', |
4045
|
|
|
$this->conditionalNumberFormatting($std->vBCSTDest), |
4046
|
|
|
true, |
4047
|
|
|
"[item $std->item] Valor da BC do ICMS ST da UF destino" |
4048
|
|
|
); |
4049
|
|
|
$this->dom->addChild( |
4050
|
|
|
$icmsST, |
4051
|
|
|
'vICMSSTDest', |
4052
|
|
|
$this->conditionalNumberFormatting($std->vICMSSTDest), |
4053
|
|
|
true, |
4054
|
|
|
"[item $std->item] Valor do ICMS ST da UF destino" |
4055
|
|
|
); |
4056
|
|
|
$this->dom->addChild( |
4057
|
|
|
$icmsST, |
4058
|
|
|
'pRedBCEfet', |
4059
|
|
|
$this->conditionalNumberFormatting($std->pRedBCEfet, 4), |
4060
|
|
|
false, |
4061
|
|
|
"[item $std->item] Percentual de redução da base de cálculo efetiva" |
4062
|
|
|
); |
4063
|
|
|
$this->dom->addChild( |
4064
|
|
|
$icmsST, |
4065
|
|
|
'vBCEfet', |
4066
|
|
|
$this->conditionalNumberFormatting($std->vBCEfet), |
4067
|
|
|
false, |
4068
|
|
|
"[item $std->item] Valor da base de cálculo efetiva" |
4069
|
|
|
); |
4070
|
|
|
$this->dom->addChild( |
4071
|
|
|
$icmsST, |
4072
|
|
|
'pICMSEfet', |
4073
|
|
|
$this->conditionalNumberFormatting($std->pICMSEfet, 4), |
4074
|
|
|
false, |
4075
|
|
|
"[item $std->item] Alíquota do ICMS efetiva" |
4076
|
|
|
); |
4077
|
|
|
$this->dom->addChild( |
4078
|
|
|
$icmsST, |
4079
|
|
|
'vICMSEfet', |
4080
|
|
|
$this->conditionalNumberFormatting($std->vICMSEfet), |
4081
|
|
|
false, |
4082
|
|
|
"[item $std->item] Valor do ICMS efetivo" |
4083
|
|
|
); |
4084
|
|
|
//caso exista a tag aICMS[$std->item] inserir nela caso contrario criar |
4085
|
|
|
if (!empty($this->aICMS[$std->item])) { |
4086
|
|
|
$tagIcms = $this->aICMS[$std->item]; |
4087
|
|
|
} else { |
4088
|
|
|
$tagIcms = $this->dom->createElement('ICMS'); |
4089
|
|
|
} |
4090
|
|
|
$this->dom->appChild($tagIcms, $icmsST, "Inserindo ICMSST em ICMS[$std->item]"); |
4091
|
|
|
$this->aICMS[$std->item] = $tagIcms; |
4092
|
|
|
return $tagIcms; |
4093
|
|
|
} |
4094
|
|
|
|
4095
|
|
|
/** |
4096
|
|
|
* Tributação ICMS pelo Simples Nacional N10c pai N01 |
4097
|
|
|
* tag NFe/infNFe/det[]/imposto/ICMS/ICMSSN N10c pai N01 |
4098
|
|
|
* @param stdClass $std |
4099
|
|
|
* @return DOMElement |
4100
|
|
|
*/ |
4101
|
|
|
public function tagICMSSN(stdClass $std) |
4102
|
|
|
{ |
4103
|
|
|
$possible = [ |
4104
|
|
|
'item', |
4105
|
|
|
'orig', |
4106
|
|
|
'CSOSN', |
4107
|
|
|
'pCredSN', |
4108
|
|
|
'vCredICMSSN', |
4109
|
|
|
'modBCST', |
4110
|
|
|
'pMVAST', |
4111
|
|
|
'pRedBCST', |
4112
|
|
|
'vBCST', |
4113
|
|
|
'pICMSST', |
4114
|
|
|
'vICMSST', |
4115
|
|
|
'vBCFCPST', |
4116
|
|
|
'pFCPST', |
4117
|
|
|
'vFCPST', |
4118
|
|
|
'vBCSTRet', |
4119
|
|
|
'pST', |
4120
|
|
|
'vICMSSTRet', |
4121
|
|
|
'vBCFCPSTRet', |
4122
|
|
|
'pFCPSTRet', |
4123
|
|
|
'vFCPSTRet', |
4124
|
|
|
'modBC', |
4125
|
|
|
'vBC', |
4126
|
|
|
'pRedBC', |
4127
|
|
|
'pICMS', |
4128
|
|
|
'vICMS', |
4129
|
|
|
'pRedBCEfet', |
4130
|
|
|
'vBCEfet', |
4131
|
|
|
'pICMSEfet', |
4132
|
|
|
'vICMSEfet', |
4133
|
|
|
'vICMSSubstituto' |
4134
|
|
|
]; |
4135
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4136
|
|
|
//totalizador generico |
4137
|
|
|
$this->stdTot->vFCPST += (float) !empty($std->vFCPST) ? $std->vFCPST : 0; |
4138
|
|
|
$this->stdTot->vFCPSTRet += (float) !empty($std->vFCPST) ? $std->vFCPSTRet : 0; |
4139
|
|
|
switch ($std->CSOSN) { |
4140
|
|
|
case '101': |
4141
|
|
|
$icmsSN = $this->dom->createElement("ICMSSN101"); |
4142
|
|
|
$this->dom->addChild( |
4143
|
|
|
$icmsSN, |
4144
|
|
|
'orig', |
4145
|
|
|
$std->orig, |
4146
|
|
|
true, |
4147
|
|
|
"[item $std->item] Origem da mercadoria" |
4148
|
|
|
); |
4149
|
|
|
$this->dom->addChild( |
4150
|
|
|
$icmsSN, |
4151
|
|
|
'CSOSN', |
4152
|
|
|
$std->CSOSN, |
4153
|
|
|
true, |
4154
|
|
|
"[item $std->item] Código de Situação da Operação Simples Nacional" |
4155
|
|
|
); |
4156
|
|
|
$this->dom->addChild( |
4157
|
|
|
$icmsSN, |
4158
|
|
|
'pCredSN', |
4159
|
|
|
$this->conditionalNumberFormatting($std->pCredSN, 2), |
4160
|
|
|
true, |
4161
|
|
|
"[item $std->item] Alíquota aplicável de cálculo do crédito (Simples Nacional)." |
4162
|
|
|
); |
4163
|
|
|
$this->dom->addChild( |
4164
|
|
|
$icmsSN, |
4165
|
|
|
'vCredICMSSN', |
4166
|
|
|
$this->conditionalNumberFormatting($std->vCredICMSSN), |
4167
|
|
|
true, |
4168
|
|
|
"[item $std->item] Valor crédito do ICMS que pode ser aproveitado nos termos do" |
4169
|
|
|
. " art. 23 da LC 123 (Simples Nacional)" |
4170
|
|
|
); |
4171
|
|
|
break; |
4172
|
|
|
case '102': |
4173
|
|
|
case '103': |
4174
|
|
|
case '300': |
4175
|
|
|
case '400': |
4176
|
|
|
$icmsSN = $this->dom->createElement("ICMSSN102"); |
4177
|
|
|
$this->dom->addChild( |
4178
|
|
|
$icmsSN, |
4179
|
|
|
'orig', |
4180
|
|
|
$std->orig, |
4181
|
|
|
true, |
4182
|
|
|
"[item $std->item] Origem da mercadoria" |
4183
|
|
|
); |
4184
|
|
|
$this->dom->addChild( |
4185
|
|
|
$icmsSN, |
4186
|
|
|
'CSOSN', |
4187
|
|
|
$std->CSOSN, |
4188
|
|
|
true, |
4189
|
|
|
"[item $std->item] Código de Situação da Operação Simples Nacional" |
4190
|
|
|
); |
4191
|
|
|
break; |
4192
|
|
|
case '201': |
4193
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
4194
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
4195
|
|
|
|
4196
|
|
|
$icmsSN = $this->dom->createElement("ICMSSN201"); |
4197
|
|
|
$this->dom->addChild( |
4198
|
|
|
$icmsSN, |
4199
|
|
|
'orig', |
4200
|
|
|
$std->orig, |
4201
|
|
|
true, |
4202
|
|
|
"[item $std->item] Origem da mercadoria" |
4203
|
|
|
); |
4204
|
|
|
$this->dom->addChild( |
4205
|
|
|
$icmsSN, |
4206
|
|
|
'CSOSN', |
4207
|
|
|
$std->CSOSN, |
4208
|
|
|
true, |
4209
|
|
|
"[item $std->item] Código de Situação da Operação Simples Nacional" |
4210
|
|
|
); |
4211
|
|
|
$this->dom->addChild( |
4212
|
|
|
$icmsSN, |
4213
|
|
|
'modBCST', |
4214
|
|
|
$std->modBCST, |
4215
|
|
|
true, |
4216
|
|
|
"[item $std->item] Alíquota aplicável de cálculo do crédito (Simples Nacional)." |
4217
|
|
|
); |
4218
|
|
|
$this->dom->addChild( |
4219
|
|
|
$icmsSN, |
4220
|
|
|
'pMVAST', |
4221
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
4222
|
|
|
false, |
4223
|
|
|
"[item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
4224
|
|
|
); |
4225
|
|
|
$this->dom->addChild( |
4226
|
|
|
$icmsSN, |
4227
|
|
|
'pRedBCST', |
4228
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
4229
|
|
|
false, |
4230
|
|
|
"[item $std->item] Percentual da Redução de BC do ICMS ST" |
4231
|
|
|
); |
4232
|
|
|
$this->dom->addChild( |
4233
|
|
|
$icmsSN, |
4234
|
|
|
'vBCST', |
4235
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
4236
|
|
|
true, |
4237
|
|
|
"[item $std->item] Valor da BC do ICMS ST" |
4238
|
|
|
); |
4239
|
|
|
$this->dom->addChild( |
4240
|
|
|
$icmsSN, |
4241
|
|
|
'pICMSST', |
4242
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
4243
|
|
|
true, |
4244
|
|
|
"[item $std->item] Alíquota do imposto do ICMS ST" |
4245
|
|
|
); |
4246
|
|
|
$this->dom->addChild( |
4247
|
|
|
$icmsSN, |
4248
|
|
|
'vICMSST', |
4249
|
|
|
$this->conditionalNumberFormatting($std->vICMSST), |
4250
|
|
|
true, |
4251
|
|
|
"[item $std->item] Valor do ICMS ST" |
4252
|
|
|
); |
4253
|
|
|
$this->dom->addChild( |
4254
|
|
|
$icmsSN, |
4255
|
|
|
'vBCFCPST', |
4256
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPST), |
4257
|
|
|
isset($std->vBCFCPST) ? true : false, |
4258
|
|
|
"[item $std->item] Valor da Base de Cálculo do FCP " |
4259
|
|
|
. "retido por Substituição Tributária" |
4260
|
|
|
); |
4261
|
|
|
$this->dom->addChild( |
4262
|
|
|
$icmsSN, |
4263
|
|
|
'pFCPST', |
4264
|
|
|
$this->conditionalNumberFormatting($std->pFCPST, 4), |
4265
|
|
|
isset($std->pFCPST) ? true : false, |
4266
|
|
|
"[item $std->item] Percentual do FCP retido por " |
4267
|
|
|
. "Substituição Tributária" |
4268
|
|
|
); |
4269
|
|
|
$this->dom->addChild( |
4270
|
|
|
$icmsSN, |
4271
|
|
|
'vFCPST', |
4272
|
|
|
$this->conditionalNumberFormatting($std->vFCPST), |
4273
|
|
|
isset($std->vFCPST) ? true : false, |
4274
|
|
|
"[item $std->item] Valor do FCP retido por Substituição Tributária" |
4275
|
|
|
); |
4276
|
|
|
$this->dom->addChild( |
4277
|
|
|
$icmsSN, |
4278
|
|
|
'pCredSN', |
4279
|
|
|
$this->conditionalNumberFormatting($std->pCredSN, 4), |
4280
|
|
|
false, |
4281
|
|
|
"[item $std->item] Alíquota aplicável de cálculo do crédito (Simples Nacional)." |
4282
|
|
|
); |
4283
|
|
|
$this->dom->addChild( |
4284
|
|
|
$icmsSN, |
4285
|
|
|
'vCredICMSSN', |
4286
|
|
|
$this->conditionalNumberFormatting($std->vCredICMSSN), |
4287
|
|
|
false, |
4288
|
|
|
"[item $std->item] Valor crédito do ICMS que pode ser aproveitado nos " |
4289
|
|
|
. "termos do art. 23 da LC 123 (Simples Nacional)" |
4290
|
|
|
); |
4291
|
|
|
break; |
4292
|
|
|
case '202': |
4293
|
|
|
case '203': |
4294
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
4295
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
4296
|
|
|
|
4297
|
|
|
$icmsSN = $this->dom->createElement("ICMSSN202"); |
4298
|
|
|
$this->dom->addChild( |
4299
|
|
|
$icmsSN, |
4300
|
|
|
'orig', |
4301
|
|
|
$std->orig, |
4302
|
|
|
true, |
4303
|
|
|
"[item $std->item] Origem da mercadoria" |
4304
|
|
|
); |
4305
|
|
|
$this->dom->addChild( |
4306
|
|
|
$icmsSN, |
4307
|
|
|
'CSOSN', |
4308
|
|
|
$std->CSOSN, |
4309
|
|
|
true, |
4310
|
|
|
"[item $std->item] Código de Situação da Operação Simples Nacional" |
4311
|
|
|
); |
4312
|
|
|
$this->dom->addChild( |
4313
|
|
|
$icmsSN, |
4314
|
|
|
'modBCST', |
4315
|
|
|
$std->modBCST, |
4316
|
|
|
true, |
4317
|
|
|
"[item $std->item] Alíquota aplicável de cálculo do crédito (Simples Nacional)." |
4318
|
|
|
); |
4319
|
|
|
$this->dom->addChild( |
4320
|
|
|
$icmsSN, |
4321
|
|
|
'pMVAST', |
4322
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
4323
|
|
|
false, |
4324
|
|
|
"[item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
4325
|
|
|
); |
4326
|
|
|
$this->dom->addChild( |
4327
|
|
|
$icmsSN, |
4328
|
|
|
'pRedBCST', |
4329
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
4330
|
|
|
false, |
4331
|
|
|
"[item $std->item] Percentual da Redução de BC do ICMS ST" |
4332
|
|
|
); |
4333
|
|
|
$this->dom->addChild( |
4334
|
|
|
$icmsSN, |
4335
|
|
|
'vBCST', |
4336
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
4337
|
|
|
true, |
4338
|
|
|
"[item $std->item] Valor da BC do ICMS ST" |
4339
|
|
|
); |
4340
|
|
|
$this->dom->addChild( |
4341
|
|
|
$icmsSN, |
4342
|
|
|
'pICMSST', |
4343
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
4344
|
|
|
true, |
4345
|
|
|
"[item $std->item] Alíquota do imposto do ICMS ST" |
4346
|
|
|
); |
4347
|
|
|
$this->dom->addChild( |
4348
|
|
|
$icmsSN, |
4349
|
|
|
'vICMSST', |
4350
|
|
|
$this->conditionalNumberFormatting($std->vICMSST), |
4351
|
|
|
true, |
4352
|
|
|
"[item $std->item] Valor do ICMS ST" |
4353
|
|
|
); |
4354
|
|
|
$this->dom->addChild( |
4355
|
|
|
$icmsSN, |
4356
|
|
|
'vBCFCPST', |
4357
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPST), |
4358
|
|
|
isset($std->vBCFCPST) ? true : false, |
4359
|
|
|
"[item $std->item] Valor da Base de Cálculo do FCP " |
4360
|
|
|
. "retido por Substituição Tributária" |
4361
|
|
|
); |
4362
|
|
|
$this->dom->addChild( |
4363
|
|
|
$icmsSN, |
4364
|
|
|
'pFCPST', |
4365
|
|
|
$this->conditionalNumberFormatting($std->pFCPST, 4), |
4366
|
|
|
isset($std->pFCPST) ? true : false, |
4367
|
|
|
"[item $std->item] Percentual do FCP retido por " |
4368
|
|
|
. "Substituição Tributária" |
4369
|
|
|
); |
4370
|
|
|
$this->dom->addChild( |
4371
|
|
|
$icmsSN, |
4372
|
|
|
'vFCPST', |
4373
|
|
|
$this->conditionalNumberFormatting($std->vFCPST), |
4374
|
|
|
isset($std->vFCPST) ? true : false, |
4375
|
|
|
"[item $std->item] Valor do FCP retido por Substituição Tributária" |
4376
|
|
|
); |
4377
|
|
|
break; |
4378
|
|
|
case '500': |
4379
|
|
|
$icmsSN = $this->dom->createElement("ICMSSN500"); |
4380
|
|
|
$this->dom->addChild( |
4381
|
|
|
$icmsSN, |
4382
|
|
|
'orig', |
4383
|
|
|
$std->orig, |
4384
|
|
|
true, |
4385
|
|
|
"[item $std->item] Origem da mercadoria" |
4386
|
|
|
); |
4387
|
|
|
$this->dom->addChild( |
4388
|
|
|
$icmsSN, |
4389
|
|
|
'CSOSN', |
4390
|
|
|
$std->CSOSN, |
4391
|
|
|
true, |
4392
|
|
|
"[item $std->item] Código de Situação da Operação Simples Nacional" |
4393
|
|
|
); |
4394
|
|
|
$this->dom->addChild( |
4395
|
|
|
$icmsSN, |
4396
|
|
|
'vBCSTRet', |
4397
|
|
|
$this->conditionalNumberFormatting($std->vBCSTRet), |
4398
|
|
|
isset($std->vBCSTRet) ? true : false, |
4399
|
|
|
"[item $std->item] Valor da BC do ICMS ST retido" |
4400
|
|
|
); |
4401
|
|
|
$this->dom->addChild( |
4402
|
|
|
$icmsSN, |
4403
|
|
|
'pST', |
4404
|
|
|
$this->conditionalNumberFormatting($std->pST, 4), |
4405
|
|
|
isset($std->pST) ? true : false, |
4406
|
|
|
"[item $std->item] Alíquota suportada pelo Consumidor Final" |
4407
|
|
|
); |
4408
|
|
|
$this->dom->addChild( |
4409
|
|
|
$icmsSN, |
4410
|
|
|
'vICMSSubstituto', |
4411
|
|
|
$this->conditionalNumberFormatting($std->vICMSSubstituto), |
4412
|
|
|
false, |
4413
|
|
|
"[item $std->item] Valor do ICMS próprio do Substituto" |
4414
|
|
|
); |
4415
|
|
|
$this->dom->addChild( |
4416
|
|
|
$icmsSN, |
4417
|
|
|
'vICMSSTRet', |
4418
|
|
|
$this->conditionalNumberFormatting($std->vICMSSTRet), |
4419
|
|
|
isset($std->vICMSSTRet) ? true : false, |
4420
|
|
|
"[item $std->item] Valor do ICMS ST retido" |
4421
|
|
|
); |
4422
|
|
|
$this->dom->addChild( |
4423
|
|
|
$icmsSN, |
4424
|
|
|
'vBCFCPSTRet', |
4425
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPSTRet, 2), |
4426
|
|
|
isset($std->vBCFCPSTRet) ? true : false, |
4427
|
|
|
"[item $std->item] Valor da Base de Cálculo do FCP " |
4428
|
|
|
. "retido anteriormente por Substituição Tributária" |
4429
|
|
|
); |
4430
|
|
|
$this->dom->addChild( |
4431
|
|
|
$icmsSN, |
4432
|
|
|
'pFCPSTRet', |
4433
|
|
|
$this->conditionalNumberFormatting($std->pFCPSTRet, 4), |
4434
|
|
|
isset($std->pFCPSTRet) ? true : false, |
4435
|
|
|
"[item $std->item] Percentual do FCP retido anteriormente por " |
4436
|
|
|
. "Substituição Tributária" |
4437
|
|
|
); |
4438
|
|
|
$this->dom->addChild( |
4439
|
|
|
$icmsSN, |
4440
|
|
|
'vFCPSTRet', |
4441
|
|
|
$this->conditionalNumberFormatting($std->vFCPSTRet), |
4442
|
|
|
isset($std->vFCPSTRet) ? true : false, |
4443
|
|
|
"[item $std->item] Valor do FCP retido anteiormente por " |
4444
|
|
|
. "Substituição Tributária" |
4445
|
|
|
); |
4446
|
|
|
$this->dom->addChild( |
4447
|
|
|
$icmsSN, |
4448
|
|
|
'pRedBCEfet', |
4449
|
|
|
$this->conditionalNumberFormatting($std->pRedBCEfet, 4), |
4450
|
|
|
isset($std->pRedBCEfet) ? true : false, |
4451
|
|
|
"[item $std->item] Percentual de redução da base " |
4452
|
|
|
. "de cálculo efetiva" |
4453
|
|
|
); |
4454
|
|
|
$this->dom->addChild( |
4455
|
|
|
$icmsSN, |
4456
|
|
|
'vBCEfet', |
4457
|
|
|
$this->conditionalNumberFormatting($std->vBCEfet), |
4458
|
|
|
isset($std->vBCEfet) ? true : false, |
4459
|
|
|
"[item $std->item] Valor da base de cálculo efetiva" |
4460
|
|
|
); |
4461
|
|
|
$this->dom->addChild( |
4462
|
|
|
$icmsSN, |
4463
|
|
|
'pICMSEfet', |
4464
|
|
|
$this->conditionalNumberFormatting($std->pICMSEfet, 4), |
4465
|
|
|
isset($std->pICMSEfet) ? true : false, |
4466
|
|
|
"[item $std->item] Alíquota do ICMS efetiva" |
4467
|
|
|
); |
4468
|
|
|
$this->dom->addChild( |
4469
|
|
|
$icmsSN, |
4470
|
|
|
'vICMSEfet', |
4471
|
|
|
$std->vICMSEfet, |
4472
|
|
|
isset($std->vICMSEfet) ? true : false, |
4473
|
|
|
"[item $std->item] Valor do ICMS efetivo" |
4474
|
|
|
); |
4475
|
|
|
break; |
4476
|
|
|
case '900': |
4477
|
|
|
$this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
4478
|
|
|
$this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
4479
|
|
|
$this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
4480
|
|
|
$this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
4481
|
|
|
$icmsSN = $this->dom->createElement("ICMSSN900"); |
4482
|
|
|
$this->dom->addChild( |
4483
|
|
|
$icmsSN, |
4484
|
|
|
'orig', |
4485
|
|
|
$std->orig, |
4486
|
|
|
true, |
4487
|
|
|
"[item $std->item] Origem da mercadoria" |
4488
|
|
|
); |
4489
|
|
|
$this->dom->addChild( |
4490
|
|
|
$icmsSN, |
4491
|
|
|
'CSOSN', |
4492
|
|
|
$std->CSOSN, |
4493
|
|
|
true, |
4494
|
|
|
"[item $std->item] Código de Situação da Operação Simples Nacional" |
4495
|
|
|
); |
4496
|
|
|
$this->dom->addChild( |
4497
|
|
|
$icmsSN, |
4498
|
|
|
'modBC', |
4499
|
|
|
$std->modBC, |
4500
|
|
|
isset($std->modBC) ? true : false, |
4501
|
|
|
"[item $std->item] Modalidade de determinação da BC do ICMS" |
4502
|
|
|
); |
4503
|
|
|
$this->dom->addChild( |
4504
|
|
|
$icmsSN, |
4505
|
|
|
'vBC', |
4506
|
|
|
$std->vBC, |
4507
|
|
|
isset($std->vBC) ? true : false, |
4508
|
|
|
"[item $std->item] Valor da BC do ICMS" |
4509
|
|
|
); |
4510
|
|
|
$this->dom->addChild( |
4511
|
|
|
$icmsSN, |
4512
|
|
|
'pRedBC', |
4513
|
|
|
$this->conditionalNumberFormatting($std->pRedBC, 4), |
4514
|
|
|
false, |
4515
|
|
|
"[item $std->item] Percentual da Redução de BC" |
4516
|
|
|
); |
4517
|
|
|
$this->dom->addChild( |
4518
|
|
|
$icmsSN, |
4519
|
|
|
'pICMS', |
4520
|
|
|
$this->conditionalNumberFormatting($std->pICMS, 4), |
4521
|
|
|
isset($std->pICMS) ? true : false, |
4522
|
|
|
"[item $std->item] Alíquota do imposto" |
4523
|
|
|
); |
4524
|
|
|
$this->dom->addChild( |
4525
|
|
|
$icmsSN, |
4526
|
|
|
'vICMS', |
4527
|
|
|
$this->conditionalNumberFormatting($std->vICMS), |
4528
|
|
|
isset($std->pICMS) ? true : false, |
4529
|
|
|
"[item $std->item] Valor do ICMS" |
4530
|
|
|
); |
4531
|
|
|
$this->dom->addChild( |
4532
|
|
|
$icmsSN, |
4533
|
|
|
'modBCST', |
4534
|
|
|
$std->modBCST, |
4535
|
|
|
isset($std->modBCST) ? true : false, |
4536
|
|
|
"[item $std->item] Alíquota aplicável de cálculo do crédito (Simples Nacional)." |
4537
|
|
|
); |
4538
|
|
|
$this->dom->addChild( |
4539
|
|
|
$icmsSN, |
4540
|
|
|
'pMVAST', |
4541
|
|
|
$this->conditionalNumberFormatting($std->pMVAST, 4), |
4542
|
|
|
false, |
4543
|
|
|
"[item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
4544
|
|
|
); |
4545
|
|
|
$this->dom->addChild( |
4546
|
|
|
$icmsSN, |
4547
|
|
|
'pRedBCST', |
4548
|
|
|
$this->conditionalNumberFormatting($std->pRedBCST, 4), |
4549
|
|
|
false, |
4550
|
|
|
"[item $std->item] Percentual da Redução de BC do ICMS ST" |
4551
|
|
|
); |
4552
|
|
|
$this->dom->addChild( |
4553
|
|
|
$icmsSN, |
4554
|
|
|
'vBCST', |
4555
|
|
|
$this->conditionalNumberFormatting($std->vBCST), |
4556
|
|
|
isset($std->vBCST) ? true : false, |
4557
|
|
|
"[item $std->item] Valor da BC do ICMS ST" |
4558
|
|
|
); |
4559
|
|
|
$this->dom->addChild( |
4560
|
|
|
$icmsSN, |
4561
|
|
|
'pICMSST', |
4562
|
|
|
$this->conditionalNumberFormatting($std->pICMSST, 4), |
4563
|
|
|
isset($std->pICMSST) ? true : false, |
4564
|
|
|
"[item $std->item] Alíquota do imposto do ICMS ST" |
4565
|
|
|
); |
4566
|
|
|
$this->dom->addChild( |
4567
|
|
|
$icmsSN, |
4568
|
|
|
'vICMSST', |
4569
|
|
|
$std->vICMSST, |
4570
|
|
|
isset($std->vICMSST) ? true : false, |
4571
|
|
|
"[item $std->item] Valor do ICMS ST" |
4572
|
|
|
); |
4573
|
|
|
$this->dom->addChild( |
4574
|
|
|
$icmsSN, |
4575
|
|
|
'vBCFCPST', |
4576
|
|
|
$this->conditionalNumberFormatting($std->vBCFCPST), |
4577
|
|
|
isset($std->vBCFCPST) ? true : false, |
4578
|
|
|
"[item $std->item] Valor da Base de Cálculo do FCP " |
4579
|
|
|
. "retido por Substituição Tributária" |
4580
|
|
|
); |
4581
|
|
|
$this->dom->addChild( |
4582
|
|
|
$icmsSN, |
4583
|
|
|
'pFCPST', |
4584
|
|
|
$this->conditionalNumberFormatting($std->pFCPST, 4), |
4585
|
|
|
isset($std->pFCPST) ? true : false, |
4586
|
|
|
"[item $std->item] Percentual do FCP retido por " |
4587
|
|
|
. "Substituição Tributária" |
4588
|
|
|
); |
4589
|
|
|
$this->dom->addChild( |
4590
|
|
|
$icmsSN, |
4591
|
|
|
'vFCPST', |
4592
|
|
|
$this->conditionalNumberFormatting($std->vFCPST), |
4593
|
|
|
isset($std->vFCPST) ? true : false, |
4594
|
|
|
"[item $std->item] Valor do FCP retido por Substituição Tributária" |
4595
|
|
|
); |
4596
|
|
|
$this->dom->addChild( |
4597
|
|
|
$icmsSN, |
4598
|
|
|
'pCredSN', |
4599
|
|
|
$this->conditionalNumberFormatting($std->pCredSN, 4), |
4600
|
|
|
isset($std->pCredSN) ? true : false, |
4601
|
|
|
"[item $std->item] Alíquota aplicável de cálculo do crédito (Simples Nacional)." |
4602
|
|
|
); |
4603
|
|
|
$this->dom->addChild( |
4604
|
|
|
$icmsSN, |
4605
|
|
|
'vCredICMSSN', |
4606
|
|
|
$this->conditionalNumberFormatting($std->vCredICMSSN), |
4607
|
|
|
isset($std->vCredICMSSN) ? true : false, |
4608
|
|
|
"[item $std->item] Valor crédito do ICMS que pode ser aproveitado nos termos do" |
4609
|
|
|
. " art. 23 da LC 123 (Simples Nacional)" |
4610
|
|
|
); |
4611
|
|
|
break; |
4612
|
|
|
} |
4613
|
|
|
//caso exista a tag aICMS[$std-item] inserir nela caso contrario criar |
4614
|
|
|
if (!empty($this->aICMS[$std->item])) { |
4615
|
|
|
$tagIcms = $this->aICMS[$std->item]; |
4616
|
|
|
} else { |
4617
|
|
|
$tagIcms = $this->dom->createElement('ICMS'); |
4618
|
|
|
} |
4619
|
|
|
if (isset($icmsSN)) { |
4620
|
|
|
$this->dom->appChild($tagIcms, $icmsSN, "Inserindo ICMSST em ICMS[$std->item]"); |
4621
|
|
|
} |
4622
|
|
|
$this->aICMS[$std->item] = $tagIcms; |
4623
|
|
|
return $tagIcms; |
4624
|
|
|
} |
4625
|
|
|
|
4626
|
|
|
/** |
4627
|
|
|
* Grupo ICMSUFDest NA01 pai M01 |
4628
|
|
|
* tag NFe/infNFe/det[]/imposto/ICMSUFDest (opcional) |
4629
|
|
|
* Grupo a ser informado nas vendas interestaduais para consumidor final, |
4630
|
|
|
* não contribuinte do ICMS |
4631
|
|
|
* @param stdClass $std |
4632
|
|
|
* @return DOMElement |
4633
|
|
|
*/ |
4634
|
|
|
public function tagICMSUFDest(stdClass $std) |
4635
|
|
|
{ |
4636
|
|
|
$possible = [ |
4637
|
|
|
'item', |
4638
|
|
|
'vBCUFDest', |
4639
|
|
|
'vBCFCPUFDest', |
4640
|
|
|
'pFCPUFDest', |
4641
|
|
|
'pICMSUFDest', |
4642
|
|
|
'pICMSInter', |
4643
|
|
|
'pICMSInterPart', |
4644
|
|
|
'vFCPUFDest', |
4645
|
|
|
'vICMSUFDest', |
4646
|
|
|
'vICMSUFRemet' |
4647
|
|
|
]; |
4648
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4649
|
|
|
$this->stdTot->vICMSUFDest += (float) $std->vICMSUFDest; |
4650
|
|
|
$this->stdTot->vFCPUFDest += (float) $std->vFCPUFDest; |
4651
|
|
|
$this->stdTot->vICMSUFRemet += (float) $std->vICMSUFRemet; |
4652
|
|
|
$icmsUFDest = $this->dom->createElement('ICMSUFDest'); |
4653
|
|
|
$this->dom->addChild( |
4654
|
|
|
$icmsUFDest, |
4655
|
|
|
"vBCUFDest", |
4656
|
|
|
$std->vBCUFDest, |
4657
|
|
|
true, |
4658
|
|
|
"[item $std->item] Valor da BC do ICMS na UF do destinatário" |
4659
|
|
|
); |
4660
|
|
|
$this->dom->addChild( |
4661
|
|
|
$icmsUFDest, |
4662
|
|
|
"vBCFCPUFDest", |
4663
|
|
|
$std->vBCFCPUFDest, |
4664
|
|
|
false, |
4665
|
|
|
"[item $std->item] Valor da BC do ICMS na UF do destinatário" |
4666
|
|
|
); |
4667
|
|
|
$this->dom->addChild( |
4668
|
|
|
$icmsUFDest, |
4669
|
|
|
"pFCPUFDest", |
4670
|
|
|
$this->conditionalNumberFormatting($std->pFCPUFDest, 4), |
4671
|
|
|
false, |
4672
|
|
|
"[item $std->item] Percentual do ICMS relativo ao Fundo de Combate à Pobreza (FCP) na UF de destino" |
4673
|
|
|
); |
4674
|
|
|
$this->dom->addChild( |
4675
|
|
|
$icmsUFDest, |
4676
|
|
|
"pICMSUFDest", |
4677
|
|
|
$this->conditionalNumberFormatting($std->pICMSUFDest, 4), |
4678
|
|
|
true, |
4679
|
|
|
"[item $std->item] Alíquota interna da UF do destinatário" |
4680
|
|
|
); |
4681
|
|
|
$this->dom->addChild( |
4682
|
|
|
$icmsUFDest, |
4683
|
|
|
"pICMSInter", |
4684
|
|
|
$this->conditionalNumberFormatting($std->pICMSInter, 2), |
4685
|
|
|
true, |
4686
|
|
|
"[item $std->item] Alíquota interestadual das UF envolvidas" |
4687
|
|
|
); |
4688
|
|
|
$this->dom->addChild( |
4689
|
|
|
$icmsUFDest, |
4690
|
|
|
"pICMSInterPart", |
4691
|
|
|
$this->conditionalNumberFormatting($std->pICMSInterPart, 4), |
4692
|
|
|
true, |
4693
|
|
|
"[item $std->item] Percentual provisório de partilha entre os Estados" |
4694
|
|
|
); |
4695
|
|
|
$this->dom->addChild( |
4696
|
|
|
$icmsUFDest, |
4697
|
|
|
"vFCPUFDest", |
4698
|
|
|
$std->vFCPUFDest, |
4699
|
|
|
false, |
4700
|
|
|
"[item $std->item] Valor do ICMS relativo ao Fundo de Combate à Pobreza (FCP) da UF de destino" |
4701
|
|
|
); |
4702
|
|
|
$this->dom->addChild( |
4703
|
|
|
$icmsUFDest, |
4704
|
|
|
"vICMSUFDest", |
4705
|
|
|
$std->vICMSUFDest, |
4706
|
|
|
true, |
4707
|
|
|
"[item $std->item] Valor do ICMS de partilha para a UF do destinatário" |
4708
|
|
|
); |
4709
|
|
|
$this->dom->addChild( |
4710
|
|
|
$icmsUFDest, |
4711
|
|
|
"vICMSUFRemet", |
4712
|
|
|
$std->vICMSUFRemet, |
4713
|
|
|
true, |
4714
|
|
|
"[item $std->item] Valor do ICMS de partilha para a UF do remetente" |
4715
|
|
|
); |
4716
|
|
|
$this->aICMSUFDest[$std->item] = $icmsUFDest; |
4717
|
|
|
return $icmsUFDest; |
4718
|
|
|
} |
4719
|
|
|
|
4720
|
|
|
/** |
4721
|
|
|
* Grupo IPI O01 pai M01 |
4722
|
|
|
* tag NFe/infNFe/det[]/imposto/IPI (opcional) |
4723
|
|
|
* @param stdClass $std |
4724
|
|
|
* @return DOMElement |
4725
|
|
|
*/ |
4726
|
|
|
public function tagIPI(stdClass $std) |
4727
|
|
|
{ |
4728
|
|
|
$possible = [ |
4729
|
|
|
'item', |
4730
|
|
|
'clEnq', |
4731
|
|
|
'CNPJProd', |
4732
|
|
|
'cSelo', |
4733
|
|
|
'qSelo', |
4734
|
|
|
'cEnq', |
4735
|
|
|
'CST', |
4736
|
|
|
'vIPI', |
4737
|
|
|
'vBC', |
4738
|
|
|
'pIPI', |
4739
|
|
|
'qUnid', |
4740
|
|
|
'vUnid' |
4741
|
|
|
]; |
4742
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4743
|
|
|
//totalizador |
4744
|
|
|
$this->stdTot->vIPI += (float) $std->vIPI; |
4745
|
|
|
$ipi = $this->dom->createElement('IPI'); |
4746
|
|
|
$this->dom->addChild( |
4747
|
|
|
$ipi, |
4748
|
|
|
"clEnq", |
4749
|
|
|
$std->clEnq, |
4750
|
|
|
false, |
4751
|
|
|
"[item $std->item] Classe de enquadramento do IPI para Cigarros e Bebidas" |
4752
|
|
|
); |
4753
|
|
|
$this->dom->addChild( |
4754
|
|
|
$ipi, |
4755
|
|
|
"CNPJProd", |
4756
|
|
|
$std->CNPJProd, |
4757
|
|
|
false, |
4758
|
|
|
"[item $std->item] CNPJ do produtor da mercadoria, quando diferente do emitente. " |
4759
|
|
|
. "Somente para os casos de exportação direta ou indireta." |
4760
|
|
|
); |
4761
|
|
|
$this->dom->addChild( |
4762
|
|
|
$ipi, |
4763
|
|
|
"cSelo", |
4764
|
|
|
$std->cSelo, |
4765
|
|
|
false, |
4766
|
|
|
"[item $std->item] Código do selo de controle IPI" |
4767
|
|
|
); |
4768
|
|
|
$this->dom->addChild( |
4769
|
|
|
$ipi, |
4770
|
|
|
"qSelo", |
4771
|
|
|
$std->qSelo, |
4772
|
|
|
false, |
4773
|
|
|
"[item $std->item] Quantidade de selo de controle" |
4774
|
|
|
); |
4775
|
|
|
$this->dom->addChild( |
4776
|
|
|
$ipi, |
4777
|
|
|
"cEnq", |
4778
|
|
|
$std->cEnq, |
4779
|
|
|
true, |
4780
|
|
|
"[item $std->item] Código de Enquadramento Legal do IPI" |
4781
|
|
|
); |
4782
|
|
|
if ($std->CST == '00' || $std->CST == '49' || $std->CST == '50' || $std->CST == '99') { |
4783
|
|
|
$ipiTrib = $this->dom->createElement('IPITrib'); |
4784
|
|
|
$this->dom->addChild( |
4785
|
|
|
$ipiTrib, |
4786
|
|
|
"CST", |
4787
|
|
|
$std->CST, |
4788
|
|
|
true, |
4789
|
|
|
"[item $std->item] Código da situação tributária do IPI" |
4790
|
|
|
); |
4791
|
|
|
$this->dom->addChild( |
4792
|
|
|
$ipiTrib, |
4793
|
|
|
"vBC", |
4794
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
4795
|
|
|
false, |
4796
|
|
|
"[item $std->item] Valor da BC do IPI" |
4797
|
|
|
); |
4798
|
|
|
$this->dom->addChild( |
4799
|
|
|
$ipiTrib, |
4800
|
|
|
"pIPI", |
4801
|
|
|
$this->conditionalNumberFormatting($std->pIPI, 4), |
4802
|
|
|
false, |
4803
|
|
|
"[item $std->item] Alíquota do IPI" |
4804
|
|
|
); |
4805
|
|
|
$this->dom->addChild( |
4806
|
|
|
$ipiTrib, |
4807
|
|
|
"qUnid", |
4808
|
|
|
$std->qUnid, |
4809
|
|
|
false, |
4810
|
|
|
"[item $std->item] Quantidade total na unidade padrão para tributação (somente para os " |
4811
|
|
|
. "produtos tributados por unidade)" |
4812
|
|
|
); |
4813
|
|
|
$this->dom->addChild( |
4814
|
|
|
$ipiTrib, |
4815
|
|
|
"vUnid", |
4816
|
|
|
$std->vUnid, |
4817
|
|
|
false, |
4818
|
|
|
"[item $std->item] Valor por Unidade Tributável" |
4819
|
|
|
); |
4820
|
|
|
$this->dom->addChild( |
4821
|
|
|
$ipiTrib, |
4822
|
|
|
"vIPI", |
4823
|
|
|
$this->conditionalNumberFormatting($std->vIPI), |
4824
|
|
|
true, |
4825
|
|
|
"[item $std->item] Valor do IPI" |
4826
|
|
|
); |
4827
|
|
|
$ipi->appendChild($ipiTrib); |
4828
|
|
|
} else { |
4829
|
|
|
$ipINT = $this->dom->createElement('IPINT'); |
4830
|
|
|
$this->dom->addChild( |
4831
|
|
|
$ipINT, |
4832
|
|
|
"CST", |
4833
|
|
|
$std->CST, |
4834
|
|
|
true, |
4835
|
|
|
"[item $std->item] Código da situação tributária do IPINT" |
4836
|
|
|
); |
4837
|
|
|
$ipi->appendChild($ipINT); |
4838
|
|
|
} |
4839
|
|
|
$this->aIPI[$std->item] = $ipi; |
4840
|
|
|
return $ipi; |
4841
|
|
|
} |
4842
|
|
|
|
4843
|
|
|
/** |
4844
|
|
|
* Grupo Imposto de Importação P01 pai M01 |
4845
|
|
|
* tag NFe/infNFe/det[]/imposto/II |
4846
|
|
|
* @param stdClass $std |
4847
|
|
|
* @return DOMElement |
4848
|
|
|
*/ |
4849
|
|
|
public function tagII(stdClass $std) |
4850
|
|
|
{ |
4851
|
|
|
$possible = [ |
4852
|
|
|
'item', |
4853
|
|
|
'vBC', |
4854
|
|
|
'vDespAdu', |
4855
|
|
|
'vII', |
4856
|
|
|
'vIOF' |
4857
|
|
|
]; |
4858
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4859
|
|
|
//totalizador |
4860
|
|
|
$this->stdTot->vII += (float) $std->vII; |
4861
|
|
|
$tii = $this->dom->createElement('II'); |
4862
|
|
|
$this->dom->addChild( |
4863
|
|
|
$tii, |
4864
|
|
|
"vBC", |
4865
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
4866
|
|
|
true, |
4867
|
|
|
"[item $std->item] Valor BC do Imposto de Importação" |
4868
|
|
|
); |
4869
|
|
|
$this->dom->addChild( |
4870
|
|
|
$tii, |
4871
|
|
|
"vDespAdu", |
4872
|
|
|
$this->conditionalNumberFormatting($std->vDespAdu), |
4873
|
|
|
true, |
4874
|
|
|
"[item $std->item] Valor despesas aduaneiras" |
4875
|
|
|
); |
4876
|
|
|
$this->dom->addChild( |
4877
|
|
|
$tii, |
4878
|
|
|
"vII", |
4879
|
|
|
$this->conditionalNumberFormatting($std->vII), |
4880
|
|
|
true, |
4881
|
|
|
"[item $std->item] Valor Imposto de Importação" |
4882
|
|
|
); |
4883
|
|
|
$this->dom->addChild( |
4884
|
|
|
$tii, |
4885
|
|
|
"vIOF", |
4886
|
|
|
$this->conditionalNumberFormatting($std->vIOF), |
4887
|
|
|
true, |
4888
|
|
|
"[item $std->item] Valor Imposto sobre Operações Financeiras" |
4889
|
|
|
); |
4890
|
|
|
$this->aII[$std->item] = $tii; |
4891
|
|
|
return $tii; |
4892
|
|
|
} |
4893
|
|
|
|
4894
|
|
|
/** |
4895
|
|
|
* Grupo PIS Q01 pai M01 |
4896
|
|
|
* tag NFe/infNFe/det[]/imposto/PIS |
4897
|
|
|
* @param stdClass $std |
4898
|
|
|
* @return DOMElement |
4899
|
|
|
*/ |
4900
|
|
|
public function tagPIS(stdClass $std) |
4901
|
|
|
{ |
4902
|
|
|
$possible = [ |
4903
|
|
|
'item', |
4904
|
|
|
'CST', |
4905
|
|
|
'vBC', |
4906
|
|
|
'pPIS', |
4907
|
|
|
'vPIS', |
4908
|
|
|
'qBCProd', |
4909
|
|
|
'vAliqProd' |
4910
|
|
|
]; |
4911
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4912
|
|
|
//totalizador |
4913
|
|
|
$this->stdTot->vPIS += (float) !empty($std->vPIS) ? $std->vPIS : 0; |
4914
|
|
|
switch ($std->CST) { |
4915
|
|
|
case '01': |
4916
|
|
|
case '02': |
4917
|
|
|
$pisItem = $this->dom->createElement('PISAliq'); |
4918
|
|
|
$this->dom->addChild( |
4919
|
|
|
$pisItem, |
4920
|
|
|
'CST', |
4921
|
|
|
$std->CST, |
4922
|
|
|
true, |
4923
|
|
|
"[item $std->item] Código de Situação Tributária do PIS" |
4924
|
|
|
); |
4925
|
|
|
$this->dom->addChild( |
4926
|
|
|
$pisItem, |
4927
|
|
|
'vBC', |
4928
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
4929
|
|
|
true, |
4930
|
|
|
"[item $std->item] Valor da Base de Cálculo do PIS" |
4931
|
|
|
); |
4932
|
|
|
$this->dom->addChild( |
4933
|
|
|
$pisItem, |
4934
|
|
|
'pPIS', |
4935
|
|
|
$this->conditionalNumberFormatting($std->pPIS, 4), |
4936
|
|
|
true, |
4937
|
|
|
"[item $std->item] Alíquota do PIS (em percentual)" |
4938
|
|
|
); |
4939
|
|
|
$this->dom->addChild( |
4940
|
|
|
$pisItem, |
4941
|
|
|
'vPIS', |
4942
|
|
|
$this->conditionalNumberFormatting($std->vPIS), |
4943
|
|
|
true, |
4944
|
|
|
"[item $std->item] Valor do PIS" |
4945
|
|
|
); |
4946
|
|
|
break; |
4947
|
|
|
case '03': |
4948
|
|
|
$pisItem = $this->dom->createElement('PISQtde'); |
4949
|
|
|
$this->dom->addChild( |
4950
|
|
|
$pisItem, |
4951
|
|
|
'CST', |
4952
|
|
|
$std->CST, |
4953
|
|
|
true, |
4954
|
|
|
"[item $std->item] Código de Situação Tributária do PIS" |
4955
|
|
|
); |
4956
|
|
|
$this->dom->addChild( |
4957
|
|
|
$pisItem, |
4958
|
|
|
'qBCProd', |
4959
|
|
|
$std->qBCProd, |
4960
|
|
|
true, |
4961
|
|
|
"[item $std->item] Quantidade Vendida" |
4962
|
|
|
); |
4963
|
|
|
$this->dom->addChild( |
4964
|
|
|
$pisItem, |
4965
|
|
|
'vAliqProd', |
4966
|
|
|
$std->vAliqProd, |
4967
|
|
|
true, |
4968
|
|
|
"[item $std->item] Alíquota do PIS (em reais)" |
4969
|
|
|
); |
4970
|
|
|
$this->dom->addChild( |
4971
|
|
|
$pisItem, |
4972
|
|
|
'vPIS', |
4973
|
|
|
$this->conditionalNumberFormatting($std->vPIS), |
4974
|
|
|
true, |
4975
|
|
|
"[item $std->item] Valor do PIS" |
4976
|
|
|
); |
4977
|
|
|
break; |
4978
|
|
|
case '04': |
4979
|
|
|
case '05': |
4980
|
|
|
case '06': |
4981
|
|
|
case '07': |
4982
|
|
|
case '08': |
4983
|
|
|
case '09': |
4984
|
|
|
$pisItem = $this->dom->createElement('PISNT'); |
4985
|
|
|
$this->dom->addChild( |
4986
|
|
|
$pisItem, |
4987
|
|
|
'CST', |
4988
|
|
|
$std->CST, |
4989
|
|
|
true, |
4990
|
|
|
"[item $std->item] Código de Situação Tributária do PIS" |
4991
|
|
|
); |
4992
|
|
|
break; |
4993
|
|
|
case '49': |
4994
|
|
|
case '50': |
4995
|
|
|
case '51': |
4996
|
|
|
case '52': |
4997
|
|
|
case '53': |
4998
|
|
|
case '54': |
4999
|
|
|
case '55': |
5000
|
|
|
case '56': |
5001
|
|
|
case '60': |
5002
|
|
|
case '61': |
5003
|
|
|
case '62': |
5004
|
|
|
case '63': |
5005
|
|
|
case '64': |
5006
|
|
|
case '65': |
5007
|
|
|
case '66': |
5008
|
|
|
case '67': |
5009
|
|
|
case '70': |
5010
|
|
|
case '71': |
5011
|
|
|
case '72': |
5012
|
|
|
case '73': |
5013
|
|
|
case '74': |
5014
|
|
|
case '75': |
5015
|
|
|
case '98': |
5016
|
|
|
case '99': |
5017
|
|
|
$pisItem = $this->dom->createElement('PISOutr'); |
5018
|
|
|
$this->dom->addChild( |
5019
|
|
|
$pisItem, |
5020
|
|
|
'CST', |
5021
|
|
|
$std->CST, |
5022
|
|
|
true, |
5023
|
|
|
"[item $std->item] Código de Situação Tributária do PIS" |
5024
|
|
|
); |
5025
|
|
|
$this->dom->addChild( |
5026
|
|
|
$pisItem, |
5027
|
|
|
'vBC', |
5028
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
5029
|
|
|
($std->vBC !== null) ? true : false, |
5030
|
|
|
"[item $std->item] Valor da Base de Cálculo do PIS" |
5031
|
|
|
); |
5032
|
|
|
$this->dom->addChild( |
5033
|
|
|
$pisItem, |
5034
|
|
|
'pPIS', |
5035
|
|
|
$this->conditionalNumberFormatting($std->pPIS, 4), |
5036
|
|
|
($std->pPIS !== null) ? true : false, |
5037
|
|
|
"[item $std->item] Alíquota do PIS (em percentual)" |
5038
|
|
|
); |
5039
|
|
|
$this->dom->addChild( |
5040
|
|
|
$pisItem, |
5041
|
|
|
'qBCProd', |
5042
|
|
|
$std->qBCProd, |
5043
|
|
|
($std->qBCProd !== null) ? true : false, |
5044
|
|
|
"[item $std->item] Quantidade Vendida" |
5045
|
|
|
); |
5046
|
|
|
$this->dom->addChild( |
5047
|
|
|
$pisItem, |
5048
|
|
|
'vAliqProd', |
5049
|
|
|
$std->vAliqProd, |
5050
|
|
|
($std->vAliqProd !== null) ? true : false, |
5051
|
|
|
"[item $std->item] Alíquota do PIS (em reais)" |
5052
|
|
|
); |
5053
|
|
|
$this->dom->addChild( |
5054
|
|
|
$pisItem, |
5055
|
|
|
'vPIS', |
5056
|
|
|
$this->conditionalNumberFormatting($std->vPIS), |
5057
|
|
|
true, |
5058
|
|
|
"[item $std->item] Valor do PIS" |
5059
|
|
|
); |
5060
|
|
|
break; |
5061
|
|
|
} |
5062
|
|
|
$pis = $this->dom->createElement('PIS'); |
5063
|
|
|
if (isset($pisItem)) { |
5064
|
|
|
$pis->appendChild($pisItem); |
5065
|
|
|
} |
5066
|
|
|
$this->aPIS[$std->item] = $pis; |
5067
|
|
|
return $pis; |
5068
|
|
|
} |
5069
|
|
|
|
5070
|
|
|
/** |
5071
|
|
|
* Grupo PIS Substituição Tributária R01 pai M01 |
5072
|
|
|
* tag NFe/infNFe/det[]/imposto/PISST (opcional) |
5073
|
|
|
* @param stdClass $std |
5074
|
|
|
* @return DOMElement |
5075
|
|
|
*/ |
5076
|
|
|
public function tagPISST(stdClass $std) |
5077
|
|
|
{ |
5078
|
|
|
$possible = [ |
5079
|
|
|
'item', |
5080
|
|
|
'vPIS', |
5081
|
|
|
'vBC', |
5082
|
|
|
'pPIS', |
5083
|
|
|
'qBCProd', |
5084
|
|
|
'vAliqProd' |
5085
|
|
|
]; |
5086
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5087
|
|
|
$pisst = $this->dom->createElement('PISST'); |
5088
|
|
|
if (!isset($std->qBCProd)) { |
5089
|
|
|
$this->dom->addChild( |
5090
|
|
|
$pisst, |
5091
|
|
|
'vBC', |
5092
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
5093
|
|
|
true, |
5094
|
|
|
"[item $std->item] Valor da Base de Cálculo do PIS" |
5095
|
|
|
); |
5096
|
|
|
$this->dom->addChild( |
5097
|
|
|
$pisst, |
5098
|
|
|
'pPIS', |
5099
|
|
|
$this->conditionalNumberFormatting($std->pPIS, 4), |
5100
|
|
|
true, |
5101
|
|
|
"[item $std->item] Alíquota do PIS (em percentual)" |
5102
|
|
|
); |
5103
|
|
|
} else { |
5104
|
|
|
$this->dom->addChild( |
5105
|
|
|
$pisst, |
5106
|
|
|
'qBCProd', |
5107
|
|
|
$std->qBCProd, |
5108
|
|
|
true, |
5109
|
|
|
"[item $std->item] Quantidade Vendida" |
5110
|
|
|
); |
5111
|
|
|
$this->dom->addChild( |
5112
|
|
|
$pisst, |
5113
|
|
|
'vAliqProd', |
5114
|
|
|
$std->vAliqProd, |
5115
|
|
|
true, |
5116
|
|
|
"[item $std->item] Alíquota do PIS (em reais)" |
5117
|
|
|
); |
5118
|
|
|
} |
5119
|
|
|
$this->dom->addChild( |
5120
|
|
|
$pisst, |
5121
|
|
|
'vPIS', |
5122
|
|
|
$this->conditionalNumberFormatting($std->vPIS), |
5123
|
|
|
true, |
5124
|
|
|
"[item $std->item] Valor do PIS" |
5125
|
|
|
); |
5126
|
|
|
$this->aPISST[$std->item] = $pisst; |
5127
|
|
|
return $pisst; |
5128
|
|
|
} |
5129
|
|
|
|
5130
|
|
|
/** |
5131
|
|
|
* Grupo COFINS S01 pai M01 |
5132
|
|
|
* tag det[item]/imposto/COFINS (opcional) |
5133
|
|
|
* @param stdClass $std |
5134
|
|
|
* @return DOMElement |
5135
|
|
|
*/ |
5136
|
|
|
public function tagCOFINS(stdClass $std) |
5137
|
|
|
{ |
5138
|
|
|
$possible = [ |
5139
|
|
|
'item', |
5140
|
|
|
'CST', |
5141
|
|
|
'vBC', |
5142
|
|
|
'pCOFINS', |
5143
|
|
|
'vCOFINS', |
5144
|
|
|
'qBCProd', |
5145
|
|
|
'vAliqProd' |
5146
|
|
|
]; |
5147
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5148
|
|
|
//totalizador |
5149
|
|
|
$this->stdTot->vCOFINS += (float) $std->vCOFINS; |
5150
|
|
|
switch ($std->CST) { |
5151
|
|
|
case '01': |
5152
|
|
|
case '02': |
5153
|
|
|
$confinsItem = $this->buildCOFINSAliq($std); |
5154
|
|
|
break; |
5155
|
|
|
case '03': |
5156
|
|
|
$confinsItem = $this->dom->createElement('COFINSQtde'); |
5157
|
|
|
$this->dom->addChild( |
5158
|
|
|
$confinsItem, |
5159
|
|
|
'CST', |
5160
|
|
|
$std->CST, |
5161
|
|
|
true, |
5162
|
|
|
"[item $std->item] Código de Situação Tributária da COFINS" |
5163
|
|
|
); |
5164
|
|
|
$this->dom->addChild( |
5165
|
|
|
$confinsItem, |
5166
|
|
|
'qBCProd', |
5167
|
|
|
$std->qBCProd, |
5168
|
|
|
true, |
5169
|
|
|
"[item $std->item] Quantidade Vendida" |
5170
|
|
|
); |
5171
|
|
|
$this->dom->addChild( |
5172
|
|
|
$confinsItem, |
5173
|
|
|
'vAliqProd', |
5174
|
|
|
$std->vAliqProd, |
5175
|
|
|
true, |
5176
|
|
|
"[item $std->item] Alíquota do COFINS (em reais)" |
5177
|
|
|
); |
5178
|
|
|
$this->dom->addChild( |
5179
|
|
|
$confinsItem, |
5180
|
|
|
'vCOFINS', |
5181
|
|
|
$this->conditionalNumberFormatting($std->vCOFINS), |
5182
|
|
|
true, |
5183
|
|
|
"[item $std->item] Valor do COFINS" |
5184
|
|
|
); |
5185
|
|
|
break; |
5186
|
|
|
case '04': |
5187
|
|
|
case '05': |
5188
|
|
|
case '06': |
5189
|
|
|
case '07': |
5190
|
|
|
case '08': |
5191
|
|
|
case '09': |
5192
|
|
|
$confinsItem = $this->buildCOFINSNT($std); |
5193
|
|
|
break; |
5194
|
|
|
case '49': |
5195
|
|
|
case '50': |
5196
|
|
|
case '51': |
5197
|
|
|
case '52': |
5198
|
|
|
case '53': |
5199
|
|
|
case '54': |
5200
|
|
|
case '55': |
5201
|
|
|
case '56': |
5202
|
|
|
case '60': |
5203
|
|
|
case '61': |
5204
|
|
|
case '62': |
5205
|
|
|
case '63': |
5206
|
|
|
case '64': |
5207
|
|
|
case '65': |
5208
|
|
|
case '66': |
5209
|
|
|
case '67': |
5210
|
|
|
case '70': |
5211
|
|
|
case '71': |
5212
|
|
|
case '72': |
5213
|
|
|
case '73': |
5214
|
|
|
case '74': |
5215
|
|
|
case '75': |
5216
|
|
|
case '98': |
5217
|
|
|
case '99': |
5218
|
|
|
$confinsItem = $this->buildCOFINSoutr($std); |
5219
|
|
|
break; |
5220
|
|
|
} |
5221
|
|
|
$confins = $this->dom->createElement('COFINS'); |
5222
|
|
|
if (isset($confinsItem)) { |
5223
|
|
|
$confins->appendChild($confinsItem); |
5224
|
|
|
} |
5225
|
|
|
$this->aCOFINS[$std->item] = $confins; |
5226
|
|
|
return $confins; |
5227
|
|
|
} |
5228
|
|
|
|
5229
|
|
|
/** |
5230
|
|
|
* Grupo COFINS Substituição Tributária T01 pai M01 |
5231
|
|
|
* tag NFe/infNFe/det[]/imposto/COFINSST (opcional) |
5232
|
|
|
* @param stdClass $std |
5233
|
|
|
* @return DOMElement |
5234
|
|
|
*/ |
5235
|
|
|
public function tagCOFINSST(stdClass $std) |
5236
|
|
|
{ |
5237
|
|
|
$possible = [ |
5238
|
|
|
'item', |
5239
|
|
|
'vCOFINS', |
5240
|
|
|
'vBC', |
5241
|
|
|
'pCOFINS', |
5242
|
|
|
'qBCProd', |
5243
|
|
|
'vAliqProd' |
5244
|
|
|
]; |
5245
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5246
|
|
|
$cofinsst = $this->dom->createElement("COFINSST"); |
5247
|
|
|
if (!isset($std->qBCProd)) { |
5248
|
|
|
$this->dom->addChild( |
5249
|
|
|
$cofinsst, |
5250
|
|
|
"vBC", |
5251
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
5252
|
|
|
true, |
5253
|
|
|
"[item $std->item] Valor da Base de Cálculo da COFINS" |
5254
|
|
|
); |
5255
|
|
|
$this->dom->addChild( |
5256
|
|
|
$cofinsst, |
5257
|
|
|
"pCOFINS", |
5258
|
|
|
$this->conditionalNumberFormatting($std->pCOFINS, 4), |
5259
|
|
|
true, |
5260
|
|
|
"[item $std->item] Alíquota da COFINS (em percentual)" |
5261
|
|
|
); |
5262
|
|
|
} else { |
5263
|
|
|
$this->dom->addChild( |
5264
|
|
|
$cofinsst, |
5265
|
|
|
"qBCProd", |
5266
|
|
|
$std->qBCProd, |
5267
|
|
|
true, |
5268
|
|
|
"[item $std->item] Quantidade Vendida" |
5269
|
|
|
); |
5270
|
|
|
$this->dom->addChild( |
5271
|
|
|
$cofinsst, |
5272
|
|
|
"vAliqProd", |
5273
|
|
|
$std->vAliqProd, |
5274
|
|
|
true, |
5275
|
|
|
"[item $std->item] Alíquota da COFINS (em reais)" |
5276
|
|
|
); |
5277
|
|
|
} |
5278
|
|
|
$this->dom->addChild( |
5279
|
|
|
$cofinsst, |
5280
|
|
|
"vCOFINS", |
5281
|
|
|
$this->conditionalNumberFormatting($std->vCOFINS), |
5282
|
|
|
true, |
5283
|
|
|
"[item $std->item] Valor da COFINS" |
5284
|
|
|
); |
5285
|
|
|
$this->aCOFINSST[$std->item] = $cofinsst; |
5286
|
|
|
return $cofinsst; |
5287
|
|
|
} |
5288
|
|
|
|
5289
|
|
|
/** |
5290
|
|
|
* Grupo ISSQN U01 pai M01 |
5291
|
|
|
* tag NFe/infNFe/det[]/imposto/ISSQN (opcional) |
5292
|
|
|
* @param stdClass $std |
5293
|
|
|
* @return DOMElement |
5294
|
|
|
*/ |
5295
|
|
|
public function tagISSQN(stdClass $std) |
5296
|
|
|
{ |
5297
|
|
|
$possible = [ |
5298
|
|
|
'item', |
5299
|
|
|
'vBC', |
5300
|
|
|
'vAliq', |
5301
|
|
|
'vISSQN', |
5302
|
|
|
'cMunFG', |
5303
|
|
|
'cListServ', |
5304
|
|
|
'vDeducao', |
5305
|
|
|
'vOutro', |
5306
|
|
|
'vDescIncond', |
5307
|
|
|
'vDescCond', |
5308
|
|
|
'vISSRet', |
5309
|
|
|
'indISS', |
5310
|
|
|
'cServico', |
5311
|
|
|
'cMun', |
5312
|
|
|
'cPais', |
5313
|
|
|
'nProcesso', |
5314
|
|
|
'indIncentivo' |
5315
|
|
|
]; |
5316
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5317
|
|
|
$issqn = $this->dom->createElement("ISSQN"); |
5318
|
|
|
$this->dom->addChild( |
5319
|
|
|
$issqn, |
5320
|
|
|
"vBC", |
5321
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
5322
|
|
|
true, |
5323
|
|
|
"[item $std->item] Valor da Base de Cálculo do ISSQN" |
5324
|
|
|
); |
5325
|
|
|
$this->dom->addChild( |
5326
|
|
|
$issqn, |
5327
|
|
|
"vAliq", |
5328
|
|
|
$this->conditionalNumberFormatting($std->vAliq, 4), |
5329
|
|
|
true, |
5330
|
|
|
"[item $std->item] Alíquota do ISSQN" |
5331
|
|
|
); |
5332
|
|
|
$this->dom->addChild( |
5333
|
|
|
$issqn, |
5334
|
|
|
"vISSQN", |
5335
|
|
|
$this->conditionalNumberFormatting($std->vISSQN), |
5336
|
|
|
true, |
5337
|
|
|
"[item $std->item] Valor do ISSQN" |
5338
|
|
|
); |
5339
|
|
|
$this->dom->addChild( |
5340
|
|
|
$issqn, |
5341
|
|
|
"cMunFG", |
5342
|
|
|
$std->cMunFG, |
5343
|
|
|
true, |
5344
|
|
|
"[item $std->item] Código do município de ocorrência do fato gerador do ISSQN" |
5345
|
|
|
); |
5346
|
|
|
$this->dom->addChild( |
5347
|
|
|
$issqn, |
5348
|
|
|
"cListServ", |
5349
|
|
|
$std->cListServ, |
5350
|
|
|
true, |
5351
|
|
|
"[item $std->item] Item da Lista de Serviços" |
5352
|
|
|
); |
5353
|
|
|
$this->dom->addChild( |
5354
|
|
|
$issqn, |
5355
|
|
|
"vDeducao", |
5356
|
|
|
$this->conditionalNumberFormatting($std->vDeducao), |
5357
|
|
|
false, |
5358
|
|
|
"[item $std->item] Valor dedução para redução da Base de Cálculo" |
5359
|
|
|
); |
5360
|
|
|
$this->dom->addChild( |
5361
|
|
|
$issqn, |
5362
|
|
|
"vOutro", |
5363
|
|
|
$this->conditionalNumberFormatting($std->vOutro), |
5364
|
|
|
false, |
5365
|
|
|
"[item $std->item] Valor outras retenções" |
5366
|
|
|
); |
5367
|
|
|
$this->dom->addChild( |
5368
|
|
|
$issqn, |
5369
|
|
|
"vDescIncond", |
5370
|
|
|
$this->conditionalNumberFormatting($std->vDescIncond), |
5371
|
|
|
false, |
5372
|
|
|
"[item $std->item] Valor desconto incondicionado" |
5373
|
|
|
); |
5374
|
|
|
$this->dom->addChild( |
5375
|
|
|
$issqn, |
5376
|
|
|
"vDescCond", |
5377
|
|
|
$this->conditionalNumberFormatting($std->vDescCond), |
5378
|
|
|
false, |
5379
|
|
|
"[item $std->item] Valor desconto condicionado" |
5380
|
|
|
); |
5381
|
|
|
$this->dom->addChild( |
5382
|
|
|
$issqn, |
5383
|
|
|
"vISSRet", |
5384
|
|
|
$this->conditionalNumberFormatting($std->vISSRet), |
5385
|
|
|
false, |
5386
|
|
|
"[item $std->item] Valor retenção ISS" |
5387
|
|
|
); |
5388
|
|
|
$this->dom->addChild( |
5389
|
|
|
$issqn, |
5390
|
|
|
"indISS", |
5391
|
|
|
$std->indISS, |
5392
|
|
|
true, |
5393
|
|
|
"[item $std->item] Indicador da exigibilidade do ISS" |
5394
|
|
|
); |
5395
|
|
|
$this->dom->addChild( |
5396
|
|
|
$issqn, |
5397
|
|
|
"cServico", |
5398
|
|
|
$std->cServico, |
5399
|
|
|
false, |
5400
|
|
|
"[item $std->item] Código do serviço prestado dentro do município" |
5401
|
|
|
); |
5402
|
|
|
$this->dom->addChild( |
5403
|
|
|
$issqn, |
5404
|
|
|
"cMun", |
5405
|
|
|
$std->cMun, |
5406
|
|
|
false, |
5407
|
|
|
"[item $std->item] Código do Município de incidência do imposto" |
5408
|
|
|
); |
5409
|
|
|
$this->dom->addChild( |
5410
|
|
|
$issqn, |
5411
|
|
|
"cPais", |
5412
|
|
|
$std->cPais, |
5413
|
|
|
false, |
5414
|
|
|
"[item $std->item] Código do País onde o serviço foi prestado" |
5415
|
|
|
); |
5416
|
|
|
$this->dom->addChild( |
5417
|
|
|
$issqn, |
5418
|
|
|
"nProcesso", |
5419
|
|
|
$std->nProcesso, |
5420
|
|
|
false, |
5421
|
|
|
"[item $std->item] Número do processo judicial ou administrativo de suspensão da exigibilidade" |
5422
|
|
|
); |
5423
|
|
|
$this->dom->addChild( |
5424
|
|
|
$issqn, |
5425
|
|
|
"indIncentivo", |
5426
|
|
|
$std->indIncentivo, |
5427
|
|
|
true, |
5428
|
|
|
"[item $std->item] Indicador de incentivo Fiscal" |
5429
|
|
|
); |
5430
|
|
|
$this->aISSQN[$std->item] = $issqn; |
5431
|
|
|
return $issqn; |
5432
|
|
|
} |
5433
|
|
|
|
5434
|
|
|
/** |
5435
|
|
|
* Informação do Imposto devolvido U50 pai H01 |
5436
|
|
|
* tag NFe/infNFe/det[]/impostoDevol (opcional) |
5437
|
|
|
* @param stdClass $std |
5438
|
|
|
* @return DOMElement |
5439
|
|
|
*/ |
5440
|
|
|
public function tagimpostoDevol(stdClass $std) |
5441
|
|
|
{ |
5442
|
|
|
$possible = [ |
5443
|
|
|
'item', |
5444
|
|
|
'pDevol', |
5445
|
|
|
'vIPIDevol' |
5446
|
|
|
]; |
5447
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5448
|
|
|
//totalizador |
5449
|
|
|
$this->stdTot->vIPIDevol += (float) $std->vIPIDevol; |
5450
|
|
|
$impostoDevol = $this->dom->createElement("impostoDevol"); |
5451
|
|
|
$this->dom->addChild( |
5452
|
|
|
$impostoDevol, |
5453
|
|
|
"pDevol", |
5454
|
|
|
$this->conditionalNumberFormatting($std->pDevol, 2), |
5455
|
|
|
true, |
5456
|
|
|
"[item $std->item] Percentual da mercadoria devolvida" |
5457
|
|
|
); |
5458
|
|
|
$parent = $this->dom->createElement("IPI"); |
5459
|
|
|
$this->dom->addChild( |
5460
|
|
|
$parent, |
5461
|
|
|
"vIPIDevol", |
5462
|
|
|
$this->conditionalNumberFormatting($std->vIPIDevol), |
5463
|
|
|
true, |
5464
|
|
|
"[item $std->item] Valor do IPI devolvido" |
5465
|
|
|
); |
5466
|
|
|
$impostoDevol->appendChild($parent); |
5467
|
|
|
$this->aImpostoDevol[$std->item] = $impostoDevol; |
5468
|
|
|
return $impostoDevol; |
5469
|
|
|
} |
5470
|
|
|
|
5471
|
|
|
/** |
5472
|
|
|
* Grupo Totais referentes ao ICMS W02 pai W01 |
5473
|
|
|
* tag NFe/infNFe/total/ICMSTot |
5474
|
|
|
* @param stdClass $std |
5475
|
|
|
* @return DOMElement |
5476
|
|
|
*/ |
5477
|
|
|
public function tagICMSTot(stdClass $std) |
5478
|
|
|
{ |
5479
|
|
|
$this->buildTotal(); |
5480
|
|
|
$vBC = isset($std->vBC) ? $std->vBC : $this->stdTot->vBC; |
5481
|
|
|
$vICMS = isset($std->vICMS) ? $std->vICMS : $this->stdTot->vICMS; |
5482
|
|
|
$vICMSDeson = !empty($std->vICMSDeson) ? $std->vICMSDeson : $this->stdTot->vICMSDeson; |
5483
|
|
|
$vBCST = !empty($std->vBCST) ? $std->vBCST : $this->stdTot->vBCST; |
5484
|
|
|
$vST = !empty($std->vST) ? $std->vST : $this->stdTot->vST; |
5485
|
|
|
$vProd = !empty($std->vProd) ? $std->vProd : $this->stdTot->vProd; |
5486
|
|
|
$vFrete = !empty($std->vFrete) ? $std->vFrete : $this->stdTot->vFrete; |
5487
|
|
|
$vSeg = !empty($std->vSeg) ? $std->vSeg : $this->stdTot->vSeg; |
5488
|
|
|
$vDesc = !empty($std->vDesc) ? $std->vDesc : $this->stdTot->vDesc; |
5489
|
|
|
$vII = !empty($std->vII) ? $std->vII : $this->stdTot->vII; |
5490
|
|
|
$vIPI = !empty($std->vIPI) ? $std->vIPI : $this->stdTot->vIPI; |
5491
|
|
|
$vPIS = !empty($std->vPIS) ? $std->vPIS : $this->stdTot->vPIS; |
5492
|
|
|
$vCOFINS = !empty($std->vCOFINS) ? $std->vCOFINS : $this->stdTot->vCOFINS; |
5493
|
|
|
$vOutro = !empty($std->vOutro) ? $std->vOutro : $this->stdTot->vOutro; |
5494
|
|
|
$vNF = !empty($std->vNF) ? $std->vNF : $this->stdTot->vNF; |
5495
|
|
|
$vIPIDevol = !empty($std->vIPIDevol) ? $std->vIPIDevol : $this->stdTot->vIPIDevol; |
5496
|
|
|
$vTotTrib = !empty($std->vTotTrib) ? $std->vTotTrib : $this->stdTot->vTotTrib; |
5497
|
|
|
$vFCP = !empty($std->vFCP) ? $std->vFCP : $this->stdTot->vFCP; |
5498
|
|
|
$vFCPST = !empty($std->vFCPST) ? $std->vFCPST : $this->stdTot->vFCPST; |
5499
|
|
|
$vFCPSTRet = !empty($std->vFCPSTRet) ? $std->vFCPSTRet : $this->stdTot->vFCPSTRet; |
5500
|
|
|
$vFCPUFDest = !empty($std->vFCPUFDest) ? $std->vFCPUFDest : $this->stdTot->vFCPUFDest; |
5501
|
|
|
$vICMSUFDest = !empty($std->vICMSUFDest) ? $std->vICMSUFDest : $this->stdTot->vICMSUFDest; |
5502
|
|
|
$vICMSUFRemet = !empty($std->vICMSUFRemet) ? $std->vICMSUFRemet : $this->stdTot->vICMSUFRemet; |
5503
|
|
|
|
5504
|
|
|
//campos opcionais incluir se maior que zero |
5505
|
|
|
$vFCPUFDest = ($vFCPUFDest > 0) ? number_format($vFCPUFDest, 2, '.', '') : null; |
5506
|
|
|
$vICMSUFDest = ($vICMSUFDest > 0) ? number_format($vICMSUFDest, 2, '.', '') : null; |
5507
|
|
|
$vICMSUFRemet = ($vICMSUFRemet > 0) ? number_format($vICMSUFRemet, 2, '.', '') : null; |
5508
|
|
|
$vTotTrib = ($vTotTrib > 0) ? number_format($vTotTrib, 2, '.', '') : null; |
5509
|
|
|
|
5510
|
|
|
//campos obrigatórios para 4.00 |
5511
|
|
|
$vFCP = number_format($vFCP, 2, '.', ''); |
5512
|
|
|
$vFCPST = number_format($vFCPST, 2, '.', ''); |
5513
|
|
|
$vFCPSTRet = number_format($vFCPSTRet, 2, '.', ''); |
5514
|
|
|
$vIPIDevol = number_format($vIPIDevol, 2, '.', ''); |
5515
|
|
|
|
5516
|
|
|
$ICMSTot = $this->dom->createElement("ICMSTot"); |
5517
|
|
|
$this->dom->addChild( |
5518
|
|
|
$ICMSTot, |
5519
|
|
|
"vBC", |
5520
|
|
|
number_format($vBC, 2, '.', ''), |
5521
|
|
|
true, |
5522
|
|
|
"Base de Cálculo do ICMS" |
5523
|
|
|
); |
5524
|
|
|
$this->dom->addChild( |
5525
|
|
|
$ICMSTot, |
5526
|
|
|
"vICMS", |
5527
|
|
|
number_format($vICMS, 2, '.', ''), |
5528
|
|
|
true, |
5529
|
|
|
"Valor Total do ICMS" |
5530
|
|
|
); |
5531
|
|
|
$this->dom->addChild( |
5532
|
|
|
$ICMSTot, |
5533
|
|
|
"vICMSDeson", |
5534
|
|
|
number_format($vICMSDeson, 2, '.', ''), |
5535
|
|
|
true, |
5536
|
|
|
"Valor Total do ICMS desonerado" |
5537
|
|
|
); |
5538
|
|
|
$this->dom->addChild( |
5539
|
|
|
$ICMSTot, |
5540
|
|
|
"vFCPUFDest", |
5541
|
|
|
$vFCPUFDest, |
5542
|
|
|
false, |
5543
|
|
|
"Valor total do ICMS relativo ao Fundo de Combate à Pobreza(FCP) " |
5544
|
|
|
. "para a UF de destino" |
5545
|
|
|
); |
5546
|
|
|
$this->dom->addChild( |
5547
|
|
|
$ICMSTot, |
5548
|
|
|
"vICMSUFDest", |
5549
|
|
|
$vICMSUFDest, |
5550
|
|
|
false, |
5551
|
|
|
"Valor total do ICMS de partilha para a UF do destinatário" |
5552
|
|
|
); |
5553
|
|
|
$this->dom->addChild( |
5554
|
|
|
$ICMSTot, |
5555
|
|
|
"vICMSUFRemet", |
5556
|
|
|
$vICMSUFRemet, |
5557
|
|
|
false, |
5558
|
|
|
"Valor total do ICMS de partilha para a UF do remetente" |
5559
|
|
|
); |
5560
|
|
|
//incluso no layout 4.00 |
5561
|
|
|
$this->dom->addChild( |
5562
|
|
|
$ICMSTot, |
5563
|
|
|
"vFCP", |
5564
|
|
|
$vFCP, |
5565
|
|
|
false, |
5566
|
|
|
"Valor total do ICMS relativo ao Fundo de Combate à Pobreza(FCP) " |
5567
|
|
|
. "para a UF de destino" |
5568
|
|
|
); |
5569
|
|
|
$this->dom->addChild( |
5570
|
|
|
$ICMSTot, |
5571
|
|
|
"vBCST", |
5572
|
|
|
number_format($vBCST, 2, '.', ''), |
5573
|
|
|
true, |
5574
|
|
|
"Base de Cálculo do ICMS ST" |
5575
|
|
|
); |
5576
|
|
|
$this->dom->addChild( |
5577
|
|
|
$ICMSTot, |
5578
|
|
|
"vST", |
5579
|
|
|
number_format($vST, 2, '.', ''), |
5580
|
|
|
true, |
5581
|
|
|
"Valor Total do ICMS ST" |
5582
|
|
|
); |
5583
|
|
|
//incluso na 4.00 |
5584
|
|
|
$this->dom->addChild( |
5585
|
|
|
$ICMSTot, |
5586
|
|
|
"vFCPST", |
5587
|
|
|
$vFCPST, |
5588
|
|
|
false, //true para 4.00 |
5589
|
|
|
"Valor Total do FCP (Fundo de Combate à Pobreza) " |
5590
|
|
|
. "retido por substituição tributária" |
5591
|
|
|
); |
5592
|
|
|
//incluso na 4.00 |
5593
|
|
|
$this->dom->addChild( |
5594
|
|
|
$ICMSTot, |
5595
|
|
|
"vFCPSTRet", |
5596
|
|
|
$vFCPSTRet, |
5597
|
|
|
false, //true para 4.00 |
5598
|
|
|
"Valor Total do FCP retido anteriormente por " |
5599
|
|
|
. "Substituição Tributária" |
5600
|
|
|
); |
5601
|
|
|
$this->dom->addChild( |
5602
|
|
|
$ICMSTot, |
5603
|
|
|
"vProd", |
5604
|
|
|
number_format($vProd, 2, '.', ''), |
5605
|
|
|
true, |
5606
|
|
|
"Valor Total dos produtos e serviços" |
5607
|
|
|
); |
5608
|
|
|
$this->dom->addChild( |
5609
|
|
|
$ICMSTot, |
5610
|
|
|
"vFrete", |
5611
|
|
|
number_format($vFrete, 2, '.', ''), |
5612
|
|
|
true, |
5613
|
|
|
"Valor Total do Frete" |
5614
|
|
|
); |
5615
|
|
|
$this->dom->addChild( |
5616
|
|
|
$ICMSTot, |
5617
|
|
|
"vSeg", |
5618
|
|
|
number_format($vSeg, 2, '.', ''), |
5619
|
|
|
true, |
5620
|
|
|
"Valor Total do Seguro" |
5621
|
|
|
); |
5622
|
|
|
$this->dom->addChild( |
5623
|
|
|
$ICMSTot, |
5624
|
|
|
"vDesc", |
5625
|
|
|
number_format($vDesc, 2, '.', ''), |
5626
|
|
|
true, |
5627
|
|
|
"Valor Total do Desconto" |
5628
|
|
|
); |
5629
|
|
|
$this->dom->addChild( |
5630
|
|
|
$ICMSTot, |
5631
|
|
|
"vII", |
5632
|
|
|
number_format($vII, 2, '.', ''), |
5633
|
|
|
true, |
5634
|
|
|
"Valor Total do II" |
5635
|
|
|
); |
5636
|
|
|
$this->dom->addChild( |
5637
|
|
|
$ICMSTot, |
5638
|
|
|
"vIPI", |
5639
|
|
|
number_format($vIPI, 2, '.', ''), |
5640
|
|
|
true, |
5641
|
|
|
"Valor Total do IPI" |
5642
|
|
|
); |
5643
|
|
|
//incluso 4.00 |
5644
|
|
|
$this->dom->addChild( |
5645
|
|
|
$ICMSTot, |
5646
|
|
|
"vIPIDevol", |
5647
|
|
|
$vIPIDevol, |
5648
|
|
|
false, |
5649
|
|
|
"Valor Total do IPI" |
5650
|
|
|
); |
5651
|
|
|
$this->dom->addChild( |
5652
|
|
|
$ICMSTot, |
5653
|
|
|
"vPIS", |
5654
|
|
|
number_format($vPIS, 2, '.', ''), |
5655
|
|
|
true, |
5656
|
|
|
"Valor do PIS" |
5657
|
|
|
); |
5658
|
|
|
$this->dom->addChild( |
5659
|
|
|
$ICMSTot, |
5660
|
|
|
"vCOFINS", |
5661
|
|
|
number_format($vCOFINS, 2, '.', ''), |
5662
|
|
|
true, |
5663
|
|
|
"Valor da COFINS" |
5664
|
|
|
); |
5665
|
|
|
$this->dom->addChild( |
5666
|
|
|
$ICMSTot, |
5667
|
|
|
"vOutro", |
5668
|
|
|
number_format($vOutro, 2, '.', ''), |
5669
|
|
|
true, |
5670
|
|
|
"Outras Despesas acessórias" |
5671
|
|
|
); |
5672
|
|
|
$this->dom->addChild( |
5673
|
|
|
$ICMSTot, |
5674
|
|
|
"vNF", |
5675
|
|
|
number_format($vNF, 2, '.', ''), |
5676
|
|
|
true, |
5677
|
|
|
"Valor Total da NF-e" |
5678
|
|
|
); |
5679
|
|
|
$this->dom->addChild( |
5680
|
|
|
$ICMSTot, |
5681
|
|
|
"vTotTrib", |
5682
|
|
|
$vTotTrib, |
5683
|
|
|
false, |
5684
|
|
|
"Valor aproximado total de tributos federais, estaduais e municipais." |
5685
|
|
|
); |
5686
|
|
|
$this->dom->appChild($this->total, $ICMSTot, ''); |
5687
|
|
|
return $ICMSTot; |
5688
|
|
|
} |
5689
|
|
|
|
5690
|
|
|
/** |
5691
|
|
|
* Grupo Totais referentes ao ISSQN W17 pai W01 |
5692
|
|
|
* tag NFe/infNFe/total/ISSQNTot (opcional) |
5693
|
|
|
* @param stdClass $std |
5694
|
|
|
* @return DOMElement |
5695
|
|
|
*/ |
5696
|
|
|
public function tagISSQNTot(stdClass $std) |
5697
|
|
|
{ |
5698
|
|
|
$possible = [ |
5699
|
|
|
'vServ', |
5700
|
|
|
'vBC', |
5701
|
|
|
'vISS', |
5702
|
|
|
'vPIS', |
5703
|
|
|
'vCOFINS', |
5704
|
|
|
'dCompet', |
5705
|
|
|
'vDeducao', |
5706
|
|
|
'vOutro', |
5707
|
|
|
'vDescIncond', |
5708
|
|
|
'vDescCond', |
5709
|
|
|
'vISSRet', |
5710
|
|
|
'cRegTrib' |
5711
|
|
|
]; |
5712
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5713
|
|
|
$this->buildTotal(); |
5714
|
|
|
$ISSQNTot = $this->dom->createElement("ISSQNtot"); |
5715
|
|
|
$this->dom->addChild( |
5716
|
|
|
$ISSQNTot, |
5717
|
|
|
"vServ", |
5718
|
|
|
$this->conditionalNumberFormatting($std->vServ), |
5719
|
|
|
false, |
5720
|
|
|
"Valor total dos Serviços sob não incidência ou não tributados pelo ICMS" |
5721
|
|
|
); |
5722
|
|
|
$this->dom->addChild( |
5723
|
|
|
$ISSQNTot, |
5724
|
|
|
"vBC", |
5725
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
5726
|
|
|
false, |
5727
|
|
|
"Valor total Base de Cálculo do ISS" |
5728
|
|
|
); |
5729
|
|
|
$this->dom->addChild( |
5730
|
|
|
$ISSQNTot, |
5731
|
|
|
"vISS", |
5732
|
|
|
$this->conditionalNumberFormatting($std->vISS), |
5733
|
|
|
false, |
5734
|
|
|
"Valor total do ISS" |
5735
|
|
|
); |
5736
|
|
|
$this->dom->addChild( |
5737
|
|
|
$ISSQNTot, |
5738
|
|
|
"vPIS", |
5739
|
|
|
$this->conditionalNumberFormatting($std->vPIS), |
5740
|
|
|
false, |
5741
|
|
|
"Valor total do PIS sobre serviços" |
5742
|
|
|
); |
5743
|
|
|
$this->dom->addChild( |
5744
|
|
|
$ISSQNTot, |
5745
|
|
|
"vCOFINS", |
5746
|
|
|
$this->conditionalNumberFormatting($std->vCOFINS), |
5747
|
|
|
false, |
5748
|
|
|
"Valor total da COFINS sobre serviços" |
5749
|
|
|
); |
5750
|
|
|
$this->dom->addChild( |
5751
|
|
|
$ISSQNTot, |
5752
|
|
|
"dCompet", |
5753
|
|
|
$std->dCompet, |
5754
|
|
|
true, |
5755
|
|
|
"Data da prestação do serviço" |
5756
|
|
|
); |
5757
|
|
|
$this->dom->addChild( |
5758
|
|
|
$ISSQNTot, |
5759
|
|
|
"vDeducao", |
5760
|
|
|
$this->conditionalNumberFormatting($std->vDeducao), |
5761
|
|
|
false, |
5762
|
|
|
"Valor total dedução para redução da Base de Cálculo" |
5763
|
|
|
); |
5764
|
|
|
$this->dom->addChild( |
5765
|
|
|
$ISSQNTot, |
5766
|
|
|
"vOutro", |
5767
|
|
|
$this->conditionalNumberFormatting($std->vOutro), |
5768
|
|
|
false, |
5769
|
|
|
"Valor total outras retenções" |
5770
|
|
|
); |
5771
|
|
|
$this->dom->addChild( |
5772
|
|
|
$ISSQNTot, |
5773
|
|
|
"vDescIncond", |
5774
|
|
|
$this->conditionalNumberFormatting($std->vDescIncond), |
5775
|
|
|
false, |
5776
|
|
|
"Valor total desconto incondicionado" |
5777
|
|
|
); |
5778
|
|
|
$this->dom->addChild( |
5779
|
|
|
$ISSQNTot, |
5780
|
|
|
"vDescCond", |
5781
|
|
|
$this->conditionalNumberFormatting($std->vDescCond), |
5782
|
|
|
false, |
5783
|
|
|
"Valor total desconto condicionado" |
5784
|
|
|
); |
5785
|
|
|
$this->dom->addChild( |
5786
|
|
|
$ISSQNTot, |
5787
|
|
|
"vISSRet", |
5788
|
|
|
$this->conditionalNumberFormatting($std->vISSRet), |
5789
|
|
|
false, |
5790
|
|
|
"Valor total retenção ISS" |
5791
|
|
|
); |
5792
|
|
|
$this->dom->addChild( |
5793
|
|
|
$ISSQNTot, |
5794
|
|
|
"cRegTrib", |
5795
|
|
|
$std->cRegTrib, |
5796
|
|
|
false, |
5797
|
|
|
"Código do Regime Especial de Tributação" |
5798
|
|
|
); |
5799
|
|
|
$this->dom->appChild($this->total, $ISSQNTot, ''); |
5800
|
|
|
return $ISSQNTot; |
5801
|
|
|
} |
5802
|
|
|
|
5803
|
|
|
/** |
5804
|
|
|
* Grupo Retenções de Tributos W23 pai W01 |
5805
|
|
|
* tag NFe/infNFe/total/reTrib (opcional) |
5806
|
|
|
* @param stdClass $std |
5807
|
|
|
* @return DOMElement |
5808
|
|
|
*/ |
5809
|
|
|
public function tagretTrib(stdClass $std) |
5810
|
|
|
{ |
5811
|
|
|
$possible = [ |
5812
|
|
|
'vRetPIS', |
5813
|
|
|
'vRetCOFINS', |
5814
|
|
|
'vRetCSLL', |
5815
|
|
|
'vBCIRRF', |
5816
|
|
|
'vIRRF', |
5817
|
|
|
'vBCRetPrev', |
5818
|
|
|
'vRetPrev' |
5819
|
|
|
]; |
5820
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5821
|
|
|
$retTrib = $this->dom->createElement("retTrib"); |
5822
|
|
|
$this->dom->addChild( |
5823
|
|
|
$retTrib, |
5824
|
|
|
"vRetPIS", |
5825
|
|
|
$this->conditionalNumberFormatting($std->vRetPIS), |
5826
|
|
|
false, |
5827
|
|
|
"Valor Retido de PIS" |
5828
|
|
|
); |
5829
|
|
|
$this->dom->addChild( |
5830
|
|
|
$retTrib, |
5831
|
|
|
"vRetCOFINS", |
5832
|
|
|
$this->conditionalNumberFormatting($std->vRetCOFINS), |
5833
|
|
|
false, |
5834
|
|
|
"Valor Retido de COFINS" |
5835
|
|
|
); |
5836
|
|
|
$this->dom->addChild( |
5837
|
|
|
$retTrib, |
5838
|
|
|
"vRetCSLL", |
5839
|
|
|
$this->conditionalNumberFormatting($std->vRetCSLL), |
5840
|
|
|
false, |
5841
|
|
|
"Valor Retido de CSLL" |
5842
|
|
|
); |
5843
|
|
|
$this->dom->addChild( |
5844
|
|
|
$retTrib, |
5845
|
|
|
"vBCIRRF", |
5846
|
|
|
$this->conditionalNumberFormatting($std->vBCIRRF), |
5847
|
|
|
false, |
5848
|
|
|
"Base de Cálculo do IRRF" |
5849
|
|
|
); |
5850
|
|
|
$this->dom->addChild( |
5851
|
|
|
$retTrib, |
5852
|
|
|
"vIRRF", |
5853
|
|
|
$this->conditionalNumberFormatting($std->vIRRF), |
5854
|
|
|
false, |
5855
|
|
|
"Valor Retido do IRRF" |
5856
|
|
|
); |
5857
|
|
|
$this->dom->addChild( |
5858
|
|
|
$retTrib, |
5859
|
|
|
"vBCRetPrev", |
5860
|
|
|
$this->conditionalNumberFormatting($std->vBCRetPrev), |
5861
|
|
|
false, |
5862
|
|
|
"Base de Cálculo da Retenção da Previdência Social" |
5863
|
|
|
); |
5864
|
|
|
$this->dom->addChild( |
5865
|
|
|
$retTrib, |
5866
|
|
|
"vRetPrev", |
5867
|
|
|
$this->conditionalNumberFormatting($std->vRetPrev), |
5868
|
|
|
false, |
5869
|
|
|
"Valor da Retenção da Previdência Social" |
5870
|
|
|
); |
5871
|
|
|
$this->dom->appChild($this->total, $retTrib, ''); |
5872
|
|
|
return $retTrib; |
5873
|
|
|
} |
5874
|
|
|
|
5875
|
|
|
/** |
5876
|
|
|
* Grupo Informações do Transporte X01 pai A01 |
5877
|
|
|
* tag NFe/infNFe/transp (obrigatório) |
5878
|
|
|
* @param stdClass $std |
5879
|
|
|
* @return DOMElement |
5880
|
|
|
*/ |
5881
|
|
|
public function tagtransp(stdClass $std) |
5882
|
|
|
{ |
5883
|
|
|
$this->transp = $this->dom->createElement("transp"); |
5884
|
|
|
$this->dom->addChild( |
5885
|
|
|
$this->transp, |
5886
|
|
|
"modFrete", |
5887
|
|
|
$std->modFrete, |
5888
|
|
|
true, |
5889
|
|
|
"Modalidade do frete" |
5890
|
|
|
); |
5891
|
|
|
return $this->transp; |
5892
|
|
|
} |
5893
|
|
|
|
5894
|
|
|
/** |
5895
|
|
|
* Grupo Transportador X03 pai X01 |
5896
|
|
|
* tag NFe/infNFe/transp/tranporta (opcional) |
5897
|
|
|
* @param stdClass $std |
5898
|
|
|
* @return DOMElement |
5899
|
|
|
*/ |
5900
|
|
|
public function tagtransporta(stdClass $std) |
5901
|
|
|
{ |
5902
|
|
|
$possible = [ |
5903
|
|
|
'xNome', |
5904
|
|
|
'IE', |
5905
|
|
|
'xEnder', |
5906
|
|
|
'xMun', |
5907
|
|
|
'UF', |
5908
|
|
|
'CNPJ', |
5909
|
|
|
'CPF' |
5910
|
|
|
]; |
5911
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5912
|
|
|
$transporta = $this->dom->createElement("transporta"); |
5913
|
|
|
$this->dom->addChild( |
5914
|
|
|
$transporta, |
5915
|
|
|
"CNPJ", |
5916
|
|
|
$std->CNPJ, |
5917
|
|
|
false, |
5918
|
|
|
"CNPJ do Transportador" |
5919
|
|
|
); |
5920
|
|
|
$this->dom->addChild( |
5921
|
|
|
$transporta, |
5922
|
|
|
"CPF", |
5923
|
|
|
$std->CPF, |
5924
|
|
|
false, |
5925
|
|
|
"CPF do Transportador" |
5926
|
|
|
); |
5927
|
|
|
$this->dom->addChild( |
5928
|
|
|
$transporta, |
5929
|
|
|
"xNome", |
5930
|
|
|
$std->xNome, |
5931
|
|
|
false, |
5932
|
|
|
"Razão Social ou nome do Transportador" |
5933
|
|
|
); |
5934
|
|
|
$this->dom->addChild( |
5935
|
|
|
$transporta, |
5936
|
|
|
"IE", |
5937
|
|
|
$std->IE, |
5938
|
|
|
false, |
5939
|
|
|
"Inscrição Estadual do Transportador" |
5940
|
|
|
); |
5941
|
|
|
$this->dom->addChild( |
5942
|
|
|
$transporta, |
5943
|
|
|
"xEnder", |
5944
|
|
|
$std->xEnder, |
5945
|
|
|
false, |
5946
|
|
|
"Endereço Completo do Transportador" |
5947
|
|
|
); |
5948
|
|
|
$this->dom->addChild( |
5949
|
|
|
$transporta, |
5950
|
|
|
"xMun", |
5951
|
|
|
$std->xMun, |
5952
|
|
|
false, |
5953
|
|
|
"Nome do município do Transportador" |
5954
|
|
|
); |
5955
|
|
|
$this->dom->addChild( |
5956
|
|
|
$transporta, |
5957
|
|
|
"UF", |
5958
|
|
|
$std->UF, |
5959
|
|
|
false, |
5960
|
|
|
"Sigla da UF do Transportador" |
5961
|
|
|
); |
5962
|
|
|
$this->dom->appChild( |
5963
|
|
|
$this->transp, |
5964
|
|
|
$transporta, |
5965
|
|
|
'A tag transp deveria ter sido carregada primeiro.' |
5966
|
|
|
); |
5967
|
|
|
$this->dom->appChild($this->transp, $transporta, "Inclusão do node vol"); |
5968
|
|
|
return $transporta; |
5969
|
|
|
} |
5970
|
|
|
|
5971
|
|
|
/** |
5972
|
|
|
* Grupo Retenção ICMS transporte X11 pai X01 |
5973
|
|
|
* tag NFe/infNFe/transp/retTransp (opcional) |
5974
|
|
|
* @param stdClass $std |
5975
|
|
|
* @return DOMElement |
5976
|
|
|
*/ |
5977
|
|
|
public function tagretTransp(stdClass $std) |
5978
|
|
|
{ |
5979
|
|
|
$possible = [ |
5980
|
|
|
'vServ', |
5981
|
|
|
'vBCRet', |
5982
|
|
|
'pICMSRet', |
5983
|
|
|
'vICMSRet', |
5984
|
|
|
'CFOP', |
5985
|
|
|
'cMunFG' |
5986
|
|
|
]; |
5987
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5988
|
|
|
$retTransp = $this->dom->createElement("retTransp"); |
5989
|
|
|
$this->dom->addChild( |
5990
|
|
|
$retTransp, |
5991
|
|
|
"vServ", |
5992
|
|
|
$this->conditionalNumberFormatting($std->vServ), |
5993
|
|
|
true, |
5994
|
|
|
"Valor do Serviço" |
5995
|
|
|
); |
5996
|
|
|
$this->dom->addChild( |
5997
|
|
|
$retTransp, |
5998
|
|
|
"vBCRet", |
5999
|
|
|
$this->conditionalNumberFormatting($std->vBCRet), |
6000
|
|
|
true, |
6001
|
|
|
"BC da Retenção do ICMS" |
6002
|
|
|
); |
6003
|
|
|
$this->dom->addChild( |
6004
|
|
|
$retTransp, |
6005
|
|
|
"pICMSRet", |
6006
|
|
|
$this->conditionalNumberFormatting($std->pICMSRet, 4), |
6007
|
|
|
true, |
6008
|
|
|
"Alíquota da Retenção" |
6009
|
|
|
); |
6010
|
|
|
$this->dom->addChild( |
6011
|
|
|
$retTransp, |
6012
|
|
|
"vICMSRet", |
6013
|
|
|
$this->conditionalNumberFormatting($std->vICMSRet), |
6014
|
|
|
true, |
6015
|
|
|
"Valor do ICMS Retido" |
6016
|
|
|
); |
6017
|
|
|
$this->dom->addChild( |
6018
|
|
|
$retTransp, |
6019
|
|
|
"CFOP", |
6020
|
|
|
$std->CFOP, |
6021
|
|
|
true, |
6022
|
|
|
"CFOP" |
6023
|
|
|
); |
6024
|
|
|
$this->dom->addChild( |
6025
|
|
|
$retTransp, |
6026
|
|
|
"cMunFG", |
6027
|
|
|
$std->cMunFG, |
6028
|
|
|
true, |
6029
|
|
|
"Código do município de ocorrência do fato gerador do ICMS do transporte" |
6030
|
|
|
); |
6031
|
|
|
$this->dom->appChild( |
6032
|
|
|
$this->transp, |
6033
|
|
|
$retTransp, |
6034
|
|
|
'A tag transp deveria ter sido carregada primeiro.' |
6035
|
|
|
); |
6036
|
|
|
return $retTransp; |
6037
|
|
|
} |
6038
|
|
|
|
6039
|
|
|
/** |
6040
|
|
|
* Grupo Veículo Transporte X18 pai X17.1 |
6041
|
|
|
* tag NFe/infNFe/transp/veicTransp (opcional) |
6042
|
|
|
* @param stdClass $std |
6043
|
|
|
* @return DOMElement |
6044
|
|
|
*/ |
6045
|
|
|
public function tagveicTransp(stdClass $std) |
6046
|
|
|
{ |
6047
|
|
|
$possible = [ |
6048
|
|
|
'placa', |
6049
|
|
|
'UF', |
6050
|
|
|
'RNTC' |
6051
|
|
|
]; |
6052
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6053
|
|
|
$veicTransp = $this->dom->createElement("veicTransp"); |
6054
|
|
|
$this->dom->addChild( |
6055
|
|
|
$veicTransp, |
6056
|
|
|
"placa", |
6057
|
|
|
$std->placa, |
6058
|
|
|
true, |
6059
|
|
|
"Placa do Veículo" |
6060
|
|
|
); |
6061
|
|
|
$this->dom->addChild( |
6062
|
|
|
$veicTransp, |
6063
|
|
|
"UF", |
6064
|
|
|
$std->UF, |
6065
|
|
|
true, |
6066
|
|
|
"Sigla da UF do Veículo" |
6067
|
|
|
); |
6068
|
|
|
$this->dom->addChild( |
6069
|
|
|
$veicTransp, |
6070
|
|
|
"RNTC", |
6071
|
|
|
$std->RNTC, |
6072
|
|
|
false, |
6073
|
|
|
"Registro Nacional de Transportador de Carga (ANTT) do Veículo" |
6074
|
|
|
); |
6075
|
|
|
$this->dom->appChild( |
6076
|
|
|
$this->transp, |
6077
|
|
|
$veicTransp, |
6078
|
|
|
'A tag transp deveria ter sido carregada primeiro.' |
6079
|
|
|
); |
6080
|
|
|
return $veicTransp; |
6081
|
|
|
} |
6082
|
|
|
|
6083
|
|
|
/** |
6084
|
|
|
* Grupo Reboque X22 pai X17.1 |
6085
|
|
|
* tag NFe/infNFe/transp/reboque (opcional) |
6086
|
|
|
* @param stdClass $std |
6087
|
|
|
* @return DOMElement |
6088
|
|
|
*/ |
6089
|
|
|
public function tagreboque(stdClass $std) |
6090
|
|
|
{ |
6091
|
|
|
$possible = [ |
6092
|
|
|
'placa', |
6093
|
|
|
'UF', |
6094
|
|
|
'RNTC' |
6095
|
|
|
]; |
6096
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6097
|
|
|
$reboque = $this->dom->createElement("reboque"); |
6098
|
|
|
$this->dom->addChild( |
6099
|
|
|
$reboque, |
6100
|
|
|
"placa", |
6101
|
|
|
$std->placa, |
6102
|
|
|
true, |
6103
|
|
|
"Placa do Veículo Reboque" |
6104
|
|
|
); |
6105
|
|
|
$this->dom->addChild( |
6106
|
|
|
$reboque, |
6107
|
|
|
"UF", |
6108
|
|
|
$std->UF, |
6109
|
|
|
true, |
6110
|
|
|
"Sigla da UF do Veículo Reboque" |
6111
|
|
|
); |
6112
|
|
|
$this->dom->addChild( |
6113
|
|
|
$reboque, |
6114
|
|
|
"RNTC", |
6115
|
|
|
$std->RNTC, |
6116
|
|
|
false, |
6117
|
|
|
"Registro Nacional de Transportador de Carga (ANTT) do Veículo Reboque" |
6118
|
|
|
); |
6119
|
|
|
$this->dom->appChild( |
6120
|
|
|
$this->transp, |
6121
|
|
|
$reboque, |
6122
|
|
|
'A tag transp deveria ter sido carregada primeiro.' |
6123
|
|
|
); |
6124
|
|
|
return $reboque; |
6125
|
|
|
} |
6126
|
|
|
|
6127
|
|
|
/** |
6128
|
|
|
* Campo Vagao X25a pai X01 |
6129
|
|
|
* tag NFe/infNFe/transp/vagao (opcional) |
6130
|
|
|
* @param stdClass $std |
6131
|
|
|
*/ |
6132
|
|
|
public function tagvagao(stdClass $std) |
6133
|
|
|
{ |
6134
|
|
|
$possible = [ |
6135
|
|
|
'vagao' |
6136
|
|
|
]; |
6137
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6138
|
|
|
$this->dom->addChild( |
6139
|
|
|
$this->transp, |
6140
|
|
|
"vagao", |
6141
|
|
|
$std->vagao, |
6142
|
|
|
false, |
6143
|
|
|
"Identificação do vagão do Veículo Reboque" |
6144
|
|
|
); |
6145
|
|
|
} |
6146
|
|
|
|
6147
|
|
|
/** |
6148
|
|
|
* Campo Balsa X25b pai X01 |
6149
|
|
|
* tag NFe/infNFe/transp/balsa (opcional) |
6150
|
|
|
* @param stdClass $std |
6151
|
|
|
*/ |
6152
|
|
|
public function tagbalsa(stdClass $std) |
6153
|
|
|
{ |
6154
|
|
|
$possible = [ |
6155
|
|
|
'balsa' |
6156
|
|
|
]; |
6157
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6158
|
|
|
$this->dom->addChild( |
6159
|
|
|
$this->transp, |
6160
|
|
|
"balsa", |
6161
|
|
|
$std->balsa, |
6162
|
|
|
false, |
6163
|
|
|
"Identificação da balsa do Veículo Reboque" |
6164
|
|
|
); |
6165
|
|
|
} |
6166
|
|
|
|
6167
|
|
|
/** |
6168
|
|
|
* Grupo Volumes X26 pai X01 |
6169
|
|
|
* tag NFe/infNFe/transp/vol (opcional) |
6170
|
|
|
* @param stdClass $std |
6171
|
|
|
* @return DOMElement |
6172
|
|
|
*/ |
6173
|
|
|
public function tagvol(stdClass $std) |
6174
|
|
|
{ |
6175
|
|
|
$possible = [ |
6176
|
|
|
'item', |
6177
|
|
|
'qVol', |
6178
|
|
|
'esp', |
6179
|
|
|
'marca', |
6180
|
|
|
'nVol', |
6181
|
|
|
'pesoL', |
6182
|
|
|
'pesoB' |
6183
|
|
|
]; |
6184
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6185
|
|
|
$vol = $this->dom->createElement("vol"); |
6186
|
|
|
$this->dom->addChild( |
6187
|
|
|
$vol, |
6188
|
|
|
"qVol", |
6189
|
|
|
$std->qVol, |
6190
|
|
|
false, |
6191
|
|
|
"Quantidade de volumes transportados" |
6192
|
|
|
); |
6193
|
|
|
$this->dom->addChild( |
6194
|
|
|
$vol, |
6195
|
|
|
"esp", |
6196
|
|
|
$std->esp, |
6197
|
|
|
false, |
6198
|
|
|
"Espécie dos volumes transportados" |
6199
|
|
|
); |
6200
|
|
|
$this->dom->addChild( |
6201
|
|
|
$vol, |
6202
|
|
|
"marca", |
6203
|
|
|
$std->marca, |
6204
|
|
|
false, |
6205
|
|
|
"Marca dos volumes transportados" |
6206
|
|
|
); |
6207
|
|
|
$this->dom->addChild( |
6208
|
|
|
$vol, |
6209
|
|
|
"nVol", |
6210
|
|
|
$std->nVol, |
6211
|
|
|
false, |
6212
|
|
|
"Numeração dos volumes transportados" |
6213
|
|
|
); |
6214
|
|
|
$this->dom->addChild( |
6215
|
|
|
$vol, |
6216
|
|
|
"pesoL", |
6217
|
|
|
$this->conditionalNumberFormatting($std->pesoL, 3), |
6218
|
|
|
false, |
6219
|
|
|
"Peso Líquido (em kg) dos volumes transportados" |
6220
|
|
|
); |
6221
|
|
|
$this->dom->addChild( |
6222
|
|
|
$vol, |
6223
|
|
|
"pesoB", |
6224
|
|
|
$this->conditionalNumberFormatting($std->pesoB, 3), |
6225
|
|
|
false, |
6226
|
|
|
"Peso Bruto (em kg) dos volumes transportados" |
6227
|
|
|
); |
6228
|
|
|
$this->aVol[$std->item] = $vol; |
6229
|
|
|
return $vol; |
6230
|
|
|
} |
6231
|
|
|
|
6232
|
|
|
/** |
6233
|
|
|
* Grupo Lacres X33 pai X26 |
6234
|
|
|
* tag NFe/infNFe/transp/vol/lacres (opcional) |
6235
|
|
|
* @param stdClass $std |
6236
|
|
|
* @return DOMElement |
6237
|
|
|
*/ |
6238
|
|
|
public function taglacres(stdClass $std) |
6239
|
|
|
{ |
6240
|
|
|
$lacre = $this->dom->createElement("lacres"); |
6241
|
|
|
$this->dom->addChild( |
6242
|
|
|
$lacre, |
6243
|
|
|
"nLacre", |
6244
|
|
|
$std->nLacre, |
6245
|
|
|
true, |
6246
|
|
|
"Número dos Lacres" |
6247
|
|
|
); |
6248
|
|
|
$this->dom->appChild($this->aVol[$std->item], $lacre, "Inclusão do node lacres"); |
6249
|
|
|
return $lacre; |
6250
|
|
|
} |
6251
|
|
|
|
6252
|
|
|
/** |
6253
|
|
|
* Node vol |
6254
|
|
|
*/ |
6255
|
|
|
protected function buildVol() |
6256
|
|
|
{ |
6257
|
|
|
foreach ($this->aVol as $num => $vol) { |
6258
|
|
|
$this->dom->appChild($this->transp, $vol, "Inclusão do node vol"); |
6259
|
|
|
} |
6260
|
|
|
} |
6261
|
|
|
|
6262
|
|
|
/** |
6263
|
|
|
* Grupo Pagamento Y pai A01 |
6264
|
|
|
* NOTA: Ajustado para NT2016_002_v1.30 |
6265
|
|
|
* tag NFe/infNFe/pag (obrigatorio na NT2016_002_v1.30) |
6266
|
|
|
* Obrigatório para 55 e 65 |
6267
|
|
|
* @param stdClass $std |
6268
|
|
|
* @return DOMElement |
6269
|
|
|
*/ |
6270
|
|
|
public function tagpag($std) |
6271
|
|
|
{ |
6272
|
|
|
$possible = [ |
6273
|
|
|
'vTroco' |
6274
|
|
|
]; |
6275
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6276
|
|
|
$pag = $this->dom->createElement("pag"); |
6277
|
|
|
//incluso no layout 4.00 |
6278
|
|
|
$this->dom->addChild( |
6279
|
|
|
$pag, |
6280
|
|
|
"vTroco", |
6281
|
|
|
$this->conditionalNumberFormatting($std->vTroco), |
6282
|
|
|
false, |
6283
|
|
|
"Valor do troco" |
6284
|
|
|
); |
6285
|
|
|
return $this->pag = $pag; |
6286
|
|
|
} |
6287
|
|
|
|
6288
|
|
|
/** |
6289
|
|
|
* Grupo de Formas de Pagamento YA01a pai YA01 |
6290
|
|
|
* NOTA: Ajuste NT_2016_002_v1.30 |
6291
|
|
|
* NOTA: Ajuste NT_2016_002_v1 51 |
6292
|
|
|
* tag NFe/infNFe/pag/detPag |
6293
|
|
|
* @param stdClass $std |
6294
|
|
|
* @return DOMElement |
6295
|
|
|
*/ |
6296
|
|
|
public function tagdetPag($std) |
6297
|
|
|
{ |
6298
|
|
|
$possible = [ |
6299
|
|
|
'indPag', |
6300
|
|
|
'tPag', |
6301
|
|
|
'vPag', |
6302
|
|
|
'CNPJ', |
6303
|
|
|
'tBand', |
6304
|
|
|
'cAut', |
6305
|
|
|
'tpIntegra' |
6306
|
|
|
]; |
6307
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6308
|
|
|
//padrão para layout 4.00 |
6309
|
|
|
$detPag = $this->dom->createElement("detPag"); |
6310
|
|
|
$this->dom->addChild( |
6311
|
|
|
$detPag, |
6312
|
|
|
"indPag", |
6313
|
|
|
$std->indPag, |
6314
|
|
|
false, |
6315
|
|
|
"Indicador da Forma de Pagamento" |
6316
|
|
|
); |
6317
|
|
|
$this->dom->addChild( |
6318
|
|
|
$detPag, |
6319
|
|
|
"tPag", |
6320
|
|
|
$std->tPag, |
6321
|
|
|
true, |
6322
|
|
|
"Forma de pagamento" |
6323
|
|
|
); |
6324
|
|
|
$this->dom->addChild( |
6325
|
|
|
$detPag, |
6326
|
|
|
"vPag", |
6327
|
|
|
$this->conditionalNumberFormatting($std->vPag), |
6328
|
|
|
true, |
6329
|
|
|
"Valor do Pagamento" |
6330
|
|
|
); |
6331
|
|
|
if (!empty($std->tpIntegra)) { |
6332
|
|
|
$card = $this->dom->createElement("card"); |
6333
|
|
|
$this->dom->addChild( |
6334
|
|
|
$card, |
6335
|
|
|
"tpIntegra", |
6336
|
|
|
$std->tpIntegra, |
6337
|
|
|
true, |
6338
|
|
|
"Tipo de Integração para pagamento" |
6339
|
|
|
); |
6340
|
|
|
$this->dom->addChild( |
6341
|
|
|
$card, |
6342
|
|
|
"CNPJ", |
6343
|
|
|
!empty($std->CNPJ) ? $std->CNPJ : null, |
6344
|
|
|
false, |
6345
|
|
|
"CNPJ da Credenciadora de cartão de crédito e/ou débito" |
6346
|
|
|
); |
6347
|
|
|
$this->dom->addChild( |
6348
|
|
|
$card, |
6349
|
|
|
"tBand", |
6350
|
|
|
!empty($std->tBand) ? $std->tBand : null, |
6351
|
|
|
false, |
6352
|
|
|
"Bandeira da operadora de cartão de crédito e/ou débito" |
6353
|
|
|
); |
6354
|
|
|
$this->dom->addChild( |
6355
|
|
|
$card, |
6356
|
|
|
"cAut", |
6357
|
|
|
!empty($std->cAut) ? $std->cAut : null, |
6358
|
|
|
false, |
6359
|
|
|
"Número de autorização da operação cartão de crédito e/ou débito" |
6360
|
|
|
); |
6361
|
|
|
$this->dom->appChild($detPag, $card, "Inclusão do node Card"); |
6362
|
|
|
} |
6363
|
|
|
$node = !empty($this->pag->getElementsByTagName("vTroco")->item(0)) |
6364
|
|
|
? $this->pag->getElementsByTagName("vTroco")->item(0) |
6365
|
|
|
: null; |
6366
|
|
|
if (!empty($node)) { |
6367
|
|
|
$this->pag->insertBefore($detPag, $node); |
6368
|
|
|
} else { |
6369
|
|
|
$this->dom->appChild($this->pag, $detPag, 'Falta tag "Pag"'); |
6370
|
|
|
} |
6371
|
|
|
return $detPag; |
6372
|
|
|
} |
6373
|
|
|
|
6374
|
|
|
/** |
6375
|
|
|
* Grupo Fatura Y02 pai Y01 |
6376
|
|
|
* tag NFe/infNFe/cobr/fat (opcional) |
6377
|
|
|
* @param stdClass $std |
6378
|
|
|
* @return DOMElement |
6379
|
|
|
*/ |
6380
|
|
|
public function tagfat(stdClass $std) |
6381
|
|
|
{ |
6382
|
|
|
$possible = [ |
6383
|
|
|
'nFat', |
6384
|
|
|
'vOrig', |
6385
|
|
|
'vDesc', |
6386
|
|
|
'vLiq' |
6387
|
|
|
]; |
6388
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6389
|
|
|
$this->buildCobr(); |
6390
|
|
|
$fat = $this->dom->createElement("fat"); |
6391
|
|
|
$this->dom->addChild( |
6392
|
|
|
$fat, |
6393
|
|
|
"nFat", |
6394
|
|
|
$std->nFat, |
6395
|
|
|
false, |
6396
|
|
|
"Número da Fatura" |
6397
|
|
|
); |
6398
|
|
|
$this->dom->addChild( |
6399
|
|
|
$fat, |
6400
|
|
|
"vOrig", |
6401
|
|
|
$this->conditionalNumberFormatting($std->vOrig), |
6402
|
|
|
false, |
6403
|
|
|
"Valor Original da Fatura" |
6404
|
|
|
); |
6405
|
|
|
$this->dom->addChild( |
6406
|
|
|
$fat, |
6407
|
|
|
"vDesc", |
6408
|
|
|
$this->conditionalNumberFormatting($std->vDesc), |
6409
|
|
|
false, |
6410
|
|
|
"Valor do desconto" |
6411
|
|
|
); |
6412
|
|
|
$this->dom->addChild( |
6413
|
|
|
$fat, |
6414
|
|
|
"vLiq", |
6415
|
|
|
$this->conditionalNumberFormatting($std->vLiq), |
6416
|
|
|
false, |
6417
|
|
|
"Valor Líquido da Fatura" |
6418
|
|
|
); |
6419
|
|
|
$this->dom->appChild($this->cobr, $fat); |
6420
|
|
|
return $fat; |
6421
|
|
|
} |
6422
|
|
|
|
6423
|
|
|
/** |
6424
|
|
|
* Grupo Duplicata Y07 pai Y02 |
6425
|
|
|
* tag NFe/infNFe/cobr/fat/dup (opcional) |
6426
|
|
|
* É necessário criar a tag fat antes de criar as duplicatas |
6427
|
|
|
* @param stdClass $std |
6428
|
|
|
* @return DOMElement |
6429
|
|
|
*/ |
6430
|
|
|
public function tagdup(stdClass $std) |
6431
|
|
|
{ |
6432
|
|
|
$possible = [ |
6433
|
|
|
'nDup', |
6434
|
|
|
'dVenc', |
6435
|
|
|
'vDup' |
6436
|
|
|
]; |
6437
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6438
|
|
|
$this->buildCobr(); |
6439
|
|
|
$dup = $this->dom->createElement("dup"); |
6440
|
|
|
$this->dom->addChild( |
6441
|
|
|
$dup, |
6442
|
|
|
"nDup", |
6443
|
|
|
$std->nDup, |
6444
|
|
|
false, |
6445
|
|
|
"Número da Duplicata" |
6446
|
|
|
); |
6447
|
|
|
$this->dom->addChild( |
6448
|
|
|
$dup, |
6449
|
|
|
"dVenc", |
6450
|
|
|
$std->dVenc, |
6451
|
|
|
false, |
6452
|
|
|
"Data de vencimento" |
6453
|
|
|
); |
6454
|
|
|
$this->dom->addChild( |
6455
|
|
|
$dup, |
6456
|
|
|
"vDup", |
6457
|
|
|
$this->conditionalNumberFormatting($std->vDup), |
6458
|
|
|
true, |
6459
|
|
|
"Valor da duplicata" |
6460
|
|
|
); |
6461
|
|
|
$this->dom->appChild($this->cobr, $dup, 'Inclui duplicata na tag cobr'); |
6462
|
|
|
return $dup; |
6463
|
|
|
} |
6464
|
|
|
|
6465
|
|
|
/** |
6466
|
|
|
* Grupo de Informações Adicionais Z01 pai A01 |
6467
|
|
|
* tag NFe/infNFe/infAdic (opcional) |
6468
|
|
|
* @param stdClass $std |
6469
|
|
|
* @return DOMElement |
6470
|
|
|
*/ |
6471
|
|
|
public function taginfAdic(stdClass $std) |
6472
|
|
|
{ |
6473
|
|
|
$possible = ['infAdFisco', 'infCpl']; |
6474
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6475
|
|
|
$this->buildInfAdic(); |
6476
|
|
|
$this->dom->addChild( |
6477
|
|
|
$this->infAdic, |
6478
|
|
|
"infAdFisco", |
6479
|
|
|
$std->infAdFisco, |
6480
|
|
|
false, |
6481
|
|
|
"Informações Adicionais de Interesse do Fisco" |
6482
|
|
|
); |
6483
|
|
|
$this->dom->addChild( |
6484
|
|
|
$this->infAdic, |
6485
|
|
|
"infCpl", |
6486
|
|
|
$std->infCpl, |
6487
|
|
|
false, |
6488
|
|
|
"Informações Complementares de interesse do Contribuinte" |
6489
|
|
|
); |
6490
|
|
|
return $this->infAdic; |
6491
|
|
|
} |
6492
|
|
|
|
6493
|
|
|
/** |
6494
|
|
|
* Grupo Campo de uso livre do contribuinte Z04 pai Z01 |
6495
|
|
|
* tag NFe/infNFe/infAdic/obsCont (opcional) |
6496
|
|
|
* O método taginfAdic deve ter sido carregado antes |
6497
|
|
|
* @param stdClass $std |
6498
|
|
|
* @return DOMElement |
6499
|
|
|
*/ |
6500
|
|
|
public function tagobsCont(stdClass $std) |
6501
|
|
|
{ |
6502
|
|
|
$possible = ['xCampo', 'xTexto']; |
6503
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6504
|
|
|
$this->buildInfAdic(); |
6505
|
|
|
$obsCont = $this->dom->createElement("obsCont"); |
6506
|
|
|
$obsCont->setAttribute("xCampo", $std->xCampo); |
6507
|
|
|
$this->dom->addChild( |
6508
|
|
|
$obsCont, |
6509
|
|
|
"xTexto", |
6510
|
|
|
$std->xTexto, |
6511
|
|
|
true, |
6512
|
|
|
"Conteúdo do campo" |
6513
|
|
|
); |
6514
|
|
|
$this->dom->appChild($this->infAdic, $obsCont, ''); |
6515
|
|
|
return $obsCont; |
6516
|
|
|
} |
6517
|
|
|
|
6518
|
|
|
/** |
6519
|
|
|
* Grupo Campo de uso livre do Fisco Z07 pai Z01 |
6520
|
|
|
* tag NFe/infNFe/infAdic/obsFisco (opcional) |
6521
|
|
|
* O método taginfAdic deve ter sido carregado antes |
6522
|
|
|
* @param stdClass $std |
6523
|
|
|
* @return DOMElement |
6524
|
|
|
*/ |
6525
|
|
|
public function tagobsFisco(stdClass $std) |
6526
|
|
|
{ |
6527
|
|
|
$possible = ['xCampo', 'xTexto']; |
6528
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6529
|
|
|
$this->buildInfAdic(); |
6530
|
|
|
$obsFisco = $this->dom->createElement("obsFisco"); |
6531
|
|
|
$obsFisco->setAttribute("xCampo", $std->xCampo); |
6532
|
|
|
$this->dom->addChild( |
6533
|
|
|
$obsFisco, |
6534
|
|
|
"xTexto", |
6535
|
|
|
$std->xTexto, |
6536
|
|
|
true, |
6537
|
|
|
"Conteúdo do campo" |
6538
|
|
|
); |
6539
|
|
|
$this->dom->appChild($this->infAdic, $obsFisco, ''); |
6540
|
|
|
return $obsFisco; |
6541
|
|
|
} |
6542
|
|
|
|
6543
|
|
|
/** |
6544
|
|
|
* Grupo Processo referenciado Z10 pai Z01 (NT2012.003) |
6545
|
|
|
* tag NFe/infNFe/procRef (opcional) |
6546
|
|
|
* O método taginfAdic deve ter sido carregado antes |
6547
|
|
|
* @param stdClass $std |
6548
|
|
|
* @return DOMElement |
6549
|
|
|
*/ |
6550
|
|
|
public function tagprocRef($std) |
6551
|
|
|
{ |
6552
|
|
|
$possible = ['nProc', 'indProc']; |
6553
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6554
|
|
|
$this->buildInfAdic(); |
6555
|
|
|
$procRef = $this->dom->createElement("procRef"); |
6556
|
|
|
$this->dom->addChild( |
6557
|
|
|
$procRef, |
6558
|
|
|
"nProc", |
6559
|
|
|
$std->nProc, |
6560
|
|
|
true, |
6561
|
|
|
"Identificador do processo ou ato concessório" |
6562
|
|
|
); |
6563
|
|
|
$this->dom->addChild( |
6564
|
|
|
$procRef, |
6565
|
|
|
"indProc", |
6566
|
|
|
$std->indProc, |
6567
|
|
|
true, |
6568
|
|
|
"Indicador da origem do processo" |
6569
|
|
|
); |
6570
|
|
|
$this->dom->appChild($this->infAdic, $procRef, ''); |
6571
|
|
|
return $procRef; |
6572
|
|
|
} |
6573
|
|
|
|
6574
|
|
|
/** |
6575
|
|
|
* Grupo Exportação ZA01 pai A01 |
6576
|
|
|
* tag NFe/infNFe/exporta (opcional) |
6577
|
|
|
* @param stdClass $std |
6578
|
|
|
* @return DOMElement |
6579
|
|
|
*/ |
6580
|
|
|
public function tagexporta(stdClass $std) |
6581
|
|
|
{ |
6582
|
|
|
$possible = ['UFSaidaPais', 'xLocExporta', 'xLocDespacho']; |
6583
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6584
|
|
|
$this->exporta = $this->dom->createElement("exporta"); |
6585
|
|
|
$this->dom->addChild( |
6586
|
|
|
$this->exporta, |
6587
|
|
|
"UFSaidaPais", |
6588
|
|
|
$std->UFSaidaPais, |
6589
|
|
|
true, |
6590
|
|
|
"Sigla da UF de Embarque ou de transposição de fronteira" |
6591
|
|
|
); |
6592
|
|
|
$this->dom->addChild( |
6593
|
|
|
$this->exporta, |
6594
|
|
|
"xLocExporta", |
6595
|
|
|
$std->xLocExporta, |
6596
|
|
|
true, |
6597
|
|
|
"Descrição do Local de Embarque ou de transposição de fronteira" |
6598
|
|
|
); |
6599
|
|
|
$this->dom->addChild( |
6600
|
|
|
$this->exporta, |
6601
|
|
|
"xLocDespacho", |
6602
|
|
|
$std->xLocDespacho, |
6603
|
|
|
false, |
6604
|
|
|
"Descrição do local de despacho" |
6605
|
|
|
); |
6606
|
|
|
return $this->exporta; |
6607
|
|
|
} |
6608
|
|
|
|
6609
|
|
|
/** |
6610
|
|
|
* Grupo Compra ZB01 pai A01 |
6611
|
|
|
* tag NFe/infNFe/compra (opcional) |
6612
|
|
|
* @param stdClass $std |
6613
|
|
|
* @return DOMElement |
6614
|
|
|
*/ |
6615
|
|
|
public function tagcompra(stdClass $std) |
6616
|
|
|
{ |
6617
|
|
|
$possible = ['xNEmp', 'xPed', 'xCont']; |
6618
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6619
|
|
|
$this->compra = $this->dom->createElement("compra"); |
6620
|
|
|
$this->dom->addChild( |
6621
|
|
|
$this->compra, |
6622
|
|
|
"xNEmp", |
6623
|
|
|
$std->xNEmp, |
6624
|
|
|
false, |
6625
|
|
|
"Nota de Empenho" |
6626
|
|
|
); |
6627
|
|
|
$this->dom->addChild( |
6628
|
|
|
$this->compra, |
6629
|
|
|
"xPed", |
6630
|
|
|
$std->xPed, |
6631
|
|
|
false, |
6632
|
|
|
"Pedido" |
6633
|
|
|
); |
6634
|
|
|
$this->dom->addChild( |
6635
|
|
|
$this->compra, |
6636
|
|
|
"xCont", |
6637
|
|
|
$std->xCont, |
6638
|
|
|
false, |
6639
|
|
|
"Contrato" |
6640
|
|
|
); |
6641
|
|
|
return $this->compra; |
6642
|
|
|
} |
6643
|
|
|
|
6644
|
|
|
/** |
6645
|
|
|
* Grupo Cana ZC01 pai A01 |
6646
|
|
|
* tag NFe/infNFe/cana (opcional) |
6647
|
|
|
* @param stdClass $std |
6648
|
|
|
* @return DOMElement |
6649
|
|
|
*/ |
6650
|
|
|
public function tagcana(stdClass $std) |
6651
|
|
|
{ |
6652
|
|
|
$possible = [ |
6653
|
|
|
'safra', |
6654
|
|
|
'ref', |
6655
|
|
|
'qTotMes', |
6656
|
|
|
'qTotAnt', |
6657
|
|
|
'qTotGer', |
6658
|
|
|
'vFor', |
6659
|
|
|
'vTotDed', |
6660
|
|
|
'vLiqFor' |
6661
|
|
|
]; |
6662
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6663
|
|
|
$this->cana = $this->dom->createElement("cana"); |
6664
|
|
|
$this->dom->addChild( |
6665
|
|
|
$this->cana, |
6666
|
|
|
"safra", |
6667
|
|
|
$std->safra, |
6668
|
|
|
true, |
6669
|
|
|
"Identificação da safra" |
6670
|
|
|
); |
6671
|
|
|
$this->dom->addChild( |
6672
|
|
|
$this->cana, |
6673
|
|
|
"ref", |
6674
|
|
|
$std->ref, |
6675
|
|
|
true, |
6676
|
|
|
"Mês e ano de referência" |
6677
|
|
|
); |
6678
|
|
|
$this->dom->addChild( |
6679
|
|
|
$this->cana, |
6680
|
|
|
"qTotMes", |
6681
|
|
|
$std->qTotMes, |
6682
|
|
|
true, |
6683
|
|
|
"Quantidade Total do Mês" |
6684
|
|
|
); |
6685
|
|
|
$this->dom->addChild( |
6686
|
|
|
$this->cana, |
6687
|
|
|
"qTotAnt", |
6688
|
|
|
$std->qTotAnt, |
6689
|
|
|
true, |
6690
|
|
|
"Quantidade Total Anterior" |
6691
|
|
|
); |
6692
|
|
|
$this->dom->addChild( |
6693
|
|
|
$this->cana, |
6694
|
|
|
"qTotGer", |
6695
|
|
|
$std->qTotGer, |
6696
|
|
|
true, |
6697
|
|
|
"Quantidade Total Geral" |
6698
|
|
|
); |
6699
|
|
|
$this->dom->addChild( |
6700
|
|
|
$this->cana, |
6701
|
|
|
"vFor", |
6702
|
|
|
$this->conditionalNumberFormatting($std->vFor), |
6703
|
|
|
true, |
6704
|
|
|
"Valor dos Fornecimentos" |
6705
|
|
|
); |
6706
|
|
|
$this->dom->addChild( |
6707
|
|
|
$this->cana, |
6708
|
|
|
"vTotDed", |
6709
|
|
|
$this->conditionalNumberFormatting($std->vTotDed), |
6710
|
|
|
true, |
6711
|
|
|
"Valor Total da Dedução" |
6712
|
|
|
); |
6713
|
|
|
$this->dom->addChild( |
6714
|
|
|
$this->cana, |
6715
|
|
|
"vLiqFor", |
6716
|
|
|
$this->conditionalNumberFormatting($std->vLiqFor), |
6717
|
|
|
true, |
6718
|
|
|
"Valor Líquido dos Fornecimentos" |
6719
|
|
|
); |
6720
|
|
|
return $this->cana; |
6721
|
|
|
} |
6722
|
|
|
|
6723
|
|
|
/** |
6724
|
|
|
* Grupo Fornecimento diário de cana ZC04 pai ZC01 |
6725
|
|
|
* tag NFe/infNFe/cana/forDia |
6726
|
|
|
* @param stdClass $std |
6727
|
|
|
* @return DOMElement |
6728
|
|
|
*/ |
6729
|
|
|
public function tagforDia(stdClass $std) |
6730
|
|
|
{ |
6731
|
|
|
$forDia = $this->dom->createElement("forDia"); |
6732
|
|
|
$forDia->setAttribute("dia", $std->dia); |
6733
|
|
|
$this->dom->addChild( |
6734
|
|
|
$forDia, |
6735
|
|
|
"qtde", |
6736
|
|
|
$std->qtde, |
6737
|
|
|
true, |
6738
|
|
|
"Quantidade" |
6739
|
|
|
); |
6740
|
|
|
$qTotMes = $this->cana->getElementsByTagName('qTotMes')->item(0); |
6741
|
|
|
$this->cana->insertBefore($forDia, $qTotMes); |
6742
|
|
|
return $forDia; |
6743
|
|
|
} |
6744
|
|
|
|
6745
|
|
|
/** |
6746
|
|
|
* Grupo Deduções – Taxas e Contribuições ZC10 pai ZC01 |
6747
|
|
|
* tag NFe/infNFe/cana/deduc (opcional) |
6748
|
|
|
* @param stdClass $std |
6749
|
|
|
* @return DOMElement |
6750
|
|
|
*/ |
6751
|
|
|
public function tagdeduc(stdClass $std) |
6752
|
|
|
{ |
6753
|
|
|
$possible = ['xDed', 'vDed']; |
6754
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6755
|
|
|
$deduc = $this->dom->createElement("deduc"); |
6756
|
|
|
$this->dom->addChild( |
6757
|
|
|
$deduc, |
6758
|
|
|
"xDed", |
6759
|
|
|
$std->xDed, |
6760
|
|
|
true, |
6761
|
|
|
"Descrição da Dedução" |
6762
|
|
|
); |
6763
|
|
|
$this->dom->addChild( |
6764
|
|
|
$deduc, |
6765
|
|
|
"vDed", |
6766
|
|
|
$this->conditionalNumberFormatting($std->vDed), |
6767
|
|
|
true, |
6768
|
|
|
"Valor da Dedução" |
6769
|
|
|
); |
6770
|
|
|
$vFor = $this->cana->getElementsByTagName('vFor')->item(0); |
6771
|
|
|
$this->cana->insertBefore($deduc, $vFor); |
6772
|
|
|
return $deduc; |
6773
|
|
|
} |
6774
|
|
|
|
6775
|
|
|
/** |
6776
|
|
|
* Informações suplementares da Nota Fiscal |
6777
|
|
|
* @param stdClass $std |
6778
|
|
|
* @return DOMElement |
6779
|
|
|
*/ |
6780
|
|
|
public function taginfNFeSupl(stdClass $std) |
6781
|
|
|
{ |
6782
|
|
|
$possible = ['qrcode', 'urlChave']; |
6783
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6784
|
|
|
|
6785
|
|
|
$infNFeSupl = $this->dom->createElement("infNFeSupl"); |
6786
|
|
|
$nodeqr = $infNFeSupl->appendChild($this->dom->createElement('qrCode')); |
6787
|
|
|
$nodeqr->appendChild($this->dom->createCDATASection($std->qrcode)); |
6788
|
|
|
//incluido no layout 4.00 |
6789
|
|
|
$std->urlChave = !empty($std->urlChave) ? $std->urlChave : null; |
6790
|
|
|
$this->dom->addChild( |
6791
|
|
|
$infNFeSupl, |
6792
|
|
|
"urlChave", |
6793
|
|
|
$std->urlChave, |
6794
|
|
|
false, |
6795
|
|
|
"URL de consulta por chave de acesso a ser impressa no DANFE NFC-e" |
6796
|
|
|
); |
6797
|
|
|
$this->infNFeSupl = $infNFeSupl; |
6798
|
|
|
return $infNFeSupl; |
6799
|
|
|
} |
6800
|
|
|
|
6801
|
|
|
/** |
6802
|
|
|
* Informações do Responsável técnico ZD01 pai A01 |
6803
|
|
|
* tag NFe/infNFe/infRespTec (opcional) |
6804
|
|
|
* @param stdClass $std |
6805
|
|
|
* @return DOMElement |
6806
|
|
|
* @throws RuntimeException |
6807
|
|
|
*/ |
6808
|
|
|
public function taginfRespTec(stdClass $std) |
6809
|
|
|
{ |
6810
|
|
|
$possible = [ |
6811
|
|
|
'CNPJ', |
6812
|
|
|
'xContato', |
6813
|
|
|
'email', |
6814
|
|
|
'fone', |
6815
|
|
|
'CSRT', |
6816
|
|
|
'idCSRT' |
6817
|
|
|
]; |
6818
|
|
|
|
6819
|
|
|
$std = $this->equilizeParameters($std, $possible); |
6820
|
|
|
$infRespTec = $this->dom->createElement("infRespTec"); |
6821
|
|
|
$this->dom->addChild( |
6822
|
|
|
$infRespTec, |
6823
|
|
|
"CNPJ", |
6824
|
|
|
$std->CNPJ, |
6825
|
|
|
true, |
6826
|
|
|
"Informar o CNPJ da pessoa jurídica responsável pelo sistema " |
6827
|
|
|
. "utilizado na emissão do documento fiscal eletrônico" |
6828
|
|
|
); |
6829
|
|
|
$this->dom->addChild( |
6830
|
|
|
$infRespTec, |
6831
|
|
|
"xContato", |
6832
|
|
|
$std->xContato, |
6833
|
|
|
true, |
6834
|
|
|
"Informar o nome da pessoa a ser contatada na empresa desenvolvedora " |
6835
|
|
|
. "do sistema utilizado na emissão do documento fiscal eletrônico" |
6836
|
|
|
); |
6837
|
|
|
$this->dom->addChild( |
6838
|
|
|
$infRespTec, |
6839
|
|
|
"email", |
6840
|
|
|
$std->email, |
6841
|
|
|
true, |
6842
|
|
|
"Informar o e-mail da pessoa a ser contatada na empresa " |
6843
|
|
|
. "desenvolvedora do sistema." |
6844
|
|
|
); |
6845
|
|
|
$this->dom->addChild( |
6846
|
|
|
$infRespTec, |
6847
|
|
|
"fone", |
6848
|
|
|
$std->fone, |
6849
|
|
|
true, |
6850
|
|
|
"Informar o telefone da pessoa a ser contatada na empresa " |
6851
|
|
|
. "desenvolvedora do sistema." |
6852
|
|
|
); |
6853
|
|
|
if (!empty($std->CSRT) && !empty($std->idCSRT)) { |
6854
|
|
|
$this->csrt = $std->CSRT; |
6855
|
|
|
$this->dom->addChild( |
6856
|
|
|
$infRespTec, |
6857
|
|
|
"idCSRT", |
6858
|
|
|
$std->idCSRT, |
6859
|
|
|
true, |
6860
|
|
|
"Identificador do CSRT utilizado para montar o hash do CSRT" |
6861
|
|
|
); |
6862
|
|
|
$this->dom->addChild( |
6863
|
|
|
$infRespTec, |
6864
|
|
|
"hashCSRT", |
6865
|
|
|
$this->hashCSRT($std->CSRT), |
6866
|
|
|
true, |
6867
|
|
|
"hash do CSRT" |
6868
|
|
|
); |
6869
|
|
|
} |
6870
|
|
|
$this->infRespTec = $infRespTec; |
6871
|
|
|
return $infRespTec; |
6872
|
|
|
} |
6873
|
|
|
|
6874
|
|
|
/** |
6875
|
|
|
* Tag raiz da NFe |
6876
|
|
|
* tag NFe DOMNode |
6877
|
|
|
* Função chamada pelo método [ monta ] |
6878
|
|
|
* |
6879
|
|
|
* @return DOMElement |
6880
|
|
|
*/ |
6881
|
|
|
protected function buildNFe() |
6882
|
|
|
{ |
6883
|
|
|
if (empty($this->NFe)) { |
6884
|
|
|
$this->NFe = $this->dom->createElement("NFe"); |
6885
|
|
|
$this->NFe->setAttribute("xmlns", "http://www.portalfiscal.inf.br/nfe"); |
6886
|
|
|
} |
6887
|
|
|
return $this->NFe; |
6888
|
|
|
} |
6889
|
|
|
|
6890
|
|
|
/** |
6891
|
|
|
* Informação de Documentos Fiscais referenciados BA01 pai B01 |
6892
|
|
|
* tag NFe/infNFe/ide/NFref |
6893
|
|
|
* Podem ser criados até 500 desses Nodes por NFe |
6894
|
|
|
* Função chamada pelos métodos |
6895
|
|
|
* [tagrefNFe] [tagrefNF] [tagrefNFP] [tagCTeref] [tagrefECF] |
6896
|
|
|
*/ |
6897
|
|
|
protected function buildNFref() |
6898
|
|
|
{ |
6899
|
|
|
$this->aNFref[] = $this->dom->createElement("NFref"); |
6900
|
|
|
return count($this->aNFref); |
6901
|
|
|
} |
6902
|
|
|
|
6903
|
|
|
/** |
6904
|
|
|
* Insere dentro dentro das tags imposto o ICMS IPI II PIS COFINS ISSQN |
6905
|
|
|
* tag NFe/infNFe/det[]/imposto |
6906
|
|
|
* @return void |
6907
|
|
|
*/ |
6908
|
|
|
protected function buildImp() |
6909
|
|
|
{ |
6910
|
|
|
foreach ($this->aImposto as $nItem => $imposto) { |
6911
|
|
|
if (!empty($this->aICMS[$nItem])) { |
6912
|
|
|
$this->dom->appChild($imposto, $this->aICMS[$nItem], "Inclusão do node ICMS"); |
6913
|
|
|
} |
6914
|
|
|
if (!empty($this->aIPI[$nItem])) { |
6915
|
|
|
$this->dom->appChild($imposto, $this->aIPI[$nItem], "Inclusão do node IPI"); |
6916
|
|
|
} |
6917
|
|
|
if (!empty($this->aII[$nItem])) { |
6918
|
|
|
$this->dom->appChild($imposto, $this->aII[$nItem], "Inclusão do node II"); |
6919
|
|
|
} |
6920
|
|
|
if (!empty($this->aISSQN[$nItem])) { |
6921
|
|
|
$this->dom->appChild($imposto, $this->aISSQN[$nItem], "Inclusão do node ISSQN"); |
6922
|
|
|
} |
6923
|
|
|
if (!empty($this->aPIS[$nItem])) { |
6924
|
|
|
$this->dom->appChild($imposto, $this->aPIS[$nItem], "Inclusão do node PIS"); |
6925
|
|
|
} |
6926
|
|
|
if (!empty($this->aPISST[$nItem])) { |
6927
|
|
|
$this->dom->appChild($imposto, $this->aPISST[$nItem], "Inclusão do node PISST"); |
6928
|
|
|
} |
6929
|
|
|
if (!empty($this->aCOFINS[$nItem])) { |
6930
|
|
|
$this->dom->appChild($imposto, $this->aCOFINS[$nItem], "Inclusão do node COFINS"); |
6931
|
|
|
} |
6932
|
|
|
if (!empty($this->aCOFINSST[$nItem])) { |
6933
|
|
|
$this->dom->appChild($imposto, $this->aCOFINSST[$nItem], "Inclusão do node COFINSST"); |
6934
|
|
|
} |
6935
|
|
|
if (!empty($this->aICMSUFDest[$nItem])) { |
6936
|
|
|
$this->dom->appChild($imposto, $this->aICMSUFDest[$nItem], "Inclusão do node ICMSUFDest"); |
6937
|
|
|
} |
6938
|
|
|
$this->aImposto[$nItem] = $imposto; |
6939
|
|
|
} |
6940
|
|
|
} |
6941
|
|
|
|
6942
|
|
|
/** |
6943
|
|
|
* Grupo COFINS tributado pela alíquota S02 pai S01 |
6944
|
|
|
* tag det/imposto/COFINS/COFINSAliq (opcional) |
6945
|
|
|
* Função chamada pelo método [ tagCOFINS ] |
6946
|
|
|
* @param stdClass $std |
6947
|
|
|
* @return DOMElement |
6948
|
|
|
*/ |
6949
|
|
|
protected function buildCOFINSAliq($std) |
6950
|
|
|
{ |
6951
|
|
|
$confinsAliq = $this->dom->createElement('COFINSAliq'); |
6952
|
|
|
$this->dom->addChild( |
6953
|
|
|
$confinsAliq, |
6954
|
|
|
'CST', |
6955
|
|
|
$std->CST, |
6956
|
|
|
true, |
6957
|
|
|
"Código de Situação Tributária da COFINS" |
6958
|
|
|
); |
6959
|
|
|
$this->dom->addChild( |
6960
|
|
|
$confinsAliq, |
6961
|
|
|
'vBC', |
6962
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
6963
|
|
|
true, |
6964
|
|
|
"Valor da Base de Cálculo da COFINS" |
6965
|
|
|
); |
6966
|
|
|
$this->dom->addChild( |
6967
|
|
|
$confinsAliq, |
6968
|
|
|
'pCOFINS', |
6969
|
|
|
$this->conditionalNumberFormatting($std->pCOFINS, 4), |
6970
|
|
|
true, |
6971
|
|
|
"Alíquota da COFINS (em percentual)" |
6972
|
|
|
); |
6973
|
|
|
$this->dom->addChild( |
6974
|
|
|
$confinsAliq, |
6975
|
|
|
'vCOFINS', |
6976
|
|
|
$this->conditionalNumberFormatting($std->vCOFINS), |
6977
|
|
|
true, |
6978
|
|
|
"Valor da COFINS" |
6979
|
|
|
); |
6980
|
|
|
return $confinsAliq; |
6981
|
|
|
} |
6982
|
|
|
|
6983
|
|
|
/** |
6984
|
|
|
* Grupo COFINS não tributado S04 pai S01 |
6985
|
|
|
* tag NFe/infNFe/det[]/imposto/COFINS/COFINSNT (opcional) |
6986
|
|
|
* Função chamada pelo método [ tagCOFINS ] |
6987
|
|
|
* @param stdClass $std |
6988
|
|
|
* @return DOMElement |
6989
|
|
|
*/ |
6990
|
|
|
protected function buildCOFINSNT(stdClass $std) |
6991
|
|
|
{ |
6992
|
|
|
$confinsnt = $this->dom->createElement('COFINSNT'); |
6993
|
|
|
$this->dom->addChild( |
6994
|
|
|
$confinsnt, |
6995
|
|
|
"CST", |
6996
|
|
|
$std->CST, |
6997
|
|
|
true, |
6998
|
|
|
"Código de Situação Tributária da COFINS" |
6999
|
|
|
); |
7000
|
|
|
return $confinsnt; |
7001
|
|
|
} |
7002
|
|
|
|
7003
|
|
|
/** |
7004
|
|
|
* Grupo COFINS Outras Operações S05 pai S01 |
7005
|
|
|
* tag NFe/infNFe/det[]/imposto/COFINS/COFINSoutr (opcional) |
7006
|
|
|
* Função chamada pelo método [ tagCOFINS ] |
7007
|
|
|
* @param stdClass $std |
7008
|
|
|
* @return DOMElement |
7009
|
|
|
*/ |
7010
|
|
|
protected function buildCOFINSoutr(stdClass $std) |
7011
|
|
|
{ |
7012
|
|
|
$confinsoutr = $this->dom->createElement('COFINSOutr'); |
7013
|
|
|
$this->dom->addChild( |
7014
|
|
|
$confinsoutr, |
7015
|
|
|
"CST", |
7016
|
|
|
$std->CST, |
7017
|
|
|
true, |
7018
|
|
|
"Código de Situação Tributária da COFINS" |
7019
|
|
|
); |
7020
|
|
|
$this->dom->addChild( |
7021
|
|
|
$confinsoutr, |
7022
|
|
|
"vBC", |
7023
|
|
|
$this->conditionalNumberFormatting($std->vBC), |
7024
|
|
|
($std->vBC !== null) ? true : false, |
7025
|
|
|
"Valor da Base de Cálculo da COFINS" |
7026
|
|
|
); |
7027
|
|
|
$this->dom->addChild( |
7028
|
|
|
$confinsoutr, |
7029
|
|
|
"pCOFINS", |
7030
|
|
|
$this->conditionalNumberFormatting($std->pCOFINS, 4), |
7031
|
|
|
($std->pCOFINS !== null) ? true : false, |
7032
|
|
|
"Alíquota da COFINS (em percentual)" |
7033
|
|
|
); |
7034
|
|
|
$this->dom->addChild( |
7035
|
|
|
$confinsoutr, |
7036
|
|
|
"qBCProd", |
7037
|
|
|
$std->qBCProd, |
7038
|
|
|
($std->qBCProd !== null) ? true : false, |
7039
|
|
|
"Quantidade Vendida" |
7040
|
|
|
); |
7041
|
|
|
$this->dom->addChild( |
7042
|
|
|
$confinsoutr, |
7043
|
|
|
"vAliqProd", |
7044
|
|
|
$std->vAliqProd, |
7045
|
|
|
($std->vAliqProd !== null) ? true : false, |
7046
|
|
|
"Alíquota da COFINS (em reais)" |
7047
|
|
|
); |
7048
|
|
|
$this->dom->addChild( |
7049
|
|
|
$confinsoutr, |
7050
|
|
|
"vCOFINS", |
7051
|
|
|
$this->conditionalNumberFormatting($std->vCOFINS), |
7052
|
|
|
true, |
7053
|
|
|
"Valor da COFINS" |
7054
|
|
|
); |
7055
|
|
|
return $confinsoutr; |
7056
|
|
|
} |
7057
|
|
|
|
7058
|
|
|
/** |
7059
|
|
|
* Insere dentro da tag det os produtos |
7060
|
|
|
* tag NFe/infNFe/det[] |
7061
|
|
|
* @return array|string |
7062
|
|
|
*/ |
7063
|
|
|
protected function buildDet() |
7064
|
|
|
{ |
7065
|
|
|
if (empty($this->aProd)) { |
7066
|
|
|
return ''; |
7067
|
|
|
} |
7068
|
|
|
//insere NVE |
7069
|
|
|
foreach ($this->aNVE as $nItem => $nve) { |
7070
|
|
|
$prod = $this->aProd[$nItem]; |
7071
|
|
|
foreach ($nve as $child) { |
7072
|
|
|
$node = $prod->getElementsByTagName("cBenef")->item(0); |
7073
|
|
|
if (empty($node)) { |
7074
|
|
|
$node = $prod->getElementsByTagName("EXTIPI")->item(0); |
7075
|
|
|
if (empty($node)) { |
7076
|
|
|
$node = $prod->getElementsByTagName("CFOP")->item(0); |
7077
|
|
|
} |
7078
|
|
|
} |
7079
|
|
|
$prod->insertBefore($child, $node); |
7080
|
|
|
} |
7081
|
|
|
} |
7082
|
|
|
//insere CEST |
7083
|
|
|
foreach ($this->aCest as $nItem => $cest) { |
7084
|
|
|
$prod = $this->aProd[$nItem]; |
7085
|
|
|
/** @var \DOMElement $child */ |
7086
|
|
|
foreach ($cest as $child) { |
7087
|
|
|
$node = $prod->getElementsByTagName("cBenef")->item(0); |
7088
|
|
|
if (empty($node)) { |
7089
|
|
|
$node = $prod->getElementsByTagName("EXTIPI")->item(0); |
7090
|
|
|
if (empty($node)) { |
7091
|
|
|
$node = $prod->getElementsByTagName("CFOP")->item(0); |
7092
|
|
|
} |
7093
|
|
|
} |
7094
|
|
|
$cchild = $child->getElementsByTagName("CEST")->item(0); |
7095
|
|
|
$prod->insertBefore($cchild, $node); |
7096
|
|
|
$cchild = $child->getElementsByTagName("indEscala")->item(0); |
7097
|
|
|
if (!empty($cchild)) { |
7098
|
|
|
$prod->insertBefore($cchild, $node); |
7099
|
|
|
} |
7100
|
|
|
$cchild = $child->getElementsByTagName("CNPJFab")->item(0); |
7101
|
|
|
if (!empty($cchild)) { |
7102
|
|
|
$prod->insertBefore($cchild, $node); |
7103
|
|
|
$this->aProd[$nItem] = $prod; |
7104
|
|
|
} |
7105
|
|
|
} |
7106
|
|
|
} |
7107
|
|
|
//insere DI |
7108
|
|
|
foreach ($this->aDI as $nItem => $aDI) { |
7109
|
|
|
$prod = $this->aProd[$nItem]; |
7110
|
|
|
foreach ($aDI as $child) { |
7111
|
|
|
$node = $prod->getElementsByTagName("xPed")->item(0); |
7112
|
|
|
if (!empty($node)) { |
7113
|
|
|
$prod->insertBefore($child, $node); |
7114
|
|
|
} else { |
7115
|
|
|
$node = $prod->getElementsByTagName("FCI")->item(0); |
7116
|
|
|
if (!empty($node)) { |
7117
|
|
|
$prod->insertBefore($child, $node); |
7118
|
|
|
} else { |
7119
|
|
|
$this->dom->appChild($prod, $child, "Inclusão do node DI"); |
7120
|
|
|
} |
7121
|
|
|
} |
7122
|
|
|
} |
7123
|
|
|
$this->aProd[$nItem] = $prod; |
7124
|
|
|
} |
7125
|
|
|
//insere detExport |
7126
|
|
|
foreach ($this->aDetExport as $nItem => $detexport) { |
7127
|
|
|
$prod = $this->aProd[$nItem]; |
7128
|
|
|
foreach ($detexport as $child) { |
7129
|
|
|
$node = $prod->getElementsByTagName("xPed")->item(0); |
7130
|
|
|
if (!empty($node)) { |
7131
|
|
|
$prod->insertBefore($child, $node); |
7132
|
|
|
} else { |
7133
|
|
|
$this->dom->appChild($prod, $child, "Inclusão do node DetExport"); |
7134
|
|
|
} |
7135
|
|
|
} |
7136
|
|
|
$this->aProd[$nItem] = $prod; |
7137
|
|
|
} |
7138
|
|
|
//insere Rastro |
7139
|
|
|
foreach ($this->aRastro as $nItem => $child) { |
7140
|
|
|
$prod = $this->aProd[$nItem]; |
7141
|
|
|
foreach ($child as $rastro) { |
7142
|
|
|
$this->dom->appChild($prod, $rastro, "Inclusão do node Rastro"); |
7143
|
|
|
} |
7144
|
|
|
$this->aProd[$nItem] = $prod; |
7145
|
|
|
} |
7146
|
|
|
//insere veiculo |
7147
|
|
|
foreach ($this->aVeicProd as $nItem => $child) { |
7148
|
|
|
$prod = $this->aProd[$nItem]; |
7149
|
|
|
$this->dom->appChild($prod, $child, "Inclusão do node veiculo"); |
7150
|
|
|
$this->aProd[$nItem] = $prod; |
7151
|
|
|
} |
7152
|
|
|
//insere medicamentos |
7153
|
|
|
foreach ($this->aMed as $nItem => $child) { |
7154
|
|
|
$prod = $this->aProd[$nItem]; |
7155
|
|
|
$this->dom->appChild($prod, $child, "Inclusão do node medicamento"); |
7156
|
|
|
$this->aProd[$nItem] = $prod; |
7157
|
|
|
} |
7158
|
|
|
//insere armas |
7159
|
|
|
foreach ($this->aArma as $nItem => $arma) { |
7160
|
|
|
$prod = $this->aProd[$nItem]; |
7161
|
|
|
foreach ($arma as $child) { |
7162
|
|
|
$node = $prod->getElementsByTagName("imposto")->item(0); |
7163
|
|
|
if (!empty($node)) { |
7164
|
|
|
$prod->insertBefore($child, $node); |
7165
|
|
|
} else { |
7166
|
|
|
$this->dom->appChild($prod, $child, "Inclusão do node arma"); |
7167
|
|
|
} |
7168
|
|
|
} |
7169
|
|
|
$this->aProd[$nItem] = $prod; |
7170
|
|
|
} |
7171
|
|
|
//insere combustivel |
7172
|
|
|
foreach ($this->aComb as $nItem => $child) { |
7173
|
|
|
$prod = $this->aProd[$nItem]; |
7174
|
|
|
if (!empty($this->aEncerrante)) { |
7175
|
|
|
$encerrante = $this->aEncerrante[$nItem]; |
7176
|
|
|
if (!empty($encerrante)) { |
7177
|
|
|
$this->dom->appChild($child, $encerrante, "inclusão do node encerrante na tag comb"); |
7178
|
|
|
} |
7179
|
|
|
} |
7180
|
|
|
$this->dom->appChild($prod, $child, "Inclusão do node combustivel"); |
7181
|
|
|
$this->aProd[$nItem] = $prod; |
7182
|
|
|
} |
7183
|
|
|
//insere RECOPI |
7184
|
|
|
foreach ($this->aRECOPI as $nItem => $child) { |
7185
|
|
|
$prod = $this->aProd[$nItem]; |
7186
|
|
|
$this->dom->appChild($prod, $child, "Inclusão do node RECOPI"); |
7187
|
|
|
$this->aProd[$nItem] = $prod; |
7188
|
|
|
} |
7189
|
|
|
//montagem da tag imposto[] |
7190
|
|
|
$this->buildImp(); |
7191
|
|
|
//montagem da tag det[] |
7192
|
|
|
foreach ($this->aProd as $nItem => $prod) { |
7193
|
|
|
$det = $this->dom->createElement("det"); |
7194
|
|
|
$det->setAttribute("nItem", $nItem); |
7195
|
|
|
$det->appendChild($prod); |
7196
|
|
|
//insere imposto |
7197
|
|
|
if (!empty($this->aImposto[$nItem])) { |
7198
|
|
|
$child = $this->aImposto[$nItem]; |
7199
|
|
|
$this->dom->appChild($det, $child, "Inclusão do node imposto"); |
7200
|
|
|
} |
7201
|
|
|
//insere impostoDevol |
7202
|
|
|
if (!empty($this->aImpostoDevol)) { |
7203
|
|
|
$child = $this->aImpostoDevol[$nItem]; |
7204
|
|
|
$this->dom->appChild($det, $child, "Inclusão do node impostoDevol"); |
7205
|
|
|
} |
7206
|
|
|
//insere infAdProd |
7207
|
|
|
if (!empty($this->aInfAdProd[$nItem])) { |
7208
|
|
|
$child = $this->aInfAdProd[$nItem]; |
7209
|
|
|
$this->dom->appChild($det, $child, "Inclusão do node infAdProd"); |
7210
|
|
|
} |
7211
|
|
|
$this->aDet[] = $det; |
7212
|
|
|
$det = null; |
|
|
|
|
7213
|
|
|
} |
7214
|
|
|
return $this->aProd; |
7215
|
|
|
} |
7216
|
|
|
|
7217
|
|
|
/** |
7218
|
|
|
* Insere a tag pag, os detalhamentos dos pagamentos e cartoes |
7219
|
|
|
* NOTA: Ajustado para NT2016_002_v1.30 |
7220
|
|
|
* tag NFe/infNFe/pag/ |
7221
|
|
|
* tag NFe/infNFe/pag/detPag[] |
7222
|
|
|
* tag NFe/infNFe/pag/detPag[]/Card |
7223
|
|
|
*/ |
7224
|
|
|
protected function buildTagPag() |
7225
|
|
|
{ |
7226
|
|
|
$this->dom->appChild($this->infNFe, $this->pag, 'Falta tag "infNFe"'); |
7227
|
|
|
} |
7228
|
|
|
|
7229
|
|
|
/** |
7230
|
|
|
* Grupo Totais da NF-e W01 pai A01 |
7231
|
|
|
* tag NFe/infNFe/total |
7232
|
|
|
*/ |
7233
|
|
|
protected function buildTotal() |
7234
|
|
|
{ |
7235
|
|
|
if (empty($this->total)) { |
7236
|
|
|
$this->total = $this->dom->createElement("total"); |
7237
|
|
|
} |
7238
|
|
|
|
7239
|
|
|
$this->stdTot->vNF = $this->stdTot->vProd |
7240
|
|
|
- $this->stdTot->vDesc |
7241
|
|
|
+ $this->stdTot->vST |
7242
|
|
|
+ $this->stdTot->vFrete |
7243
|
|
|
+ $this->stdTot->vSeg |
7244
|
|
|
+ $this->stdTot->vOutro |
7245
|
|
|
+ $this->stdTot->vII |
7246
|
|
|
+ $this->stdTot->vIPI |
7247
|
|
|
+ $this->stdTot->vIPIDevol; |
7248
|
|
|
//round all values |
7249
|
|
|
$this->stdTot->vBC = round($this->stdTot->vBC, 2); |
7250
|
|
|
$this->stdTot->vICMS = round($this->stdTot->vICMS, 2); |
7251
|
|
|
$this->stdTot->vICMSDeson = round($this->stdTot->vICMSDeson, 2); |
7252
|
|
|
$this->stdTot->vFCP = round($this->stdTot->vFCP, 2); |
7253
|
|
|
$this->stdTot->vFCPUFDest = round($this->stdTot->vFCPUFDest, 2); |
7254
|
|
|
$this->stdTot->vICMSUFDest = round($this->stdTot->vICMSUFDest, 2); |
7255
|
|
|
$this->stdTot->vICMSUFRemet = round($this->stdTot->vICMSUFRemet, 2); |
7256
|
|
|
$this->stdTot->vBCST = round($this->stdTot->vBCST, 2); |
7257
|
|
|
$this->stdTot->vST = round($this->stdTot->vST, 2); |
7258
|
|
|
$this->stdTot->vFCPST = round($this->stdTot->vFCPST, 2); |
7259
|
|
|
$this->stdTot->vFCPSTRet = round($this->stdTot->vFCPSTRet, 2); |
7260
|
|
|
$this->stdTot->vProd = round($this->stdTot->vProd, 2); |
7261
|
|
|
$this->stdTot->vFrete = round($this->stdTot->vFrete, 2); |
7262
|
|
|
$this->stdTot->vSeg = round($this->stdTot->vSeg, 2); |
7263
|
|
|
$this->stdTot->vDesc = round($this->stdTot->vDesc, 2); |
7264
|
|
|
$this->stdTot->vII = round($this->stdTot->vII, 2); |
7265
|
|
|
$this->stdTot->vIPI = round($this->stdTot->vIPI, 2); |
7266
|
|
|
$this->stdTot->vIPIDevol = round($this->stdTot->vIPIDevol, 2); |
7267
|
|
|
$this->stdTot->vPIS = round($this->stdTot->vPIS, 2); |
7268
|
|
|
$this->stdTot->vCOFINS = round($this->stdTot->vCOFINS, 2); |
7269
|
|
|
$this->stdTot->vOutro = round($this->stdTot->vOutro, 2); |
7270
|
|
|
$this->stdTot->vNF = round($this->stdTot->vNF, 2); |
7271
|
|
|
$this->stdTot->vTotTrib = round($this->stdTot->vTotTrib, 2); |
7272
|
|
|
} |
7273
|
|
|
|
7274
|
|
|
/** |
7275
|
|
|
* Grupo Cobrança Y01 pai A01 |
7276
|
|
|
* tag NFe/infNFe/cobr (opcional) |
7277
|
|
|
* Depende de fat |
7278
|
|
|
*/ |
7279
|
|
|
protected function buildCobr() |
7280
|
|
|
{ |
7281
|
|
|
if (empty($this->cobr)) { |
7282
|
|
|
$this->cobr = $this->dom->createElement("cobr"); |
7283
|
|
|
} |
7284
|
|
|
} |
7285
|
|
|
|
7286
|
|
|
/** |
7287
|
|
|
* Grupo de Informações Adicionais Z01 pai A01 |
7288
|
|
|
* tag NFe/infNFe/infAdic (opcional) |
7289
|
|
|
* Função chamada pelos metodos |
7290
|
|
|
* [taginfAdic] [tagobsCont] [tagobsFisco] [tagprocRef] |
7291
|
|
|
* @return DOMElement |
7292
|
|
|
*/ |
7293
|
|
|
protected function buildInfAdic() |
7294
|
|
|
{ |
7295
|
|
|
if (empty($this->infAdic)) { |
7296
|
|
|
$this->infAdic = $this->dom->createElement("infAdic"); |
7297
|
|
|
} |
7298
|
|
|
return $this->infAdic; |
7299
|
|
|
} |
7300
|
|
|
|
7301
|
|
|
/** |
7302
|
|
|
* Remonta a chave da NFe de 44 digitos com base em seus dados |
7303
|
|
|
* já contidos na NFE. |
7304
|
|
|
* Isso é útil no caso da chave informada estar errada |
7305
|
|
|
* se a chave estiver errada a mesma é substituida |
7306
|
|
|
* @param Dom $dom |
7307
|
|
|
* @return void |
7308
|
|
|
*/ |
7309
|
|
|
protected function checkNFeKey(Dom $dom) |
7310
|
|
|
{ |
7311
|
|
|
$infNFe = $dom->getElementsByTagName("infNFe")->item(0); |
7312
|
|
|
$ide = $dom->getElementsByTagName("ide")->item(0); |
7313
|
|
|
$emit = $dom->getElementsByTagName("emit")->item(0); |
7314
|
|
|
$cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue; |
7315
|
|
|
$dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue; |
7316
|
|
|
if (!empty($emit->getElementsByTagName('CNPJ')->item(0)->nodeValue)) { |
7317
|
|
|
$doc = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
7318
|
|
|
} else { |
7319
|
|
|
$doc = $emit->getElementsByTagName('CPF')->item(0)->nodeValue; |
7320
|
|
|
} |
7321
|
|
|
$mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue; |
7322
|
|
|
$serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue; |
7323
|
|
|
$nNF = $ide->getElementsByTagName('nNF')->item(0)->nodeValue; |
7324
|
|
|
$tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue; |
7325
|
|
|
$cNF = $ide->getElementsByTagName('cNF')->item(0)->nodeValue; |
7326
|
|
|
$chave = str_replace('NFe', '', $infNFe->getAttribute("Id")); |
7327
|
|
|
$dt = new DateTime($dhEmi); |
7328
|
|
|
$infRespTec = $dom->getElementsByTagName("infRespTec")->item(0); |
7329
|
|
|
$chaveMontada = Keys::build( |
7330
|
|
|
$cUF, |
7331
|
|
|
$dt->format('y'), |
7332
|
|
|
$dt->format('m'), |
7333
|
|
|
$doc, |
7334
|
|
|
$mod, |
7335
|
|
|
$serie, |
7336
|
|
|
$nNF, |
7337
|
|
|
$tpEmis, |
7338
|
|
|
$cNF |
7339
|
|
|
); |
7340
|
|
|
if (empty($chave)) { |
7341
|
|
|
//chave não foi passada por parâmetro então colocar a chavemontada |
7342
|
|
|
$infNFe->setAttribute('Id', "NFe$chaveMontada"); |
7343
|
|
|
$chave = $chaveMontada; |
7344
|
|
|
$this->chNFe = $chaveMontada; |
7345
|
|
|
//trocar também o hash se o CSRT for passado |
7346
|
|
|
if (!empty($this->csrt)) { |
7347
|
|
|
$hashCSRT = $this->hashCSRT($this->csrt); |
7348
|
|
|
$infRespTec->getElementsByTagName("hashCSRT") |
7349
|
|
|
->item(0)->nodeValue = $hashCSRT; |
7350
|
|
|
} |
7351
|
|
|
} |
7352
|
|
|
//caso a chave contida na NFe esteja errada |
7353
|
|
|
//substituir a chave |
7354
|
|
|
if ($chaveMontada != $chave) { |
7355
|
|
|
$this->chNFe = $chaveMontada; |
7356
|
|
|
$this->errors[] = "A chave informada está incorreta [$chave] => [correto: $chaveMontada]."; |
7357
|
|
|
} |
7358
|
|
|
} |
7359
|
|
|
|
7360
|
|
|
/** |
7361
|
|
|
* Retorna os erros detectados |
7362
|
|
|
* @return array |
7363
|
|
|
*/ |
7364
|
|
|
public function getErrors() |
7365
|
|
|
{ |
7366
|
|
|
return $this->errors; |
7367
|
|
|
} |
7368
|
|
|
|
7369
|
|
|
/** |
7370
|
|
|
* Includes missing or unsupported properties in stdClass |
7371
|
|
|
* Replace all unsuported chars |
7372
|
|
|
* @param stdClass $std |
7373
|
|
|
* @param array $possible |
7374
|
|
|
* @return stdClass |
7375
|
|
|
*/ |
7376
|
7 |
|
protected function equilizeParameters(stdClass $std, $possible) |
7377
|
|
|
{ |
7378
|
7 |
|
$arr = get_object_vars($std); |
7379
|
7 |
|
foreach ($possible as $key) { |
7380
|
7 |
|
if (!array_key_exists($key, $arr)) { |
7381
|
6 |
|
$std->$key = null; |
7382
|
|
|
} else { |
7383
|
7 |
|
if (is_string($std->$key)) { |
7384
|
7 |
|
$std->$key = trim(Strings::replaceUnacceptableCharacters($std->$key)); |
7385
|
7 |
|
if ($this->replaceAccentedChars) { |
7386
|
7 |
|
$std->$key = Strings::toASCII($std->$key); |
7387
|
|
|
} |
7388
|
|
|
} |
7389
|
|
|
} |
7390
|
|
|
} |
7391
|
7 |
|
return $std; |
7392
|
|
|
} |
7393
|
|
|
|
7394
|
|
|
/** |
7395
|
|
|
* Calcula hash sha1 retornando Base64Binary |
7396
|
|
|
* @param string $CSRT |
7397
|
|
|
* @return string |
7398
|
|
|
*/ |
7399
|
|
|
protected function hashCSRT($CSRT) |
7400
|
|
|
{ |
7401
|
|
|
$comb = $CSRT . $this->chNFe; |
7402
|
|
|
return base64_encode(sha1($comb, true)); |
7403
|
|
|
} |
7404
|
|
|
|
7405
|
|
|
protected function conditionalNumberFormatting($value = null, $decimal = 2) |
7406
|
|
|
{ |
7407
|
|
|
if (is_numeric($value)) { |
7408
|
|
|
return number_format($value, $decimal, '.', ''); |
7409
|
|
|
} |
7410
|
|
|
return null; |
7411
|
|
|
} |
7412
|
|
|
} |
7413
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.