Complex classes like Make often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Make, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
29 | class Make |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | public $errors = []; |
||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | public $chNFe; |
||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | public $xml; |
||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $version; |
||
48 | /** |
||
49 | * @var integer |
||
50 | */ |
||
51 | protected $mod = 55; |
||
52 | /** |
||
53 | * @var \NFePHP\Common\DOMImproved |
||
54 | */ |
||
55 | public $dom; |
||
56 | /** |
||
57 | * @var integer |
||
58 | */ |
||
59 | protected $tpAmb = 2; |
||
60 | /** |
||
61 | * @var DOMElement |
||
62 | */ |
||
63 | protected $NFe; |
||
64 | /** |
||
65 | * @var DOMElement |
||
66 | */ |
||
67 | protected $infNFe; |
||
68 | /** |
||
69 | * @var DOMElement |
||
70 | */ |
||
71 | protected $ide; |
||
72 | /** |
||
73 | * @var DOMElement |
||
74 | */ |
||
75 | protected $emit; |
||
76 | /** |
||
77 | * @var DOMElement |
||
78 | */ |
||
79 | protected $enderEmit; |
||
80 | /** |
||
81 | * @var DOMElement |
||
82 | */ |
||
83 | protected $dest; |
||
84 | /** |
||
85 | * @var DOMElement |
||
86 | */ |
||
87 | protected $enderDest; |
||
88 | /** |
||
89 | * @var DOMElement |
||
90 | */ |
||
91 | protected $retirada; |
||
92 | /** |
||
93 | * @var DOMElement |
||
94 | */ |
||
95 | protected $entrega; |
||
96 | /** |
||
97 | * @var DOMElement |
||
98 | */ |
||
99 | protected $total; |
||
100 | /** |
||
101 | * @var DOMElement |
||
102 | */ |
||
103 | protected $cobr; |
||
104 | /** |
||
105 | * @var DOMElement |
||
106 | */ |
||
107 | protected $transp; |
||
108 | /** |
||
109 | * @var DOMElement |
||
110 | */ |
||
111 | protected $infAdic; |
||
112 | /** |
||
113 | * @var DOMElement |
||
114 | */ |
||
115 | protected $exporta; |
||
116 | /** |
||
117 | * @var DOMElement |
||
118 | */ |
||
119 | protected $compra; |
||
120 | /** |
||
121 | * @var DOMElement |
||
122 | */ |
||
123 | protected $cana; |
||
124 | /** |
||
125 | * @var DOMElement |
||
126 | */ |
||
127 | protected $infNFeSupl; |
||
128 | /** |
||
129 | * @var array of DOMElements |
||
130 | */ |
||
131 | protected $aNFref = []; |
||
132 | /** |
||
133 | * @var array of DOMElements |
||
134 | */ |
||
135 | protected $aDup = []; |
||
136 | /** |
||
137 | * @var DOMElement |
||
138 | */ |
||
139 | protected $pag; |
||
140 | /** |
||
141 | * @var array of DOMElements |
||
142 | */ |
||
143 | protected $aDetPag = []; |
||
144 | /** |
||
145 | * @var DOMElement |
||
146 | */ |
||
147 | protected $intermed; |
||
148 | /** |
||
149 | * @var array of DOMElements |
||
150 | */ |
||
151 | protected $aReboque = []; |
||
152 | /** |
||
153 | * @var array of DOMElements |
||
154 | */ |
||
155 | protected $aVol = []; |
||
156 | /** |
||
157 | * @var array of DOMElements |
||
158 | */ |
||
159 | protected $aAutXML = []; |
||
160 | /** |
||
161 | * @var array of DOMElements |
||
162 | */ |
||
163 | protected $aDet = []; |
||
164 | /** |
||
165 | * @var array of DOMElements |
||
166 | */ |
||
167 | protected $aProd = []; |
||
168 | /** |
||
169 | * @var array of DOMElements |
||
170 | */ |
||
171 | protected $aRastro = []; |
||
172 | /** |
||
173 | * @var array of DOMElements |
||
174 | */ |
||
175 | protected $aNVE = []; |
||
176 | /** |
||
177 | * @var array of DOMElements |
||
178 | */ |
||
179 | protected $aCest = []; |
||
180 | /** |
||
181 | * @var array of DOMElements |
||
182 | */ |
||
183 | protected $aRECOPI = []; |
||
184 | /** |
||
185 | * @var array of DOMElements |
||
186 | */ |
||
187 | protected $aDetExport = []; |
||
188 | /** |
||
189 | * @var array of DOMElements |
||
190 | */ |
||
191 | protected $aDI = []; |
||
192 | /** |
||
193 | * @var array of DOMElements |
||
194 | */ |
||
195 | protected $aAdi = []; |
||
196 | /** |
||
197 | * @var array of DOMElements |
||
198 | */ |
||
199 | protected $aVeicProd = []; |
||
200 | /** |
||
201 | * @var array of DOMElements |
||
202 | */ |
||
203 | protected $aMed = []; |
||
204 | /** |
||
205 | * @var array of DOMElements |
||
206 | */ |
||
207 | protected $aArma = []; |
||
208 | /** |
||
209 | * @var array of DOMElements |
||
210 | */ |
||
211 | protected $aComb = []; |
||
212 | /** |
||
213 | * @var array of DOMElements |
||
214 | */ |
||
215 | protected $aEncerrante = []; |
||
216 | /** |
||
217 | * @var array of DOMElements |
||
218 | */ |
||
219 | protected $aImposto = []; |
||
220 | /** |
||
221 | * @var array of DOMElements |
||
222 | */ |
||
223 | protected $aICMS = []; |
||
224 | /** |
||
225 | * @var array of DOMElements |
||
226 | */ |
||
227 | protected $aICMSUFDest = []; |
||
228 | /** |
||
229 | * @var array of DOMElements |
||
230 | */ |
||
231 | protected $aIPI = []; |
||
232 | /** |
||
233 | * @var array of DOMElements |
||
234 | */ |
||
235 | protected $aII = []; |
||
236 | /** |
||
237 | * @var array of DOMElements |
||
238 | */ |
||
239 | protected $aISSQN = []; |
||
240 | /** |
||
241 | * @var array |
||
242 | */ |
||
243 | protected $aPIS = []; |
||
244 | /** |
||
245 | * @var array of DOMElements |
||
246 | */ |
||
247 | protected $aPISST = []; |
||
248 | /** |
||
249 | * @var array of DOMElements |
||
250 | */ |
||
251 | protected $aCOFINS = []; |
||
252 | /** |
||
253 | * @var array of DOMElements |
||
254 | */ |
||
255 | protected $aCOFINSST = []; |
||
256 | /** |
||
257 | * @var array of DOMElements |
||
258 | */ |
||
259 | protected $aImpostoDevol = []; |
||
260 | /** |
||
261 | * @var array of DOMElements |
||
262 | */ |
||
263 | protected $aInfAdProd = []; |
||
264 | /** |
||
265 | * @var array of DOMElements |
||
266 | */ |
||
267 | protected $aObsCont = []; |
||
268 | /** |
||
269 | * @var array of DOMElements |
||
270 | */ |
||
271 | protected $aObsFisco = []; |
||
272 | /** |
||
273 | * @var array of DOMElements |
||
274 | */ |
||
275 | protected $aProcRef = []; |
||
276 | /** |
||
277 | * @var stdClass |
||
278 | */ |
||
279 | protected $stdTot; |
||
280 | /** |
||
281 | * @var DOMElement |
||
282 | */ |
||
283 | protected $infRespTec; |
||
284 | /** |
||
285 | * @var string |
||
286 | */ |
||
287 | protected $csrt; |
||
288 | /** |
||
289 | * @var boolean |
||
290 | */ |
||
291 | protected $replaceAccentedChars = false; |
||
292 | |||
293 | /** |
||
294 | * Função construtora cria um objeto DOMDocument |
||
295 | * que será carregado com o documento fiscal |
||
296 | */ |
||
297 | 7 | public function __construct() |
|
298 | { |
||
299 | 7 | $this->dom = new Dom('1.0', 'UTF-8'); |
|
300 | 7 | $this->dom->preserveWhiteSpace = false; |
|
301 | 7 | $this->dom->formatOutput = false; |
|
302 | //elemento totalizador |
||
303 | 7 | $this->stdTot = new \stdClass(); |
|
304 | 7 | $this->stdTot->vBC = 0; |
|
305 | 7 | $this->stdTot->vICMS = 0; |
|
306 | 7 | $this->stdTot->vICMSDeson = 0; |
|
307 | 7 | $this->stdTot->vFCP = 0; |
|
308 | 7 | $this->stdTot->vFCPUFDest = 0; |
|
309 | 7 | $this->stdTot->vICMSUFDest = 0; |
|
310 | 7 | $this->stdTot->vICMSUFRemet = 0; |
|
311 | 7 | $this->stdTot->vBCST = 0; |
|
312 | 7 | $this->stdTot->vST = 0; |
|
313 | 7 | $this->stdTot->vFCPST = 0; |
|
314 | 7 | $this->stdTot->vFCPSTRet = 0; |
|
315 | 7 | $this->stdTot->vProd = 0; |
|
316 | 7 | $this->stdTot->vFrete = 0; |
|
317 | 7 | $this->stdTot->vSeg = 0; |
|
318 | 7 | $this->stdTot->vDesc = 0; |
|
319 | 7 | $this->stdTot->vII = 0; |
|
320 | 7 | $this->stdTot->vIPI = 0; |
|
321 | 7 | $this->stdTot->vIPIDevol = 0; |
|
322 | 7 | $this->stdTot->vPIS = 0; |
|
323 | 7 | $this->stdTot->vCOFINS = 0; |
|
324 | 7 | $this->stdTot->vOutro = 0; |
|
325 | 7 | $this->stdTot->vNF = 0; |
|
326 | 7 | $this->stdTot->vTotTrib = 0; |
|
327 | 7 | } |
|
328 | |||
329 | /** |
||
330 | * Set character convertion to ASCII only ou not |
||
331 | * @param bool $option |
||
332 | */ |
||
333 | public function setOnlyAscii($option = false) |
||
334 | { |
||
335 | $this->replaceAccentedChars = $option; |
||
336 | } |
||
337 | |||
338 | /** |
||
339 | * Returns xml string and assembly it is necessary |
||
340 | * @return string |
||
341 | */ |
||
342 | public function getXML() |
||
343 | { |
||
344 | if (empty($this->xml)) { |
||
345 | $this->montaNFe(); |
||
346 | } |
||
347 | return $this->xml; |
||
348 | } |
||
349 | |||
350 | /** |
||
351 | * Retorns the key number of NFe (44 digits) |
||
352 | * @return string |
||
353 | */ |
||
354 | 1 | public function getChave() |
|
355 | { |
||
356 | 1 | return $this->chNFe; |
|
357 | } |
||
358 | |||
359 | /** |
||
360 | * Returns the model of NFe 55 or 65 |
||
361 | * @return int |
||
362 | */ |
||
363 | public function getModelo() |
||
364 | { |
||
365 | return $this->mod; |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * Call method of xml assembly. For compatibility only. |
||
370 | * @return string |
||
371 | */ |
||
372 | public function montaNFe() |
||
373 | { |
||
374 | return $this->monta(); |
||
375 | } |
||
376 | |||
377 | /** |
||
378 | * NFe xml mount method |
||
379 | * this function returns TRUE on success or FALSE on error |
||
380 | * The xml of the NFe must be retrieved by the getXML() function or |
||
381 | * directly by the public property $xml |
||
382 | * |
||
383 | * @return string |
||
384 | * @throws RuntimeException |
||
385 | */ |
||
386 | public function monta() |
||
387 | { |
||
388 | if (!empty($this->errors)) { |
||
389 | $this->errors = array_merge($this->errors, $this->dom->errors); |
||
390 | } else { |
||
391 | $this->errors = $this->dom->errors; |
||
392 | } |
||
393 | //cria a tag raiz da Nfe |
||
394 | $this->buildNFe(); |
||
395 | //processa nfeRef e coloca as tags na tag ide |
||
396 | foreach ($this->aNFref as $nfeRef) { |
||
397 | $this->dom->appChild($this->ide, $nfeRef, 'Falta tag "ide"'); |
||
398 | } |
||
399 | //monta as tags det e coloca no array $this->aDet com os detalhes dos produtos |
||
400 | $this->buildDet(); |
||
401 | //[2] tag ide (5 B01) |
||
402 | $this->dom->appChild($this->infNFe, $this->ide, 'Falta tag "infNFe"'); |
||
403 | //[8] tag emit (30 C01) |
||
404 | $this->dom->appChild($this->infNFe, $this->emit, 'Falta tag "infNFe"'); |
||
405 | //[10] tag dest (62 E01) |
||
406 | $this->dom->appChild($this->infNFe, $this->dest, 'Falta tag "infNFe"'); |
||
407 | //[12] tag retirada (80 F01) |
||
408 | $this->dom->appChild($this->infNFe, $this->retirada, 'Falta tag "infNFe"'); |
||
409 | //[13] tag entrega (89 G01) |
||
410 | $this->dom->appChild($this->infNFe, $this->entrega, 'Falta tag "infNFe"'); |
||
411 | //[14] tag autXML (97a.1 G50) |
||
412 | foreach ($this->aAutXML as $aut) { |
||
413 | $this->dom->appChild($this->infNFe, $aut, 'Falta tag "infNFe"'); |
||
414 | } |
||
415 | //[14a] tag det (98 H01) |
||
416 | foreach ($this->aDet as $det) { |
||
417 | $this->dom->appChild($this->infNFe, $det, 'Falta tag "infNFe"'); |
||
418 | } |
||
419 | //[28a] tag total (326 W01) |
||
420 | $this->dom->appChild($this->infNFe, $this->total, 'Falta tag "infNFe"'); |
||
421 | //mota a tag vol |
||
422 | $this->buildVol(); |
||
423 | //[32] tag transp (356 X01) |
||
424 | $this->dom->appChild($this->infNFe, $this->transp, 'Falta tag "infNFe"'); |
||
425 | //[39a] tag cobr (389 Y01) |
||
426 | $this->dom->appChild($this->infNFe, $this->cobr, 'Falta tag "infNFe"'); |
||
427 | //[42] tag pag (398a YA01) |
||
428 | //processa Pag e coloca as tags na tag pag |
||
429 | $this->buildTagPag(); |
||
430 | //[43] tag infIntermed (398.26 YB01) NT 2020.006_1.00 |
||
431 | $this->dom->appChild($this->infNFe, $this->intermed, 'Falta tag "infNFe"'); |
||
432 | //[44] tag infAdic (399 Z01) |
||
433 | $this->dom->appChild($this->infNFe, $this->infAdic, 'Falta tag "infNFe"'); |
||
434 | //[48] tag exporta (402 ZA01) |
||
435 | $this->dom->appChild($this->infNFe, $this->exporta, 'Falta tag "infNFe"'); |
||
436 | //[49] tag compra (405 ZB01) |
||
437 | $this->dom->appChild($this->infNFe, $this->compra, 'Falta tag "infNFe"'); |
||
438 | //[50] tag cana (409 ZC01) |
||
439 | $this->dom->appChild($this->infNFe, $this->cana, 'Falta tag "infNFe"'); |
||
440 | //Responsável Técnico |
||
441 | $this->dom->appChild($this->infNFe, $this->infRespTec, 'Falta tag "infNFe"'); |
||
442 | //[1] tag infNFe (1 A01) |
||
443 | $this->dom->appChild($this->NFe, $this->infNFe, 'Falta tag "NFe"'); |
||
444 | //[0] tag NFe |
||
445 | $this->dom->appendChild($this->NFe); |
||
446 | // testa da chave |
||
447 | $this->checkNFeKey($this->dom); |
||
448 | $this->xml = $this->dom->saveXML(); |
||
449 | if (count($this->errors) > 0) { |
||
450 | throw new RuntimeException('Existem erros nas tags. Obtenha os erros com getErrors().'); |
||
451 | } |
||
452 | return $this->xml; |
||
453 | } |
||
454 | |||
455 | /** |
||
456 | * Informações da NF-e A01 pai NFe |
||
457 | * tag NFe/infNFe |
||
458 | * @param stdClass $std |
||
459 | * @return DOMElement |
||
460 | */ |
||
461 | 7 | public function taginfNFe(stdClass $std) |
|
462 | { |
||
463 | 7 | $possible = ['Id', 'versao', 'pk_nItem']; |
|
464 | 7 | $std = $this->equilizeParameters($std, $possible); |
|
465 | 7 | $chave = preg_replace('/[^0-9]/', '', $std->Id); |
|
466 | 7 | $this->infNFe = $this->dom->createElement("infNFe"); |
|
467 | 7 | $this->infNFe->setAttribute("Id", 'NFe' . $chave); |
|
468 | 7 | $this->infNFe->setAttribute( |
|
469 | 7 | "versao", |
|
470 | 7 | $std->versao |
|
471 | ); |
||
472 | 7 | $this->version = $std->versao; |
|
473 | 7 | if (!empty($std->pk_nItem)) { |
|
474 | 1 | $this->infNFe->setAttribute("pk_nItem", $std->pk_nItem); |
|
475 | } |
||
476 | 7 | $this->chNFe = $chave; |
|
477 | 7 | return $this->infNFe; |
|
478 | } |
||
479 | |||
480 | /** |
||
481 | * Informações de identificação da NF-e B01 pai A01 |
||
482 | * NOTA: Ajustado para NT2020_006_v1.00 |
||
483 | * tag NFe/infNFe/ide |
||
484 | * @param stdClass $std |
||
485 | * @return DOMElement |
||
486 | */ |
||
487 | 4 | public function tagide(stdClass $std) |
|
488 | { |
||
489 | $possible = [ |
||
490 | 4 | 'cUF', |
|
491 | 'cNF', |
||
492 | 'natOp', |
||
493 | 'indPag', |
||
494 | 'mod', |
||
495 | 'serie', |
||
496 | 'nNF', |
||
497 | 'dhEmi', |
||
498 | 'dhSaiEnt', |
||
499 | 'tpNF', |
||
500 | 'idDest', |
||
501 | 'cMunFG', |
||
502 | 'tpImp', |
||
503 | 'tpEmis', |
||
504 | 'cDV', |
||
505 | 'tpAmb', |
||
506 | 'finNFe', |
||
507 | 'indFinal', |
||
508 | 'indPres', |
||
509 | 'indIntermed', |
||
510 | 'procEmi', |
||
511 | 'verProc', |
||
512 | 'dhCont', |
||
513 | 'xJust' |
||
514 | ]; |
||
515 | 4 | $std = $this->equilizeParameters($std, $possible); |
|
516 | |||
517 | 4 | if (empty($std->cNF)) { |
|
518 | 1 | $std->cNF = Keys::random($std->nNF); |
|
519 | } |
||
520 | 4 | if (empty($std->cDV)) { |
|
521 | 2 | $std->cDV = 0; |
|
522 | } |
||
523 | //validação conforme NT 2019.001 |
||
524 | 4 | $std->cNF = str_pad($std->cNF, 8, '0', STR_PAD_LEFT); |
|
525 | 4 | if (intval($std->cNF) == intval($std->nNF)) { |
|
526 | throw new InvalidArgumentException("O valor [{$std->cNF}] não é " |
||
527 | . "aceitável para cNF, não pode ser igual ao de nNF, vide NT2019.001"); |
||
528 | } |
||
529 | 4 | if (method_exists(Keys::class, 'cNFIsValid')) { |
|
530 | 4 | if (!Keys::cNFIsValid($std->cNF)) { |
|
531 | throw new InvalidArgumentException("O valor [{$std->cNF}] para cNF " |
||
532 | . "é invalido, deve respeitar a NT2019.001"); |
||
533 | } |
||
534 | } |
||
535 | 4 | $this->tpAmb = $std->tpAmb; |
|
536 | 4 | $this->mod = $std->mod; |
|
537 | 4 | $identificador = 'B01 <ide> - '; |
|
538 | 4 | $ide = $this->dom->createElement("ide"); |
|
539 | 4 | $this->dom->addChild( |
|
540 | 4 | $ide, |
|
541 | 4 | "cUF", |
|
542 | 4 | $std->cUF, |
|
543 | 4 | true, |
|
544 | 4 | $identificador . "Código da UF do emitente do Documento Fiscal" |
|
545 | ); |
||
546 | 4 | $this->dom->addChild( |
|
547 | 4 | $ide, |
|
548 | 4 | "cNF", |
|
549 | 4 | $std->cNF, |
|
550 | 4 | true, |
|
551 | 4 | $identificador . "Código Numérico que compõe a Chave de Acesso" |
|
552 | ); |
||
553 | 4 | $this->dom->addChild( |
|
554 | 4 | $ide, |
|
555 | 4 | "natOp", |
|
556 | 4 | substr(trim($std->natOp), 0, 60), |
|
557 | 4 | true, |
|
558 | 4 | $identificador . "Descrição da Natureza da Operação" |
|
559 | ); |
||
560 | 4 | $this->dom->addChild( |
|
561 | 4 | $ide, |
|
562 | 4 | "mod", |
|
563 | 4 | $std->mod, |
|
564 | 4 | true, |
|
565 | 4 | $identificador . "Código do Modelo do Documento Fiscal" |
|
566 | ); |
||
567 | 4 | $this->dom->addChild( |
|
568 | 4 | $ide, |
|
569 | 4 | "serie", |
|
570 | 4 | $std->serie, |
|
571 | 4 | true, |
|
572 | 4 | $identificador . "Série do Documento Fiscal" |
|
573 | ); |
||
574 | 4 | $this->dom->addChild( |
|
575 | 4 | $ide, |
|
576 | 4 | "nNF", |
|
577 | 4 | $std->nNF, |
|
578 | 4 | true, |
|
579 | 4 | $identificador . "Número do Documento Fiscal" |
|
580 | ); |
||
581 | 4 | $this->dom->addChild( |
|
582 | 4 | $ide, |
|
583 | 4 | "dhEmi", |
|
584 | 4 | $std->dhEmi, |
|
585 | 4 | true, |
|
586 | 4 | $identificador . "Data e hora de emissão do Documento Fiscal" |
|
587 | ); |
||
588 | 4 | if ($std->mod == '55' && !empty($std->dhSaiEnt)) { |
|
589 | 1 | $this->dom->addChild( |
|
590 | 1 | $ide, |
|
591 | 1 | "dhSaiEnt", |
|
592 | 1 | $std->dhSaiEnt, |
|
593 | 1 | false, |
|
594 | 1 | $identificador . "Data e hora de Saída ou da Entrada da Mercadoria/Produto" |
|
595 | ); |
||
596 | } |
||
597 | 4 | $this->dom->addChild( |
|
598 | 4 | $ide, |
|
599 | 4 | "tpNF", |
|
600 | 4 | $std->tpNF, |
|
601 | 4 | true, |
|
602 | 4 | $identificador . "Tipo de Operação" |
|
603 | ); |
||
604 | 4 | $this->dom->addChild( |
|
605 | 4 | $ide, |
|
606 | 4 | "idDest", |
|
607 | 4 | $std->idDest, |
|
608 | 4 | true, |
|
609 | 4 | $identificador . "Identificador de local de destino da operação" |
|
610 | ); |
||
611 | 4 | $this->dom->addChild( |
|
612 | 4 | $ide, |
|
613 | 4 | "cMunFG", |
|
614 | 4 | $std->cMunFG, |
|
615 | 4 | true, |
|
616 | 4 | $identificador . "Código do Município de Ocorrência do Fato Gerador" |
|
617 | ); |
||
618 | 4 | $this->dom->addChild( |
|
619 | 4 | $ide, |
|
620 | 4 | "tpImp", |
|
621 | 4 | $std->tpImp, |
|
622 | 4 | true, |
|
623 | 4 | $identificador . "Formato de Impressão do DANFE" |
|
624 | ); |
||
625 | 4 | $this->dom->addChild( |
|
626 | 4 | $ide, |
|
627 | 4 | "tpEmis", |
|
628 | 4 | $std->tpEmis, |
|
629 | 4 | true, |
|
630 | 4 | $identificador . "Tipo de Emissão da NF-e" |
|
631 | ); |
||
632 | 4 | $this->dom->addChild( |
|
633 | 4 | $ide, |
|
634 | 4 | "cDV", |
|
635 | 4 | !empty($std->cDV) ? $std->cDV : '0', |
|
636 | 4 | true, |
|
637 | 4 | $identificador . "Dígito Verificador da Chave de Acesso da NF-e" |
|
638 | ); |
||
639 | 4 | $this->dom->addChild( |
|
640 | 4 | $ide, |
|
641 | 4 | "tpAmb", |
|
642 | 4 | $std->tpAmb, |
|
643 | 4 | true, |
|
644 | 4 | $identificador . "Identificação do Ambiente" |
|
645 | ); |
||
646 | 4 | $this->dom->addChild( |
|
647 | 4 | $ide, |
|
648 | 4 | "finNFe", |
|
649 | 4 | $std->finNFe, |
|
650 | 4 | true, |
|
651 | 4 | $identificador . "Finalidade de emissão da NF-e" |
|
652 | ); |
||
653 | 4 | $this->dom->addChild( |
|
654 | 4 | $ide, |
|
655 | 4 | "indFinal", |
|
656 | 4 | $std->indFinal, |
|
657 | 4 | true, |
|
658 | 4 | $identificador . "Indica operação com Consumidor final" |
|
659 | ); |
||
660 | 4 | $this->dom->addChild( |
|
661 | 4 | $ide, |
|
662 | 4 | "indPres", |
|
663 | 4 | $std->indPres, |
|
664 | 4 | true, |
|
665 | 4 | $identificador . "Indicador de presença do comprador no estabelecimento comercial no momento da operação" |
|
666 | ); |
||
667 | 4 | $this->dom->addChild( |
|
668 | 4 | $ide, |
|
669 | 4 | "indIntermed", |
|
670 | 4 | $std->indIntermed ?? null, |
|
671 | 4 | false, |
|
672 | 4 | $identificador . "Indicador de intermediador/marketplace" |
|
673 | ); |
||
674 | 4 | $this->dom->addChild( |
|
675 | 4 | $ide, |
|
676 | 4 | "procEmi", |
|
677 | 4 | $std->procEmi, |
|
678 | 4 | true, |
|
679 | 4 | $identificador . "Processo de emissão da NF-e" |
|
680 | ); |
||
681 | 4 | $this->dom->addChild( |
|
682 | 4 | $ide, |
|
683 | 4 | "verProc", |
|
684 | 4 | $std->verProc, |
|
685 | 4 | true, |
|
686 | 4 | $identificador . "Versão do Processo de emissão da NF-e" |
|
687 | ); |
||
688 | 4 | if (!empty($std->dhCont) && !empty($std->xJust)) { |
|
689 | 1 | $this->dom->addChild( |
|
690 | 1 | $ide, |
|
691 | 1 | "dhCont", |
|
692 | 1 | $std->dhCont, |
|
693 | 1 | true, |
|
694 | 1 | $identificador . "Data e Hora da entrada em contingência" |
|
695 | ); |
||
696 | 1 | $this->dom->addChild( |
|
697 | 1 | $ide, |
|
698 | 1 | "xJust", |
|
699 | 1 | substr(trim($std->xJust), 0, 256), |
|
700 | 1 | true, |
|
701 | 1 | $identificador . "Justificativa da entrada em contingência" |
|
702 | ); |
||
703 | } |
||
704 | 4 | $this->ide = $ide; |
|
705 | 4 | return $ide; |
|
706 | } |
||
707 | |||
708 | /** |
||
709 | * Chave de acesso da NF-e referenciada BA02 pai BA01 |
||
710 | * tag NFe/infNFe/ide/NFref/refNFe |
||
711 | * @param stdClass $std |
||
712 | * @return DOMElement |
||
713 | */ |
||
714 | public function tagrefNFe(stdClass $std) |
||
715 | { |
||
716 | $possible = ['refNFe']; |
||
717 | $std = $this->equilizeParameters($std, $possible); |
||
718 | |||
719 | $num = $this->buildNFref(); |
||
720 | $refNFe = $this->dom->createElement("refNFe", $std->refNFe); |
||
721 | $this->dom->appChild($this->aNFref[$num - 1], $refNFe); |
||
722 | return $refNFe; |
||
723 | } |
||
724 | |||
725 | /** |
||
726 | * Informação da NF modelo 1/1A referenciada BA03 pai BA01 |
||
727 | * tag NFe/infNFe/ide/NFref/NF DOMNode |
||
728 | * @param stdClass $std |
||
729 | * @return DOMElement |
||
730 | */ |
||
731 | public function tagrefNF(stdClass $std) |
||
732 | { |
||
733 | $possible = ['cUF', 'AAMM', 'CNPJ', 'mod', 'serie', 'nNF']; |
||
734 | $std = $this->equilizeParameters($std, $possible); |
||
735 | |||
736 | $identificador = 'BA03 <refNF> - '; |
||
737 | $num = $this->buildNFref(); |
||
738 | $refNF = $this->dom->createElement("refNF"); |
||
739 | $this->dom->addChild( |
||
740 | $refNF, |
||
741 | "cUF", |
||
742 | $std->cUF, |
||
743 | true, |
||
744 | $identificador . "Código da UF do emitente" |
||
745 | ); |
||
746 | $this->dom->addChild( |
||
747 | $refNF, |
||
748 | "AAMM", |
||
749 | $std->AAMM, |
||
750 | true, |
||
751 | $identificador . "Ano e Mês de emissão da NF-e" |
||
752 | ); |
||
753 | $this->dom->addChild( |
||
754 | $refNF, |
||
755 | "CNPJ", |
||
756 | $std->CNPJ, |
||
757 | true, |
||
758 | $identificador . "CNPJ do emitente" |
||
759 | ); |
||
760 | $this->dom->addChild( |
||
761 | $refNF, |
||
762 | "mod", |
||
763 | $std->mod, |
||
764 | true, |
||
765 | $identificador . "Modelo do Documento Fiscal" |
||
766 | ); |
||
767 | $this->dom->addChild( |
||
768 | $refNF, |
||
769 | "serie", |
||
770 | $std->serie, |
||
771 | true, |
||
772 | $identificador . "Série do Documento Fiscal" |
||
773 | ); |
||
774 | $this->dom->addChild( |
||
775 | $refNF, |
||
776 | "nNF", |
||
777 | $std->nNF, |
||
778 | true, |
||
779 | $identificador . "Número do Documento Fiscal" |
||
780 | ); |
||
781 | $this->dom->appChild($this->aNFref[$num - 1], $refNF); |
||
782 | return $refNF; |
||
783 | } |
||
784 | |||
785 | /** |
||
786 | * Informações da NF de produtor rural referenciada BA10 pai BA01 |
||
787 | * tag NFe/infNFe/ide/NFref/refNFP |
||
788 | * @param stdClass $std |
||
789 | * @return DOMElement |
||
790 | */ |
||
791 | public function tagrefNFP(stdClass $std) |
||
792 | { |
||
793 | $possible = [ |
||
794 | 'cUF', |
||
795 | 'AAMM', |
||
796 | 'CNPJ', |
||
797 | 'CPF', |
||
798 | 'IE', |
||
799 | 'mod', |
||
800 | 'serie', |
||
801 | 'nNF' |
||
802 | ]; |
||
803 | $std = $this->equilizeParameters($std, $possible); |
||
804 | |||
805 | $identificador = 'BA10 <refNFP> - '; |
||
806 | $num = $this->buildNFref(); |
||
807 | $refNFP = $this->dom->createElement("refNFP"); |
||
808 | $this->dom->addChild( |
||
809 | $refNFP, |
||
810 | "cUF", |
||
811 | $std->cUF, |
||
812 | true, |
||
813 | $identificador . "Código da UF do emitente" |
||
814 | ); |
||
815 | $this->dom->addChild( |
||
816 | $refNFP, |
||
817 | "AAMM", |
||
818 | $std->AAMM, |
||
819 | true, |
||
820 | $identificador . "AAMM da emissão da NF de produtor" |
||
821 | ); |
||
822 | $this->dom->addChild( |
||
823 | $refNFP, |
||
824 | "CNPJ", |
||
825 | $std->CNPJ, |
||
826 | false, |
||
827 | $identificador . "Informar o CNPJ do emitente da NF de produtor" |
||
828 | ); |
||
829 | $this->dom->addChild( |
||
830 | $refNFP, |
||
831 | "CPF", |
||
832 | $std->CPF, |
||
833 | false, |
||
834 | $identificador . "Informar o CPF do emitente da NF de produtor" |
||
835 | ); |
||
836 | $this->dom->addChild( |
||
837 | $refNFP, |
||
838 | "IE", |
||
839 | $std->IE, |
||
840 | true, |
||
841 | $identificador . "Informar a IE do emitente da NF de Produtor ou o literal 'ISENTO'" |
||
842 | ); |
||
843 | $this->dom->addChild( |
||
844 | $refNFP, |
||
845 | "mod", |
||
846 | str_pad($std->mod, 2, '0', STR_PAD_LEFT), |
||
847 | true, |
||
848 | $identificador . "Modelo do Documento Fiscal" |
||
849 | ); |
||
850 | $this->dom->addChild( |
||
851 | $refNFP, |
||
852 | "serie", |
||
853 | $std->serie, |
||
854 | true, |
||
855 | $identificador . "Série do Documento Fiscal" |
||
856 | ); |
||
857 | $this->dom->addChild( |
||
858 | $refNFP, |
||
859 | "nNF", |
||
860 | $std->nNF, |
||
861 | true, |
||
862 | $identificador . "Número do Documento Fiscal" |
||
863 | ); |
||
864 | $this->dom->appChild($this->aNFref[$num - 1], $refNFP); |
||
865 | return $refNFP; |
||
866 | } |
||
867 | |||
868 | /** |
||
869 | * Chave de acesso do CT-e referenciada BA19 pai BA01 |
||
870 | * tag NFe/infNFe/ide/NFref/refCTe |
||
871 | * @param stdClass $std |
||
872 | * @return DOMElement |
||
873 | */ |
||
874 | public function tagrefCTe(stdClass $std) |
||
875 | { |
||
876 | $possible = ['refCTe']; |
||
877 | $std = $this->equilizeParameters($std, $possible); |
||
878 | |||
879 | $num = $this->buildNFref(); |
||
880 | $refCTe = $this->dom->createElement("refCTe", $std->refCTe); |
||
881 | $this->dom->appChild($this->aNFref[$num - 1], $refCTe); |
||
882 | return $refCTe; |
||
883 | } |
||
884 | |||
885 | /** |
||
886 | * Informações do Cupom Fiscal referenciado BA20 pai BA01 |
||
887 | * tag NFe/infNFe/ide/NFref/refECF |
||
888 | * @param stdClass $std |
||
889 | * @return DOMElement |
||
890 | */ |
||
891 | public function tagrefECF(stdClass $std) |
||
892 | { |
||
893 | $possible = ['mod', 'nECF', 'nCOO']; |
||
894 | $std = $this->equilizeParameters($std, $possible); |
||
895 | |||
896 | $identificador = 'BA20 <refECF> - '; |
||
897 | $num = $this->buildNFref(); |
||
898 | $refECF = $this->dom->createElement("refECF"); |
||
899 | $this->dom->addChild( |
||
900 | $refECF, |
||
901 | "mod", |
||
902 | $std->mod, |
||
903 | true, |
||
904 | $identificador . "Modelo do Documento Fiscal" |
||
905 | ); |
||
906 | $this->dom->addChild( |
||
907 | $refECF, |
||
908 | "nECF", |
||
909 | str_pad($std->nECF, 3, '0', STR_PAD_LEFT), |
||
910 | true, |
||
911 | $identificador . "Número de ordem sequencial do ECF" |
||
912 | ); |
||
913 | $this->dom->addChild( |
||
914 | $refECF, |
||
915 | "nCOO", |
||
916 | str_pad($std->nCOO, 6, '0', STR_PAD_LEFT), |
||
917 | true, |
||
918 | $identificador . "Número do Contador de Ordem de Operação - COO" |
||
919 | ); |
||
920 | $this->dom->appChild($this->aNFref[$num - 1], $refECF); |
||
921 | return $refECF; |
||
922 | } |
||
923 | |||
924 | /** |
||
925 | * Identificação do emitente da NF-e C01 pai A01 |
||
926 | * tag NFe/infNFe/emit |
||
927 | * @param stdClass $std |
||
928 | * @return DOMElement |
||
929 | */ |
||
930 | public function tagemit(stdClass $std) |
||
931 | { |
||
932 | $possible = [ |
||
933 | 'xNome', |
||
934 | 'xFant', |
||
935 | 'IE', |
||
936 | 'IEST', |
||
937 | 'IM', |
||
938 | 'CNAE', |
||
939 | 'CRT', |
||
940 | 'CNPJ', |
||
941 | 'CPF' |
||
942 | ]; |
||
943 | $std = $this->equilizeParameters($std, $possible); |
||
944 | $identificador = 'C01 <emit> - '; |
||
945 | $this->emit = $this->dom->createElement("emit"); |
||
946 | if (!empty($std->CNPJ)) { |
||
947 | $this->dom->addChild( |
||
948 | $this->emit, |
||
949 | "CNPJ", |
||
950 | Strings::onlyNumbers($std->CNPJ), |
||
951 | false, |
||
952 | $identificador . "CNPJ do emitente" |
||
953 | ); |
||
954 | } elseif (!empty($std->CPF)) { |
||
955 | $this->dom->addChild( |
||
956 | $this->emit, |
||
957 | "CPF", |
||
958 | Strings::onlyNumbers($std->CPF), |
||
959 | false, |
||
960 | $identificador . "CPF do remetente" |
||
961 | ); |
||
962 | } |
||
963 | $this->dom->addChild( |
||
964 | $this->emit, |
||
965 | "xNome", |
||
966 | substr(trim($std->xNome), 0, 60), |
||
967 | true, |
||
968 | $identificador . "Razão Social ou Nome do emitente" |
||
969 | ); |
||
970 | $this->dom->addChild( |
||
971 | $this->emit, |
||
972 | "xFant", |
||
973 | substr(trim($std->xFant), 0, 60), |
||
974 | false, |
||
975 | $identificador . "Nome fantasia do emitente" |
||
976 | ); |
||
977 | if ($std->IE != 'ISENTO') { |
||
978 | $std->IE = Strings::onlyNumbers($std->IE); |
||
979 | } |
||
980 | $this->dom->addChild( |
||
981 | $this->emit, |
||
982 | "IE", |
||
983 | $std->IE, |
||
984 | true, |
||
985 | $identificador . "Inscrição Estadual do emitente" |
||
986 | ); |
||
987 | $this->dom->addChild( |
||
988 | $this->emit, |
||
989 | "IEST", |
||
990 | Strings::onlyNumbers($std->IEST), |
||
991 | false, |
||
992 | $identificador . "IE do Substituto Tributário do emitente" |
||
993 | ); |
||
994 | $this->dom->addChild( |
||
995 | $this->emit, |
||
996 | "IM", |
||
997 | Strings::onlyNumbers($std->IM), |
||
998 | false, |
||
999 | $identificador . "Inscrição Municipal do Prestador de Serviço do emitente" |
||
1000 | ); |
||
1001 | if (!empty($std->IM) && !empty($std->CNAE)) { |
||
1002 | $this->dom->addChild( |
||
1003 | $this->emit, |
||
1004 | "CNAE", |
||
1005 | Strings::onlyNumbers($std->CNAE), |
||
1006 | false, |
||
1007 | $identificador . "CNAE fiscal do emitente" |
||
1008 | ); |
||
1009 | } |
||
1010 | $this->dom->addChild( |
||
1011 | $this->emit, |
||
1012 | "CRT", |
||
1013 | $std->CRT, |
||
1014 | true, |
||
1015 | $identificador . "Código de Regime Tributário do emitente" |
||
1016 | ); |
||
1017 | return $this->emit; |
||
1018 | } |
||
1019 | |||
1020 | /** |
||
1021 | * Endereço do emitente C05 pai C01 |
||
1022 | * tag NFe/infNFe/emit/endEmit |
||
1023 | * @param stdClass $std |
||
1024 | * @return DOMElement |
||
1025 | */ |
||
1026 | public function tagenderEmit(stdClass $std) |
||
1027 | { |
||
1028 | $possible = [ |
||
1029 | 'xLgr', |
||
1030 | 'nro', |
||
1031 | 'xCpl', |
||
1032 | 'xBairro', |
||
1033 | 'cMun', |
||
1034 | 'xMun', |
||
1035 | 'UF', |
||
1036 | 'CEP', |
||
1037 | 'cPais', |
||
1038 | 'xPais', |
||
1039 | 'fone' |
||
1040 | ]; |
||
1041 | $std = $this->equilizeParameters($std, $possible); |
||
1042 | |||
1043 | $identificador = 'C05 <enderEmit> - '; |
||
1044 | $this->enderEmit = $this->dom->createElement("enderEmit"); |
||
1045 | $this->dom->addChild( |
||
1046 | $this->enderEmit, |
||
1047 | "xLgr", |
||
1048 | substr(trim($std->xLgr), 0, 60), |
||
1049 | true, |
||
1050 | $identificador . "Logradouro do Endereço do emitente" |
||
1051 | ); |
||
1052 | $this->dom->addChild( |
||
1053 | $this->enderEmit, |
||
1054 | "nro", |
||
1055 | substr(trim($std->nro), 0, 60), |
||
1056 | true, |
||
1057 | $identificador . "Número do Endereço do emitente" |
||
1058 | ); |
||
1059 | $this->dom->addChild( |
||
1060 | $this->enderEmit, |
||
1061 | "xCpl", |
||
1062 | substr(trim($std->xCpl), 0, 60), |
||
1063 | false, |
||
1064 | $identificador . "Complemento do Endereço do emitente" |
||
1065 | ); |
||
1066 | $this->dom->addChild( |
||
1067 | $this->enderEmit, |
||
1068 | "xBairro", |
||
1069 | substr(trim($std->xBairro), 0, 60), |
||
1070 | true, |
||
1071 | $identificador . "Bairro do Endereço do emitente" |
||
1072 | ); |
||
1073 | $this->dom->addChild( |
||
1074 | $this->enderEmit, |
||
1075 | "cMun", |
||
1076 | Strings::onlyNumbers($std->cMun), |
||
1077 | true, |
||
1078 | $identificador . "Código do município do Endereço do emitente" |
||
1079 | ); |
||
1080 | $this->dom->addChild( |
||
1081 | $this->enderEmit, |
||
1082 | "xMun", |
||
1083 | substr(trim($std->xMun), 0, 60), |
||
1084 | true, |
||
1085 | $identificador . "Nome do município do Endereço do emitente" |
||
1086 | ); |
||
1087 | $this->dom->addChild( |
||
1088 | $this->enderEmit, |
||
1089 | "UF", |
||
1090 | strtoupper(trim($std->UF)), |
||
1091 | true, |
||
1092 | $identificador . "Sigla da UF do Endereço do emitente" |
||
1093 | ); |
||
1094 | $this->dom->addChild( |
||
1095 | $this->enderEmit, |
||
1096 | "CEP", |
||
1097 | Strings::onlyNumbers($std->CEP), |
||
1098 | true, |
||
1099 | $identificador . "Código do CEP do Endereço do emitente" |
||
1100 | ); |
||
1101 | $this->dom->addChild( |
||
1102 | $this->enderEmit, |
||
1103 | "cPais", |
||
1104 | Strings::onlyNumbers($std->cPais), |
||
1105 | false, |
||
1106 | $identificador . "Código do País do Endereço do emitente" |
||
1107 | ); |
||
1108 | $this->dom->addChild( |
||
1109 | $this->enderEmit, |
||
1110 | "xPais", |
||
1111 | substr(trim($std->xPais), 0, 60), |
||
1112 | false, |
||
1113 | $identificador . "Nome do País do Endereço do emitente" |
||
1114 | ); |
||
1115 | $this->dom->addChild( |
||
1116 | $this->enderEmit, |
||
1117 | "fone", |
||
1118 | trim($std->fone), |
||
1119 | false, |
||
1120 | $identificador . "Telefone do Endereço do emitente" |
||
1121 | ); |
||
1122 | $node = $this->emit->getElementsByTagName("IE")->item(0); |
||
1123 | $this->emit->insertBefore($this->enderEmit, $node); |
||
1124 | return $this->enderEmit; |
||
1125 | } |
||
1126 | |||
1127 | /** |
||
1128 | * Identificação do Destinatário da NF-e E01 pai A01 |
||
1129 | * tag NFe/infNFe/dest (opcional para modelo 65) |
||
1130 | * @param stdClass $std |
||
1131 | * @return DOMElement |
||
1132 | */ |
||
1133 | public function tagdest(stdClass $std) |
||
1134 | { |
||
1135 | $possible = [ |
||
1136 | 'xNome', |
||
1137 | 'indIEDest', |
||
1138 | 'IE', |
||
1139 | 'ISUF', |
||
1140 | 'IM', |
||
1141 | 'email', |
||
1142 | 'CNPJ', |
||
1143 | 'CPF', |
||
1144 | 'idEstrangeiro' |
||
1145 | ]; |
||
1146 | $std = $this->equilizeParameters($std, $possible); |
||
1147 | $identificador = 'E01 <dest> - '; |
||
1148 | $flagNome = true; //marca se xNome é ou não obrigatório |
||
1149 | $temIE = $std->IE != '' && $std->IE != 'ISENTO'; // Tem inscrição municipal |
||
1150 | $this->dest = $this->dom->createElement("dest"); |
||
1151 | if (!$temIE && $std->indIEDest == 1) { |
||
1152 | $std->indIEDest = 2; |
||
1153 | } |
||
1154 | if ($this->mod == '65') { |
||
1155 | $std->indIEDest = 9; |
||
1156 | if ($std->xNome == '') { |
||
1157 | $flagNome = false; //marca se xNome é ou não obrigatório |
||
1158 | } |
||
1159 | } |
||
1160 | $xNome = $std->xNome; |
||
1161 | if ($this->tpAmb == '2') { |
||
1162 | $xNome = 'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
1163 | //a exigência do CNPJ 99999999000191 não existe mais |
||
1164 | } |
||
1165 | if (!empty($std->CNPJ)) { |
||
1166 | $this->dom->addChild( |
||
1167 | $this->dest, |
||
1168 | "CNPJ", |
||
1169 | Strings::onlyNumbers($std->CNPJ), |
||
1170 | true, |
||
1171 | $identificador . "CNPJ do destinatário" |
||
1172 | ); |
||
1173 | } elseif (!empty($std->CPF)) { |
||
1174 | $this->dom->addChild( |
||
1175 | $this->dest, |
||
1176 | "CPF", |
||
1177 | Strings::onlyNumbers($std->CPF), |
||
1178 | true, |
||
1179 | $identificador . "CPF do destinatário" |
||
1180 | ); |
||
1181 | } elseif ($std->idEstrangeiro !== null) { |
||
1182 | $this->dom->addChild( |
||
1183 | $this->dest, |
||
1184 | "idEstrangeiro", |
||
1185 | $std->idEstrangeiro, |
||
1186 | true, |
||
1187 | $identificador . "Identificação do destinatário no caso de comprador estrangeiro", |
||
1188 | true |
||
1189 | ); |
||
1190 | $std->indIEDest = '9'; |
||
1191 | } |
||
1192 | $this->dom->addChild( |
||
1193 | $this->dest, |
||
1194 | "xNome", |
||
1195 | substr(trim($xNome), 0, 60), |
||
1196 | $flagNome, //se mod 55 true ou mod 65 false |
||
1197 | $identificador . "Razão Social ou nome do destinatário" |
||
1198 | ); |
||
1199 | $this->dom->addChild( |
||
1200 | $this->dest, |
||
1201 | "indIEDest", |
||
1202 | Strings::onlyNumbers($std->indIEDest), |
||
1203 | true, |
||
1204 | $identificador . "Indicador da IE do Destinatário" |
||
1205 | ); |
||
1206 | if ($temIE) { |
||
1207 | $this->dom->addChild( |
||
1208 | $this->dest, |
||
1209 | "IE", |
||
1210 | $std->IE, |
||
1211 | true, |
||
1212 | $identificador . "Inscrição Estadual do Destinatário" |
||
1213 | ); |
||
1214 | } |
||
1215 | $this->dom->addChild( |
||
1216 | $this->dest, |
||
1217 | "ISUF", |
||
1218 | Strings::onlyNumbers($std->ISUF), |
||
1219 | false, |
||
1220 | $identificador . "Inscrição na SUFRAMA do destinatário" |
||
1221 | ); |
||
1222 | $this->dom->addChild( |
||
1223 | $this->dest, |
||
1224 | "IM", |
||
1225 | Strings::onlyNumbers($std->IM), |
||
1226 | false, |
||
1227 | $identificador . "Inscrição Municipal do Tomador do Serviço do destinatário" |
||
1228 | ); |
||
1229 | $this->dom->addChild( |
||
1230 | $this->dest, |
||
1231 | "email", |
||
1232 | substr(trim($std->email), 0, 60), |
||
1233 | false, |
||
1234 | $identificador . "Email do destinatário" |
||
1235 | ); |
||
1236 | return $this->dest; |
||
1237 | } |
||
1238 | |||
1239 | /** |
||
1240 | * Endereço do Destinatário da NF-e E05 pai E01 |
||
1241 | * tag NFe/infNFe/dest/enderDest (opcional para modelo 65) |
||
1242 | * Os dados do destinatário devem ser inseridos antes deste método |
||
1243 | * @param stdClass $std |
||
1244 | * @return DOMElement |
||
1245 | */ |
||
1246 | public function tagenderDest(stdClass $std) |
||
1247 | { |
||
1248 | $possible = [ |
||
1249 | 'xLgr', |
||
1250 | 'nro', |
||
1251 | 'xCpl', |
||
1252 | 'xBairro', |
||
1253 | 'cMun', |
||
1254 | 'xMun', |
||
1255 | 'UF', |
||
1256 | 'CEP', |
||
1257 | 'cPais', |
||
1258 | 'xPais', |
||
1259 | 'fone' |
||
1260 | ]; |
||
1261 | $std = $this->equilizeParameters($std, $possible); |
||
1262 | |||
1263 | $identificador = 'E05 <enderDest> - '; |
||
1264 | if (empty($this->dest)) { |
||
1265 | throw new RuntimeException('A TAG dest deve ser criada antes do endereço do mesmo.'); |
||
1266 | } |
||
1267 | $this->enderDest = $this->dom->createElement("enderDest"); |
||
1268 | $this->dom->addChild( |
||
1269 | $this->enderDest, |
||
1270 | "xLgr", |
||
1271 | $std->xLgr, |
||
1272 | true, |
||
1273 | $identificador . "Logradouro do Endereço do Destinatário" |
||
1274 | ); |
||
1275 | $this->dom->addChild( |
||
1276 | $this->enderDest, |
||
1277 | "nro", |
||
1278 | $std->nro, |
||
1279 | true, |
||
1280 | $identificador . "Número do Endereço do Destinatário" |
||
1281 | ); |
||
1282 | $this->dom->addChild( |
||
1283 | $this->enderDest, |
||
1284 | "xCpl", |
||
1285 | $std->xCpl, |
||
1286 | false, |
||
1287 | $identificador . "Complemento do Endereço do Destinatário" |
||
1288 | ); |
||
1289 | $this->dom->addChild( |
||
1290 | $this->enderDest, |
||
1291 | "xBairro", |
||
1292 | $std->xBairro, |
||
1293 | true, |
||
1294 | $identificador . "Bairro do Endereço do Destinatário" |
||
1295 | ); |
||
1296 | $this->dom->addChild( |
||
1297 | $this->enderDest, |
||
1298 | "cMun", |
||
1299 | $std->cMun, |
||
1300 | true, |
||
1301 | $identificador . "Código do município do Endereço do Destinatário" |
||
1302 | ); |
||
1303 | $this->dom->addChild( |
||
1304 | $this->enderDest, |
||
1305 | "xMun", |
||
1306 | $std->xMun, |
||
1307 | true, |
||
1308 | $identificador . "Nome do município do Endereço do Destinatário" |
||
1309 | ); |
||
1310 | $this->dom->addChild( |
||
1311 | $this->enderDest, |
||
1312 | "UF", |
||
1313 | $std->UF, |
||
1314 | true, |
||
1315 | $identificador . "Sigla da UF do Endereço do Destinatário" |
||
1316 | ); |
||
1317 | $this->dom->addChild( |
||
1318 | $this->enderDest, |
||
1319 | "CEP", |
||
1320 | $std->CEP, |
||
1321 | false, |
||
1322 | $identificador . "Código do CEP do Endereço do Destinatário" |
||
1323 | ); |
||
1324 | $this->dom->addChild( |
||
1325 | $this->enderDest, |
||
1326 | "cPais", |
||
1327 | $std->cPais, |
||
1328 | false, |
||
1329 | $identificador . "Código do País do Endereço do Destinatário" |
||
1330 | ); |
||
1331 | $this->dom->addChild( |
||
1332 | $this->enderDest, |
||
1333 | "xPais", |
||
1334 | $std->xPais, |
||
1335 | false, |
||
1336 | $identificador . "Nome do País do Endereço do Destinatário" |
||
1337 | ); |
||
1338 | $this->dom->addChild( |
||
1339 | $this->enderDest, |
||
1340 | "fone", |
||
1341 | $std->fone, |
||
1342 | false, |
||
1343 | $identificador . "Telefone do Endereço do Destinatário" |
||
1344 | ); |
||
1345 | $node = $this->dest->getElementsByTagName("indIEDest")->item(0); |
||
1346 | if (!isset($node)) { |
||
1347 | $node = $this->dest->getElementsByTagName("IE")->item(0); |
||
1348 | } |
||
1349 | $this->dest->insertBefore($this->enderDest, $node); |
||
1350 | return $this->enderDest; |
||
1351 | } |
||
1352 | |||
1353 | /** |
||
1354 | * Identificação do Local de retirada F01 pai A01 |
||
1355 | * tag NFe/infNFe/retirada (opcional) |
||
1356 | * NOTA: ajustado para NT 2018.005 |
||
1357 | * @param stdClass $std |
||
1358 | * @return DOMElement |
||
1359 | */ |
||
1360 | public function tagretirada(stdClass $std) |
||
1361 | { |
||
1362 | $possible = [ |
||
1363 | 'xLgr', |
||
1364 | 'nro', |
||
1365 | 'xCpl', |
||
1366 | 'xBairro', |
||
1367 | 'cMun', |
||
1368 | 'xMun', |
||
1369 | 'UF', |
||
1370 | 'CNPJ', |
||
1371 | 'CPF', |
||
1372 | 'xNome', |
||
1373 | 'CEP', |
||
1374 | 'cPais', |
||
1375 | 'xPais', |
||
1376 | 'fone', |
||
1377 | 'email', |
||
1378 | 'IE' |
||
1379 | ]; |
||
1380 | $std = $this->equilizeParameters($std, $possible); |
||
1381 | $identificador = 'F01 <retirada> - '; |
||
1382 | $this->retirada = $this->dom->createElement("retirada"); |
||
1383 | $this->dom->addChild( |
||
1384 | $this->retirada, |
||
1385 | "CNPJ", |
||
1386 | $std->CNPJ, |
||
1387 | false, |
||
1388 | $identificador . "CNPJ do Cliente da Retirada" |
||
1389 | ); |
||
1390 | $this->dom->addChild( |
||
1391 | $this->retirada, |
||
1392 | "CPF", |
||
1393 | $std->CPF, |
||
1394 | false, |
||
1395 | $identificador . "CPF do Cliente da Retirada" |
||
1396 | ); |
||
1397 | $this->dom->addChild( |
||
1398 | $this->retirada, |
||
1399 | "xNome", |
||
1400 | $std->xNome, |
||
1401 | false, |
||
1402 | $identificador . "Nome do Cliente da Retirada" |
||
1403 | ); |
||
1404 | $this->dom->addChild( |
||
1405 | $this->retirada, |
||
1406 | "xLgr", |
||
1407 | $std->xLgr, |
||
1408 | true, |
||
1409 | $identificador . "Logradouro do Endereco do Cliente da Retirada" |
||
1410 | ); |
||
1411 | $this->dom->addChild( |
||
1412 | $this->retirada, |
||
1413 | "nro", |
||
1414 | $std->nro, |
||
1415 | true, |
||
1416 | $identificador . "Número do Endereco do Cliente da Retirada" |
||
1417 | ); |
||
1418 | $this->dom->addChild( |
||
1419 | $this->retirada, |
||
1420 | "xCpl", |
||
1421 | $std->xCpl, |
||
1422 | false, |
||
1423 | $identificador . "Complemento do Endereco do Cliente da Retirada" |
||
1424 | ); |
||
1425 | $this->dom->addChild( |
||
1426 | $this->retirada, |
||
1427 | "xBairro", |
||
1428 | $std->xBairro, |
||
1429 | true, |
||
1430 | $identificador . "Bairro do Endereco do Cliente da Retirada" |
||
1431 | ); |
||
1432 | $this->dom->addChild( |
||
1433 | $this->retirada, |
||
1434 | "cMun", |
||
1435 | $std->cMun, |
||
1436 | true, |
||
1437 | $identificador . "Código do município do Endereco do Cliente da Retirada" |
||
1438 | ); |
||
1439 | $this->dom->addChild( |
||
1440 | $this->retirada, |
||
1441 | "xMun", |
||
1442 | $std->xMun, |
||
1443 | true, |
||
1444 | $identificador . "Nome do município do Endereco do Cliente da Retirada" |
||
1445 | ); |
||
1446 | $this->dom->addChild( |
||
1447 | $this->retirada, |
||
1448 | "UF", |
||
1449 | $std->UF, |
||
1450 | true, |
||
1451 | $identificador . "Sigla da UF do Endereco do Cliente da Retirada" |
||
1452 | ); |
||
1453 | $this->dom->addChild( |
||
1454 | $this->retirada, |
||
1455 | "CEP", |
||
1456 | $std->CEP, |
||
1457 | false, |
||
1458 | $identificador . "CEP do Endereco do Cliente da Retirada" |
||
1459 | ); |
||
1460 | $this->dom->addChild( |
||
1461 | $this->retirada, |
||
1462 | "cPais", |
||
1463 | $std->cPais, |
||
1464 | false, |
||
1465 | $identificador . "Codigo do Pais do Endereco do Cliente da Retirada" |
||
1466 | ); |
||
1467 | $this->dom->addChild( |
||
1468 | $this->retirada, |
||
1469 | "xPais", |
||
1470 | $std->xPais, |
||
1471 | false, |
||
1472 | $identificador . "Pais do Endereco do Cliente da Retirada" |
||
1473 | ); |
||
1474 | $this->dom->addChild( |
||
1475 | $this->retirada, |
||
1476 | "fone", |
||
1477 | $std->fone, |
||
1478 | false, |
||
1479 | $identificador . "Fone do Endereco do Cliente da Retirada" |
||
1480 | ); |
||
1481 | $this->dom->addChild( |
||
1482 | $this->retirada, |
||
1483 | "email", |
||
1484 | $std->email, |
||
1485 | false, |
||
1486 | $identificador . "Email do Endereco do Cliente da Retirada" |
||
1487 | ); |
||
1488 | $this->dom->addChild( |
||
1489 | $this->retirada, |
||
1490 | "IE", |
||
1491 | $std->IE, |
||
1492 | false, |
||
1493 | $identificador . "IE do Cliente da Retirada" |
||
1494 | ); |
||
1495 | return $this->retirada; |
||
1496 | } |
||
1497 | |||
1498 | /** |
||
1499 | * Identificação do Local de entrega G01 pai A01 |
||
1500 | * tag NFe/infNFe/entrega (opcional) |
||
1501 | * NOTA: ajustado para NT 2018.005 |
||
1502 | * @param stdClass $std |
||
1503 | * @return DOMElement |
||
1504 | */ |
||
1505 | public function tagentrega(stdClass $std) |
||
1506 | { |
||
1507 | $possible = [ |
||
1508 | 'xLgr', |
||
1509 | 'nro', |
||
1510 | 'xCpl', |
||
1511 | 'xBairro', |
||
1512 | 'cMun', |
||
1513 | 'xMun', |
||
1514 | 'UF', |
||
1515 | 'CNPJ', |
||
1516 | 'CPF', |
||
1517 | 'xNome', |
||
1518 | 'CEP', |
||
1519 | 'cPais', |
||
1520 | 'xPais', |
||
1521 | 'fone', |
||
1522 | 'email', |
||
1523 | 'IE' |
||
1524 | ]; |
||
1525 | $std = $this->equilizeParameters($std, $possible); |
||
1526 | $identificador = 'G01 <entrega> - '; |
||
1527 | $this->entrega = $this->dom->createElement("entrega"); |
||
1528 | $this->dom->addChild( |
||
1529 | $this->entrega, |
||
1530 | "CNPJ", |
||
1531 | $std->CNPJ, |
||
1532 | false, |
||
1533 | $identificador . "CNPJ do Cliente da Entrega" |
||
1534 | ); |
||
1535 | $this->dom->addChild( |
||
1536 | $this->entrega, |
||
1537 | "CPF", |
||
1538 | $std->CPF, |
||
1539 | false, |
||
1540 | $identificador . "CPF do Cliente da Entrega" |
||
1541 | ); |
||
1542 | $this->dom->addChild( |
||
1543 | $this->entrega, |
||
1544 | "xNome", |
||
1545 | $std->xNome, |
||
1546 | false, |
||
1547 | $identificador . "Nome do Cliente da Entrega" |
||
1548 | ); |
||
1549 | $this->dom->addChild( |
||
1550 | $this->entrega, |
||
1551 | "xLgr", |
||
1552 | $std->xLgr, |
||
1553 | true, |
||
1554 | $identificador . "Logradouro do Endereco do Cliente da Entrega" |
||
1555 | ); |
||
1556 | $this->dom->addChild( |
||
1557 | $this->entrega, |
||
1558 | "nro", |
||
1559 | $std->nro, |
||
1560 | true, |
||
1561 | $identificador . "Número do Endereco do Cliente da Entrega" |
||
1562 | ); |
||
1563 | $this->dom->addChild( |
||
1564 | $this->entrega, |
||
1565 | "xCpl", |
||
1566 | $std->xCpl, |
||
1567 | false, |
||
1568 | $identificador . "Complemento do Endereco do Cliente da Entrega" |
||
1569 | ); |
||
1570 | $this->dom->addChild( |
||
1571 | $this->entrega, |
||
1572 | "xBairro", |
||
1573 | $std->xBairro, |
||
1574 | true, |
||
1575 | $identificador . "Bairro do Endereco do Cliente da Entrega" |
||
1576 | ); |
||
1577 | $this->dom->addChild( |
||
1578 | $this->entrega, |
||
1579 | "cMun", |
||
1580 | $std->cMun, |
||
1581 | true, |
||
1582 | $identificador . "Código do município do Endereco do Cliente da Entrega" |
||
1583 | ); |
||
1584 | $this->dom->addChild( |
||
1585 | $this->entrega, |
||
1586 | "xMun", |
||
1587 | $std->xMun, |
||
1588 | true, |
||
1589 | $identificador . "Nome do município do Endereco do Cliente da Entrega" |
||
1590 | ); |
||
1591 | $this->dom->addChild( |
||
1592 | $this->entrega, |
||
1593 | "UF", |
||
1594 | $std->UF, |
||
1595 | true, |
||
1596 | $identificador . "Sigla da UF do Endereco do Cliente da Entrega" |
||
1597 | ); |
||
1598 | $this->dom->addChild( |
||
1599 | $this->entrega, |
||
1600 | "CEP", |
||
1601 | $std->CEP, |
||
1602 | false, |
||
1603 | $identificador . "CEP do Endereco do Cliente da Entrega" |
||
1604 | ); |
||
1605 | $this->dom->addChild( |
||
1606 | $this->entrega, |
||
1607 | "cPais", |
||
1608 | $std->cPais, |
||
1609 | false, |
||
1610 | $identificador . "Codigo do Pais do Endereco do Cliente da Entrega" |
||
1611 | ); |
||
1612 | $this->dom->addChild( |
||
1613 | $this->entrega, |
||
1614 | "xPais", |
||
1615 | $std->xPais, |
||
1616 | false, |
||
1617 | $identificador . "Pais do Endereco do Cliente da Entrega" |
||
1618 | ); |
||
1619 | $this->dom->addChild( |
||
1620 | $this->entrega, |
||
1621 | "fone", |
||
1622 | $std->fone, |
||
1623 | false, |
||
1624 | $identificador . "Fone do Endereco do Cliente da Entrega" |
||
1625 | ); |
||
1626 | $this->dom->addChild( |
||
1627 | $this->entrega, |
||
1628 | "email", |
||
1629 | $std->email, |
||
1630 | false, |
||
1631 | $identificador . "Email do Endereco do Cliente da Entrega" |
||
1632 | ); |
||
1633 | $this->dom->addChild( |
||
1634 | $this->entrega, |
||
1635 | "IE", |
||
1636 | $std->IE, |
||
1637 | false, |
||
1638 | $identificador . "IE do Cliente da Entrega" |
||
1639 | ); |
||
1640 | return $this->entrega; |
||
1641 | } |
||
1642 | |||
1643 | /** |
||
1644 | * Pessoas autorizadas para o download do XML da NF-e G50 pai A01 |
||
1645 | * tag NFe/infNFe/autXML |
||
1646 | * @param stdClass $std |
||
1647 | * @return DOMElement |
||
1648 | */ |
||
1649 | public function tagautXML(stdClass $std) |
||
1650 | { |
||
1651 | $possible = ['CNPJ', 'CPF']; |
||
1652 | $std = $this->equilizeParameters($std, $possible); |
||
1653 | $identificador = 'G50 <autXML> - '; |
||
1654 | $std->CNPJ = !empty($std->CNPJ) ? $std->CNPJ : null; |
||
1655 | $std->CPF = !empty($std->CPF) ? $std->CPF : null; |
||
1656 | $autXML = $this->dom->createElement("autXML"); |
||
1657 | $this->dom->addChild( |
||
1658 | $autXML, |
||
1659 | "CNPJ", |
||
1660 | $std->CNPJ, |
||
1661 | false, |
||
1662 | $identificador . "CNPJ do Cliente Autorizado" |
||
1663 | ); |
||
1664 | $this->dom->addChild( |
||
1665 | $autXML, |
||
1666 | "CPF", |
||
1667 | $std->CPF, |
||
1668 | false, |
||
1669 | $identificador . "CPF do Cliente Autorizado" |
||
1670 | ); |
||
1671 | $this->aAutXML[] = $autXML; |
||
1672 | return $autXML; |
||
1673 | } |
||
1674 | |||
1675 | /** |
||
1676 | * Informações adicionais do produto V01 pai H01 |
||
1677 | * tag NFe/infNFe/det[]/infAdProd |
||
1678 | * @param stdClass $std |
||
1679 | * @return DOMElement |
||
1680 | */ |
||
1681 | public function taginfAdProd(stdClass $std) |
||
1682 | { |
||
1683 | $possible = ['item', 'infAdProd']; |
||
1684 | $std = $this->equilizeParameters($std, $possible); |
||
1685 | $infAdProd = $this->dom->createElement( |
||
1686 | "infAdProd", |
||
1687 | substr(trim($std->infAdProd), 0, 500) |
||
1688 | ); |
||
1689 | $this->aInfAdProd[$std->item] = $infAdProd; |
||
1690 | return $infAdProd; |
||
1691 | } |
||
1692 | |||
1693 | /** |
||
1694 | * Detalhamento de Produtos e Serviços I01 pai H01 |
||
1695 | * tag NFe/infNFe/det[]/prod |
||
1696 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
1697 | * @param stdClass $std |
||
1698 | * @return DOMElement |
||
1699 | */ |
||
1700 | public function tagprod(stdClass $std) |
||
1701 | { |
||
1702 | $possible = [ |
||
1703 | 'item', |
||
1704 | 'cProd', |
||
1705 | 'cEAN', |
||
1706 | 'xProd', |
||
1707 | 'NCM', |
||
1708 | 'cBenef', |
||
1709 | 'EXTIPI', |
||
1710 | 'CFOP', |
||
1711 | 'uCom', |
||
1712 | 'qCom', |
||
1713 | 'vUnCom', |
||
1714 | 'vProd', |
||
1715 | 'cEANTrib', |
||
1716 | 'uTrib', |
||
1717 | 'qTrib', |
||
1718 | 'vUnTrib', |
||
1719 | 'vFrete', |
||
1720 | 'vSeg', |
||
1721 | 'vDesc', |
||
1722 | 'vOutro', |
||
1723 | 'indTot', |
||
1724 | 'xPed', |
||
1725 | 'nItemPed', |
||
1726 | 'nFCI' |
||
1727 | ]; |
||
1728 | $std = $this->equilizeParameters($std, $possible); |
||
1729 | //totalizador |
||
1730 | if ($std->indTot == 1) { |
||
1731 | $this->stdTot->vProd += (float) $std->vProd; |
||
1732 | } |
||
1733 | $this->stdTot->vFrete += (float) $std->vFrete; |
||
1734 | $this->stdTot->vSeg += (float) $std->vSeg; |
||
1735 | $this->stdTot->vDesc += (float) $std->vDesc; |
||
1736 | $this->stdTot->vOutro += (float) $std->vOutro; |
||
1737 | |||
1738 | $cean = !empty($std->cEAN) ? trim(strtoupper($std->cEAN)) : ''; |
||
1739 | $ceantrib = !empty($std->cEANTrib) ? trim(strtoupper($std->cEANTrib)) : ''; |
||
1740 | //throw exception if not is Valid |
||
1741 | try { |
||
1742 | Gtin::isValid($cean); |
||
1743 | } catch (\InvalidArgumentException $e) { |
||
1744 | $this->errors[] = "cEANT {$cean} " . $e->getMessage(); |
||
1745 | } |
||
1746 | |||
1747 | try { |
||
1748 | Gtin::isValid($ceantrib); |
||
1749 | } catch (\InvalidArgumentException $e) { |
||
1750 | $this->errors[] = "cEANTrib {$ceantrib} " . $e->getMessage(); |
||
1751 | } |
||
1752 | |||
1753 | $identificador = 'I01 <prod> - '; |
||
1754 | $prod = $this->dom->createElement("prod"); |
||
1755 | $this->dom->addChild( |
||
1756 | $prod, |
||
1757 | "cProd", |
||
1758 | $std->cProd, |
||
1759 | true, |
||
1760 | $identificador . "[item $std->item] Código do produto ou serviço" |
||
1761 | ); |
||
1762 | $this->dom->addChild( |
||
1763 | $prod, |
||
1764 | "cEAN", |
||
1765 | $cean, |
||
1766 | true, |
||
1767 | $identificador . "[item $std->item] GTIN (Global Trade Item Number) do produto, antigo " |
||
1768 | . "código EAN ou código de barras", |
||
1769 | true |
||
1770 | ); |
||
1771 | $xProd = $std->xProd; |
||
1772 | if ($this->tpAmb == '2' && $this->mod == '65' && $std->item === 1) { |
||
1773 | $xProd = 'NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
1774 | } |
||
1775 | $this->dom->addChild( |
||
1776 | $prod, |
||
1777 | "xProd", |
||
1778 | $xProd, |
||
1779 | true, |
||
1780 | $identificador . "[item $std->item] Descrição do produto ou serviço" |
||
1781 | ); |
||
1782 | $this->dom->addChild( |
||
1783 | $prod, |
||
1784 | "NCM", |
||
1785 | $std->NCM, |
||
1786 | true, |
||
1787 | $identificador . "[item $std->item] Código NCM com 8 dígitos ou 2 dígitos (gênero)" |
||
1788 | ); |
||
1789 | //incluido no layout 4.00 |
||
1790 | $this->dom->addChild( |
||
1791 | $prod, |
||
1792 | "cBenef", |
||
1793 | $std->cBenef, |
||
1794 | false, |
||
1795 | $identificador . "[item $std->item] Código de Benefício Fiscal utilizado pela UF" |
||
1796 | ); |
||
1797 | $this->dom->addChild( |
||
1798 | $prod, |
||
1799 | "EXTIPI", |
||
1800 | $std->EXTIPI, |
||
1801 | false, |
||
1802 | $identificador . "[item $std->item] Preencher de acordo com o código EX da TIPI" |
||
1803 | ); |
||
1804 | $this->dom->addChild( |
||
1805 | $prod, |
||
1806 | "CFOP", |
||
1807 | $std->CFOP, |
||
1808 | true, |
||
1809 | $identificador . "[item $std->item] Código Fiscal de Operações e Prestações" |
||
1810 | ); |
||
1811 | $this->dom->addChild( |
||
1812 | $prod, |
||
1813 | "uCom", |
||
1814 | $std->uCom, |
||
1815 | true, |
||
1816 | $identificador . "[item $std->item] Unidade Comercial do produto" |
||
1817 | ); |
||
1818 | $this->dom->addChild( |
||
1819 | $prod, |
||
1820 | "qCom", |
||
1821 | $std->qCom, |
||
1822 | true, |
||
1823 | $identificador . "[item $std->item] Quantidade Comercial do produto" |
||
1824 | ); |
||
1825 | $this->dom->addChild( |
||
1826 | $prod, |
||
1827 | "vUnCom", |
||
1828 | $std->vUnCom, |
||
1829 | true, |
||
1830 | $identificador . "[item $std->item] Valor Unitário de Comercialização do produto" |
||
1831 | ); |
||
1832 | $this->dom->addChild( |
||
1833 | $prod, |
||
1834 | "vProd", |
||
1835 | $std->vProd, |
||
1836 | true, |
||
1837 | $identificador . "[item $std->item] Valor Total Bruto dos Produtos ou Serviços" |
||
1838 | ); |
||
1839 | $this->dom->addChild( |
||
1840 | $prod, |
||
1841 | "cEANTrib", |
||
1842 | $ceantrib, |
||
1843 | true, |
||
1844 | $identificador . "[item $std->item] GTIN (Global Trade Item Number) da unidade tributável, antigo " |
||
1845 | . "código EAN ou código de barras", |
||
1846 | true |
||
1847 | ); |
||
1848 | $this->dom->addChild( |
||
1849 | $prod, |
||
1850 | "uTrib", |
||
1851 | $std->uTrib, |
||
1852 | true, |
||
1853 | $identificador . "[item $std->item] Unidade Tributável do produto" |
||
1854 | ); |
||
1855 | $this->dom->addChild( |
||
1856 | $prod, |
||
1857 | "qTrib", |
||
1858 | $std->qTrib, |
||
1859 | true, |
||
1860 | $identificador . "[item $std->item] Quantidade Tributável do produto" |
||
1861 | ); |
||
1862 | $this->dom->addChild( |
||
1863 | $prod, |
||
1864 | "vUnTrib", |
||
1865 | $std->vUnTrib, |
||
1866 | true, |
||
1867 | $identificador . "[item $std->item] Valor Unitário de tributação do produto" |
||
1868 | ); |
||
1869 | $this->dom->addChild( |
||
1870 | $prod, |
||
1871 | "vFrete", |
||
1872 | $this->conditionalNumberFormatting($std->vFrete), |
||
1873 | false, |
||
1874 | $identificador . "[item $std->item] Valor Total do Frete" |
||
1875 | ); |
||
1876 | $this->dom->addChild( |
||
1877 | $prod, |
||
1878 | "vSeg", |
||
1879 | $this->conditionalNumberFormatting($std->vSeg), |
||
1880 | false, |
||
1881 | $identificador . "[item $std->item] Valor Total do Seguro" |
||
1882 | ); |
||
1883 | $this->dom->addChild( |
||
1884 | $prod, |
||
1885 | "vDesc", |
||
1886 | $this->conditionalNumberFormatting($std->vDesc), |
||
1887 | false, |
||
1888 | $identificador . "[item $std->item] Valor do Desconto" |
||
1889 | ); |
||
1890 | $this->dom->addChild( |
||
1891 | $prod, |
||
1892 | "vOutro", |
||
1893 | $this->conditionalNumberFormatting($std->vOutro), |
||
1894 | false, |
||
1895 | $identificador . "[item $std->item] Outras despesas acessórias" |
||
1896 | ); |
||
1897 | $this->dom->addChild( |
||
1898 | $prod, |
||
1899 | "indTot", |
||
1900 | $std->indTot, |
||
1901 | true, |
||
1902 | $identificador . "[item $std->item] Indica se valor do Item (vProd) entra no valor total da NF-e (vProd)" |
||
1903 | ); |
||
1904 | $this->dom->addChild( |
||
1905 | $prod, |
||
1906 | "xPed", |
||
1907 | $std->xPed, |
||
1908 | false, |
||
1909 | $identificador . "[item $std->item] Número do Pedido de Compra" |
||
1910 | ); |
||
1911 | $this->dom->addChild( |
||
1912 | $prod, |
||
1913 | "nItemPed", |
||
1914 | $std->nItemPed, |
||
1915 | false, |
||
1916 | $identificador . "[item $std->item] Item do Pedido de Compra" |
||
1917 | ); |
||
1918 | $this->dom->addChild( |
||
1919 | $prod, |
||
1920 | "nFCI", |
||
1921 | $std->nFCI, |
||
1922 | false, |
||
1923 | $identificador . "[item $std->item] Número de controle da FCI " |
||
1924 | . "Ficha de Conteúdo de Importação" |
||
1925 | ); |
||
1926 | $this->aProd[$std->item] = $prod; |
||
1927 | return $prod; |
||
1928 | } |
||
1929 | |||
1930 | /** |
||
1931 | * NVE NOMENCLATURA DE VALOR ADUANEIRO E ESTATÍSTICA |
||
1932 | * Podem ser até 8 NVE's por item |
||
1933 | * |
||
1934 | * @param stdClass $std |
||
1935 | * @return DOMElement|null |
||
1936 | */ |
||
1937 | public function tagNVE(stdClass $std) |
||
1938 | { |
||
1939 | $possible = ['item', 'NVE']; |
||
1940 | $std = $this->equilizeParameters($std, $possible); |
||
1941 | |||
1942 | if ($std->NVE == '') { |
||
1943 | return null; |
||
1944 | } |
||
1945 | $nve = $this->dom->createElement("NVE", $std->NVE); |
||
1946 | $this->aNVE[$std->item][] = $nve; |
||
1947 | return $nve; |
||
1948 | } |
||
1949 | |||
1950 | /** |
||
1951 | * Código Especificador da Substituição Tributária – CEST, |
||
1952 | * que identifica a mercadoria sujeita aos regimes de substituição |
||
1953 | * tributária e de antecipação do recolhimento do imposto. |
||
1954 | * vide NT2015.003 I05C pai |
||
1955 | * tag NFe/infNFe/det[item]/prod/CEST (opcional) |
||
1956 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
1957 | * @param stdClass $std |
||
1958 | * @return DOMElement |
||
1959 | */ |
||
1960 | public function tagCEST(stdClass $std) |
||
1961 | { |
||
1962 | $possible = ['item', 'CEST', 'indEscala', 'CNPJFab']; |
||
1963 | $std = $this->equilizeParameters($std, $possible); |
||
1964 | $identificador = 'I05b <ctrltST> - '; |
||
1965 | $ctrltST = $this->dom->createElement("ctrltST"); |
||
1966 | $this->dom->addChild( |
||
1967 | $ctrltST, |
||
1968 | "CEST", |
||
1969 | Strings::onlyNumbers($std->CEST), |
||
1970 | true, |
||
1971 | "$identificador [item $std->item] Numero CEST" |
||
1972 | ); |
||
1973 | //incluido no layout 4.00 |
||
1974 | $this->dom->addChild( |
||
1975 | $ctrltST, |
||
1976 | "indEscala", |
||
1977 | trim($std->indEscala), |
||
1978 | false, |
||
1979 | "$identificador [item $std->item] Indicador de Produção em escala relevante" |
||
1980 | ); |
||
1981 | //incluido no layout 4.00 |
||
1982 | $this->dom->addChild( |
||
1983 | $ctrltST, |
||
1984 | "CNPJFab", |
||
1985 | Strings::onlyNumbers($std->CNPJFab), |
||
1986 | false, |
||
1987 | "$identificador [item $std->item] CNPJ do Fabricante da Mercadoria," |
||
1988 | . "obrigatório para produto em escala NÃO relevante." |
||
1989 | ); |
||
1990 | $this->aCest[$std->item][] = $ctrltST; |
||
1991 | return $ctrltST; |
||
1992 | } |
||
1993 | |||
1994 | /** |
||
1995 | * tag NFe/infNFe/det[item]/prod/nRECOPI |
||
1996 | * @param stdClass $std |
||
1997 | * @return DOMElement |
||
1998 | */ |
||
1999 | public function tagRECOPI(stdClass $std) |
||
2000 | { |
||
2001 | $possible = ['item', 'nRECOPI']; |
||
2002 | $std = $this->equilizeParameters($std, $possible); |
||
2003 | $recopi = $this->dom->createElement("nRECOPI", $std->nRECOPI); |
||
2004 | $this->aRECOPI[$std->item] = $recopi; |
||
2005 | return $recopi; |
||
2006 | } |
||
2007 | |||
2008 | /** |
||
2009 | * Declaração de Importação I8 pai I01 |
||
2010 | * tag NFe/infNFe/det[]/prod/DI |
||
2011 | * @param stdClass $std |
||
2012 | * @return DOMElement |
||
2013 | */ |
||
2014 | public function tagDI(stdClass $std) |
||
2015 | { |
||
2016 | $possible = [ |
||
2017 | 'item', |
||
2018 | 'nDI', |
||
2019 | 'dDI', |
||
2020 | 'xLocDesemb', |
||
2021 | 'UFDesemb', |
||
2022 | 'dDesemb', |
||
2023 | 'tpViaTransp', |
||
2024 | 'vAFRMM', |
||
2025 | 'tpIntermedio', |
||
2026 | 'CNPJ', |
||
2027 | 'UFTerceiro', |
||
2028 | 'cExportador' |
||
2029 | ]; |
||
2030 | $std = $this->equilizeParameters($std, $possible); |
||
2031 | $identificador = 'I8 <DI> - '; |
||
2032 | $tDI = $this->dom->createElement("DI"); |
||
2033 | $this->dom->addChild( |
||
2034 | $tDI, |
||
2035 | "nDI", |
||
2036 | $std->nDI, |
||
2037 | true, |
||
2038 | $identificador . "[item $std->item] Número do Documento de Importação (DI, DSI, DIRE, ...)" |
||
2039 | ); |
||
2040 | $this->dom->addChild( |
||
2041 | $tDI, |
||
2042 | "dDI", |
||
2043 | $std->dDI, |
||
2044 | true, |
||
2045 | $identificador . "[item $std->item] Data de Registro do documento" |
||
2046 | ); |
||
2047 | $this->dom->addChild( |
||
2048 | $tDI, |
||
2049 | "xLocDesemb", |
||
2050 | $std->xLocDesemb, |
||
2051 | true, |
||
2052 | $identificador . "[item $std->item] Local de desembaraço" |
||
2053 | ); |
||
2054 | $this->dom->addChild( |
||
2055 | $tDI, |
||
2056 | "UFDesemb", |
||
2057 | $std->UFDesemb, |
||
2058 | true, |
||
2059 | $identificador . "[item $std->item] Sigla da UF onde ocorreu o Desembaraço Aduaneiro" |
||
2060 | ); |
||
2061 | $this->dom->addChild( |
||
2062 | $tDI, |
||
2063 | "dDesemb", |
||
2064 | $std->dDesemb, |
||
2065 | true, |
||
2066 | $identificador . "[item $std->item] Data do Desembaraço Aduaneiro" |
||
2067 | ); |
||
2068 | $this->dom->addChild( |
||
2069 | $tDI, |
||
2070 | "tpViaTransp", |
||
2071 | $std->tpViaTransp, |
||
2072 | true, |
||
2073 | $identificador . "[item $std->item] Via de transporte internacional " |
||
2074 | . "informada na Declaração de Importação (DI)" |
||
2075 | ); |
||
2076 | $this->dom->addChild( |
||
2077 | $tDI, |
||
2078 | "vAFRMM", |
||
2079 | $this->conditionalNumberFormatting($std->vAFRMM), |
||
2080 | false, |
||
2081 | $identificador . "[item $std->item] Valor da AFRMM " |
||
2082 | . "- Adicional ao Frete para Renovação da Marinha Mercante" |
||
2083 | ); |
||
2084 | $this->dom->addChild( |
||
2085 | $tDI, |
||
2086 | "tpIntermedio", |
||
2087 | $std->tpIntermedio, |
||
2088 | true, |
||
2089 | $identificador . "[item $std->item] Forma de importação quanto a intermediação" |
||
2090 | ); |
||
2091 | $this->dom->addChild( |
||
2092 | $tDI, |
||
2093 | "CNPJ", |
||
2094 | $std->CNPJ, |
||
2095 | false, |
||
2096 | $identificador . "[item $std->item] CNPJ do adquirente ou do encomendante" |
||
2097 | ); |
||
2098 | $this->dom->addChild( |
||
2099 | $tDI, |
||
2100 | "UFTerceiro", |
||
2101 | $std->UFTerceiro, |
||
2102 | false, |
||
2103 | $identificador . "[item $std->item] Sigla da UF do adquirente ou do encomendante" |
||
2104 | ); |
||
2105 | $this->dom->addChild( |
||
2106 | $tDI, |
||
2107 | "cExportador", |
||
2108 | $std->cExportador, |
||
2109 | true, |
||
2110 | $identificador . "[item $std->item] Código do Exportador" |
||
2111 | ); |
||
2112 | $this->aDI[$std->item][$std->nDI] = $tDI; |
||
2113 | return $tDI; |
||
2114 | } |
||
2115 | |||
2116 | /** |
||
2117 | * Adições I25 pai I18 |
||
2118 | * tag NFe/infNFe/det[]/prod/DI/adi |
||
2119 | * @param stdClass $std |
||
2120 | * @return DOMElement |
||
2121 | */ |
||
2122 | public function tagadi(stdClass $std) |
||
2123 | { |
||
2124 | $possible = [ |
||
2125 | 'item', |
||
2126 | 'nDI', |
||
2127 | 'nAdicao', |
||
2128 | 'nSeqAdic', |
||
2129 | 'cFabricante', |
||
2130 | 'vDescDI', |
||
2131 | 'nDraw' |
||
2132 | ]; |
||
2133 | $std = $this->equilizeParameters($std, $possible); |
||
2134 | $identificador = 'I25 <adi> - '; |
||
2135 | $adi = $this->dom->createElement("adi"); |
||
2136 | $this->dom->addChild( |
||
2137 | $adi, |
||
2138 | "nAdicao", |
||
2139 | $std->nAdicao, |
||
2140 | true, |
||
2141 | $identificador . "[item $std->item] Número da Adição" |
||
2142 | ); |
||
2143 | $this->dom->addChild( |
||
2144 | $adi, |
||
2145 | "nSeqAdic", |
||
2146 | $std->nSeqAdic, |
||
2147 | true, |
||
2148 | $identificador . "[item $std->item] Número sequencial do item dentro da Adição" |
||
2149 | ); |
||
2150 | $this->dom->addChild( |
||
2151 | $adi, |
||
2152 | "cFabricante", |
||
2153 | $std->cFabricante, |
||
2154 | true, |
||
2155 | $identificador . "[item $std->item] Código do fabricante estrangeiro" |
||
2156 | ); |
||
2157 | $this->dom->addChild( |
||
2158 | $adi, |
||
2159 | "vDescDI", |
||
2160 | $this->conditionalNumberFormatting($std->vDescDI), |
||
2161 | false, |
||
2162 | $identificador . "[item $std->item] Valor do desconto do item da DI Adição" |
||
2163 | ); |
||
2164 | $this->dom->addChild( |
||
2165 | $adi, |
||
2166 | "nDraw", |
||
2167 | $std->nDraw, |
||
2168 | false, |
||
2169 | $identificador . "[item $std->item] Número do ato concessório de Drawback" |
||
2170 | ); |
||
2171 | $this->aAdi[$std->item][$std->nDI][] = $adi; |
||
2172 | //colocar a adi em seu DI respectivo |
||
2173 | $nodeDI = $this->aDI[$std->item][$std->nDI]; |
||
2174 | $this->dom->appChild($nodeDI, $adi); |
||
2175 | $this->aDI[$std->item][$std->nDI] = $nodeDI; |
||
2176 | return $adi; |
||
2177 | } |
||
2178 | |||
2179 | /** |
||
2180 | * Grupo de informações de exportação para o item I50 pai I01 |
||
2181 | * tag NFe/infNFe/det[]/prod/detExport |
||
2182 | * @param stdClass $std |
||
2183 | * @return DOMElement |
||
2184 | */ |
||
2185 | public function tagdetExport(stdClass $std) |
||
2186 | { |
||
2187 | $possible = [ |
||
2188 | 'item', |
||
2189 | 'nDraw' |
||
2190 | ]; |
||
2191 | $std = $this->equilizeParameters($std, $possible); |
||
2192 | $identificador = 'I50 <detExport> - '; |
||
2193 | $detExport = $this->dom->createElement("detExport"); |
||
2194 | $this->dom->addChild( |
||
2195 | $detExport, |
||
2196 | "nDraw", |
||
2197 | Strings::onlyNumbers($std->nDraw), |
||
2198 | false, |
||
2199 | $identificador . "[item $std->item] Número do ato concessório de Drawback" |
||
2200 | ); |
||
2201 | $this->aDetExport[$std->item][] = $detExport; |
||
2202 | return $detExport; |
||
2203 | } |
||
2204 | |||
2205 | /** |
||
2206 | * Grupo de informações de exportação para o item I52 pai I52 |
||
2207 | * tag NFe/infNFe/det[]/prod/detExport |
||
2208 | * @param stdClass $std |
||
2209 | * @return DOMElement |
||
2210 | */ |
||
2211 | public function tagdetExportInd(stdClass $std) |
||
2212 | { |
||
2213 | $possible = [ |
||
2214 | 'item', |
||
2215 | 'nRE', |
||
2216 | 'chNFe', |
||
2217 | 'qExport' |
||
2218 | ]; |
||
2219 | $std = $this->equilizeParameters($std, $possible); |
||
2220 | $identificador = 'I52 <exportInd> - '; |
||
2221 | $exportInd = $this->dom->createElement("exportInd"); |
||
2222 | $this->dom->addChild( |
||
2223 | $exportInd, |
||
2224 | "nRE", |
||
2225 | Strings::onlyNumbers($std->nRE), |
||
2226 | true, |
||
2227 | $identificador . "[item $std->item] Número do Registro de Exportação" |
||
2228 | ); |
||
2229 | $this->dom->addChild( |
||
2230 | $exportInd, |
||
2231 | "chNFe", |
||
2232 | Strings::onlyNumbers($std->chNFe), |
||
2233 | true, |
||
2234 | $identificador . "[item $std->item] Chave de Acesso da NF-e recebida para exportação" |
||
2235 | ); |
||
2236 | $this->dom->addChild( |
||
2237 | $exportInd, |
||
2238 | "qExport", |
||
2239 | $this->conditionalNumberFormatting($std->qExport, 4), |
||
2240 | true, |
||
2241 | $identificador . "[item $std->item] Quantidade do item realmente exportado" |
||
2242 | ); |
||
2243 | //obtem o ultimo detExport |
||
2244 | $nDE = count($this->aDetExport[$std->item]) - 1; |
||
2245 | if ($nDE < 0) { |
||
2246 | throw new RuntimeException('A TAG detExportInd deve ser criada depois da detExport, pois pertence a ela.'); |
||
2247 | } |
||
2248 | //colocar a exportInd em seu DetExport respectivo |
||
2249 | $nodeDetExport = $this->aDetExport[$std->item][$nDE]; |
||
2250 | $this->dom->appChild($nodeDetExport, $exportInd); |
||
2251 | $this->aDetExport[$std->item][$nDE] = $nodeDetExport; |
||
2252 | return $exportInd; |
||
2253 | } |
||
2254 | |||
2255 | /** |
||
2256 | * Rastreabilidade do produto podem ser até 500 por item TAG I80 pai I01 |
||
2257 | * NOTA: Ajustado para NT2016_002_v1.00 |
||
2258 | * tag NFe/infNFe/det[]/prod/rastro |
||
2259 | * @param stdClass $std |
||
2260 | * @return DOMElement |
||
2261 | */ |
||
2262 | public function tagRastro(stdClass $std) |
||
2263 | { |
||
2264 | $possible = [ |
||
2265 | 'item', |
||
2266 | 'nLote', |
||
2267 | 'qLote', |
||
2268 | 'dFab', |
||
2269 | 'dVal', |
||
2270 | 'cAgreg' |
||
2271 | ]; |
||
2272 | $std = $this->equilizeParameters($std, $possible); |
||
2273 | $identificador = 'I80 <rastro> - '; |
||
2274 | $rastro = $this->dom->createElement("rastro"); |
||
2275 | $this->dom->addChild( |
||
2276 | $rastro, |
||
2277 | "nLote", |
||
2278 | substr(trim($std->nLote), 0, 20), |
||
2279 | true, |
||
2280 | $identificador . "[item $std->item] Número do lote" |
||
2281 | ); |
||
2282 | $this->dom->addChild( |
||
2283 | $rastro, |
||
2284 | "qLote", |
||
2285 | $this->conditionalNumberFormatting($std->qLote, 3), |
||
2286 | true, |
||
2287 | $identificador . "[item $std->item] Quantidade do lote" |
||
2288 | ); |
||
2289 | $this->dom->addChild( |
||
2290 | $rastro, |
||
2291 | "dFab", |
||
2292 | trim($std->dFab), |
||
2293 | true, |
||
2294 | $identificador . "[item $std->item] Data de fabricação" |
||
2295 | ); |
||
2296 | $this->dom->addChild( |
||
2297 | $rastro, |
||
2298 | "dVal", |
||
2299 | trim($std->dVal), |
||
2300 | true, |
||
2301 | $identificador . "[item $std->item] Data da validade" |
||
2302 | ); |
||
2303 | $this->dom->addChild( |
||
2304 | $rastro, |
||
2305 | "cAgreg", |
||
2306 | Strings::onlyNumbers($std->cAgreg), |
||
2307 | false, |
||
2308 | $identificador . "[item $std->item] Código de Agregação" |
||
2309 | ); |
||
2310 | $this->aRastro[$std->item][] = $rastro; |
||
2311 | return $rastro; |
||
2312 | } |
||
2313 | |||
2314 | /** |
||
2315 | * Detalhamento de Veículos novos J01 pai I90 |
||
2316 | * tag NFe/infNFe/det[]/prod/veicProd (opcional) |
||
2317 | * @param stdClass $std |
||
2318 | * @return DOMElement |
||
2319 | */ |
||
2320 | public function tagveicProd(stdClass $std) |
||
2321 | { |
||
2322 | $possible = [ |
||
2323 | 'item', |
||
2324 | 'tpOp', |
||
2325 | 'chassi', |
||
2326 | 'cCor', |
||
2327 | 'xCor', |
||
2328 | 'pot', |
||
2329 | 'cilin', |
||
2330 | 'pesoL', |
||
2331 | 'pesoB', |
||
2332 | 'nSerie', |
||
2333 | 'tpComb', |
||
2334 | 'nMotor', |
||
2335 | 'CMT', |
||
2336 | 'dist', |
||
2337 | 'anoMod', |
||
2338 | 'anoFab', |
||
2339 | 'tpPint', |
||
2340 | 'tpVeic', |
||
2341 | 'espVeic', |
||
2342 | 'VIN', |
||
2343 | 'condVeic', |
||
2344 | 'cMod', |
||
2345 | 'cCorDENATRAN', |
||
2346 | 'lota', |
||
2347 | 'tpRest' |
||
2348 | ]; |
||
2349 | $std = $this->equilizeParameters($std, $possible); |
||
2350 | $identificador = 'J01 <veicProd> - '; |
||
2351 | $veicProd = $this->dom->createElement("veicProd"); |
||
2352 | $this->dom->addChild( |
||
2353 | $veicProd, |
||
2354 | "tpOp", |
||
2355 | $std->tpOp, |
||
2356 | true, |
||
2357 | "$identificador [item $std->item] Tipo da operação do veículo" |
||
2358 | ); |
||
2359 | $this->dom->addChild( |
||
2360 | $veicProd, |
||
2361 | "chassi", |
||
2362 | $std->chassi, |
||
2363 | true, |
||
2364 | "$identificador [item $std->item] Chassi do veículo" |
||
2365 | ); |
||
2366 | $this->dom->addChild( |
||
2367 | $veicProd, |
||
2368 | "cCor", |
||
2369 | $std->cCor, |
||
2370 | true, |
||
2371 | "$identificador [item $std->item] Cor do veículo" |
||
2372 | ); |
||
2373 | $this->dom->addChild( |
||
2374 | $veicProd, |
||
2375 | "xCor", |
||
2376 | $std->xCor, |
||
2377 | true, |
||
2378 | "$identificador [item $std->item] Descrição da Cor do veículo" |
||
2379 | ); |
||
2380 | $this->dom->addChild( |
||
2381 | $veicProd, |
||
2382 | "pot", |
||
2383 | $std->pot, |
||
2384 | true, |
||
2385 | "$identificador [item $std->item] Potência Motor (CV) do veículo" |
||
2386 | ); |
||
2387 | $this->dom->addChild( |
||
2388 | $veicProd, |
||
2389 | "cilin", |
||
2390 | $std->cilin, |
||
2391 | true, |
||
2392 | "$identificador [item $std->item] Cilindradas do veículo" |
||
2393 | ); |
||
2394 | $this->dom->addChild( |
||
2395 | $veicProd, |
||
2396 | "pesoL", |
||
2397 | $this->conditionalNumberFormatting($std->pesoL, 3), |
||
2398 | true, |
||
2399 | "$identificador [item $std->item] Peso Líquido do veículo" |
||
2400 | ); |
||
2401 | $this->dom->addChild( |
||
2402 | $veicProd, |
||
2403 | "pesoB", |
||
2404 | $this->conditionalNumberFormatting($std->pesoB, 3), |
||
2405 | true, |
||
2406 | "$identificador [item $std->item] Peso Bruto do veículo" |
||
2407 | ); |
||
2408 | $this->dom->addChild( |
||
2409 | $veicProd, |
||
2410 | "nSerie", |
||
2411 | $std->nSerie, |
||
2412 | true, |
||
2413 | "$identificador [item $std->item] Serial (série) do veículo" |
||
2414 | ); |
||
2415 | $this->dom->addChild( |
||
2416 | $veicProd, |
||
2417 | "tpComb", |
||
2418 | $std->tpComb, |
||
2419 | true, |
||
2420 | "$identificador [item $std->item] Tipo de combustível do veículo" |
||
2421 | ); |
||
2422 | $this->dom->addChild( |
||
2423 | $veicProd, |
||
2424 | "nMotor", |
||
2425 | $std->nMotor, |
||
2426 | true, |
||
2427 | "$identificador [item $std->item] Número de Motor do veículo" |
||
2428 | ); |
||
2429 | $this->dom->addChild( |
||
2430 | $veicProd, |
||
2431 | "CMT", |
||
2432 | $this->conditionalNumberFormatting($std->CMT, 4), |
||
2433 | true, |
||
2434 | "$identificador [item $std->item] Capacidade Máxima de Tração do veículo" |
||
2435 | ); |
||
2436 | $this->dom->addChild( |
||
2437 | $veicProd, |
||
2438 | "dist", |
||
2439 | $std->dist, |
||
2440 | true, |
||
2441 | "$identificador [item $std->item] Distância entre eixos do veículo" |
||
2442 | ); |
||
2443 | $this->dom->addChild( |
||
2444 | $veicProd, |
||
2445 | "anoMod", |
||
2446 | $std->anoMod, |
||
2447 | true, |
||
2448 | "$identificador [item $std->item] Ano Modelo de Fabricação do veículo" |
||
2449 | ); |
||
2450 | $this->dom->addChild( |
||
2451 | $veicProd, |
||
2452 | "anoFab", |
||
2453 | $std->anoFab, |
||
2454 | true, |
||
2455 | "$identificador [item $std->item] Ano de Fabricação do veículo" |
||
2456 | ); |
||
2457 | $this->dom->addChild( |
||
2458 | $veicProd, |
||
2459 | "tpPint", |
||
2460 | $std->tpPint, |
||
2461 | true, |
||
2462 | "$identificador [item $std->item] Tipo de Pintura do veículo" |
||
2463 | ); |
||
2464 | $this->dom->addChild( |
||
2465 | $veicProd, |
||
2466 | "tpVeic", |
||
2467 | $std->tpVeic, |
||
2468 | true, |
||
2469 | "$identificador [item $std->item] Tipo de Veículo" |
||
2470 | ); |
||
2471 | $this->dom->addChild( |
||
2472 | $veicProd, |
||
2473 | "espVeic", |
||
2474 | $std->espVeic, |
||
2475 | true, |
||
2476 | "$identificador [item $std->item] Espécie de Veículo" |
||
2477 | ); |
||
2478 | $this->dom->addChild( |
||
2479 | $veicProd, |
||
2480 | "VIN", |
||
2481 | $std->VIN, |
||
2482 | true, |
||
2483 | "$identificador [item $std->item] Condição do VIN do veículo" |
||
2484 | ); |
||
2485 | $this->dom->addChild( |
||
2486 | $veicProd, |
||
2487 | "condVeic", |
||
2488 | $std->condVeic, |
||
2489 | true, |
||
2490 | "$identificador [item $std->item] Condição do Veículo" |
||
2491 | ); |
||
2492 | $this->dom->addChild( |
||
2493 | $veicProd, |
||
2494 | "cMod", |
||
2495 | $std->cMod, |
||
2496 | true, |
||
2497 | "$identificador [item $std->item] Código Marca Modelo do veículo" |
||
2498 | ); |
||
2499 | $this->dom->addChild( |
||
2500 | $veicProd, |
||
2501 | "cCorDENATRAN", |
||
2502 | $std->cCorDENATRAN, |
||
2503 | true, |
||
2504 | "$identificador [item $std->item] Código da Cor do veículo" |
||
2505 | ); |
||
2506 | $this->dom->addChild( |
||
2507 | $veicProd, |
||
2508 | "lota", |
||
2509 | $std->lota, |
||
2510 | true, |
||
2511 | "$identificador [item $std->item] Capacidade máxima de lotação do veículo" |
||
2512 | ); |
||
2513 | $this->dom->addChild( |
||
2514 | $veicProd, |
||
2515 | "tpRest", |
||
2516 | $std->tpRest, |
||
2517 | true, |
||
2518 | "$identificador [item $std->item] Restrição do veículo" |
||
2519 | ); |
||
2520 | $this->aVeicProd[$std->item] = $veicProd; |
||
2521 | return $veicProd; |
||
2522 | } |
||
2523 | |||
2524 | /** |
||
2525 | * Detalhamento de medicamentos K01 pai I90 |
||
2526 | * NOTA: Ajustado para NT2018.005 |
||
2527 | * tag NFe/infNFe/det[]/prod/med (opcional) |
||
2528 | * @param stdClass $std |
||
2529 | * @return DOMElement |
||
2530 | */ |
||
2531 | public function tagmed(stdClass $std) |
||
2532 | { |
||
2533 | $possible = [ |
||
2534 | 'item', |
||
2535 | 'vPMC', |
||
2536 | 'cProdANVISA', |
||
2537 | 'xMotivoIsencao' |
||
2538 | ]; |
||
2539 | $std = $this->equilizeParameters($std, $possible); |
||
2540 | $identificador = 'K01 <med> - '; |
||
2541 | $med = $this->dom->createElement("med"); |
||
2542 | $this->dom->addChild( |
||
2543 | $med, |
||
2544 | "cProdANVISA", |
||
2545 | $std->cProdANVISA, |
||
2546 | false, |
||
2547 | "$identificador [item $std->item] Numero ANVISA" |
||
2548 | ); |
||
2549 | $this->dom->addChild( |
||
2550 | $med, |
||
2551 | "xMotivoIsencao", |
||
2552 | $std->xMotivoIsencao, |
||
2553 | false, |
||
2554 | "$identificador [item $std->item] Motivo da isenção da ANVISA" |
||
2555 | ); |
||
2556 | $this->dom->addChild( |
||
2557 | $med, |
||
2558 | "vPMC", |
||
2559 | $this->conditionalNumberFormatting($std->vPMC), |
||
2560 | true, |
||
2561 | "$identificador [item $std->item] Preço máximo consumidor" |
||
2562 | ); |
||
2563 | $this->aMed[$std->item] = $med; |
||
2564 | return $med; |
||
2565 | } |
||
2566 | |||
2567 | /** |
||
2568 | * Detalhamento de armas L01 pai I90 |
||
2569 | * tag NFe/infNFe/det[]/prod/arma (opcional) |
||
2570 | * @param stdClass $std |
||
2571 | * @return DOMElement |
||
2572 | */ |
||
2573 | public function tagarma(stdClass $std) |
||
2574 | { |
||
2575 | $possible = [ |
||
2576 | 'item', |
||
2577 | 'nAR', |
||
2578 | 'tpArma', |
||
2579 | 'nSerie', |
||
2580 | 'nCano', |
||
2581 | 'descr' |
||
2582 | ]; |
||
2583 | $std = $this->equilizeParameters($std, $possible); |
||
2584 | $identificador = 'L01 <arma> - '; |
||
2585 | $arma = $this->dom->createElement("arma"); |
||
2586 | $this->dom->addChild( |
||
2587 | $arma, |
||
2588 | "tpArma", |
||
2589 | $std->tpArma, |
||
2590 | true, |
||
2591 | "$identificador [item $std->item] Indicador do tipo de arma de fogo" |
||
2592 | ); |
||
2593 | $this->dom->addChild( |
||
2594 | $arma, |
||
2595 | "nSerie", |
||
2596 | $std->nSerie, |
||
2597 | true, |
||
2598 | "$identificador [item $std->item] Número de série da arma" |
||
2599 | ); |
||
2600 | $this->dom->addChild( |
||
2601 | $arma, |
||
2602 | "nCano", |
||
2603 | $std->nCano, |
||
2604 | true, |
||
2605 | "$identificador [item $std->item] Número de série do cano" |
||
2606 | ); |
||
2607 | $this->dom->addChild( |
||
2608 | $arma, |
||
2609 | "descr", |
||
2610 | $std->descr, |
||
2611 | true, |
||
2612 | "$identificador [item $std->item] Descrição completa da arma, compreendendo: calibre, marca, capacidade, " |
||
2613 | . "tipo de funcionamento, comprimento e demais elementos que " |
||
2614 | . "permitam a sua perfeita identificação." |
||
2615 | ); |
||
2616 | $this->aArma[$std->item][$std->nAR] = $arma; |
||
2617 | return $arma; |
||
2618 | } |
||
2619 | |||
2620 | /** |
||
2621 | * Detalhamento de combustiveis L101 pai I90 |
||
2622 | * tag NFe/infNFe/det[]/prod/comb (opcional) |
||
2623 | * LA|cProdANP|pMixGN|CODIF|qTemp|UFCons| |
||
2624 | * |
||
2625 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
2626 | * LA|cProdANP|descANP|pGLP|pGNn|pGNi|vPart|CODIF|qTemp|UFCons| |
||
2627 | * @param stdClass $std |
||
2628 | * @return DOMElement |
||
2629 | */ |
||
2630 | public function tagcomb(stdClass $std) |
||
2631 | { |
||
2632 | $possible = [ |
||
2633 | 'item', |
||
2634 | 'cProdANP', |
||
2635 | 'descANP', |
||
2636 | 'pGLP', |
||
2637 | 'pGNn', |
||
2638 | 'pGNi', |
||
2639 | 'vPart', |
||
2640 | 'CODIF', |
||
2641 | 'qTemp', |
||
2642 | 'UFCons', |
||
2643 | 'qBCProd', |
||
2644 | 'vAliqProd', |
||
2645 | 'vCIDE' |
||
2646 | ]; |
||
2647 | $std = $this->equilizeParameters($std, $possible); |
||
2648 | |||
2649 | $identificador = 'L101 <comb> - '; |
||
2650 | $comb = $this->dom->createElement("comb"); |
||
2651 | $this->dom->addChild( |
||
2652 | $comb, |
||
2653 | "cProdANP", |
||
2654 | $std->cProdANP, |
||
2655 | true, |
||
2656 | "$identificador [item $std->item] Código de produto da ANP" |
||
2657 | ); |
||
2658 | //incluso no layout 4.00 |
||
2659 | $this->dom->addChild( |
||
2660 | $comb, |
||
2661 | "descANP", |
||
2662 | $std->descANP, |
||
2663 | false, |
||
2664 | "$identificador [item $std->item] Utilizar a descrição de produtos do " |
||
2665 | . "Sistema de Informações de Movimentação de Produtos - " |
||
2666 | . "SIMP (http://www.anp.gov.br/simp/" |
||
2667 | ); |
||
2668 | //incluso no layout 4.00 |
||
2669 | $this->dom->addChild( |
||
2670 | $comb, |
||
2671 | "pGLP", |
||
2672 | $this->conditionalNumberFormatting($std->pGLP, 4), |
||
2673 | false, |
||
2674 | "$identificador [item $std->item] Percentual do GLP derivado do " |
||
2675 | . "petróleo no produto GLP (cProdANP=210203001) 1v4" |
||
2676 | ); |
||
2677 | //incluso no layout 4.00 |
||
2678 | $this->dom->addChild( |
||
2679 | $comb, |
||
2680 | "pGNn", |
||
2681 | $this->conditionalNumberFormatting($std->pGNn, 4), |
||
2682 | false, |
||
2683 | "$identificador [item $std->item] Percentual de Gás Natural Nacional" |
||
2684 | . " – GLGNn para o produto GLP (cProdANP=210203001) 1v4" |
||
2685 | ); |
||
2686 | //incluso no layout 4.00 |
||
2687 | $this->dom->addChild( |
||
2688 | $comb, |
||
2689 | "pGNi", |
||
2690 | $this->conditionalNumberFormatting($std->pGNi, 4), |
||
2691 | false, |
||
2692 | "$identificador [item $std->item] Percentual de Gás Natural Importado" |
||
2693 | . " – GLGNi para o produto GLP (cProdANP=210203001) 1v4" |
||
2694 | ); |
||
2695 | //incluso no layout 4.00 |
||
2696 | $this->dom->addChild( |
||
2697 | $comb, |
||
2698 | "vPart", |
||
2699 | $this->conditionalNumberFormatting($std->vPart), |
||
2700 | false, |
||
2701 | "$identificador [item $std->item] Valor de partida (cProdANP=210203001) " |
||
2702 | ); |
||
2703 | $this->dom->addChild( |
||
2704 | $comb, |
||
2705 | "CODIF", |
||
2706 | $std->CODIF, |
||
2707 | false, |
||
2708 | "[item $std->item] Código de autorização / registro do CODIF" |
||
2709 | ); |
||
2710 | $this->dom->addChild( |
||
2711 | $comb, |
||
2712 | "qTemp", |
||
2713 | $this->conditionalNumberFormatting($std->qTemp, 4), |
||
2714 | false, |
||
2715 | "$identificador [item $std->item] Quantidade de combustível faturada à temperatura ambiente." |
||
2716 | ); |
||
2717 | $this->dom->addChild( |
||
2718 | $comb, |
||
2719 | "UFCons", |
||
2720 | $std->UFCons, |
||
2721 | true, |
||
2722 | "[item $std->item] Sigla da UF de consumo" |
||
2723 | ); |
||
2724 | if ($std->qBCProd != "") { |
||
2725 | $tagCIDE = $this->dom->createElement("CIDE"); |
||
2726 | $this->dom->addChild( |
||
2727 | $tagCIDE, |
||
2728 | "qBCProd", |
||
2729 | $std->qBCProd, |
||
2730 | true, |
||
2731 | "$identificador [item $std->item] BC da CIDE" |
||
2732 | ); |
||
2733 | $this->dom->addChild( |
||
2734 | $tagCIDE, |
||
2735 | "vAliqProd", |
||
2736 | $this->conditionalNumberFormatting($std->vAliqProd, 4), |
||
2737 | true, |
||
2738 | "$identificador [item $std->item] Valor da alíquota da CIDE" |
||
2739 | ); |
||
2740 | $this->dom->addChild( |
||
2741 | $tagCIDE, |
||
2742 | "vCIDE", |
||
2743 | $this->conditionalNumberFormatting($std->vCIDE), |
||
2744 | true, |
||
2745 | "$identificador [item $std->item] Valor da CIDE" |
||
2746 | ); |
||
2747 | $this->dom->appChild($comb, $tagCIDE); |
||
2748 | } |
||
2749 | $this->aComb[$std->item] = $comb; |
||
2750 | return $comb; |
||
2751 | } |
||
2752 | |||
2753 | /** |
||
2754 | * informações relacionadas com as operações de combustíveis, subgrupo de |
||
2755 | * encerrante que permite o controle sobre as operações de venda de combustíveis |
||
2756 | * LA11 pai LA01 |
||
2757 | * tag NFe/infNFe/det[]/prod/comb/encerrante (opcional) |
||
2758 | * @param stdClass $std |
||
2759 | * @return DOMElement |
||
2760 | */ |
||
2761 | public function tagencerrante(stdClass $std) |
||
2762 | { |
||
2763 | $possible = [ |
||
2764 | 'item', |
||
2765 | 'nBico', |
||
2766 | 'nBomba', |
||
2767 | 'nTanque', |
||
2768 | 'vEncIni', |
||
2769 | 'vEncFin' |
||
2770 | ]; |
||
2771 | $std = $this->equilizeParameters($std, $possible); |
||
2772 | $identificador = 'LA11 <encerrante> - '; |
||
2773 | $encerrante = $this->dom->createElement("encerrante"); |
||
2774 | $this->dom->addChild( |
||
2775 | $encerrante, |
||
2776 | "nBico", |
||
2777 | $std->nBico, |
||
2778 | true, |
||
2779 | "$identificador [item $std->item] Número de identificação do bico utilizado no abastecimento" |
||
2780 | ); |
||
2781 | $this->dom->addChild( |
||
2782 | $encerrante, |
||
2783 | "nBomba", |
||
2784 | $std->nBomba, |
||
2785 | false, |
||
2786 | "$identificador [item $std->item] Número de identificação da bomba ao qual o bico está interligado" |
||
2787 | ); |
||
2788 | $this->dom->addChild( |
||
2789 | $encerrante, |
||
2790 | "nTanque", |
||
2791 | $std->nTanque, |
||
2792 | true, |
||
2793 | "$identificador [item $std->item] Número de identificação do tanque ao qual o bico está interligado" |
||
2794 | ); |
||
2795 | $this->dom->addChild( |
||
2796 | $encerrante, |
||
2797 | "vEncIni", |
||
2798 | $this->conditionalNumberFormatting($std->vEncIni), |
||
2799 | true, |
||
2800 | "$identificador [item $std->item] Valor do Encerrante no início do abastecimento" |
||
2801 | ); |
||
2802 | $this->dom->addChild( |
||
2803 | $encerrante, |
||
2804 | "vEncFin", |
||
2805 | $this->conditionalNumberFormatting($std->vEncFin), |
||
2806 | true, |
||
2807 | "$identificador [item $std->item] Valor do Encerrante no final do abastecimento" |
||
2808 | ); |
||
2809 | $this->aEncerrante[$std->item] = $encerrante; |
||
2810 | return $encerrante; |
||
2811 | } |
||
2812 | |||
2813 | /** |
||
2814 | * Impostos com o valor total tributado M01 pai H01 |
||
2815 | * tag NFe/infNFe/det[]/imposto |
||
2816 | * @param stdClass $std |
||
2817 | * @return DOMElement |
||
2818 | */ |
||
2819 | public function tagimposto(stdClass $std) |
||
2820 | { |
||
2821 | $possible = ['item', 'vTotTrib']; |
||
2822 | $std = $this->equilizeParameters($std, $possible); |
||
2823 | //totalizador dos valores dos itens |
||
2824 | $this->stdTot->vTotTrib += (float) $std->vTotTrib; |
||
2825 | $identificador = 'M01 <imposto> - '; |
||
2826 | $imposto = $this->dom->createElement("imposto"); |
||
2827 | $this->dom->addChild( |
||
2828 | $imposto, |
||
2829 | "vTotTrib", |
||
2830 | $this->conditionalNumberFormatting($std->vTotTrib), |
||
2831 | false, |
||
2832 | "$identificador [item $std->item] Valor aproximado total de tributos federais, estaduais e municipais." |
||
2833 | ); |
||
2834 | $this->aImposto[$std->item] = $imposto; |
||
2835 | return $imposto; |
||
2836 | } |
||
2837 | |||
2838 | /** |
||
2839 | * Informações do ICMS da Operação própria e ST N01 pai M01 |
||
2840 | * tag NFe/infNFe/det[]/imposto/ICMS |
||
2841 | * @param stdClass $std |
||
2842 | * @return DOMElement |
||
2843 | */ |
||
2844 | public function tagICMS(stdClass $std) |
||
2845 | { |
||
2846 | $possible = [ |
||
2847 | 'item', |
||
2848 | 'orig', |
||
2849 | 'CST', |
||
2850 | 'modBC', |
||
2851 | 'vBC', |
||
2852 | 'pICMS', |
||
2853 | 'vICMS', |
||
2854 | 'pFCP', |
||
2855 | 'vFCP', |
||
2856 | 'vBCFCP', |
||
2857 | 'modBCST', |
||
2858 | 'pMVAST', |
||
2859 | 'pRedBCST', |
||
2860 | 'vBCST', |
||
2861 | 'pICMSST', |
||
2862 | 'vICMSST', |
||
2863 | 'vBCFCPST', |
||
2864 | 'pFCPST', |
||
2865 | 'vFCPST', |
||
2866 | 'vICMSDeson', |
||
2867 | 'motDesICMS', |
||
2868 | 'pRedBC', |
||
2869 | 'vICMSOp', |
||
2870 | 'pDif', |
||
2871 | 'vICMSDif', |
||
2872 | 'vBCSTRet', |
||
2873 | 'pST', |
||
2874 | 'vICMSSTRet', |
||
2875 | 'vBCFCPSTRet', |
||
2876 | 'pFCPSTRet', |
||
2877 | 'vFCPSTRet', |
||
2878 | 'pRedBCEfet', |
||
2879 | 'vBCEfet', |
||
2880 | 'pICMSEfet', |
||
2881 | 'vICMSEfet', |
||
2882 | 'vICMSSubstituto' |
||
2883 | ]; |
||
2884 | $std = $this->equilizeParameters($std, $possible); |
||
2885 | //totalização generica |
||
2886 | $this->stdTot->vICMSDeson += (float) !empty($std->vICMSDeson) ? $std->vICMSDeson : 0; |
||
2887 | $this->stdTot->vFCP += (float) !empty($std->vFCP) ? $std->vFCP : 0; |
||
2888 | $this->stdTot->vFCPST += (float) !empty($std->vFCPST) ? $std->vFCPST : 0; |
||
2889 | $this->stdTot->vFCPSTRet += (float) !empty($std->vFCPSTRet) ? $std->vFCPSTRet : 0; |
||
2890 | $identificador = 'N01 <ICMSxx> - '; |
||
2891 | switch ($std->CST) { |
||
2892 | case '00': |
||
2893 | $this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
||
2894 | $this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
||
2895 | |||
2896 | $icms = $this->dom->createElement("ICMS00"); |
||
2897 | $this->dom->addChild( |
||
2898 | $icms, |
||
2899 | 'orig', |
||
2900 | $std->orig, |
||
2901 | true, |
||
2902 | "$identificador [item $std->item] Origem da mercadoria" |
||
2903 | ); |
||
2904 | $this->dom->addChild( |
||
2905 | $icms, |
||
2906 | 'CST', |
||
2907 | $std->CST, |
||
2908 | true, |
||
2909 | "$identificador [item $std->item] Tributação do ICMS = 00" |
||
2910 | ); |
||
2911 | $this->dom->addChild( |
||
2912 | $icms, |
||
2913 | 'modBC', |
||
2914 | $std->modBC, |
||
2915 | true, |
||
2916 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
||
2917 | ); |
||
2918 | $this->dom->addChild( |
||
2919 | $icms, |
||
2920 | 'vBC', |
||
2921 | $this->conditionalNumberFormatting($std->vBC), |
||
2922 | true, |
||
2923 | "$identificador [item $std->item] Valor da BC do ICMS" |
||
2924 | ); |
||
2925 | $this->dom->addChild( |
||
2926 | $icms, |
||
2927 | 'pICMS', |
||
2928 | $this->conditionalNumberFormatting($std->pICMS, 4), |
||
2929 | true, |
||
2930 | "$identificador [item $std->item] Alíquota do imposto" |
||
2931 | ); |
||
2932 | $this->dom->addChild( |
||
2933 | $icms, |
||
2934 | 'vICMS', |
||
2935 | $this->conditionalNumberFormatting($std->vICMS), |
||
2936 | true, |
||
2937 | "$identificador [item $std->item] Valor do ICMS" |
||
2938 | ); |
||
2939 | $this->dom->addChild( |
||
2940 | $icms, |
||
2941 | 'pFCP', |
||
2942 | $this->conditionalNumberFormatting($std->pFCP, 4), |
||
2943 | false, |
||
2944 | "$identificador [item $std->item] Percentual do Fundo de " |
||
2945 | . "Combate à Pobreza (FCP)" |
||
2946 | ); |
||
2947 | $this->dom->addChild( |
||
2948 | $icms, |
||
2949 | 'vFCP', |
||
2950 | $this->conditionalNumberFormatting($std->vFCP), |
||
2951 | false, |
||
2952 | "$identificador [item $std->item] Valor do Fundo de Combate " |
||
2953 | . "à Pobreza (FCP)" |
||
2954 | ); |
||
2955 | break; |
||
2956 | case '10': |
||
2957 | $this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
||
2958 | $this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
||
2959 | $this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
||
2960 | $this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
||
2961 | |||
2962 | $icms = $this->dom->createElement("ICMS10"); |
||
2963 | $this->dom->addChild( |
||
2964 | $icms, |
||
2965 | 'orig', |
||
2966 | $std->orig, |
||
2967 | true, |
||
2968 | "$identificador [item $std->item] Origem da mercadoria" |
||
2969 | ); |
||
2970 | $this->dom->addChild( |
||
2971 | $icms, |
||
2972 | 'CST', |
||
2973 | $std->CST, |
||
2974 | true, |
||
2975 | "$identificador [item $std->item] Tributação do ICMS = 10" |
||
2976 | ); |
||
2977 | $this->dom->addChild( |
||
2978 | $icms, |
||
2979 | 'modBC', |
||
2980 | $std->modBC, |
||
2981 | true, |
||
2982 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
||
2983 | ); |
||
2984 | $this->dom->addChild( |
||
2985 | $icms, |
||
2986 | 'vBC', |
||
2987 | $this->conditionalNumberFormatting($std->vBC), |
||
2988 | true, |
||
2989 | "$identificador [item $std->item] Valor da BC do ICMS" |
||
2990 | ); |
||
2991 | $this->dom->addChild( |
||
2992 | $icms, |
||
2993 | 'pICMS', |
||
2994 | $this->conditionalNumberFormatting($std->pICMS, 4), |
||
2995 | true, |
||
2996 | "$identificador [item $std->item] Alíquota do imposto" |
||
2997 | ); |
||
2998 | $this->dom->addChild( |
||
2999 | $icms, |
||
3000 | 'vICMS', |
||
3001 | $this->conditionalNumberFormatting($std->vICMS), |
||
3002 | true, |
||
3003 | "$identificador [item $std->item] Valor do ICMS" |
||
3004 | ); |
||
3005 | $this->dom->addChild( |
||
3006 | $icms, |
||
3007 | 'vBCFCP', |
||
3008 | $this->conditionalNumberFormatting($std->vBCFCP), |
||
3009 | false, |
||
3010 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
||
3011 | ); |
||
3012 | $this->dom->addChild( |
||
3013 | $icms, |
||
3014 | 'pFCP', |
||
3015 | $this->conditionalNumberFormatting($std->pFCP, 4), |
||
3016 | false, |
||
3017 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3018 | . "Combate à Pobreza (FCP)" |
||
3019 | ); |
||
3020 | $this->dom->addChild( |
||
3021 | $icms, |
||
3022 | 'vFCP', |
||
3023 | $this->conditionalNumberFormatting($std->vFCP), |
||
3024 | false, |
||
3025 | "$identificador [item $std->item] Valor do FCP" |
||
3026 | ); |
||
3027 | $this->dom->addChild( |
||
3028 | $icms, |
||
3029 | 'modBCST', |
||
3030 | $std->modBCST, |
||
3031 | true, |
||
3032 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
||
3033 | ); |
||
3034 | $this->dom->addChild( |
||
3035 | $icms, |
||
3036 | 'pMVAST', |
||
3037 | $this->conditionalNumberFormatting($std->pMVAST, 4), |
||
3038 | false, |
||
3039 | "$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
||
3040 | ); |
||
3041 | $this->dom->addChild( |
||
3042 | $icms, |
||
3043 | 'pRedBCST', |
||
3044 | $this->conditionalNumberFormatting($std->pRedBCST, 4), |
||
3045 | false, |
||
3046 | "$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
||
3047 | ); |
||
3048 | $this->dom->addChild( |
||
3049 | $icms, |
||
3050 | 'vBCST', |
||
3051 | $this->conditionalNumberFormatting($std->vBCST), |
||
3052 | true, |
||
3053 | "$identificador [item $std->item] Valor da BC do ICMS ST" |
||
3054 | ); |
||
3055 | $this->dom->addChild( |
||
3056 | $icms, |
||
3057 | 'pICMSST', |
||
3058 | $this->conditionalNumberFormatting($std->pICMSST, 4), |
||
3059 | true, |
||
3060 | "$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
||
3061 | ); |
||
3062 | $this->dom->addChild( |
||
3063 | $icms, |
||
3064 | 'vICMSST', |
||
3065 | $this->conditionalNumberFormatting($std->vICMSST), |
||
3066 | true, |
||
3067 | "$identificador [item $std->item] Valor do ICMS ST" |
||
3068 | ); |
||
3069 | $this->dom->addChild( |
||
3070 | $icms, |
||
3071 | 'vBCFCPST', |
||
3072 | $this->conditionalNumberFormatting($std->vBCFCPST), |
||
3073 | false, |
||
3074 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
||
3075 | ); |
||
3076 | $this->dom->addChild( |
||
3077 | $icms, |
||
3078 | 'pFCPST', |
||
3079 | $this->conditionalNumberFormatting($std->pFCPST, 4), |
||
3080 | false, |
||
3081 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3082 | . "Combate à Pobreza (FCP) ST" |
||
3083 | ); |
||
3084 | $this->dom->addChild( |
||
3085 | $icms, |
||
3086 | 'vFCPST', |
||
3087 | $this->conditionalNumberFormatting($std->vFCPST), |
||
3088 | false, |
||
3089 | "$identificador [item $std->item] Valor do FCP ST" |
||
3090 | ); |
||
3091 | break; |
||
3092 | case '20': |
||
3093 | $this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
||
3094 | $this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
||
3095 | |||
3096 | $icms = $this->dom->createElement("ICMS20"); |
||
3097 | $this->dom->addChild( |
||
3098 | $icms, |
||
3099 | 'orig', |
||
3100 | $std->orig, |
||
3101 | true, |
||
3102 | "$identificador [item $std->item] Origem da mercadoria" |
||
3103 | ); |
||
3104 | $this->dom->addChild( |
||
3105 | $icms, |
||
3106 | 'CST', |
||
3107 | $std->CST, |
||
3108 | true, |
||
3109 | "$identificador [item $std->item] Tributação do ICMS = 20" |
||
3110 | ); |
||
3111 | $this->dom->addChild( |
||
3112 | $icms, |
||
3113 | 'modBC', |
||
3114 | $std->modBC, |
||
3115 | true, |
||
3116 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
||
3117 | ); |
||
3118 | $this->dom->addChild( |
||
3119 | $icms, |
||
3120 | 'pRedBC', |
||
3121 | $this->conditionalNumberFormatting($std->pRedBC, 4), |
||
3122 | true, |
||
3123 | "$identificador [item $std->item] Percentual da Redução de BC" |
||
3124 | ); |
||
3125 | $this->dom->addChild( |
||
3126 | $icms, |
||
3127 | 'vBC', |
||
3128 | $this->conditionalNumberFormatting($std->vBC), |
||
3129 | true, |
||
3130 | "$identificador [item $std->item] Valor da BC do ICMS" |
||
3131 | ); |
||
3132 | $this->dom->addChild( |
||
3133 | $icms, |
||
3134 | 'pICMS', |
||
3135 | $this->conditionalNumberFormatting($std->pICMS, 4), |
||
3136 | true, |
||
3137 | "$identificador [item $std->item] Alíquota do imposto" |
||
3138 | ); |
||
3139 | $this->dom->addChild( |
||
3140 | $icms, |
||
3141 | 'vICMS', |
||
3142 | $this->conditionalNumberFormatting($std->vICMS), |
||
3143 | true, |
||
3144 | "$identificador [item $std->item] Valor do ICMS" |
||
3145 | ); |
||
3146 | $this->dom->addChild( |
||
3147 | $icms, |
||
3148 | 'vBCFCP', |
||
3149 | $this->conditionalNumberFormatting($std->vBCFCP), |
||
3150 | false, |
||
3151 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
||
3152 | ); |
||
3153 | $this->dom->addChild( |
||
3154 | $icms, |
||
3155 | 'pFCP', |
||
3156 | $this->conditionalNumberFormatting($std->pFCP, 4), |
||
3157 | false, |
||
3158 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3159 | . "Combate à Pobreza (FCP)" |
||
3160 | ); |
||
3161 | $this->dom->addChild( |
||
3162 | $icms, |
||
3163 | 'vFCP', |
||
3164 | $this->conditionalNumberFormatting($std->vFCP), |
||
3165 | false, |
||
3166 | "$identificador [item $std->item] Valor do FCP" |
||
3167 | ); |
||
3168 | $this->dom->addChild( |
||
3169 | $icms, |
||
3170 | 'vICMSDeson', |
||
3171 | $this->conditionalNumberFormatting($std->vICMSDeson), |
||
3172 | false, |
||
3173 | "$identificador [item $std->item] Valor do ICMS desonerado" |
||
3174 | ); |
||
3175 | $this->dom->addChild( |
||
3176 | $icms, |
||
3177 | 'motDesICMS', |
||
3178 | $std->motDesICMS, |
||
3179 | false, |
||
3180 | "$identificador [item $std->item] Motivo da desoneração do ICMS" |
||
3181 | ); |
||
3182 | break; |
||
3183 | case '30': |
||
3184 | $this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
||
3185 | $this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
||
3186 | |||
3187 | $icms = $this->dom->createElement("ICMS30"); |
||
3188 | $this->dom->addChild( |
||
3189 | $icms, |
||
3190 | 'orig', |
||
3191 | $std->orig, |
||
3192 | true, |
||
3193 | "$identificador [item $std->item] Origem da mercadoria" |
||
3194 | ); |
||
3195 | $this->dom->addChild( |
||
3196 | $icms, |
||
3197 | 'CST', |
||
3198 | $std->CST, |
||
3199 | true, |
||
3200 | "$identificador [item $std->item] Tributação do ICMS = 30" |
||
3201 | ); |
||
3202 | $this->dom->addChild( |
||
3203 | $icms, |
||
3204 | 'modBCST', |
||
3205 | $std->modBCST, |
||
3206 | true, |
||
3207 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
||
3208 | ); |
||
3209 | $this->dom->addChild( |
||
3210 | $icms, |
||
3211 | 'pMVAST', |
||
3212 | $this->conditionalNumberFormatting($std->pMVAST, 4), |
||
3213 | false, |
||
3214 | "$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
||
3215 | ); |
||
3216 | $this->dom->addChild( |
||
3217 | $icms, |
||
3218 | 'pRedBCST', |
||
3219 | $this->conditionalNumberFormatting($std->pRedBCST, 4), |
||
3220 | false, |
||
3221 | "$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
||
3222 | ); |
||
3223 | $this->dom->addChild( |
||
3224 | $icms, |
||
3225 | 'vBCST', |
||
3226 | $this->conditionalNumberFormatting($std->vBCST), |
||
3227 | true, |
||
3228 | "$identificador [item $std->item] Valor da BC do ICMS ST" |
||
3229 | ); |
||
3230 | $this->dom->addChild( |
||
3231 | $icms, |
||
3232 | 'pICMSST', |
||
3233 | $this->conditionalNumberFormatting($std->pICMSST, 4), |
||
3234 | true, |
||
3235 | "$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
||
3236 | ); |
||
3237 | $this->dom->addChild( |
||
3238 | $icms, |
||
3239 | 'vICMSST', |
||
3240 | $this->conditionalNumberFormatting($std->vICMSST), |
||
3241 | true, |
||
3242 | "$identificador [item $std->item] Valor do ICMS ST" |
||
3243 | ); |
||
3244 | $this->dom->addChild( |
||
3245 | $icms, |
||
3246 | 'vBCFCPST', |
||
3247 | $this->conditionalNumberFormatting($std->vBCFCPST), |
||
3248 | false, |
||
3249 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
||
3250 | ); |
||
3251 | $this->dom->addChild( |
||
3252 | $icms, |
||
3253 | 'pFCPST', |
||
3254 | $this->conditionalNumberFormatting($std->pFCPST, 4), |
||
3255 | false, |
||
3256 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3257 | . "Combate à Pobreza (FCP) ST" |
||
3258 | ); |
||
3259 | $this->dom->addChild( |
||
3260 | $icms, |
||
3261 | 'vFCPST', |
||
3262 | $this->conditionalNumberFormatting($std->vFCPST), |
||
3263 | false, |
||
3264 | "$identificador [item $std->item] Valor do FCP ST" |
||
3265 | ); |
||
3266 | $this->dom->addChild( |
||
3267 | $icms, |
||
3268 | 'vICMSDeson', |
||
3269 | $this->conditionalNumberFormatting($std->vICMSDeson), |
||
3270 | false, |
||
3271 | "$identificador [item $std->item] Valor do ICMS desonerado" |
||
3272 | ); |
||
3273 | $this->dom->addChild( |
||
3274 | $icms, |
||
3275 | 'motDesICMS', |
||
3276 | $std->motDesICMS, |
||
3277 | false, |
||
3278 | "$identificador [item $std->item] Motivo da desoneração do ICMS" |
||
3279 | ); |
||
3280 | break; |
||
3281 | case '40': |
||
3282 | case '41': |
||
3283 | case '50': |
||
3284 | $icms = $this->dom->createElement("ICMS40"); |
||
3285 | $this->dom->addChild( |
||
3286 | $icms, |
||
3287 | 'orig', |
||
3288 | $std->orig, |
||
3289 | true, |
||
3290 | "$identificador [item $std->item] Origem da mercadoria" |
||
3291 | ); |
||
3292 | $this->dom->addChild( |
||
3293 | $icms, |
||
3294 | 'CST', |
||
3295 | $std->CST, |
||
3296 | true, |
||
3297 | "$identificador [item $std->item] Tributação do ICMS $std->CST" |
||
3298 | ); |
||
3299 | $this->dom->addChild( |
||
3300 | $icms, |
||
3301 | 'vICMSDeson', |
||
3302 | $this->conditionalNumberFormatting($std->vICMSDeson), |
||
3303 | false, |
||
3304 | "$identificador [item $std->item] Valor do ICMS desonerado" |
||
3305 | ); |
||
3306 | $this->dom->addChild( |
||
3307 | $icms, |
||
3308 | 'motDesICMS', |
||
3309 | $std->motDesICMS, |
||
3310 | false, |
||
3311 | "$identificador [item $std->item] Motivo da desoneração do ICMS" |
||
3312 | ); |
||
3313 | break; |
||
3314 | case '51': |
||
3315 | $icms = $this->dom->createElement("ICMS51"); |
||
3316 | $this->dom->addChild( |
||
3317 | $icms, |
||
3318 | 'orig', |
||
3319 | $std->orig, |
||
3320 | true, |
||
3321 | "$identificador [item $std->item] Origem da mercadoria" |
||
3322 | ); |
||
3323 | $this->dom->addChild( |
||
3324 | $icms, |
||
3325 | 'CST', |
||
3326 | $std->CST, |
||
3327 | true, |
||
3328 | "$identificador [item $std->item] Tributação do ICMS = 51" |
||
3329 | ); |
||
3330 | $this->dom->addChild( |
||
3331 | $icms, |
||
3332 | 'modBC', |
||
3333 | $std->modBC, |
||
3334 | false, |
||
3335 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
||
3336 | ); |
||
3337 | $this->dom->addChild( |
||
3338 | $icms, |
||
3339 | 'pRedBC', |
||
3340 | $this->conditionalNumberFormatting($std->pRedBC, 4), |
||
3341 | false, |
||
3342 | "$identificador [item $std->item] Percentual da Redução de BC" |
||
3343 | ); |
||
3344 | $this->dom->addChild( |
||
3345 | $icms, |
||
3346 | 'vBC', |
||
3347 | $this->conditionalNumberFormatting($std->vBC), |
||
3348 | false, |
||
3349 | "$identificador [item $std->item] Valor da BC do ICMS" |
||
3350 | ); |
||
3351 | $this->dom->addChild( |
||
3352 | $icms, |
||
3353 | 'pICMS', |
||
3354 | $this->conditionalNumberFormatting($std->pICMS, 4), |
||
3355 | false, |
||
3356 | "$identificador [item $std->item] Alíquota do imposto" |
||
3357 | ); |
||
3358 | $this->dom->addChild( |
||
3359 | $icms, |
||
3360 | 'vICMSOp', |
||
3361 | $this->conditionalNumberFormatting($std->vICMSOp), |
||
3362 | false, |
||
3363 | "$identificador [item $std->item] Valor do ICMS da Operação" |
||
3364 | ); |
||
3365 | $this->dom->addChild( |
||
3366 | $icms, |
||
3367 | 'pDif', |
||
3368 | $this->conditionalNumberFormatting($std->pDif, 4), |
||
3369 | false, |
||
3370 | "$identificador [item $std->item] Percentual do diferimento" |
||
3371 | ); |
||
3372 | $this->dom->addChild( |
||
3373 | $icms, |
||
3374 | 'vICMSDif', |
||
3375 | $this->conditionalNumberFormatting($std->vICMSDif), |
||
3376 | false, |
||
3377 | "$identificador [item $std->item] Valor do ICMS diferido" |
||
3378 | ); |
||
3379 | $this->dom->addChild( |
||
3380 | $icms, |
||
3381 | 'vICMS', |
||
3382 | $this->conditionalNumberFormatting($std->vICMS), |
||
3383 | false, |
||
3384 | "$identificador [item $std->item] Valor do ICMS realmente devido" |
||
3385 | ); |
||
3386 | $this->dom->addChild( |
||
3387 | $icms, |
||
3388 | 'vBCFCP', |
||
3389 | $this->conditionalNumberFormatting($std->vBCFCP), |
||
3390 | false, |
||
3391 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
||
3392 | ); |
||
3393 | $this->dom->addChild( |
||
3394 | $icms, |
||
3395 | 'pFCP', |
||
3396 | $this->conditionalNumberFormatting($std->pFCP, 4), |
||
3397 | false, |
||
3398 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3399 | . "Combate à Pobreza (FCP)" |
||
3400 | ); |
||
3401 | $this->dom->addChild( |
||
3402 | $icms, |
||
3403 | 'vFCP', |
||
3404 | $this->conditionalNumberFormatting($std->vFCP), |
||
3405 | false, |
||
3406 | "$identificador [item $std->item] Valor do FCP" |
||
3407 | ); |
||
3408 | break; |
||
3409 | case '60': |
||
3410 | $icms = $this->dom->createElement("ICMS60"); |
||
3411 | $this->dom->addChild( |
||
3412 | $icms, |
||
3413 | 'orig', |
||
3414 | $std->orig, |
||
3415 | true, |
||
3416 | "$identificador [item $std->item] Origem da mercadoria" |
||
3417 | ); |
||
3418 | $this->dom->addChild( |
||
3419 | $icms, |
||
3420 | 'CST', |
||
3421 | $std->CST, |
||
3422 | true, |
||
3423 | "$identificador [item $std->item] Tributação do ICMS = 60" |
||
3424 | ); |
||
3425 | $this->dom->addChild( |
||
3426 | $icms, |
||
3427 | 'vBCSTRet', |
||
3428 | $this->conditionalNumberFormatting($std->vBCSTRet), |
||
3429 | false, |
||
3430 | "$identificador [item $std->item] Valor da BC do ICMS ST retido" |
||
3431 | ); |
||
3432 | $this->dom->addChild( |
||
3433 | $icms, |
||
3434 | 'pST', |
||
3435 | $this->conditionalNumberFormatting($std->pST, 4), |
||
3436 | false, |
||
3437 | "$identificador [item $std->item] Valor do ICMS ST retido" |
||
3438 | ); |
||
3439 | $this->dom->addChild( |
||
3440 | $icms, |
||
3441 | 'vICMSSubstituto', |
||
3442 | $this->conditionalNumberFormatting($std->vICMSSubstituto), |
||
3443 | false, |
||
3444 | "$identificador [item $std->item] Valor do ICMS próprio do Substituto" |
||
3445 | ); |
||
3446 | $this->dom->addChild( |
||
3447 | $icms, |
||
3448 | 'vICMSSTRet', |
||
3449 | $this->conditionalNumberFormatting($std->vICMSSTRet), |
||
3450 | false, |
||
3451 | "$identificador [item $std->item] Valor do ICMS ST retido" |
||
3452 | ); |
||
3453 | $this->dom->addChild( |
||
3454 | $icms, |
||
3455 | 'vBCFCPSTRet', |
||
3456 | $this->conditionalNumberFormatting($std->vBCFCPSTRet), |
||
3457 | false, |
||
3458 | "$identificador [item $std->item] Valor da Base de Cálculo " |
||
3459 | . "do FCP retido anteriormente por ST" |
||
3460 | ); |
||
3461 | $this->dom->addChild( |
||
3462 | $icms, |
||
3463 | 'pFCPSTRet', |
||
3464 | $this->conditionalNumberFormatting($std->pFCPSTRet, 4), |
||
3465 | false, |
||
3466 | "$identificador [item $std->item] Percentual do FCP retido " |
||
3467 | . "anteriormente por Substituição Tributária" |
||
3468 | ); |
||
3469 | $this->dom->addChild( |
||
3470 | $icms, |
||
3471 | 'vFCPSTRet', |
||
3472 | $this->conditionalNumberFormatting($std->vFCPSTRet), |
||
3473 | false, |
||
3474 | "$identificador [item $std->item] Valor do FCP retido por " |
||
3475 | . "Substituição Tributária" |
||
3476 | ); |
||
3477 | $this->dom->addChild( |
||
3478 | $icms, |
||
3479 | 'pRedBCEfet', |
||
3480 | $this->conditionalNumberFormatting($std->pRedBCEfet, 4), |
||
3481 | false, |
||
3482 | "$identificador [item $std->item] Percentual de redução " |
||
3483 | . "para obtenção da base de cálculo efetiva (vBCEfet)" |
||
3484 | ); |
||
3485 | $this->dom->addChild( |
||
3486 | $icms, |
||
3487 | 'vBCEfet', |
||
3488 | $this->conditionalNumberFormatting($std->vBCEfet), |
||
3489 | false, |
||
3490 | "$identificador [item $std->item] base de calculo efetiva" |
||
3491 | ); |
||
3492 | $this->dom->addChild( |
||
3493 | $icms, |
||
3494 | 'pICMSEfet', |
||
3495 | $this->conditionalNumberFormatting($std->pICMSEfet, 4), |
||
3496 | false, |
||
3497 | "$identificador [item $std->item] Alíquota do ICMS na operação a consumidor final" |
||
3498 | ); |
||
3499 | $this->dom->addChild( |
||
3500 | $icms, |
||
3501 | 'vICMSEfet', |
||
3502 | $this->conditionalNumberFormatting($std->vICMSEfet), |
||
3503 | false, |
||
3504 | "$identificador [item $std->item] Valor do ICMS efetivo" |
||
3505 | ); |
||
3506 | break; |
||
3507 | case '70': |
||
3508 | $this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
||
3509 | $this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
||
3510 | $this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
||
3511 | $this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
||
3512 | |||
3513 | $icms = $this->dom->createElement("ICMS70"); |
||
3514 | $this->dom->addChild( |
||
3515 | $icms, |
||
3516 | 'orig', |
||
3517 | $std->orig, |
||
3518 | true, |
||
3519 | "$identificador [item $std->item] Origem da mercadoria" |
||
3520 | ); |
||
3521 | $this->dom->addChild( |
||
3522 | $icms, |
||
3523 | 'CST', |
||
3524 | $std->CST, |
||
3525 | true, |
||
3526 | "$identificador [item $std->item] Tributação do ICMS = 70" |
||
3527 | ); |
||
3528 | $this->dom->addChild( |
||
3529 | $icms, |
||
3530 | 'modBC', |
||
3531 | $std->modBC, |
||
3532 | true, |
||
3533 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
||
3534 | ); |
||
3535 | $this->dom->addChild( |
||
3536 | $icms, |
||
3537 | 'pRedBC', |
||
3538 | $this->conditionalNumberFormatting($std->pRedBC, 4), |
||
3539 | true, |
||
3540 | "$identificador [item $std->item] Percentual da Redução de BC" |
||
3541 | ); |
||
3542 | $this->dom->addChild( |
||
3543 | $icms, |
||
3544 | 'vBC', |
||
3545 | $this->conditionalNumberFormatting($std->vBC), |
||
3546 | true, |
||
3547 | "$identificador [item $std->item] Valor da BC do ICMS" |
||
3548 | ); |
||
3549 | $this->dom->addChild( |
||
3550 | $icms, |
||
3551 | 'pICMS', |
||
3552 | $this->conditionalNumberFormatting($std->pICMS, 4), |
||
3553 | true, |
||
3554 | "$identificador [item $std->item] Alíquota do imposto" |
||
3555 | ); |
||
3556 | $this->dom->addChild( |
||
3557 | $icms, |
||
3558 | 'vICMS', |
||
3559 | $this->conditionalNumberFormatting($std->vICMS), |
||
3560 | true, |
||
3561 | "$identificador [item $std->item] Valor do ICMS" |
||
3562 | ); |
||
3563 | $this->dom->addChild( |
||
3564 | $icms, |
||
3565 | 'vBCFCP', |
||
3566 | $this->conditionalNumberFormatting($std->vBCFCP), |
||
3567 | false, |
||
3568 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
||
3569 | ); |
||
3570 | $this->dom->addChild( |
||
3571 | $icms, |
||
3572 | 'pFCP', |
||
3573 | $this->conditionalNumberFormatting($std->pFCP, 4), |
||
3574 | false, |
||
3575 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3576 | . "Combate à Pobreza (FCP)" |
||
3577 | ); |
||
3578 | $this->dom->addChild( |
||
3579 | $icms, |
||
3580 | 'vFCP', |
||
3581 | $std->vFCP, |
||
3582 | false, |
||
3583 | "$identificador [item $std->item] Valor do FCP" |
||
3584 | ); |
||
3585 | $this->dom->addChild( |
||
3586 | $icms, |
||
3587 | 'modBCST', |
||
3588 | $std->modBCST, |
||
3589 | true, |
||
3590 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
||
3591 | ); |
||
3592 | $this->dom->addChild( |
||
3593 | $icms, |
||
3594 | 'pMVAST', |
||
3595 | $this->conditionalNumberFormatting($std->pMVAST, 4), |
||
3596 | false, |
||
3597 | "$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
||
3598 | ); |
||
3599 | $this->dom->addChild( |
||
3600 | $icms, |
||
3601 | 'pRedBCST', |
||
3602 | $this->conditionalNumberFormatting($std->pRedBCST, 4), |
||
3603 | false, |
||
3604 | "$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
||
3605 | ); |
||
3606 | $this->dom->addChild( |
||
3607 | $icms, |
||
3608 | 'vBCST', |
||
3609 | $this->conditionalNumberFormatting($std->vBCST), |
||
3610 | true, |
||
3611 | "$identificador [item $std->item] Valor da BC do ICMS ST" |
||
3612 | ); |
||
3613 | $this->dom->addChild( |
||
3614 | $icms, |
||
3615 | 'pICMSST', |
||
3616 | $this->conditionalNumberFormatting($std->pICMSST, 4), |
||
3617 | true, |
||
3618 | "$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
||
3619 | ); |
||
3620 | $this->dom->addChild( |
||
3621 | $icms, |
||
3622 | 'vICMSST', |
||
3623 | $this->conditionalNumberFormatting($std->vICMSST), |
||
3624 | true, |
||
3625 | "$identificador [item $std->item] Valor do ICMS ST" |
||
3626 | ); |
||
3627 | $this->dom->addChild( |
||
3628 | $icms, |
||
3629 | 'vBCFCPST', |
||
3630 | $this->conditionalNumberFormatting($std->vBCFCPST), |
||
3631 | false, |
||
3632 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
||
3633 | ); |
||
3634 | $this->dom->addChild( |
||
3635 | $icms, |
||
3636 | 'pFCPST', |
||
3637 | $this->conditionalNumberFormatting($std->pFCPST, 4), |
||
3638 | false, |
||
3639 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3640 | . "Combate à Pobreza (FCP) ST" |
||
3641 | ); |
||
3642 | $this->dom->addChild( |
||
3643 | $icms, |
||
3644 | 'vFCPST', |
||
3645 | $this->conditionalNumberFormatting($std->vFCPST), |
||
3646 | false, |
||
3647 | "$identificador [item $std->item] Valor do FCP ST" |
||
3648 | ); |
||
3649 | $this->dom->addChild( |
||
3650 | $icms, |
||
3651 | 'vICMSDeson', |
||
3652 | $this->conditionalNumberFormatting($std->vICMSDeson), |
||
3653 | false, |
||
3654 | "$identificador [item $std->item] Valor do ICMS desonerado" |
||
3655 | ); |
||
3656 | $this->dom->addChild( |
||
3657 | $icms, |
||
3658 | 'motDesICMS', |
||
3659 | $std->motDesICMS, |
||
3660 | false, |
||
3661 | "$identificador [item $std->item] Motivo da desoneração do ICMS" |
||
3662 | ); |
||
3663 | break; |
||
3664 | case '90': |
||
3665 | $this->stdTot->vBC += (float) !empty($std->vBC) ? $std->vBC : 0; |
||
3666 | $this->stdTot->vICMS += (float) !empty($std->vICMS) ? $std->vICMS : 0; |
||
3667 | $this->stdTot->vBCST += (float) !empty($std->vBCST) ? $std->vBCST : 0; |
||
3668 | $this->stdTot->vST += (float) !empty($std->vICMSST) ? $std->vICMSST : 0; |
||
3669 | |||
3670 | $icms = $this->dom->createElement("ICMS90"); |
||
3671 | $this->dom->addChild( |
||
3672 | $icms, |
||
3673 | 'orig', |
||
3674 | $std->orig, |
||
3675 | true, |
||
3676 | "$identificador [item $std->item] Origem da mercadoria" |
||
3677 | ); |
||
3678 | $this->dom->addChild( |
||
3679 | $icms, |
||
3680 | 'CST', |
||
3681 | $std->CST, |
||
3682 | true, |
||
3683 | "$identificador [item $std->item] Tributação do ICMS = 90" |
||
3684 | ); |
||
3685 | $this->dom->addChild( |
||
3686 | $icms, |
||
3687 | 'modBC', |
||
3688 | $std->modBC, |
||
3689 | false, |
||
3690 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS" |
||
3691 | ); |
||
3692 | $this->dom->addChild( |
||
3693 | $icms, |
||
3694 | 'vBC', |
||
3695 | $this->conditionalNumberFormatting($std->vBC), |
||
3696 | false, |
||
3697 | "$identificador [item $std->item] Valor da BC do ICMS" |
||
3698 | ); |
||
3699 | $this->dom->addChild( |
||
3700 | $icms, |
||
3701 | 'pRedBC', |
||
3702 | $this->conditionalNumberFormatting($std->pRedBC, 4), |
||
3703 | false, |
||
3704 | "$identificador [item $std->item] Percentual da Redução de BC" |
||
3705 | ); |
||
3706 | $this->dom->addChild( |
||
3707 | $icms, |
||
3708 | 'pICMS', |
||
3709 | $this->conditionalNumberFormatting($std->pICMS, 4), |
||
3710 | false, |
||
3711 | "$identificador [item $std->item] Alíquota do imposto" |
||
3712 | ); |
||
3713 | $this->dom->addChild( |
||
3714 | $icms, |
||
3715 | 'vICMS', |
||
3716 | $this->conditionalNumberFormatting($std->vICMS), |
||
3717 | false, |
||
3718 | "$identificador [item $std->item] Valor do ICMS" |
||
3719 | ); |
||
3720 | $this->dom->addChild( |
||
3721 | $icms, |
||
3722 | 'vBCFCP', |
||
3723 | $this->conditionalNumberFormatting($std->vBCFCP), |
||
3724 | false, |
||
3725 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP" |
||
3726 | ); |
||
3727 | $this->dom->addChild( |
||
3728 | $icms, |
||
3729 | 'pFCP', |
||
3730 | $this->conditionalNumberFormatting($std->pFCP, 4), |
||
3731 | false, |
||
3732 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3733 | . "Combate à Pobreza (FCP)" |
||
3734 | ); |
||
3735 | $this->dom->addChild( |
||
3736 | $icms, |
||
3737 | 'vFCP', |
||
3738 | $this->conditionalNumberFormatting($std->vFCP), |
||
3739 | false, |
||
3740 | "$identificador [item $std->item] Valor do FCP" |
||
3741 | ); |
||
3742 | $this->dom->addChild( |
||
3743 | $icms, |
||
3744 | 'modBCST', |
||
3745 | $std->modBCST, |
||
3746 | false, |
||
3747 | "$identificador [item $std->item] Modalidade de determinação da BC do ICMS ST" |
||
3748 | ); |
||
3749 | $this->dom->addChild( |
||
3750 | $icms, |
||
3751 | 'pMVAST', |
||
3752 | $this->conditionalNumberFormatting($std->pMVAST, 4), |
||
3753 | false, |
||
3754 | "$identificador [item $std->item] Percentual da margem de valor Adicionado do ICMS ST" |
||
3755 | ); |
||
3756 | $this->dom->addChild( |
||
3757 | $icms, |
||
3758 | 'pRedBCST', |
||
3759 | $this->conditionalNumberFormatting($std->pRedBCST, 4), |
||
3760 | false, |
||
3761 | "$identificador [item $std->item] Percentual da Redução de BC do ICMS ST" |
||
3762 | ); |
||
3763 | $this->dom->addChild( |
||
3764 | $icms, |
||
3765 | 'vBCST', |
||
3766 | $this->conditionalNumberFormatting($std->vBCST), |
||
3767 | false, |
||
3768 | "$identificador [item $std->item] Valor da BC do ICMS ST" |
||
3769 | ); |
||
3770 | $this->dom->addChild( |
||
3771 | $icms, |
||
3772 | 'pICMSST', |
||
3773 | $this->conditionalNumberFormatting($std->pICMSST, 4), |
||
3774 | false, |
||
3775 | "$identificador [item $std->item] Alíquota do imposto do ICMS ST" |
||
3776 | ); |
||
3777 | $this->dom->addChild( |
||
3778 | $icms, |
||
3779 | 'vICMSST', |
||
3780 | $this->conditionalNumberFormatting($std->vICMSST), |
||
3781 | false, |
||
3782 | "$identificador [item $std->item] Valor do ICMS ST" |
||
3783 | ); |
||
3784 | $this->dom->addChild( |
||
3785 | $icms, |
||
3786 | 'vBCFCPST', |
||
3787 | $this->conditionalNumberFormatting($std->vBCFCPST), |
||
3788 | false, |
||
3789 | "$identificador [item $std->item] Valor da Base de Cálculo do FCP ST" |
||
3790 | ); |
||
3791 | $this->dom->addChild( |
||
3792 | $icms, |
||
3793 | 'pFCPST', |
||
3794 | $this->conditionalNumberFormatting($std->pFCPST, 4), |
||
3795 | false, |
||
3796 | "$identificador [item $std->item] Percentual do Fundo de " |
||
3797 | . "Combate à Pobreza (FCP) ST" |
||
3798 | ); |
||
3799 | $this->dom->addChild( |
||
3800 | $icms, |
||
3801 | 'vFCPST', |
||
3802 | $this->conditionalNumberFormatting($std->vFCPST), |
||
3803 | false, |
||
3804 | "$identificador [item $std->item] Valor do FCP ST" |
||
3805 | ); |
||
3806 | $this->dom->addChild( |
||
3807 | $icms, |
||
3808 | 'vICMSDeson', |
||
3809 | $this->conditionalNumberFormatting($std->vICMSDeson), |
||
3810 | false, |
||
3811 | "$identificador [item $std->item] Valor do ICMS desonerado" |
||
3812 | ); |
||
3813 | $this->dom->addChild( |
||
3814 | $icms, |
||
3815 | 'motDesICMS', |
||
3816 | $std->motDesICMS, |
||
3817 | false, |
||
3818 | "$identificador [item $std->item] Motivo da desoneração do ICMS" |
||
3819 | ); |
||
3820 | break; |
||
3821 | } |
||
3822 | $tagIcms = $this->dom->createElement('ICMS'); |
||
3823 | if (isset($icms)) { |
||
3824 | $tagIcms->appendChild($icms); |
||
3825 | } |
||
3826 | $this->aICMS[$std->item] = $tagIcms; |
||
3827 | return $tagIcms; |
||
3828 | } |
||
3829 | |||
3830 | /** |
||
3831 | * Grupo de Partilha do ICMS entre a UF de origem e UF de destino ou |
||
3832 | * a UF definida na legislação. N10a pai N01 |
||
3833 | * tag NFe/infNFe/det[]/imposto/ICMS/ICMSPart |
||
3834 | * @param stdClass $std |
||
3835 | * @return DOMElement |
||
3836 | */ |
||
3837 | public function tagICMSPart(stdClass $std) |
||
3978 | |||
3979 | /** |
||
3980 | * Grupo de Repasse de ICMSST retido anteriormente em operações |
||
3981 | * interestaduais com repasses através do Substituto Tributário |
||
3982 | * NOTA: ajustado NT 2018.005 |
||
3983 | * tag NFe/infNFe/det[]/imposto/ICMS/ICMSST N10b pai N01 |
||
3984 | * @param stdClass $std |
||
3985 | * @return DOMElement |
||
3986 | */ |
||
3987 | public function tagICMSST(stdClass $std) |
||
3988 | { |
||
3989 | $possible = [ |
||
3990 | 'item', |
||
3991 | 'orig', |
||
3992 | 'CST', |
||
3993 | 'vBCSTRet', |
||
3994 | 'vICMSSTRet', |
||
3995 | 'vBCSTDest', |
||
3996 | 'vICMSSTDest', |
||
3997 | 'vBCFCPSTRet', |
||
3998 | 'pFCPSTRet', |
||
3999 | 'vFCPSTRet', |
||
4000 | 'pST', |
||
4001 | 'vICMSSubstituto', |
||
4002 | 'pRedBCEfet', |
||
4003 | 'vBCEfet', |
||
4004 | 'pICMSEfet', |
||
4005 | 'vICMSEfet' |
||
4006 | ]; |
||
4007 | $std = $this->equilizeParameters($std, $possible); |
||
4008 | $icmsST = $this->dom->createElement("ICMSST"); |
||
4009 | $this->dom->addChild( |
||
4010 | $icmsST, |
||
4011 | 'orig', |
||
4012 | $std->orig, |
||
4013 | true, |
||
4014 | "[item $std->item] Origem da mercadoria" |
||
4015 | ); |
||
4016 | $this->dom->addChild( |
||
4124 | |||
4125 | /** |
||
4126 | * Tributação ICMS pelo Simples Nacional N10c pai N01 |
||
4127 | * tag NFe/infNFe/det[]/imposto/ICMS/ICMSSN N10c pai N01 |
||
4128 | * @param stdClass $std |
||
4129 | * @return DOMElement |
||
4130 | */ |
||
4131 | public function tagICMSSN(stdClass $std) |
||
4655 | |||
4656 | /** |
||
4657 | * Grupo ICMSUFDest NA01 pai M01 |
||
4658 | * tag NFe/infNFe/det[]/imposto/ICMSUFDest (opcional) |
||
4659 | * Grupo a ser informado nas vendas interestaduais para consumidor final, |
||
4660 | * não contribuinte do ICMS |
||
4661 | * @param stdClass $std |
||
4662 | * @return DOMElement |
||
4663 | */ |
||
4664 | public function tagICMSUFDest(stdClass $std) |
||
4749 | |||
4750 | /** |
||
4751 | * Grupo IPI O01 pai M01 |
||
4752 | * tag NFe/infNFe/det[]/imposto/IPI (opcional) |
||
4753 | * @param stdClass $std |
||
4754 | * @return DOMElement |
||
4755 | */ |
||
4756 | public function tagIPI(stdClass $std) |
||
4872 | |||
4873 | /** |
||
4874 | * Grupo Imposto de Importação P01 pai M01 |
||
4875 | * tag NFe/infNFe/det[]/imposto/II |
||
4876 | * @param stdClass $std |
||
4877 | * @return DOMElement |
||
4878 | */ |
||
4879 | public function tagII(stdClass $std) |
||
4923 | |||
4924 | /** |
||
4925 | * Grupo PIS Q01 pai M01 |
||
4926 | * tag NFe/infNFe/det[]/imposto/PIS |
||
4927 | * @param stdClass $std |
||
4928 | * @return DOMElement |
||
4929 | */ |
||
4930 | public function tagPIS(stdClass $std) |
||
5104 | |||
5105 | /** |
||
5106 | * Grupo PIS Substituição Tributária R01 pai M01 |
||
5107 | * tag NFe/infNFe/det[]/imposto/PISST (opcional) |
||
5108 | * @param stdClass $std |
||
5109 | * @return DOMElement |
||
5110 | */ |
||
5111 | public function tagPISST(stdClass $std) |
||
5164 | |||
5165 | /** |
||
5166 | * Grupo COFINS S01 pai M01 |
||
5167 | * tag det[item]/imposto/COFINS (opcional) |
||
5168 | * @param stdClass $std |
||
5169 | * @return DOMElement |
||
5170 | */ |
||
5171 | public function tagCOFINS(stdClass $std) |
||
5267 | |||
5268 | /** |
||
5269 | * Grupo COFINS Substituição Tributária T01 pai M01 |
||
5270 | * tag NFe/infNFe/det[]/imposto/COFINSST (opcional) |
||
5271 | * @param stdClass $std |
||
5272 | * @return DOMElement |
||
5273 | */ |
||
5274 | public function tagCOFINSST(stdClass $std) |
||
5327 | |||
5328 | /** |
||
5329 | * Grupo ISSQN U01 pai M01 |
||
5330 | * tag NFe/infNFe/det[]/imposto/ISSQN (opcional) |
||
5331 | * @param stdClass $std |
||
5332 | * @return DOMElement |
||
5333 | */ |
||
5334 | public function tagISSQN(stdClass $std) |
||
5472 | |||
5473 | /** |
||
5474 | * Informação do Imposto devolvido U50 pai H01 |
||
5475 | * tag NFe/infNFe/det[]/impostoDevol (opcional) |
||
5476 | * @param stdClass $std |
||
5477 | * @return DOMElement |
||
5478 | */ |
||
5479 | public function tagimpostoDevol(stdClass $std) |
||
5509 | |||
5510 | /** |
||
5511 | * Grupo Totais referentes ao ICMS W02 pai W01 |
||
5512 | * tag NFe/infNFe/total/ICMSTot |
||
5513 | * @param stdClass $std |
||
5514 | * @return DOMElement |
||
5515 | */ |
||
5516 | public function tagICMSTot(stdClass $std) |
||
5728 | |||
5729 | /** |
||
5730 | * Grupo Totais referentes ao ISSQN W17 pai W01 |
||
5731 | * tag NFe/infNFe/total/ISSQNTot (opcional) |
||
5732 | * @param stdClass $std |
||
5733 | * @return DOMElement |
||
5734 | */ |
||
5735 | public function tagISSQNTot(stdClass $std) |
||
5841 | |||
5842 | /** |
||
5843 | * Grupo Retenções de Tributos W23 pai W01 |
||
5844 | * tag NFe/infNFe/total/reTrib (opcional) |
||
5845 | * @param stdClass $std |
||
5846 | * @return DOMElement |
||
5847 | */ |
||
5848 | public function tagretTrib(stdClass $std) |
||
5913 | |||
5914 | /** |
||
5915 | * Grupo Informações do Transporte X01 pai A01 |
||
5916 | * tag NFe/infNFe/transp (obrigatório) |
||
5917 | * @param stdClass $std |
||
5918 | * @return DOMElement |
||
5919 | */ |
||
5920 | public function tagtransp(stdClass $std) |
||
5932 | |||
5933 | /** |
||
5934 | * Grupo Transportador X03 pai X01 |
||
5935 | * tag NFe/infNFe/transp/tranporta (opcional) |
||
5936 | * @param stdClass $std |
||
5937 | * @return DOMElement |
||
5938 | */ |
||
5939 | public function tagtransporta(stdClass $std) |
||
6009 | |||
6010 | /** |
||
6011 | * Grupo Retenção ICMS transporte X11 pai X01 |
||
6012 | * tag NFe/infNFe/transp/retTransp (opcional) |
||
6013 | * @param stdClass $std |
||
6014 | * @return DOMElement |
||
6015 | */ |
||
6016 | public function tagretTransp(stdClass $std) |
||
6077 | |||
6078 | /** |
||
6079 | * Grupo Veículo Transporte X18 pai X17.1 |
||
6080 | * tag NFe/infNFe/transp/veicTransp (opcional) |
||
6081 | * @param stdClass $std |
||
6082 | * @return DOMElement |
||
6083 | */ |
||
6084 | public function tagveicTransp(stdClass $std) |
||
6121 | |||
6122 | /** |
||
6123 | * Grupo Reboque X22 pai X17.1 |
||
6124 | * tag NFe/infNFe/transp/reboque (opcional) |
||
6125 | * @param stdClass $std |
||
6126 | * @return DOMElement |
||
6127 | */ |
||
6128 | public function tagreboque(stdClass $std) |
||
6165 | |||
6166 | /** |
||
6167 | * Campo Vagao X25a pai X01 |
||
6168 | * tag NFe/infNFe/transp/vagao (opcional) |
||
6169 | * @param stdClass $std |
||
6170 | */ |
||
6171 | public function tagvagao(stdClass $std) |
||
6185 | |||
6186 | /** |
||
6187 | * Campo Balsa X25b pai X01 |
||
6188 | * tag NFe/infNFe/transp/balsa (opcional) |
||
6189 | * @param stdClass $std |
||
6190 | */ |
||
6191 | public function tagbalsa(stdClass $std) |
||
6205 | |||
6206 | /** |
||
6207 | * Grupo Volumes X26 pai X01 |
||
6208 | * tag NFe/infNFe/transp/vol (opcional) |
||
6209 | * @param stdClass $std |
||
6210 | * @return DOMElement |
||
6211 | */ |
||
6212 | public function tagvol(stdClass $std) |
||
6270 | |||
6271 | /** |
||
6272 | * Grupo Lacres X33 pai X26 |
||
6273 | * tag NFe/infNFe/transp/vol/lacres (opcional) |
||
6274 | * @param stdClass $std |
||
6275 | * @return DOMElement |
||
6276 | */ |
||
6277 | public function taglacres(stdClass $std) |
||
6290 | |||
6291 | /** |
||
6292 | * Node vol |
||
6293 | */ |
||
6294 | protected function buildVol() |
||
6300 | |||
6301 | /** |
||
6302 | * Grupo Pagamento Y pai A01 |
||
6303 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
6304 | * tag NFe/infNFe/pag (obrigatorio na NT2016_002_v1.30) |
||
6305 | * Obrigatório para 55 e 65 |
||
6306 | * @param stdClass $std |
||
6307 | * @return DOMElement |
||
6308 | */ |
||
6309 | public function tagpag($std) |
||
6326 | |||
6327 | /** |
||
6328 | * Grupo de Formas de Pagamento YA01a pai YA01 |
||
6329 | * NOTA: Ajuste NT_2016_002_v1.30 |
||
6330 | * NOTA: Ajuste NT_2016_002_v1 51 |
||
6331 | * tag NFe/infNFe/pag/detPag |
||
6332 | * @param stdClass $std |
||
6333 | * @return DOMElement |
||
6334 | */ |
||
6335 | public function tagdetPag($std) |
||
6412 | |||
6413 | public function tagIntermed(stdClass $std) |
||
6438 | |||
6439 | /** |
||
6440 | * Grupo Fatura Y02 pai Y01 |
||
6441 | * tag NFe/infNFe/cobr/fat (opcional) |
||
6442 | * @param stdClass $std |
||
6443 | * @return DOMElement |
||
6444 | */ |
||
6445 | public function tagfat(stdClass $std) |
||
6487 | |||
6488 | /** |
||
6489 | * Grupo Duplicata Y07 pai Y02 |
||
6490 | * tag NFe/infNFe/cobr/fat/dup (opcional) |
||
6491 | * É necessário criar a tag fat antes de criar as duplicatas |
||
6492 | * @param stdClass $std |
||
6493 | * @return DOMElement |
||
6494 | */ |
||
6495 | public function tagdup(stdClass $std) |
||
6529 | |||
6530 | /** |
||
6531 | * Grupo de Informações Adicionais Z01 pai A01 |
||
6532 | * tag NFe/infNFe/infAdic (opcional) |
||
6533 | * @param stdClass $std |
||
6534 | * @return DOMElement |
||
6535 | */ |
||
6536 | public function taginfAdic(stdClass $std) |
||
6557 | |||
6558 | /** |
||
6559 | * Grupo Campo de uso livre do contribuinte Z04 pai Z01 |
||
6560 | * tag NFe/infNFe/infAdic/obsCont (opcional) |
||
6561 | * O método taginfAdic deve ter sido carregado antes |
||
6562 | * @param stdClass $std |
||
6563 | * @return DOMElement |
||
6564 | */ |
||
6565 | public function tagobsCont(stdClass $std) |
||
6582 | |||
6583 | /** |
||
6584 | * Grupo Campo de uso livre do Fisco Z07 pai Z01 |
||
6585 | * tag NFe/infNFe/infAdic/obsFisco (opcional) |
||
6586 | * O método taginfAdic deve ter sido carregado antes |
||
6587 | * @param stdClass $std |
||
6588 | * @return DOMElement |
||
6589 | */ |
||
6590 | public function tagobsFisco(stdClass $std) |
||
6607 | |||
6608 | /** |
||
6609 | * Grupo Processo referenciado Z10 pai Z01 (NT2012.003) |
||
6610 | * tag NFe/infNFe/procRef (opcional) |
||
6611 | * O método taginfAdic deve ter sido carregado antes |
||
6612 | * @param stdClass $std |
||
6613 | * @return DOMElement |
||
6614 | */ |
||
6615 | public function tagprocRef($std) |
||
6638 | |||
6639 | /** |
||
6640 | * Grupo Exportação ZA01 pai A01 |
||
6641 | * tag NFe/infNFe/exporta (opcional) |
||
6642 | * @param stdClass $std |
||
6643 | * @return DOMElement |
||
6644 | */ |
||
6645 | public function tagexporta(stdClass $std) |
||
6673 | |||
6674 | /** |
||
6675 | * Grupo Compra ZB01 pai A01 |
||
6676 | * tag NFe/infNFe/compra (opcional) |
||
6677 | * @param stdClass $std |
||
6678 | * @return DOMElement |
||
6679 | */ |
||
6680 | public function tagcompra(stdClass $std) |
||
6708 | |||
6709 | /** |
||
6710 | * Grupo Cana ZC01 pai A01 |
||
6711 | * tag NFe/infNFe/cana (opcional) |
||
6712 | * @param stdClass $std |
||
6713 | * @return DOMElement |
||
6714 | */ |
||
6715 | public function tagcana(stdClass $std) |
||
6787 | |||
6788 | /** |
||
6789 | * Grupo Fornecimento diário de cana ZC04 pai ZC01 |
||
6790 | * tag NFe/infNFe/cana/forDia |
||
6791 | * @param stdClass $std |
||
6792 | * @return DOMElement |
||
6793 | */ |
||
6794 | public function tagforDia(stdClass $std) |
||
6809 | |||
6810 | /** |
||
6811 | * Grupo Deduções – Taxas e Contribuições ZC10 pai ZC01 |
||
6812 | * tag NFe/infNFe/cana/deduc (opcional) |
||
6813 | * @param stdClass $std |
||
6814 | * @return DOMElement |
||
6815 | */ |
||
6816 | public function tagdeduc(stdClass $std) |
||
6839 | |||
6840 | /** |
||
6841 | * Informações suplementares da Nota Fiscal |
||
6842 | * @param stdClass $std |
||
6843 | * @return DOMElement |
||
6844 | */ |
||
6845 | public function taginfNFeSupl(stdClass $std) |
||
6865 | |||
6866 | /** |
||
6867 | * Informações do Responsável técnico ZD01 pai A01 |
||
6868 | * tag NFe/infNFe/infRespTec (opcional) |
||
6869 | * @param stdClass $std |
||
6870 | * @return DOMElement |
||
6871 | * @throws RuntimeException |
||
6872 | */ |
||
6873 | public function taginfRespTec(stdClass $std) |
||
6938 | |||
6939 | /** |
||
6940 | * Tag raiz da NFe |
||
6941 | * tag NFe DOMNode |
||
6942 | * Função chamada pelo método [ monta ] |
||
6943 | * |
||
6944 | * @return DOMElement |
||
6945 | */ |
||
6946 | protected function buildNFe() |
||
6954 | |||
6955 | /** |
||
6956 | * Informação de Documentos Fiscais referenciados BA01 pai B01 |
||
6957 | * tag NFe/infNFe/ide/NFref |
||
6958 | * Podem ser criados até 500 desses Nodes por NFe |
||
6959 | * Função chamada pelos métodos |
||
6960 | * [tagrefNFe] [tagrefNF] [tagrefNFP] [tagCTeref] [tagrefECF] |
||
6961 | */ |
||
6962 | protected function buildNFref() |
||
6967 | |||
6968 | /** |
||
6969 | * Insere dentro dentro das tags imposto o ICMS IPI II PIS COFINS ISSQN |
||
6970 | * tag NFe/infNFe/det[]/imposto |
||
6971 | * @return void |
||
6972 | */ |
||
6973 | protected function buildImp() |
||
7006 | |||
7007 | /** |
||
7008 | * Grupo COFINS tributado pela alíquota S02 pai S01 |
||
7009 | * tag det/imposto/COFINS/COFINSAliq (opcional) |
||
7010 | * Função chamada pelo método [ tagCOFINS ] |
||
7011 | * @param stdClass $std |
||
7012 | * @return DOMElement |
||
7013 | */ |
||
7014 | protected function buildCOFINSAliq($std) |
||
7047 | |||
7048 | /** |
||
7049 | * Grupo COFINS não tributado S04 pai S01 |
||
7050 | * tag NFe/infNFe/det[]/imposto/COFINS/COFINSNT (opcional) |
||
7051 | * Função chamada pelo método [ tagCOFINS ] |
||
7052 | * @param stdClass $std |
||
7053 | * @return DOMElement |
||
7054 | */ |
||
7055 | protected function buildCOFINSNT(stdClass $std) |
||
7067 | |||
7068 | /** |
||
7069 | * Grupo COFINS Outras Operações S05 pai S01 |
||
7070 | * tag NFe/infNFe/det[]/imposto/COFINS/COFINSoutr (opcional) |
||
7071 | * Função chamada pelo método [ tagCOFINS ] |
||
7072 | * @param stdClass $std |
||
7073 | * @return DOMElement |
||
7074 | */ |
||
7075 | protected function buildCOFINSoutr(stdClass $std) |
||
7122 | |||
7123 | /** |
||
7124 | * Insere dentro da tag det os produtos |
||
7125 | * tag NFe/infNFe/det[] |
||
7126 | * @return array|string |
||
7127 | */ |
||
7128 | protected function buildDet() |
||
7281 | |||
7282 | /** |
||
7283 | * Insere a tag pag, os detalhamentos dos pagamentos e cartoes |
||
7284 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
7285 | * tag NFe/infNFe/pag/ |
||
7286 | * tag NFe/infNFe/pag/detPag[] |
||
7287 | * tag NFe/infNFe/pag/detPag[]/Card |
||
7288 | */ |
||
7289 | protected function buildTagPag() |
||
7293 | |||
7294 | /** |
||
7295 | * Grupo Totais da NF-e W01 pai A01 |
||
7296 | * tag NFe/infNFe/total |
||
7297 | */ |
||
7298 | protected function buildTotal() |
||
7338 | |||
7339 | /** |
||
7340 | * Grupo Cobrança Y01 pai A01 |
||
7341 | * tag NFe/infNFe/cobr (opcional) |
||
7342 | * Depende de fat |
||
7343 | */ |
||
7344 | protected function buildCobr() |
||
7350 | |||
7351 | /** |
||
7352 | * Grupo de Informações Adicionais Z01 pai A01 |
||
7353 | * tag NFe/infNFe/infAdic (opcional) |
||
7354 | * Função chamada pelos metodos |
||
7355 | * [taginfAdic] [tagobsCont] [tagobsFisco] [tagprocRef] |
||
7356 | * @return DOMElement |
||
7357 | */ |
||
7358 | protected function buildInfAdic() |
||
7365 | |||
7366 | /** |
||
7367 | * Remonta a chave da NFe de 44 digitos com base em seus dados |
||
7368 | * já contidos na NFE. |
||
7369 | * Isso é útil no caso da chave informada estar errada |
||
7370 | * se a chave estiver errada a mesma é substituida |
||
7371 | * @param Dom $dom |
||
7372 | * @return void |
||
7373 | */ |
||
7374 | protected function checkNFeKey(Dom $dom) |
||
7425 | |||
7426 | /** |
||
7427 | * Retorna os erros detectados |
||
7428 | * @return array |
||
7429 | */ |
||
7430 | public function getErrors() |
||
7434 | |||
7435 | /** |
||
7436 | * Includes missing or unsupported properties in stdClass |
||
7437 | * Replace all unsuported chars |
||
7438 | * @param stdClass $std |
||
7439 | * @param array $possible |
||
7440 | * @return stdClass |
||
7441 | */ |
||
7442 | 7 | protected function equilizeParameters(stdClass $std, $possible) |
|
7459 | |||
7460 | /** |
||
7461 | * Calcula hash sha1 retornando Base64Binary |
||
7462 | * @param string $CSRT |
||
7463 | * @return string |
||
7464 | */ |
||
7465 | protected function hashCSRT($CSRT) |
||
7470 | |||
7471 | protected function conditionalNumberFormatting($value = null, $decimal = 2) |
||
7478 | } |
||
7479 |
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.