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