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 | * @var array |
||
| 33 | */ |
||
| 34 | public $errors = []; |
||
| 35 | /** |
||
| 36 | * @var string |
||
| 37 | */ |
||
| 38 | public $chNFe; |
||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | public $xml; |
||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | protected $version; |
||
| 47 | /** |
||
| 48 | * @var integer |
||
| 49 | */ |
||
| 50 | protected $mod = 55; |
||
| 51 | /** |
||
| 52 | * @var \NFePHP\Common\DOMImproved |
||
| 53 | */ |
||
| 54 | public $dom; |
||
| 55 | /** |
||
| 56 | * @var integer |
||
| 57 | */ |
||
| 58 | protected $tpAmb = 2; |
||
| 59 | /** |
||
| 60 | * @var DOMElement |
||
| 61 | */ |
||
| 62 | protected $NFe; |
||
| 63 | /** |
||
| 64 | * @var DOMElement |
||
| 65 | */ |
||
| 66 | protected $infNFe; |
||
| 67 | /** |
||
| 68 | * @var DOMElement |
||
| 69 | */ |
||
| 70 | protected $ide; |
||
| 71 | /** |
||
| 72 | * @var DOMElement |
||
| 73 | */ |
||
| 74 | protected $emit; |
||
| 75 | /** |
||
| 76 | * @var DOMElement |
||
| 77 | */ |
||
| 78 | protected $enderEmit; |
||
| 79 | /** |
||
| 80 | * @var DOMElement |
||
| 81 | */ |
||
| 82 | protected $dest; |
||
| 83 | /** |
||
| 84 | * @var DOMElement |
||
| 85 | */ |
||
| 86 | protected $enderDest; |
||
| 87 | /** |
||
| 88 | * @var DOMElement |
||
| 89 | */ |
||
| 90 | protected $retirada; |
||
| 91 | /** |
||
| 92 | * @var DOMElement |
||
| 93 | */ |
||
| 94 | protected $entrega; |
||
| 95 | /** |
||
| 96 | * @var DOMElement |
||
| 97 | */ |
||
| 98 | protected $total; |
||
| 99 | /** |
||
| 100 | * @var DOMElement |
||
| 101 | */ |
||
| 102 | protected $cobr; |
||
| 103 | /** |
||
| 104 | * @var DOMElement |
||
| 105 | */ |
||
| 106 | protected $transp; |
||
| 107 | /** |
||
| 108 | * @var DOMElement |
||
| 109 | */ |
||
| 110 | protected $infAdic; |
||
| 111 | /** |
||
| 112 | * @var DOMElement |
||
| 113 | */ |
||
| 114 | protected $exporta; |
||
| 115 | /** |
||
| 116 | * @var DOMElement |
||
| 117 | */ |
||
| 118 | protected $compra; |
||
| 119 | /** |
||
| 120 | * @var DOMElement |
||
| 121 | */ |
||
| 122 | protected $cana; |
||
| 123 | /** |
||
| 124 | * @var DOMElement |
||
| 125 | */ |
||
| 126 | protected $infNFeSupl; |
||
| 127 | /** |
||
| 128 | * @var array of DOMElements |
||
| 129 | */ |
||
| 130 | protected $aNFref = []; |
||
| 131 | /** |
||
| 132 | * @var array of DOMElements |
||
| 133 | */ |
||
| 134 | protected $aDup = []; |
||
| 135 | /** |
||
| 136 | * @var DOMElement |
||
| 137 | */ |
||
| 138 | protected $pag; |
||
| 139 | /** |
||
| 140 | * @var array of DOMElements |
||
| 141 | */ |
||
| 142 | protected $aDetPag = []; |
||
| 143 | /** |
||
| 144 | * @var DOMElement |
||
| 145 | */ |
||
| 146 | protected $intermed; |
||
| 147 | /** |
||
| 148 | * @var array of DOMElements |
||
| 149 | */ |
||
| 150 | protected $aReboque = []; |
||
| 151 | /** |
||
| 152 | * @var array of DOMElements |
||
| 153 | */ |
||
| 154 | protected $aVol = []; |
||
| 155 | /** |
||
| 156 | * @var array of DOMElements |
||
| 157 | */ |
||
| 158 | protected $aAutXML = []; |
||
| 159 | /** |
||
| 160 | * @var array of DOMElements |
||
| 161 | */ |
||
| 162 | protected $aDet = []; |
||
| 163 | /** |
||
| 164 | * @var array of DOMElements |
||
| 165 | */ |
||
| 166 | protected $aProd = []; |
||
| 167 | /** |
||
| 168 | * @var array of DOMElements |
||
| 169 | */ |
||
| 170 | protected $aRastro = []; |
||
| 171 | /** |
||
| 172 | * @var array of DOMElements |
||
| 173 | */ |
||
| 174 | protected $aNVE = []; |
||
| 175 | /** |
||
| 176 | * @var array of DOMElements |
||
| 177 | */ |
||
| 178 | protected $aCest = []; |
||
| 179 | /** |
||
| 180 | * @var array of DOMElements |
||
| 181 | */ |
||
| 182 | protected $aRECOPI = []; |
||
| 183 | /** |
||
| 184 | * @var array of DOMElements |
||
| 185 | */ |
||
| 186 | protected $aDetExport = []; |
||
| 187 | /** |
||
| 188 | * @var array of DOMElements |
||
| 189 | */ |
||
| 190 | protected $aDI = []; |
||
| 191 | /** |
||
| 192 | * @var array of DOMElements |
||
| 193 | */ |
||
| 194 | protected $aAdi = []; |
||
| 195 | /** |
||
| 196 | * @var array of DOMElements |
||
| 197 | */ |
||
| 198 | protected $aVeicProd = []; |
||
| 199 | /** |
||
| 200 | * @var array of DOMElements |
||
| 201 | */ |
||
| 202 | protected $aMed = []; |
||
| 203 | /** |
||
| 204 | * @var array of DOMElements |
||
| 205 | */ |
||
| 206 | protected $aArma = []; |
||
| 207 | /** |
||
| 208 | * @var array of DOMElements |
||
| 209 | */ |
||
| 210 | protected $aComb = []; |
||
| 211 | /** |
||
| 212 | * @var array of DOMElements |
||
| 213 | */ |
||
| 214 | protected $aEncerrante = []; |
||
| 215 | /** |
||
| 216 | * @var array of DOMElements |
||
| 217 | */ |
||
| 218 | protected $aImposto = []; |
||
| 219 | /** |
||
| 220 | * @var array of DOMElements |
||
| 221 | */ |
||
| 222 | protected $aICMS = []; |
||
| 223 | /** |
||
| 224 | * @var array of DOMElements |
||
| 225 | */ |
||
| 226 | protected $aICMSUFDest = []; |
||
| 227 | /** |
||
| 228 | * @var array of DOMElements |
||
| 229 | */ |
||
| 230 | protected $aIPI = []; |
||
| 231 | /** |
||
| 232 | * @var array of DOMElements |
||
| 233 | */ |
||
| 234 | protected $aII = []; |
||
| 235 | /** |
||
| 236 | * @var array of DOMElements |
||
| 237 | */ |
||
| 238 | protected $aISSQN = []; |
||
| 239 | /** |
||
| 240 | * @var array |
||
| 241 | */ |
||
| 242 | protected $aPIS = []; |
||
| 243 | /** |
||
| 244 | * @var array of DOMElements |
||
| 245 | */ |
||
| 246 | protected $aPISST = []; |
||
| 247 | /** |
||
| 248 | * @var array of DOMElements |
||
| 249 | */ |
||
| 250 | protected $aCOFINS = []; |
||
| 251 | /** |
||
| 252 | * @var array of DOMElements |
||
| 253 | */ |
||
| 254 | protected $aCOFINSST = []; |
||
| 255 | /** |
||
| 256 | * @var array of DOMElements |
||
| 257 | */ |
||
| 258 | protected $aImpostoDevol = []; |
||
| 259 | /** |
||
| 260 | * @var array of DOMElements |
||
| 261 | */ |
||
| 262 | protected $aInfAdProd = []; |
||
| 263 | /** |
||
| 264 | * @var array of DOMElements |
||
| 265 | */ |
||
| 266 | protected $aObsCont = []; |
||
| 267 | /** |
||
| 268 | * @var array of DOMElements |
||
| 269 | */ |
||
| 270 | protected $aObsFisco = []; |
||
| 271 | /** |
||
| 272 | * @var array of DOMElements |
||
| 273 | */ |
||
| 274 | protected $aProcRef = []; |
||
| 275 | /** |
||
| 276 | * @var stdClass |
||
| 277 | */ |
||
| 278 | protected $stdTot; |
||
| 279 | /** |
||
| 280 | * @var DOMElement |
||
| 281 | */ |
||
| 282 | protected $infRespTec; |
||
| 283 | /** |
||
| 284 | * @var string |
||
| 285 | */ |
||
| 286 | protected $csrt; |
||
| 287 | /** |
||
| 288 | * @var boolean |
||
| 289 | */ |
||
| 290 | protected $replaceAccentedChars = false; |
||
| 291 | |||
| 292 | /** |
||
| 293 | * Função construtora cria um objeto DOMDocument |
||
| 294 | * que será carregado com o documento fiscal |
||
| 295 | */ |
||
| 296 | 7 | public function __construct() |
|
| 297 | { |
||
| 298 | 7 | $this->dom = new Dom('1.0', 'UTF-8'); |
|
| 299 | 7 | $this->dom->preserveWhiteSpace = false; |
|
| 300 | 7 | $this->dom->formatOutput = false; |
|
| 301 | //elemento totalizador |
||
| 302 | 7 | $this->stdTot = new \stdClass(); |
|
| 303 | 7 | $this->stdTot->vBC = 0; |
|
| 304 | 7 | $this->stdTot->vICMS = 0; |
|
| 305 | 7 | $this->stdTot->vICMSDeson = 0; |
|
| 306 | 7 | $this->stdTot->vFCP = 0; |
|
| 307 | 7 | $this->stdTot->vFCPUFDest = 0; |
|
| 308 | 7 | $this->stdTot->vICMSUFDest = 0; |
|
| 309 | 7 | $this->stdTot->vICMSUFRemet = 0; |
|
| 310 | 7 | $this->stdTot->vBCST = 0; |
|
| 311 | 7 | $this->stdTot->vST = 0; |
|
| 312 | 7 | $this->stdTot->vFCPST = 0; |
|
| 313 | 7 | $this->stdTot->vFCPSTRet = 0; |
|
| 314 | 7 | $this->stdTot->vProd = 0; |
|
| 315 | 7 | $this->stdTot->vFrete = 0; |
|
| 316 | 7 | $this->stdTot->vSeg = 0; |
|
| 317 | 7 | $this->stdTot->vDesc = 0; |
|
| 318 | 7 | $this->stdTot->vII = 0; |
|
| 319 | 7 | $this->stdTot->vIPI = 0; |
|
| 320 | 7 | $this->stdTot->vIPIDevol = 0; |
|
| 321 | 7 | $this->stdTot->vPIS = 0; |
|
| 322 | 7 | $this->stdTot->vCOFINS = 0; |
|
| 323 | 7 | $this->stdTot->vOutro = 0; |
|
| 324 | 7 | $this->stdTot->vNF = 0; |
|
| 325 | 7 | $this->stdTot->vTotTrib = 0; |
|
| 326 | 7 | } |
|
| 327 | |||
| 328 | /** |
||
| 329 | * Set character convertion to ASCII only ou not |
||
| 330 | * @param bool $option |
||
| 331 | */ |
||
| 332 | public function setOnlyAscii($option = false) |
||
| 333 | { |
||
| 334 | $this->replaceAccentedChars = $option; |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * Returns xml string and assembly it is necessary |
||
| 339 | * @return string |
||
| 340 | */ |
||
| 341 | public function getXML() |
||
| 342 | { |
||
| 343 | if (empty($this->xml)) { |
||
| 344 | $this->montaNFe(); |
||
| 345 | } |
||
| 346 | return $this->xml; |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * Retorns the key number of NFe (44 digits) |
||
| 351 | * @return string |
||
| 352 | */ |
||
| 353 | 1 | public function getChave() |
|
| 354 | { |
||
| 355 | 1 | return $this->chNFe; |
|
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * Returns the model of NFe 55 or 65 |
||
| 360 | * @return int |
||
| 361 | */ |
||
| 362 | public function getModelo() |
||
| 363 | { |
||
| 364 | return $this->mod; |
||
| 365 | } |
||
| 366 | |||
| 367 | /** |
||
| 368 | * Call method of xml assembly. For compatibility only. |
||
| 369 | * @return string |
||
| 370 | */ |
||
| 371 | public function montaNFe() |
||
| 372 | { |
||
| 373 | return $this->monta(); |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * NFe xml mount method |
||
| 378 | * this function returns TRUE on success or FALSE on error |
||
| 379 | * The xml of the NFe must be retrieved by the getXML() function or |
||
| 380 | * directly by the public property $xml |
||
| 381 | * |
||
| 382 | * @return string |
||
| 383 | * @throws RuntimeException |
||
| 384 | */ |
||
| 385 | public function monta() |
||
| 386 | { |
||
| 387 | if (!empty($this->errors)) { |
||
| 388 | $this->errors = array_merge($this->errors, $this->dom->errors); |
||
| 389 | } else { |
||
| 390 | $this->errors = $this->dom->errors; |
||
| 391 | } |
||
| 392 | //cria a tag raiz da Nfe |
||
| 393 | $this->buildNFe(); |
||
| 394 | //processa nfeRef e coloca as tags na tag ide |
||
| 395 | foreach ($this->aNFref as $nfeRef) { |
||
| 396 | $this->dom->appChild($this->ide, $nfeRef, 'Falta tag "ide"'); |
||
| 397 | } |
||
| 398 | //monta as tags det e coloca no array $this->aDet com os detalhes dos produtos |
||
| 399 | $this->buildDet(); |
||
| 400 | //[2] tag ide (5 B01) |
||
| 401 | $this->dom->appChild($this->infNFe, $this->ide, 'Falta tag "infNFe"'); |
||
| 402 | //[8] tag emit (30 C01) |
||
| 403 | $this->dom->appChild($this->infNFe, $this->emit, 'Falta tag "infNFe"'); |
||
| 404 | //[10] tag dest (62 E01) |
||
| 405 | $this->dom->appChild($this->infNFe, $this->dest, 'Falta tag "infNFe"'); |
||
| 406 | //[12] tag retirada (80 F01) |
||
| 407 | $this->dom->appChild($this->infNFe, $this->retirada, 'Falta tag "infNFe"'); |
||
| 408 | //[13] tag entrega (89 G01) |
||
| 409 | $this->dom->appChild($this->infNFe, $this->entrega, 'Falta tag "infNFe"'); |
||
| 410 | //[14] tag autXML (97a.1 G50) |
||
| 411 | foreach ($this->aAutXML as $aut) { |
||
| 412 | $this->dom->appChild($this->infNFe, $aut, 'Falta tag "infNFe"'); |
||
| 413 | } |
||
| 414 | //[14a] tag det (98 H01) |
||
| 415 | foreach ($this->aDet as $det) { |
||
| 416 | $this->dom->appChild($this->infNFe, $det, 'Falta tag "infNFe"'); |
||
| 417 | } |
||
| 418 | //força a construção do total caso não sejam chamado metodo tagICMSTot() |
||
| 419 | if (empty($this->total)) { |
||
| 420 | $std = new \stdClass(); |
||
| 421 | $this->tagICMSTot($std); |
||
| 422 | } |
||
| 423 | //[28a] tag total (326 W01) |
||
| 424 | $this->dom->appChild($this->infNFe, $this->total, 'Falta tag "infNFe"'); |
||
| 425 | //mota a tag vol |
||
| 426 | $this->buildVol(); |
||
| 427 | //[32] tag transp (356 X01) |
||
| 428 | $this->dom->appChild($this->infNFe, $this->transp, 'Falta tag "infNFe"'); |
||
| 429 | //[39a] tag cobr (389 Y01) |
||
| 430 | $this->dom->appChild($this->infNFe, $this->cobr, 'Falta tag "infNFe"'); |
||
| 431 | //[42] tag pag (398a YA01) |
||
| 432 | //processa Pag e coloca as tags na tag pag |
||
| 433 | $this->buildTagPag(); |
||
| 434 | //[43] tag infIntermed (398.26 YB01) NT 2020.006_1.00 |
||
| 435 | $this->dom->appChild($this->infNFe, $this->intermed, 'Falta tag "infNFe"'); |
||
| 436 | //[44] tag infAdic (399 Z01) |
||
| 437 | $this->dom->appChild($this->infNFe, $this->infAdic, 'Falta tag "infNFe"'); |
||
| 438 | //[48] tag exporta (402 ZA01) |
||
| 439 | $this->dom->appChild($this->infNFe, $this->exporta, 'Falta tag "infNFe"'); |
||
| 440 | //[49] tag compra (405 ZB01) |
||
| 441 | $this->dom->appChild($this->infNFe, $this->compra, 'Falta tag "infNFe"'); |
||
| 442 | //[50] tag cana (409 ZC01) |
||
| 443 | $this->dom->appChild($this->infNFe, $this->cana, 'Falta tag "infNFe"'); |
||
| 444 | //Responsável Técnico |
||
| 445 | $this->dom->appChild($this->infNFe, $this->infRespTec, 'Falta tag "infNFe"'); |
||
| 446 | //[1] tag infNFe (1 A01) |
||
| 447 | $this->dom->appChild($this->NFe, $this->infNFe, 'Falta tag "NFe"'); |
||
| 448 | //[0] tag NFe |
||
| 449 | $this->dom->appendChild($this->NFe); |
||
| 450 | // testa da chave |
||
| 451 | $this->checkNFeKey($this->dom); |
||
| 452 | $this->xml = $this->dom->saveXML(); |
||
| 453 | if (count($this->errors) > 0) { |
||
| 454 | throw new RuntimeException('Existem erros nas tags. Obtenha os erros com getErrors().'); |
||
| 455 | } |
||
| 456 | return $this->xml; |
||
| 457 | } |
||
| 458 | |||
| 459 | /** |
||
| 460 | * Informações da NF-e A01 pai NFe |
||
| 461 | * tag NFe/infNFe |
||
| 462 | * @param stdClass $std |
||
| 463 | * @return DOMElement |
||
| 464 | */ |
||
| 465 | 7 | public function taginfNFe(stdClass $std) |
|
| 466 | { |
||
| 467 | 7 | $possible = ['Id', 'versao', 'pk_nItem']; |
|
| 468 | 7 | $std = $this->equilizeParameters($std, $possible); |
|
| 469 | 7 | $chave = preg_replace('/[^0-9]/', '', $std->Id); |
|
| 470 | 7 | $this->infNFe = $this->dom->createElement("infNFe"); |
|
| 471 | 7 | $this->infNFe->setAttribute("Id", 'NFe' . $chave); |
|
| 472 | 7 | $this->infNFe->setAttribute( |
|
| 473 | 7 | "versao", |
|
| 474 | 7 | $std->versao |
|
| 475 | ); |
||
| 476 | 7 | $this->version = $std->versao; |
|
| 477 | 7 | if (!empty($std->pk_nItem)) { |
|
| 478 | 1 | $this->infNFe->setAttribute("pk_nItem", $std->pk_nItem); |
|
| 479 | } |
||
| 480 | 7 | $this->chNFe = $chave; |
|
| 481 | 7 | return $this->infNFe; |
|
| 482 | } |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Informações de identificação da NF-e B01 pai A01 |
||
| 486 | * NOTA: Ajustado para NT2020_006_v1.00 |
||
| 487 | * tag NFe/infNFe/ide |
||
| 488 | * @param stdClass $std |
||
| 489 | * @return DOMElement |
||
| 490 | */ |
||
| 491 | 4 | public function tagide(stdClass $std) |
|
| 492 | { |
||
| 493 | $possible = [ |
||
| 494 | 4 | 'cUF', |
|
| 495 | 'cNF', |
||
| 496 | 'natOp', |
||
| 497 | 'indPag', |
||
| 498 | 'mod', |
||
| 499 | 'serie', |
||
| 500 | 'nNF', |
||
| 501 | 'dhEmi', |
||
| 502 | 'dhSaiEnt', |
||
| 503 | 'tpNF', |
||
| 504 | 'idDest', |
||
| 505 | 'cMunFG', |
||
| 506 | 'tpImp', |
||
| 507 | 'tpEmis', |
||
| 508 | 'cDV', |
||
| 509 | 'tpAmb', |
||
| 510 | 'finNFe', |
||
| 511 | 'indFinal', |
||
| 512 | 'indPres', |
||
| 513 | 'indIntermed', |
||
| 514 | 'procEmi', |
||
| 515 | 'verProc', |
||
| 516 | 'dhCont', |
||
| 517 | 'xJust' |
||
| 518 | ]; |
||
| 519 | 4 | $std = $this->equilizeParameters($std, $possible); |
|
| 520 | |||
| 521 | 4 | if (empty($std->cNF)) { |
|
| 522 | 1 | $std->cNF = Keys::random($std->nNF); |
|
| 523 | } |
||
| 524 | 4 | if (empty($std->cDV)) { |
|
| 525 | 2 | $std->cDV = 0; |
|
| 526 | } |
||
| 527 | //validação conforme NT 2019.001 |
||
| 528 | 4 | $std->cNF = str_pad($std->cNF, 8, '0', STR_PAD_LEFT); |
|
| 529 | 4 | if (intval($std->cNF) == intval($std->nNF)) { |
|
| 530 | throw new InvalidArgumentException("O valor [{$std->cNF}] não é " |
||
| 531 | . "aceitável para cNF, não pode ser igual ao de nNF, vide NT2019.001"); |
||
| 532 | } |
||
| 533 | 4 | if (method_exists(Keys::class, 'cNFIsValid')) { |
|
| 534 | 4 | if (!Keys::cNFIsValid($std->cNF)) { |
|
| 535 | throw new InvalidArgumentException("O valor [{$std->cNF}] para cNF " |
||
| 536 | . "é invalido, deve respeitar a NT2019.001"); |
||
| 537 | } |
||
| 538 | } |
||
| 539 | 4 | $this->tpAmb = $std->tpAmb; |
|
| 540 | 4 | $this->mod = $std->mod; |
|
| 541 | 4 | $identificador = 'B01 <ide> - '; |
|
| 542 | 4 | $ide = $this->dom->createElement("ide"); |
|
| 543 | 4 | $this->dom->addChild( |
|
| 544 | 4 | $ide, |
|
| 545 | 4 | "cUF", |
|
| 546 | 4 | $std->cUF, |
|
| 547 | 4 | true, |
|
| 548 | 4 | $identificador . "Código da UF do emitente do Documento Fiscal" |
|
| 549 | ); |
||
| 550 | 4 | $this->dom->addChild( |
|
| 551 | 4 | $ide, |
|
| 552 | 4 | "cNF", |
|
| 553 | 4 | $std->cNF, |
|
| 554 | 4 | true, |
|
| 555 | 4 | $identificador . "Código Numérico que compõe a Chave de Acesso" |
|
| 556 | ); |
||
| 557 | 4 | $this->dom->addChild( |
|
| 558 | 4 | $ide, |
|
| 559 | 4 | "natOp", |
|
| 560 | 4 | substr(trim($std->natOp), 0, 60), |
|
| 561 | 4 | true, |
|
| 562 | 4 | $identificador . "Descrição da Natureza da Operação" |
|
| 563 | ); |
||
| 564 | 4 | $this->dom->addChild( |
|
| 565 | 4 | $ide, |
|
| 566 | 4 | "mod", |
|
| 567 | 4 | $std->mod, |
|
| 568 | 4 | true, |
|
| 569 | 4 | $identificador . "Código do Modelo do Documento Fiscal" |
|
| 570 | ); |
||
| 571 | 4 | $this->dom->addChild( |
|
| 572 | 4 | $ide, |
|
| 573 | 4 | "serie", |
|
| 574 | 4 | $std->serie, |
|
| 575 | 4 | true, |
|
| 576 | 4 | $identificador . "Série do Documento Fiscal" |
|
| 577 | ); |
||
| 578 | 4 | $this->dom->addChild( |
|
| 579 | 4 | $ide, |
|
| 580 | 4 | "nNF", |
|
| 581 | 4 | $std->nNF, |
|
| 582 | 4 | true, |
|
| 583 | 4 | $identificador . "Número do Documento Fiscal" |
|
| 584 | ); |
||
| 585 | 4 | $this->dom->addChild( |
|
| 586 | 4 | $ide, |
|
| 587 | 4 | "dhEmi", |
|
| 588 | 4 | $std->dhEmi, |
|
| 589 | 4 | true, |
|
| 590 | 4 | $identificador . "Data e hora de emissão do Documento Fiscal" |
|
| 591 | ); |
||
| 592 | 4 | if ($std->mod == '55' && !empty($std->dhSaiEnt)) { |
|
| 593 | 1 | $this->dom->addChild( |
|
| 594 | 1 | $ide, |
|
| 595 | 1 | "dhSaiEnt", |
|
| 596 | 1 | $std->dhSaiEnt, |
|
| 597 | 1 | false, |
|
| 598 | 1 | $identificador . "Data e hora de Saída ou da Entrada da Mercadoria/Produto" |
|
| 599 | ); |
||
| 600 | } |
||
| 601 | 4 | $this->dom->addChild( |
|
| 602 | 4 | $ide, |
|
| 603 | 4 | "tpNF", |
|
| 604 | 4 | $std->tpNF, |
|
| 605 | 4 | true, |
|
| 606 | 4 | $identificador . "Tipo de Operação" |
|
| 607 | ); |
||
| 608 | 4 | $this->dom->addChild( |
|
| 609 | 4 | $ide, |
|
| 610 | 4 | "idDest", |
|
| 611 | 4 | $std->idDest, |
|
| 612 | 4 | true, |
|
| 613 | 4 | $identificador . "Identificador de local de destino da operação" |
|
| 614 | ); |
||
| 615 | 4 | $this->dom->addChild( |
|
| 616 | 4 | $ide, |
|
| 617 | 4 | "cMunFG", |
|
| 618 | 4 | $std->cMunFG, |
|
| 619 | 4 | true, |
|
| 620 | 4 | $identificador . "Código do Município de Ocorrência do Fato Gerador" |
|
| 621 | ); |
||
| 622 | 4 | $this->dom->addChild( |
|
| 623 | 4 | $ide, |
|
| 624 | 4 | "tpImp", |
|
| 625 | 4 | $std->tpImp, |
|
| 626 | 4 | true, |
|
| 627 | 4 | $identificador . "Formato de Impressão do DANFE" |
|
| 628 | ); |
||
| 629 | 4 | $this->dom->addChild( |
|
| 630 | 4 | $ide, |
|
| 631 | 4 | "tpEmis", |
|
| 632 | 4 | $std->tpEmis, |
|
| 633 | 4 | true, |
|
| 634 | 4 | $identificador . "Tipo de Emissão da NF-e" |
|
| 635 | ); |
||
| 636 | 4 | $this->dom->addChild( |
|
| 637 | 4 | $ide, |
|
| 638 | 4 | "cDV", |
|
| 639 | 4 | !empty($std->cDV) ? $std->cDV : '0', |
|
| 640 | 4 | true, |
|
| 641 | 4 | $identificador . "Dígito Verificador da Chave de Acesso da NF-e" |
|
| 642 | ); |
||
| 643 | 4 | $this->dom->addChild( |
|
| 644 | 4 | $ide, |
|
| 645 | 4 | "tpAmb", |
|
| 646 | 4 | $std->tpAmb, |
|
| 647 | 4 | true, |
|
| 648 | 4 | $identificador . "Identificação do Ambiente" |
|
| 649 | ); |
||
| 650 | 4 | $this->dom->addChild( |
|
| 651 | 4 | $ide, |
|
| 652 | 4 | "finNFe", |
|
| 653 | 4 | $std->finNFe, |
|
| 654 | 4 | true, |
|
| 655 | 4 | $identificador . "Finalidade de emissão da NF-e" |
|
| 656 | ); |
||
| 657 | 4 | $this->dom->addChild( |
|
| 658 | 4 | $ide, |
|
| 659 | 4 | "indFinal", |
|
| 660 | 4 | $std->indFinal, |
|
| 661 | 4 | true, |
|
| 662 | 4 | $identificador . "Indica operação com Consumidor final" |
|
| 663 | ); |
||
| 664 | 4 | $this->dom->addChild( |
|
| 665 | 4 | $ide, |
|
| 666 | 4 | "indPres", |
|
| 667 | 4 | $std->indPres, |
|
| 668 | 4 | true, |
|
| 669 | 4 | $identificador . "Indicador de presença do comprador no estabelecimento comercial no momento da operação" |
|
| 670 | ); |
||
| 671 | 4 | $this->dom->addChild( |
|
| 672 | 4 | $ide, |
|
| 673 | 4 | "indIntermed", |
|
| 674 | 4 | isset($std->indIntermed) ? $std->indIntermed : null, |
|
| 675 | 4 | false, |
|
| 676 | 4 | $identificador . "Indicador de intermediador/marketplace" |
|
| 677 | ); |
||
| 678 | 4 | $this->dom->addChild( |
|
| 679 | 4 | $ide, |
|
| 680 | 4 | "procEmi", |
|
| 681 | 4 | $std->procEmi, |
|
| 682 | 4 | true, |
|
| 683 | 4 | $identificador . "Processo de emissão da NF-e" |
|
| 684 | ); |
||
| 685 | 4 | $this->dom->addChild( |
|
| 686 | 4 | $ide, |
|
| 687 | 4 | "verProc", |
|
| 688 | 4 | $std->verProc, |
|
| 689 | 4 | true, |
|
| 690 | 4 | $identificador . "Versão do Processo de emissão da NF-e" |
|
| 691 | ); |
||
| 692 | 4 | if (!empty($std->dhCont) && !empty($std->xJust)) { |
|
| 693 | 1 | $this->dom->addChild( |
|
| 694 | 1 | $ide, |
|
| 695 | 1 | "dhCont", |
|
| 696 | 1 | $std->dhCont, |
|
| 697 | 1 | true, |
|
| 698 | 1 | $identificador . "Data e Hora da entrada em contingência" |
|
| 699 | ); |
||
| 700 | 1 | $this->dom->addChild( |
|
| 701 | 1 | $ide, |
|
| 702 | 1 | "xJust", |
|
| 703 | 1 | substr(trim($std->xJust), 0, 256), |
|
| 704 | 1 | true, |
|
| 705 | 1 | $identificador . "Justificativa da entrada em contingência" |
|
| 706 | ); |
||
| 707 | } |
||
| 708 | 4 | $this->ide = $ide; |
|
| 709 | 4 | return $ide; |
|
| 710 | } |
||
| 711 | |||
| 712 | /** |
||
| 713 | * Chave de acesso da NF-e referenciada BA02 pai BA01 |
||
| 714 | * tag NFe/infNFe/ide/NFref/refNFe |
||
| 715 | * @param stdClass $std |
||
| 716 | * @return DOMElement |
||
| 717 | */ |
||
| 718 | public function tagrefNFe(stdClass $std) |
||
| 719 | { |
||
| 720 | $possible = ['refNFe']; |
||
| 721 | $std = $this->equilizeParameters($std, $possible); |
||
| 722 | |||
| 723 | $num = $this->buildNFref(); |
||
| 724 | $refNFe = $this->dom->createElement("refNFe", $std->refNFe); |
||
| 725 | $this->dom->appChild($this->aNFref[$num - 1], $refNFe); |
||
| 726 | return $refNFe; |
||
| 727 | } |
||
| 728 | |||
| 729 | /** |
||
| 730 | * Informação da NF modelo 1/1A referenciada BA03 pai BA01 |
||
| 731 | * tag NFe/infNFe/ide/NFref/NF DOMNode |
||
| 732 | * @param stdClass $std |
||
| 733 | * @return DOMElement |
||
| 734 | */ |
||
| 735 | public function tagrefNF(stdClass $std) |
||
| 736 | { |
||
| 737 | $possible = ['cUF', 'AAMM', 'CNPJ', 'mod', 'serie', 'nNF']; |
||
| 738 | $std = $this->equilizeParameters($std, $possible); |
||
| 739 | |||
| 740 | $identificador = 'BA03 <refNF> - '; |
||
| 741 | $num = $this->buildNFref(); |
||
| 742 | $refNF = $this->dom->createElement("refNF"); |
||
| 743 | $this->dom->addChild( |
||
| 744 | $refNF, |
||
| 745 | "cUF", |
||
| 746 | $std->cUF, |
||
| 747 | true, |
||
| 748 | $identificador . "Código da UF do emitente" |
||
| 749 | ); |
||
| 750 | $this->dom->addChild( |
||
| 751 | $refNF, |
||
| 752 | "AAMM", |
||
| 753 | $std->AAMM, |
||
| 754 | true, |
||
| 755 | $identificador . "Ano e Mês de emissão da NF-e" |
||
| 756 | ); |
||
| 757 | $this->dom->addChild( |
||
| 758 | $refNF, |
||
| 759 | "CNPJ", |
||
| 760 | $std->CNPJ, |
||
| 761 | true, |
||
| 762 | $identificador . "CNPJ do emitente" |
||
| 763 | ); |
||
| 764 | $this->dom->addChild( |
||
| 765 | $refNF, |
||
| 766 | "mod", |
||
| 767 | $std->mod, |
||
| 768 | true, |
||
| 769 | $identificador . "Modelo do Documento Fiscal" |
||
| 770 | ); |
||
| 771 | $this->dom->addChild( |
||
| 772 | $refNF, |
||
| 773 | "serie", |
||
| 774 | $std->serie, |
||
| 775 | true, |
||
| 776 | $identificador . "Série do Documento Fiscal" |
||
| 777 | ); |
||
| 778 | $this->dom->addChild( |
||
| 779 | $refNF, |
||
| 780 | "nNF", |
||
| 781 | $std->nNF, |
||
| 782 | true, |
||
| 783 | $identificador . "Número do Documento Fiscal" |
||
| 784 | ); |
||
| 785 | $this->dom->appChild($this->aNFref[$num - 1], $refNF); |
||
| 786 | return $refNF; |
||
| 787 | } |
||
| 788 | |||
| 789 | /** |
||
| 790 | * Informações da NF de produtor rural referenciada BA10 pai BA01 |
||
| 791 | * tag NFe/infNFe/ide/NFref/refNFP |
||
| 792 | * @param stdClass $std |
||
| 793 | * @return DOMElement |
||
| 794 | */ |
||
| 795 | public function tagrefNFP(stdClass $std) |
||
| 796 | { |
||
| 797 | $possible = [ |
||
| 798 | 'cUF', |
||
| 799 | 'AAMM', |
||
| 800 | 'CNPJ', |
||
| 801 | 'CPF', |
||
| 802 | 'IE', |
||
| 803 | 'mod', |
||
| 804 | 'serie', |
||
| 805 | 'nNF' |
||
| 806 | ]; |
||
| 807 | $std = $this->equilizeParameters($std, $possible); |
||
| 808 | |||
| 809 | $identificador = 'BA10 <refNFP> - '; |
||
| 810 | $num = $this->buildNFref(); |
||
| 811 | $refNFP = $this->dom->createElement("refNFP"); |
||
| 812 | $this->dom->addChild( |
||
| 813 | $refNFP, |
||
| 814 | "cUF", |
||
| 815 | $std->cUF, |
||
| 816 | true, |
||
| 817 | $identificador . "Código da UF do emitente" |
||
| 818 | ); |
||
| 819 | $this->dom->addChild( |
||
| 820 | $refNFP, |
||
| 821 | "AAMM", |
||
| 822 | $std->AAMM, |
||
| 823 | true, |
||
| 824 | $identificador . "AAMM da emissão da NF de produtor" |
||
| 825 | ); |
||
| 826 | $this->dom->addChild( |
||
| 827 | $refNFP, |
||
| 828 | "CNPJ", |
||
| 829 | $std->CNPJ, |
||
| 830 | false, |
||
| 831 | $identificador . "Informar o CNPJ do emitente da NF de produtor" |
||
| 832 | ); |
||
| 833 | $this->dom->addChild( |
||
| 834 | $refNFP, |
||
| 835 | "CPF", |
||
| 836 | $std->CPF, |
||
| 837 | false, |
||
| 838 | $identificador . "Informar o CPF do emitente da NF de produtor" |
||
| 839 | ); |
||
| 840 | $this->dom->addChild( |
||
| 841 | $refNFP, |
||
| 842 | "IE", |
||
| 843 | $std->IE, |
||
| 844 | true, |
||
| 845 | $identificador . "Informar a IE do emitente da NF de Produtor ou o literal 'ISENTO'" |
||
| 846 | ); |
||
| 847 | $this->dom->addChild( |
||
| 848 | $refNFP, |
||
| 849 | "mod", |
||
| 850 | str_pad($std->mod, 2, '0', STR_PAD_LEFT), |
||
| 851 | true, |
||
| 852 | $identificador . "Modelo do Documento Fiscal" |
||
| 853 | ); |
||
| 854 | $this->dom->addChild( |
||
| 855 | $refNFP, |
||
| 856 | "serie", |
||
| 857 | $std->serie, |
||
| 858 | true, |
||
| 859 | $identificador . "Série do Documento Fiscal" |
||
| 860 | ); |
||
| 861 | $this->dom->addChild( |
||
| 862 | $refNFP, |
||
| 863 | "nNF", |
||
| 864 | $std->nNF, |
||
| 865 | true, |
||
| 866 | $identificador . "Número do Documento Fiscal" |
||
| 867 | ); |
||
| 868 | $this->dom->appChild($this->aNFref[$num - 1], $refNFP); |
||
| 869 | return $refNFP; |
||
| 870 | } |
||
| 871 | |||
| 872 | /** |
||
| 873 | * Chave de acesso do CT-e referenciada BA19 pai BA01 |
||
| 874 | * tag NFe/infNFe/ide/NFref/refCTe |
||
| 875 | * @param stdClass $std |
||
| 876 | * @return DOMElement |
||
| 877 | */ |
||
| 878 | public function tagrefCTe(stdClass $std) |
||
| 879 | { |
||
| 880 | $possible = ['refCTe']; |
||
| 881 | $std = $this->equilizeParameters($std, $possible); |
||
| 882 | |||
| 883 | $num = $this->buildNFref(); |
||
| 884 | $refCTe = $this->dom->createElement("refCTe", $std->refCTe); |
||
| 885 | $this->dom->appChild($this->aNFref[$num - 1], $refCTe); |
||
| 886 | return $refCTe; |
||
| 887 | } |
||
| 888 | |||
| 889 | /** |
||
| 890 | * Informações do Cupom Fiscal referenciado BA20 pai BA01 |
||
| 891 | * tag NFe/infNFe/ide/NFref/refECF |
||
| 892 | * @param stdClass $std |
||
| 893 | * @return DOMElement |
||
| 894 | */ |
||
| 895 | public function tagrefECF(stdClass $std) |
||
| 896 | { |
||
| 897 | $possible = ['mod', 'nECF', 'nCOO']; |
||
| 898 | $std = $this->equilizeParameters($std, $possible); |
||
| 899 | |||
| 900 | $identificador = 'BA20 <refECF> - '; |
||
| 901 | $num = $this->buildNFref(); |
||
| 902 | $refECF = $this->dom->createElement("refECF"); |
||
| 903 | $this->dom->addChild( |
||
| 904 | $refECF, |
||
| 905 | "mod", |
||
| 906 | $std->mod, |
||
| 907 | true, |
||
| 908 | $identificador . "Modelo do Documento Fiscal" |
||
| 909 | ); |
||
| 910 | $this->dom->addChild( |
||
| 911 | $refECF, |
||
| 912 | "nECF", |
||
| 913 | str_pad($std->nECF, 3, '0', STR_PAD_LEFT), |
||
| 914 | true, |
||
| 915 | $identificador . "Número de ordem sequencial do ECF" |
||
| 916 | ); |
||
| 917 | $this->dom->addChild( |
||
| 918 | $refECF, |
||
| 919 | "nCOO", |
||
| 920 | str_pad($std->nCOO, 6, '0', STR_PAD_LEFT), |
||
| 921 | true, |
||
| 922 | $identificador . "Número do Contador de Ordem de Operação - COO" |
||
| 923 | ); |
||
| 924 | $this->dom->appChild($this->aNFref[$num - 1], $refECF); |
||
| 925 | return $refECF; |
||
| 926 | } |
||
| 927 | |||
| 928 | /** |
||
| 929 | * Identificação do emitente da NF-e C01 pai A01 |
||
| 930 | * tag NFe/infNFe/emit |
||
| 931 | * @param stdClass $std |
||
| 932 | * @return DOMElement |
||
| 933 | */ |
||
| 934 | public function tagemit(stdClass $std) |
||
| 935 | { |
||
| 936 | $possible = [ |
||
| 937 | 'xNome', |
||
| 938 | 'xFant', |
||
| 939 | 'IE', |
||
| 940 | 'IEST', |
||
| 941 | 'IM', |
||
| 942 | 'CNAE', |
||
| 943 | 'CRT', |
||
| 944 | 'CNPJ', |
||
| 945 | 'CPF' |
||
| 946 | ]; |
||
| 947 | $std = $this->equilizeParameters($std, $possible); |
||
| 948 | $identificador = 'C01 <emit> - '; |
||
| 949 | $this->emit = $this->dom->createElement("emit"); |
||
| 950 | if (!empty($std->CNPJ)) { |
||
| 951 | $this->dom->addChild( |
||
| 952 | $this->emit, |
||
| 953 | "CNPJ", |
||
| 954 | Strings::onlyNumbers($std->CNPJ), |
||
| 955 | false, |
||
| 956 | $identificador . "CNPJ do emitente" |
||
| 957 | ); |
||
| 958 | } elseif (!empty($std->CPF)) { |
||
| 959 | $this->dom->addChild( |
||
| 960 | $this->emit, |
||
| 961 | "CPF", |
||
| 962 | Strings::onlyNumbers($std->CPF), |
||
| 963 | false, |
||
| 964 | $identificador . "CPF do remetente" |
||
| 965 | ); |
||
| 966 | } |
||
| 967 | $this->dom->addChild( |
||
| 968 | $this->emit, |
||
| 969 | "xNome", |
||
| 970 | substr(trim($std->xNome), 0, 60), |
||
| 971 | true, |
||
| 972 | $identificador . "Razão Social ou Nome do emitente" |
||
| 973 | ); |
||
| 974 | $this->dom->addChild( |
||
| 975 | $this->emit, |
||
| 976 | "xFant", |
||
| 977 | substr(trim($std->xFant), 0, 60), |
||
| 978 | false, |
||
| 979 | $identificador . "Nome fantasia do emitente" |
||
| 980 | ); |
||
| 981 | if ($std->IE != 'ISENTO') { |
||
| 982 | $std->IE = Strings::onlyNumbers($std->IE); |
||
| 983 | } |
||
| 984 | $this->dom->addChild( |
||
| 985 | $this->emit, |
||
| 986 | "IE", |
||
| 987 | $std->IE, |
||
| 988 | true, |
||
| 989 | $identificador . "Inscrição Estadual do emitente" |
||
| 990 | ); |
||
| 991 | $this->dom->addChild( |
||
| 992 | $this->emit, |
||
| 993 | "IEST", |
||
| 994 | Strings::onlyNumbers($std->IEST), |
||
| 995 | false, |
||
| 996 | $identificador . "IE do Substituto Tributário do emitente" |
||
| 997 | ); |
||
| 998 | $this->dom->addChild( |
||
| 999 | $this->emit, |
||
| 1000 | "IM", |
||
| 1001 | Strings::onlyNumbers($std->IM), |
||
| 1002 | false, |
||
| 1003 | $identificador . "Inscrição Municipal do Prestador de Serviço do emitente" |
||
| 1004 | ); |
||
| 1005 | if (!empty($std->IM) && !empty($std->CNAE)) { |
||
| 1006 | $this->dom->addChild( |
||
| 1007 | $this->emit, |
||
| 1008 | "CNAE", |
||
| 1009 | Strings::onlyNumbers($std->CNAE), |
||
| 1010 | false, |
||
| 1011 | $identificador . "CNAE fiscal do emitente" |
||
| 1012 | ); |
||
| 1013 | } |
||
| 1014 | $this->dom->addChild( |
||
| 1015 | $this->emit, |
||
| 1016 | "CRT", |
||
| 1017 | $std->CRT, |
||
| 1018 | true, |
||
| 1019 | $identificador . "Código de Regime Tributário do emitente" |
||
| 1020 | ); |
||
| 1021 | return $this->emit; |
||
| 1022 | } |
||
| 1023 | |||
| 1024 | /** |
||
| 1025 | * Endereço do emitente C05 pai C01 |
||
| 1026 | * tag NFe/infNFe/emit/endEmit |
||
| 1027 | * @param stdClass $std |
||
| 1028 | * @return DOMElement |
||
| 1029 | */ |
||
| 1030 | public function tagenderEmit(stdClass $std) |
||
| 1031 | { |
||
| 1032 | $possible = [ |
||
| 1033 | 'xLgr', |
||
| 1034 | 'nro', |
||
| 1035 | 'xCpl', |
||
| 1036 | 'xBairro', |
||
| 1037 | 'cMun', |
||
| 1038 | 'xMun', |
||
| 1039 | 'UF', |
||
| 1040 | 'CEP', |
||
| 1041 | 'cPais', |
||
| 1042 | 'xPais', |
||
| 1043 | 'fone' |
||
| 1044 | ]; |
||
| 1045 | $std = $this->equilizeParameters($std, $possible); |
||
| 1046 | |||
| 1047 | $identificador = 'C05 <enderEmit> - '; |
||
| 1048 | $this->enderEmit = $this->dom->createElement("enderEmit"); |
||
| 1049 | $this->dom->addChild( |
||
| 1050 | $this->enderEmit, |
||
| 1051 | "xLgr", |
||
| 1052 | substr(trim($std->xLgr), 0, 60), |
||
| 1053 | true, |
||
| 1054 | $identificador . "Logradouro do Endereço do emitente" |
||
| 1055 | ); |
||
| 1056 | $this->dom->addChild( |
||
| 1057 | $this->enderEmit, |
||
| 1058 | "nro", |
||
| 1059 | substr(trim($std->nro), 0, 60), |
||
| 1060 | true, |
||
| 1061 | $identificador . "Número do Endereço do emitente" |
||
| 1062 | ); |
||
| 1063 | $this->dom->addChild( |
||
| 1064 | $this->enderEmit, |
||
| 1065 | "xCpl", |
||
| 1066 | substr(trim($std->xCpl), 0, 60), |
||
| 1067 | false, |
||
| 1068 | $identificador . "Complemento do Endereço do emitente" |
||
| 1069 | ); |
||
| 1070 | $this->dom->addChild( |
||
| 1071 | $this->enderEmit, |
||
| 1072 | "xBairro", |
||
| 1073 | substr(trim($std->xBairro), 0, 60), |
||
| 1074 | true, |
||
| 1075 | $identificador . "Bairro do Endereço do emitente" |
||
| 1076 | ); |
||
| 1077 | $this->dom->addChild( |
||
| 1078 | $this->enderEmit, |
||
| 1079 | "cMun", |
||
| 1080 | Strings::onlyNumbers($std->cMun), |
||
| 1081 | true, |
||
| 1082 | $identificador . "Código do município do Endereço do emitente" |
||
| 1083 | ); |
||
| 1084 | $this->dom->addChild( |
||
| 1085 | $this->enderEmit, |
||
| 1086 | "xMun", |
||
| 1087 | substr(trim($std->xMun), 0, 60), |
||
| 1088 | true, |
||
| 1089 | $identificador . "Nome do município do Endereço do emitente" |
||
| 1090 | ); |
||
| 1091 | $this->dom->addChild( |
||
| 1092 | $this->enderEmit, |
||
| 1093 | "UF", |
||
| 1094 | strtoupper(trim($std->UF)), |
||
| 1095 | true, |
||
| 1096 | $identificador . "Sigla da UF do Endereço do emitente" |
||
| 1097 | ); |
||
| 1098 | $this->dom->addChild( |
||
| 1099 | $this->enderEmit, |
||
| 1100 | "CEP", |
||
| 1101 | Strings::onlyNumbers($std->CEP), |
||
| 1102 | true, |
||
| 1103 | $identificador . "Código do CEP do Endereço do emitente" |
||
| 1104 | ); |
||
| 1105 | $this->dom->addChild( |
||
| 1106 | $this->enderEmit, |
||
| 1107 | "cPais", |
||
| 1108 | Strings::onlyNumbers($std->cPais), |
||
| 1109 | false, |
||
| 1110 | $identificador . "Código do País do Endereço do emitente" |
||
| 1111 | ); |
||
| 1112 | $this->dom->addChild( |
||
| 1113 | $this->enderEmit, |
||
| 1114 | "xPais", |
||
| 1115 | substr(trim($std->xPais), 0, 60), |
||
| 1116 | false, |
||
| 1117 | $identificador . "Nome do País do Endereço do emitente" |
||
| 1118 | ); |
||
| 1119 | $this->dom->addChild( |
||
| 1120 | $this->enderEmit, |
||
| 1121 | "fone", |
||
| 1122 | trim($std->fone), |
||
| 1123 | false, |
||
| 1124 | $identificador . "Telefone do Endereço do emitente" |
||
| 1125 | ); |
||
| 1126 | $node = $this->emit->getElementsByTagName("IE")->item(0); |
||
| 1127 | $this->emit->insertBefore($this->enderEmit, $node); |
||
| 1128 | return $this->enderEmit; |
||
| 1129 | } |
||
| 1130 | |||
| 1131 | /** |
||
| 1132 | * Identificação do Destinatário da NF-e E01 pai A01 |
||
| 1133 | * tag NFe/infNFe/dest (opcional para modelo 65) |
||
| 1134 | * @param stdClass $std |
||
| 1135 | * @return DOMElement |
||
| 1136 | */ |
||
| 1137 | public function tagdest(stdClass $std) |
||
| 1138 | { |
||
| 1139 | $possible = [ |
||
| 1140 | 'xNome', |
||
| 1141 | 'indIEDest', |
||
| 1142 | 'IE', |
||
| 1143 | 'ISUF', |
||
| 1144 | 'IM', |
||
| 1145 | 'email', |
||
| 1146 | 'CNPJ', |
||
| 1147 | 'CPF', |
||
| 1148 | 'idEstrangeiro' |
||
| 1149 | ]; |
||
| 1150 | $std = $this->equilizeParameters($std, $possible); |
||
| 1151 | $identificador = 'E01 <dest> - '; |
||
| 1152 | $flagNome = true; //marca se xNome é ou não obrigatório |
||
| 1153 | $temIE = $std->IE != '' && $std->IE != 'ISENTO'; // Tem inscrição municipal |
||
| 1154 | $this->dest = $this->dom->createElement("dest"); |
||
| 1155 | if (!$temIE && $std->indIEDest == 1) { |
||
| 1156 | $std->indIEDest = 2; |
||
| 1157 | } |
||
| 1158 | if ($this->mod == '65') { |
||
| 1159 | $std->indIEDest = 9; |
||
| 1160 | if ($std->xNome == '') { |
||
| 1161 | $flagNome = false; //marca se xNome é ou não obrigatório |
||
| 1162 | } |
||
| 1163 | } |
||
| 1164 | $xNome = $std->xNome; |
||
| 1165 | if ($this->tpAmb == '2') { |
||
| 1166 | $xNome = 'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
| 1167 | //a exigência do CNPJ 99999999000191 não existe mais |
||
| 1168 | } |
||
| 1169 | if (!empty($std->CNPJ)) { |
||
| 1170 | $this->dom->addChild( |
||
| 1171 | $this->dest, |
||
| 1172 | "CNPJ", |
||
| 1173 | Strings::onlyNumbers($std->CNPJ), |
||
| 1174 | true, |
||
| 1175 | $identificador . "CNPJ do destinatário" |
||
| 1176 | ); |
||
| 1177 | } elseif (!empty($std->CPF)) { |
||
| 1178 | $this->dom->addChild( |
||
| 1179 | $this->dest, |
||
| 1180 | "CPF", |
||
| 1181 | Strings::onlyNumbers($std->CPF), |
||
| 1182 | true, |
||
| 1183 | $identificador . "CPF do destinatário" |
||
| 1184 | ); |
||
| 1185 | } elseif ($std->idEstrangeiro !== null) { |
||
| 1186 | $this->dom->addChild( |
||
| 1187 | $this->dest, |
||
| 1188 | "idEstrangeiro", |
||
| 1189 | $std->idEstrangeiro, |
||
| 1190 | true, |
||
| 1191 | $identificador . "Identificação do destinatário no caso de comprador estrangeiro", |
||
| 1192 | true |
||
| 1193 | ); |
||
| 1194 | $std->indIEDest = '9'; |
||
| 1195 | } |
||
| 1196 | $this->dom->addChild( |
||
| 1197 | $this->dest, |
||
| 1198 | "xNome", |
||
| 1199 | substr(trim($xNome), 0, 60), |
||
| 1200 | $flagNome, //se mod 55 true ou mod 65 false |
||
| 1201 | $identificador . "Razão Social ou nome do destinatário" |
||
| 1202 | ); |
||
| 1203 | $this->dom->addChild( |
||
| 1204 | $this->dest, |
||
| 1205 | "indIEDest", |
||
| 1206 | Strings::onlyNumbers($std->indIEDest), |
||
| 1207 | true, |
||
| 1208 | $identificador . "Indicador da IE do Destinatário" |
||
| 1209 | ); |
||
| 1210 | if ($temIE) { |
||
| 1211 | $this->dom->addChild( |
||
| 1212 | $this->dest, |
||
| 1213 | "IE", |
||
| 1214 | $std->IE, |
||
| 1215 | true, |
||
| 1216 | $identificador . "Inscrição Estadual do Destinatário" |
||
| 1217 | ); |
||
| 1218 | } |
||
| 1219 | $this->dom->addChild( |
||
| 1220 | $this->dest, |
||
| 1221 | "ISUF", |
||
| 1222 | Strings::onlyNumbers($std->ISUF), |
||
| 1223 | false, |
||
| 1224 | $identificador . "Inscrição na SUFRAMA do destinatário" |
||
| 1225 | ); |
||
| 1226 | $this->dom->addChild( |
||
| 1227 | $this->dest, |
||
| 1228 | "IM", |
||
| 1229 | Strings::onlyNumbers($std->IM), |
||
| 1230 | false, |
||
| 1231 | $identificador . "Inscrição Municipal do Tomador do Serviço do destinatário" |
||
| 1232 | ); |
||
| 1233 | $this->dom->addChild( |
||
| 1234 | $this->dest, |
||
| 1235 | "email", |
||
| 1236 | substr(trim($std->email), 0, 60), |
||
| 1237 | false, |
||
| 1238 | $identificador . "Email do destinatário" |
||
| 1239 | ); |
||
| 1240 | return $this->dest; |
||
| 1241 | } |
||
| 1242 | |||
| 1243 | /** |
||
| 1244 | * Endereço do Destinatário da NF-e E05 pai E01 |
||
| 1245 | * tag NFe/infNFe/dest/enderDest (opcional para modelo 65) |
||
| 1246 | * Os dados do destinatário devem ser inseridos antes deste método |
||
| 1247 | * @param stdClass $std |
||
| 1248 | * @return DOMElement |
||
| 1249 | */ |
||
| 1250 | public function tagenderDest(stdClass $std) |
||
| 1251 | { |
||
| 1252 | $possible = [ |
||
| 1253 | 'xLgr', |
||
| 1254 | 'nro', |
||
| 1255 | 'xCpl', |
||
| 1256 | 'xBairro', |
||
| 1257 | 'cMun', |
||
| 1258 | 'xMun', |
||
| 1259 | 'UF', |
||
| 1260 | 'CEP', |
||
| 1261 | 'cPais', |
||
| 1262 | 'xPais', |
||
| 1263 | 'fone' |
||
| 1264 | ]; |
||
| 1265 | $std = $this->equilizeParameters($std, $possible); |
||
| 1266 | |||
| 1267 | $identificador = 'E05 <enderDest> - '; |
||
| 1268 | if (empty($this->dest)) { |
||
| 1269 | throw new RuntimeException('A TAG dest deve ser criada antes do endereço do mesmo.'); |
||
| 1270 | } |
||
| 1271 | $this->enderDest = $this->dom->createElement("enderDest"); |
||
| 1272 | $this->dom->addChild( |
||
| 1273 | $this->enderDest, |
||
| 1274 | "xLgr", |
||
| 1275 | $std->xLgr, |
||
| 1276 | true, |
||
| 1277 | $identificador . "Logradouro do Endereço do Destinatário" |
||
| 1278 | ); |
||
| 1279 | $this->dom->addChild( |
||
| 1280 | $this->enderDest, |
||
| 1281 | "nro", |
||
| 1282 | $std->nro, |
||
| 1283 | true, |
||
| 1284 | $identificador . "Número do Endereço do Destinatário" |
||
| 1285 | ); |
||
| 1286 | $this->dom->addChild( |
||
| 1287 | $this->enderDest, |
||
| 1288 | "xCpl", |
||
| 1289 | $std->xCpl, |
||
| 1290 | false, |
||
| 1291 | $identificador . "Complemento do Endereço do Destinatário" |
||
| 1292 | ); |
||
| 1293 | $this->dom->addChild( |
||
| 1294 | $this->enderDest, |
||
| 1295 | "xBairro", |
||
| 1296 | $std->xBairro, |
||
| 1297 | true, |
||
| 1298 | $identificador . "Bairro do Endereço do Destinatário" |
||
| 1299 | ); |
||
| 1300 | $this->dom->addChild( |
||
| 1301 | $this->enderDest, |
||
| 1302 | "cMun", |
||
| 1303 | $std->cMun, |
||
| 1304 | true, |
||
| 1305 | $identificador . "Código do município do Endereço do Destinatário" |
||
| 1306 | ); |
||
| 1307 | $this->dom->addChild( |
||
| 1308 | $this->enderDest, |
||
| 1309 | "xMun", |
||
| 1310 | $std->xMun, |
||
| 1311 | true, |
||
| 1312 | $identificador . "Nome do município do Endereço do Destinatário" |
||
| 1313 | ); |
||
| 1314 | $this->dom->addChild( |
||
| 1315 | $this->enderDest, |
||
| 1316 | "UF", |
||
| 1317 | $std->UF, |
||
| 1318 | true, |
||
| 1319 | $identificador . "Sigla da UF do Endereço do Destinatário" |
||
| 1320 | ); |
||
| 1321 | $this->dom->addChild( |
||
| 1322 | $this->enderDest, |
||
| 1323 | "CEP", |
||
| 1324 | $std->CEP, |
||
| 1325 | false, |
||
| 1326 | $identificador . "Código do CEP do Endereço do Destinatário" |
||
| 1327 | ); |
||
| 1328 | $this->dom->addChild( |
||
| 1329 | $this->enderDest, |
||
| 1330 | "cPais", |
||
| 1331 | $std->cPais, |
||
| 1332 | false, |
||
| 1333 | $identificador . "Código do País do Endereço do Destinatário" |
||
| 1334 | ); |
||
| 1335 | $this->dom->addChild( |
||
| 1336 | $this->enderDest, |
||
| 1337 | "xPais", |
||
| 1338 | $std->xPais, |
||
| 1339 | false, |
||
| 1340 | $identificador . "Nome do País do Endereço do Destinatário" |
||
| 1341 | ); |
||
| 1342 | $this->dom->addChild( |
||
| 1343 | $this->enderDest, |
||
| 1344 | "fone", |
||
| 1345 | $std->fone, |
||
| 1346 | false, |
||
| 1347 | $identificador . "Telefone do Endereço do Destinatário" |
||
| 1348 | ); |
||
| 1349 | $node = $this->dest->getElementsByTagName("indIEDest")->item(0); |
||
| 1350 | if (!isset($node)) { |
||
| 1351 | $node = $this->dest->getElementsByTagName("IE")->item(0); |
||
| 1352 | } |
||
| 1353 | $this->dest->insertBefore($this->enderDest, $node); |
||
| 1354 | return $this->enderDest; |
||
| 1355 | } |
||
| 1356 | |||
| 1357 | /** |
||
| 1358 | * Identificação do Local de retirada F01 pai A01 |
||
| 1359 | * tag NFe/infNFe/retirada (opcional) |
||
| 1360 | * NOTA: ajustado para NT 2018.005 |
||
| 1361 | * @param stdClass $std |
||
| 1362 | * @return DOMElement |
||
| 1363 | */ |
||
| 1364 | public function tagretirada(stdClass $std) |
||
| 1365 | { |
||
| 1366 | $possible = [ |
||
| 1367 | 'xLgr', |
||
| 1368 | 'nro', |
||
| 1369 | 'xCpl', |
||
| 1370 | 'xBairro', |
||
| 1371 | 'cMun', |
||
| 1372 | 'xMun', |
||
| 1373 | 'UF', |
||
| 1374 | 'CNPJ', |
||
| 1375 | 'CPF', |
||
| 1376 | 'xNome', |
||
| 1377 | 'CEP', |
||
| 1378 | 'cPais', |
||
| 1379 | 'xPais', |
||
| 1380 | 'fone', |
||
| 1381 | 'email', |
||
| 1382 | 'IE' |
||
| 1383 | ]; |
||
| 1384 | $std = $this->equilizeParameters($std, $possible); |
||
| 1385 | $identificador = 'F01 <retirada> - '; |
||
| 1386 | $this->retirada = $this->dom->createElement("retirada"); |
||
| 1387 | $this->dom->addChild( |
||
| 1388 | $this->retirada, |
||
| 1389 | "CNPJ", |
||
| 1390 | $std->CNPJ, |
||
| 1391 | false, |
||
| 1392 | $identificador . "CNPJ do Cliente da Retirada" |
||
| 1393 | ); |
||
| 1394 | $this->dom->addChild( |
||
| 1395 | $this->retirada, |
||
| 1396 | "CPF", |
||
| 1397 | $std->CPF, |
||
| 1398 | false, |
||
| 1399 | $identificador . "CPF do Cliente da Retirada" |
||
| 1400 | ); |
||
| 1401 | $this->dom->addChild( |
||
| 1402 | $this->retirada, |
||
| 1403 | "xNome", |
||
| 1404 | $std->xNome, |
||
| 1405 | false, |
||
| 1406 | $identificador . "Nome do Cliente da Retirada" |
||
| 1407 | ); |
||
| 1408 | $this->dom->addChild( |
||
| 1409 | $this->retirada, |
||
| 1410 | "xLgr", |
||
| 1411 | $std->xLgr, |
||
| 1412 | true, |
||
| 1413 | $identificador . "Logradouro do Endereco do Cliente da Retirada" |
||
| 1414 | ); |
||
| 1415 | $this->dom->addChild( |
||
| 1416 | $this->retirada, |
||
| 1417 | "nro", |
||
| 1418 | $std->nro, |
||
| 1419 | true, |
||
| 1420 | $identificador . "Número do Endereco do Cliente da Retirada" |
||
| 1421 | ); |
||
| 1422 | $this->dom->addChild( |
||
| 1423 | $this->retirada, |
||
| 1424 | "xCpl", |
||
| 1425 | $std->xCpl, |
||
| 1426 | false, |
||
| 1427 | $identificador . "Complemento do Endereco do Cliente da Retirada" |
||
| 1428 | ); |
||
| 1429 | $this->dom->addChild( |
||
| 1430 | $this->retirada, |
||
| 1431 | "xBairro", |
||
| 1432 | $std->xBairro, |
||
| 1433 | true, |
||
| 1434 | $identificador . "Bairro do Endereco do Cliente da Retirada" |
||
| 1435 | ); |
||
| 1436 | $this->dom->addChild( |
||
| 1437 | $this->retirada, |
||
| 1438 | "cMun", |
||
| 1439 | $std->cMun, |
||
| 1440 | true, |
||
| 1441 | $identificador . "Código do município do Endereco do Cliente da Retirada" |
||
| 1442 | ); |
||
| 1443 | $this->dom->addChild( |
||
| 1444 | $this->retirada, |
||
| 1445 | "xMun", |
||
| 1446 | $std->xMun, |
||
| 1447 | true, |
||
| 1448 | $identificador . "Nome do município do Endereco do Cliente da Retirada" |
||
| 1449 | ); |
||
| 1450 | $this->dom->addChild( |
||
| 1451 | $this->retirada, |
||
| 1452 | "UF", |
||
| 1453 | $std->UF, |
||
| 1454 | true, |
||
| 1455 | $identificador . "Sigla da UF do Endereco do Cliente da Retirada" |
||
| 1456 | ); |
||
| 1457 | $this->dom->addChild( |
||
| 1458 | $this->retirada, |
||
| 1459 | "CEP", |
||
| 1460 | $std->CEP, |
||
| 1461 | false, |
||
| 1462 | $identificador . "CEP do Endereco do Cliente da Retirada" |
||
| 1463 | ); |
||
| 1464 | $this->dom->addChild( |
||
| 1465 | $this->retirada, |
||
| 1466 | "cPais", |
||
| 1467 | $std->cPais, |
||
| 1468 | false, |
||
| 1469 | $identificador . "Codigo do Pais do Endereco do Cliente da Retirada" |
||
| 1470 | ); |
||
| 1471 | $this->dom->addChild( |
||
| 1472 | $this->retirada, |
||
| 1473 | "xPais", |
||
| 1474 | $std->xPais, |
||
| 1475 | false, |
||
| 1476 | $identificador . "Pais do Endereco do Cliente da Retirada" |
||
| 1477 | ); |
||
| 1478 | $this->dom->addChild( |
||
| 1479 | $this->retirada, |
||
| 1480 | "fone", |
||
| 1481 | $std->fone, |
||
| 1482 | false, |
||
| 1483 | $identificador . "Fone do Endereco do Cliente da Retirada" |
||
| 1484 | ); |
||
| 1485 | $this->dom->addChild( |
||
| 1486 | $this->retirada, |
||
| 1487 | "email", |
||
| 1488 | $std->email, |
||
| 1489 | false, |
||
| 1490 | $identificador . "Email do Endereco do Cliente da Retirada" |
||
| 1491 | ); |
||
| 1492 | $this->dom->addChild( |
||
| 1493 | $this->retirada, |
||
| 1494 | "IE", |
||
| 1495 | $std->IE, |
||
| 1496 | false, |
||
| 1497 | $identificador . "IE do Cliente da Retirada" |
||
| 1498 | ); |
||
| 1499 | return $this->retirada; |
||
| 1500 | } |
||
| 1501 | |||
| 1502 | /** |
||
| 1503 | * Identificação do Local de entrega G01 pai A01 |
||
| 1504 | * tag NFe/infNFe/entrega (opcional) |
||
| 1505 | * NOTA: ajustado para NT 2018.005 |
||
| 1506 | * @param stdClass $std |
||
| 1507 | * @return DOMElement |
||
| 1508 | */ |
||
| 1509 | public function tagentrega(stdClass $std) |
||
| 1510 | { |
||
| 1511 | $possible = [ |
||
| 1512 | 'xLgr', |
||
| 1513 | 'nro', |
||
| 1514 | 'xCpl', |
||
| 1515 | 'xBairro', |
||
| 1516 | 'cMun', |
||
| 1517 | 'xMun', |
||
| 1518 | 'UF', |
||
| 1519 | 'CNPJ', |
||
| 1520 | 'CPF', |
||
| 1521 | 'xNome', |
||
| 1522 | 'CEP', |
||
| 1523 | 'cPais', |
||
| 1524 | 'xPais', |
||
| 1525 | 'fone', |
||
| 1526 | 'email', |
||
| 1527 | 'IE' |
||
| 1528 | ]; |
||
| 1529 | $std = $this->equilizeParameters($std, $possible); |
||
| 1530 | $identificador = 'G01 <entrega> - '; |
||
| 1531 | $this->entrega = $this->dom->createElement("entrega"); |
||
| 1532 | $this->dom->addChild( |
||
| 1533 | $this->entrega, |
||
| 1534 | "CNPJ", |
||
| 1535 | $std->CNPJ, |
||
| 1536 | false, |
||
| 1537 | $identificador . "CNPJ do Cliente da Entrega" |
||
| 1538 | ); |
||
| 1539 | $this->dom->addChild( |
||
| 1540 | $this->entrega, |
||
| 1541 | "CPF", |
||
| 1542 | $std->CPF, |
||
| 1543 | false, |
||
| 1544 | $identificador . "CPF do Cliente da Entrega" |
||
| 1545 | ); |
||
| 1546 | $this->dom->addChild( |
||
| 1547 | $this->entrega, |
||
| 1548 | "xNome", |
||
| 1549 | $std->xNome, |
||
| 1550 | false, |
||
| 1551 | $identificador . "Nome do Cliente da Entrega" |
||
| 1552 | ); |
||
| 1553 | $this->dom->addChild( |
||
| 1554 | $this->entrega, |
||
| 1555 | "xLgr", |
||
| 1556 | $std->xLgr, |
||
| 1557 | true, |
||
| 1558 | $identificador . "Logradouro do Endereco do Cliente da Entrega" |
||
| 1559 | ); |
||
| 1560 | $this->dom->addChild( |
||
| 1561 | $this->entrega, |
||
| 1562 | "nro", |
||
| 1563 | $std->nro, |
||
| 1564 | true, |
||
| 1565 | $identificador . "Número do Endereco do Cliente da Entrega" |
||
| 1566 | ); |
||
| 1567 | $this->dom->addChild( |
||
| 1568 | $this->entrega, |
||
| 1569 | "xCpl", |
||
| 1570 | $std->xCpl, |
||
| 1571 | false, |
||
| 1572 | $identificador . "Complemento do Endereco do Cliente da Entrega" |
||
| 1573 | ); |
||
| 1574 | $this->dom->addChild( |
||
| 1575 | $this->entrega, |
||
| 1576 | "xBairro", |
||
| 1577 | $std->xBairro, |
||
| 1578 | true, |
||
| 1579 | $identificador . "Bairro do Endereco do Cliente da Entrega" |
||
| 1580 | ); |
||
| 1581 | $this->dom->addChild( |
||
| 1582 | $this->entrega, |
||
| 1583 | "cMun", |
||
| 1584 | $std->cMun, |
||
| 1585 | true, |
||
| 1586 | $identificador . "Código do município do Endereco do Cliente da Entrega" |
||
| 1587 | ); |
||
| 1588 | $this->dom->addChild( |
||
| 1589 | $this->entrega, |
||
| 1590 | "xMun", |
||
| 1591 | $std->xMun, |
||
| 1592 | true, |
||
| 1593 | $identificador . "Nome do município do Endereco do Cliente da Entrega" |
||
| 1594 | ); |
||
| 1595 | $this->dom->addChild( |
||
| 1596 | $this->entrega, |
||
| 1597 | "UF", |
||
| 1598 | $std->UF, |
||
| 1599 | true, |
||
| 1600 | $identificador . "Sigla da UF do Endereco do Cliente da Entrega" |
||
| 1601 | ); |
||
| 1602 | $this->dom->addChild( |
||
| 1603 | $this->entrega, |
||
| 1604 | "CEP", |
||
| 1605 | $std->CEP, |
||
| 1606 | false, |
||
| 1607 | $identificador . "CEP do Endereco do Cliente da Entrega" |
||
| 1608 | ); |
||
| 1609 | $this->dom->addChild( |
||
| 1610 | $this->entrega, |
||
| 1611 | "cPais", |
||
| 1612 | $std->cPais, |
||
| 1613 | false, |
||
| 1614 | $identificador . "Codigo do Pais do Endereco do Cliente da Entrega" |
||
| 1615 | ); |
||
| 1616 | $this->dom->addChild( |
||
| 1617 | $this->entrega, |
||
| 1618 | "xPais", |
||
| 1619 | $std->xPais, |
||
| 1620 | false, |
||
| 1621 | $identificador . "Pais do Endereco do Cliente da Entrega" |
||
| 1622 | ); |
||
| 1623 | $this->dom->addChild( |
||
| 1624 | $this->entrega, |
||
| 1625 | "fone", |
||
| 1626 | $std->fone, |
||
| 1627 | false, |
||
| 1628 | $identificador . "Fone do Endereco do Cliente da Entrega" |
||
| 1629 | ); |
||
| 1630 | $this->dom->addChild( |
||
| 1631 | $this->entrega, |
||
| 1632 | "email", |
||
| 1633 | $std->email, |
||
| 1634 | false, |
||
| 1635 | $identificador . "Email do Endereco do Cliente da Entrega" |
||
| 1636 | ); |
||
| 1637 | $this->dom->addChild( |
||
| 1638 | $this->entrega, |
||
| 1639 | "IE", |
||
| 1640 | $std->IE, |
||
| 1641 | false, |
||
| 1642 | $identificador . "IE do Cliente da Entrega" |
||
| 1643 | ); |
||
| 1644 | return $this->entrega; |
||
| 1645 | } |
||
| 1646 | |||
| 1647 | /** |
||
| 1648 | * Pessoas autorizadas para o download do XML da NF-e G50 pai A01 |
||
| 1649 | * tag NFe/infNFe/autXML |
||
| 1650 | * @param stdClass $std |
||
| 1651 | * @return DOMElement |
||
| 1652 | */ |
||
| 1653 | public function tagautXML(stdClass $std) |
||
| 1654 | { |
||
| 1655 | $possible = ['CNPJ', 'CPF']; |
||
| 1656 | $std = $this->equilizeParameters($std, $possible); |
||
| 1657 | $identificador = 'G50 <autXML> - '; |
||
| 1658 | $std->CNPJ = !empty($std->CNPJ) ? $std->CNPJ : null; |
||
| 1659 | $std->CPF = !empty($std->CPF) ? $std->CPF : null; |
||
| 1660 | $autXML = $this->dom->createElement("autXML"); |
||
| 1661 | $this->dom->addChild( |
||
| 1662 | $autXML, |
||
| 1663 | "CNPJ", |
||
| 1664 | $std->CNPJ, |
||
| 1665 | false, |
||
| 1666 | $identificador . "CNPJ do Cliente Autorizado" |
||
| 1667 | ); |
||
| 1668 | $this->dom->addChild( |
||
| 1669 | $autXML, |
||
| 1670 | "CPF", |
||
| 1671 | $std->CPF, |
||
| 1672 | false, |
||
| 1673 | $identificador . "CPF do Cliente Autorizado" |
||
| 1674 | ); |
||
| 1675 | $this->aAutXML[] = $autXML; |
||
| 1676 | return $autXML; |
||
| 1677 | } |
||
| 1678 | |||
| 1679 | /** |
||
| 1680 | * Informações adicionais do produto V01 pai H01 |
||
| 1681 | * tag NFe/infNFe/det[]/infAdProd |
||
| 1682 | * @param stdClass $std |
||
| 1683 | * @return DOMElement |
||
| 1684 | */ |
||
| 1685 | public function taginfAdProd(stdClass $std) |
||
| 1686 | { |
||
| 1687 | $possible = ['item', 'infAdProd']; |
||
| 1688 | $std = $this->equilizeParameters($std, $possible); |
||
| 1689 | $infAdProd = $this->dom->createElement( |
||
| 1690 | "infAdProd", |
||
| 1691 | substr(trim($std->infAdProd), 0, 500) |
||
| 1692 | ); |
||
| 1693 | $this->aInfAdProd[$std->item] = $infAdProd; |
||
| 1694 | return $infAdProd; |
||
| 1695 | } |
||
| 1696 | |||
| 1697 | /** |
||
| 1698 | * Detalhamento de Produtos e Serviços I01 pai H01 |
||
| 1699 | * tag NFe/infNFe/det[]/prod |
||
| 1700 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
| 1701 | * @param stdClass $std |
||
| 1702 | * @return DOMElement |
||
| 1703 | */ |
||
| 1704 | public function tagprod(stdClass $std) |
||
| 1705 | { |
||
| 1706 | $possible = [ |
||
| 1707 | 'item', |
||
| 1708 | 'cProd', |
||
| 1709 | 'cEAN', |
||
| 1710 | 'xProd', |
||
| 1711 | 'NCM', |
||
| 1712 | 'cBenef', |
||
| 1713 | 'EXTIPI', |
||
| 1714 | 'CFOP', |
||
| 1715 | 'uCom', |
||
| 1716 | 'qCom', |
||
| 1717 | 'vUnCom', |
||
| 1718 | 'vProd', |
||
| 1719 | 'cEANTrib', |
||
| 1720 | 'uTrib', |
||
| 1721 | 'qTrib', |
||
| 1722 | 'vUnTrib', |
||
| 1723 | 'vFrete', |
||
| 1724 | 'vSeg', |
||
| 1725 | 'vDesc', |
||
| 1726 | 'vOutro', |
||
| 1727 | 'indTot', |
||
| 1728 | 'xPed', |
||
| 1729 | 'nItemPed', |
||
| 1730 | 'nFCI' |
||
| 1731 | ]; |
||
| 1732 | $std = $this->equilizeParameters($std, $possible); |
||
| 1733 | //totalizador |
||
| 1734 | if ($std->indTot == 1) { |
||
| 1735 | $this->stdTot->vProd += (float) $std->vProd; |
||
| 1736 | } |
||
| 1737 | $this->stdTot->vFrete += (float) $std->vFrete; |
||
| 1738 | $this->stdTot->vSeg += (float) $std->vSeg; |
||
| 1739 | $this->stdTot->vDesc += (float) $std->vDesc; |
||
| 1740 | $this->stdTot->vOutro += (float) $std->vOutro; |
||
| 1741 | |||
| 1742 | $cean = !empty($std->cEAN) ? trim(strtoupper($std->cEAN)) : ''; |
||
| 1743 | $ceantrib = !empty($std->cEANTrib) ? trim(strtoupper($std->cEANTrib)) : ''; |
||
| 1744 | //throw exception if not is Valid |
||
| 1745 | try { |
||
| 1746 | Gtin::isValid($cean); |
||
| 1747 | } catch (\InvalidArgumentException $e) { |
||
| 1748 | $this->errors[] = "cEANT {$cean} " . $e->getMessage(); |
||
| 1749 | } |
||
| 1750 | |||
| 1751 | try { |
||
| 1752 | Gtin::isValid($ceantrib); |
||
| 1753 | } catch (\InvalidArgumentException $e) { |
||
| 1754 | $this->errors[] = "cEANTrib {$ceantrib} " . $e->getMessage(); |
||
| 1755 | } |
||
| 1756 | |||
| 1757 | $identificador = 'I01 <prod> - '; |
||
| 1758 | $prod = $this->dom->createElement("prod"); |
||
| 1759 | $this->dom->addChild( |
||
| 1760 | $prod, |
||
| 1761 | "cProd", |
||
| 1762 | $std->cProd, |
||
| 1763 | true, |
||
| 1764 | $identificador . "[item $std->item] Código do produto ou serviço" |
||
| 1765 | ); |
||
| 1766 | $this->dom->addChild( |
||
| 1767 | $prod, |
||
| 1768 | "cEAN", |
||
| 1769 | $cean, |
||
| 1770 | true, |
||
| 1771 | $identificador . "[item $std->item] GTIN (Global Trade Item Number) do produto, antigo " |
||
| 1772 | . "código EAN ou código de barras", |
||
| 1773 | true |
||
| 1774 | ); |
||
| 1775 | $xProd = $std->xProd; |
||
| 1776 | if ($this->tpAmb == '2' && $this->mod == '65' && $std->item === 1) { |
||
| 1777 | $xProd = 'NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
| 1778 | } |
||
| 1779 | $this->dom->addChild( |
||
| 1780 | $prod, |
||
| 1781 | "xProd", |
||
| 1782 | $xProd, |
||
| 1783 | true, |
||
| 1784 | $identificador . "[item $std->item] Descrição do produto ou serviço" |
||
| 1785 | ); |
||
| 1786 | $this->dom->addChild( |
||
| 1787 | $prod, |
||
| 1788 | "NCM", |
||
| 1789 | $std->NCM, |
||
| 1790 | true, |
||
| 1791 | $identificador . "[item $std->item] Código NCM com 8 dígitos ou 2 dígitos (gênero)" |
||
| 1792 | ); |
||
| 1793 | //incluido no layout 4.00 |
||
| 1794 | $this->dom->addChild( |
||
| 1795 | $prod, |
||
| 1796 | "cBenef", |
||
| 1797 | $std->cBenef, |
||
| 1798 | false, |
||
| 1799 | $identificador . "[item $std->item] Código de Benefício Fiscal utilizado pela UF" |
||
| 1800 | ); |
||
| 1801 | $this->dom->addChild( |
||
| 1802 | $prod, |
||
| 1803 | "EXTIPI", |
||
| 1804 | $std->EXTIPI, |
||
| 1805 | false, |
||
| 1806 | $identificador . "[item $std->item] Preencher de acordo com o código EX da TIPI" |
||
| 1807 | ); |
||
| 1808 | $this->dom->addChild( |
||
| 1809 | $prod, |
||
| 1810 | "CFOP", |
||
| 1811 | $std->CFOP, |
||
| 1812 | true, |
||
| 1813 | $identificador . "[item $std->item] Código Fiscal de Operações e Prestações" |
||
| 1814 | ); |
||
| 1815 | $this->dom->addChild( |
||
| 1816 | $prod, |
||
| 1817 | "uCom", |
||
| 1818 | $std->uCom, |
||
| 1819 | true, |
||
| 1820 | $identificador . "[item $std->item] Unidade Comercial do produto" |
||
| 1821 | ); |
||
| 1822 | $this->dom->addChild( |
||
| 1823 | $prod, |
||
| 1824 | "qCom", |
||
| 1825 | $this->conditionalNumberFormatting($std->qCom, 4), |
||
| 1826 | true, |
||
| 1827 | $identificador . "[item $std->item] Quantidade Comercial do produto" |
||
| 1828 | ); |
||
| 1829 | $this->dom->addChild( |
||
| 1830 | $prod, |
||
| 1831 | "vUnCom", |
||
| 1832 | $this->conditionalNumberFormatting($std->vUnCom, 10), |
||
| 1833 | true, |
||
| 1834 | $identificador . "[item $std->item] Valor Unitário de Comercialização do produto" |
||
| 1835 | ); |
||
| 1836 | $this->dom->addChild( |
||
| 1837 | $prod, |
||
| 1838 | "vProd", |
||
| 1839 | $this->conditionalNumberFormatting($std->vProd), |
||
| 1840 | true, |
||
| 1841 | $identificador . "[item $std->item] Valor Total Bruto dos Produtos ou Serviços" |
||
| 1842 | ); |
||
| 1843 | $this->dom->addChild( |
||
| 1844 | $prod, |
||
| 1845 | "cEANTrib", |
||
| 1846 | $ceantrib, |
||
| 1847 | true, |
||
| 1848 | $identificador . "[item $std->item] GTIN (Global Trade Item Number) da unidade tributável, antigo " |
||
| 1849 | . "código EAN ou código de barras", |
||
| 1850 | true |
||
| 1851 | ); |
||
| 1852 | $this->dom->addChild( |
||
| 1853 | $prod, |
||
| 1854 | "uTrib", |
||
| 1855 | $std->uTrib, |
||
| 1856 | true, |
||
| 1857 | $identificador . "[item $std->item] Unidade Tributável do produto" |
||
| 1858 | ); |
||
| 1859 | $this->dom->addChild( |
||
| 1860 | $prod, |
||
| 1861 | "qTrib", |
||
| 1862 | $this->conditionalNumberFormatting($std->qTrib, 4), |
||
| 1863 | true, |
||
| 1864 | $identificador . "[item $std->item] Quantidade Tributável do produto" |
||
| 1865 | ); |
||
| 1866 | $this->dom->addChild( |
||
| 1867 | $prod, |
||
| 1868 | "vUnTrib", |
||
| 1869 | $this->conditionalNumberFormatting($std->vUnTrib, 10), |
||
| 1870 | true, |
||
| 1871 | $identificador . "[item $std->item] Valor Unitário de tributação do produto" |
||
| 1872 | ); |
||
| 1873 | $this->dom->addChild( |
||
| 1874 | $prod, |
||
| 1875 | "vFrete", |
||
| 1876 | $this->conditionalNumberFormatting($std->vFrete), |
||
| 1877 | false, |
||
| 1878 | $identificador . "[item $std->item] Valor Total do Frete" |
||
| 1879 | ); |
||
| 1880 | $this->dom->addChild( |
||
| 1881 | $prod, |
||
| 1882 | "vSeg", |
||
| 1883 | $this->conditionalNumberFormatting($std->vSeg), |
||
| 1884 | false, |
||
| 1885 | $identificador . "[item $std->item] Valor Total do Seguro" |
||
| 1886 | ); |
||
| 1887 | $this->dom->addChild( |
||
| 1888 | $prod, |
||
| 1889 | "vDesc", |
||
| 1890 | $this->conditionalNumberFormatting($std->vDesc), |
||
| 1891 | false, |
||
| 1892 | $identificador . "[item $std->item] Valor do Desconto" |
||
| 1893 | ); |
||
| 1894 | $this->dom->addChild( |
||
| 1895 | $prod, |
||
| 1896 | "vOutro", |
||
| 1897 | $this->conditionalNumberFormatting($std->vOutro), |
||
| 1898 | false, |
||
| 1899 | $identificador . "[item $std->item] Outras despesas acessórias" |
||
| 1900 | ); |
||
| 1901 | $this->dom->addChild( |
||
| 1902 | $prod, |
||
| 1903 | "indTot", |
||
| 1904 | $std->indTot, |
||
| 1905 | true, |
||
| 1906 | $identificador . "[item $std->item] Indica se valor do Item (vProd) entra no valor total da NF-e (vProd)" |
||
| 1907 | ); |
||
| 1908 | $this->dom->addChild( |
||
| 1909 | $prod, |
||
| 1910 | "xPed", |
||
| 1911 | $std->xPed, |
||
| 1912 | false, |
||
| 1913 | $identificador . "[item $std->item] Número do Pedido de Compra" |
||
| 1914 | ); |
||
| 1915 | $this->dom->addChild( |
||
| 1916 | $prod, |
||
| 1917 | "nItemPed", |
||
| 1918 | $std->nItemPed, |
||
| 1919 | false, |
||
| 1920 | $identificador . "[item $std->item] Item do Pedido de Compra" |
||
| 1921 | ); |
||
| 1922 | $this->dom->addChild( |
||
| 1923 | $prod, |
||
| 1924 | "nFCI", |
||
| 1925 | $std->nFCI, |
||
| 1926 | false, |
||
| 1927 | $identificador . "[item $std->item] Número de controle da FCI " |
||
| 1928 | . "Ficha de Conteúdo de Importação" |
||
| 1929 | ); |
||
| 1930 | $this->aProd[$std->item] = $prod; |
||
| 1931 | return $prod; |
||
| 1932 | } |
||
| 1933 | |||
| 1934 | /** |
||
| 1935 | * NVE NOMENCLATURA DE VALOR ADUANEIRO E ESTATÍSTICA |
||
| 1936 | * Podem ser até 8 NVE's por item |
||
| 1937 | * |
||
| 1938 | * @param stdClass $std |
||
| 1939 | * @return DOMElement|null |
||
| 1940 | */ |
||
| 1941 | public function tagNVE(stdClass $std) |
||
| 1953 | |||
| 1954 | /** |
||
| 1955 | * Código Especificador da Substituição Tributária – CEST, |
||
| 1956 | * que identifica a mercadoria sujeita aos regimes de substituição |
||
| 1957 | * tributária e de antecipação do recolhimento do imposto. |
||
| 1958 | * vide NT2015.003 I05C pai |
||
| 1959 | * tag NFe/infNFe/det[item]/prod/CEST (opcional) |
||
| 1960 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
| 1961 | * @param stdClass $std |
||
| 1962 | * @return DOMElement |
||
| 1963 | */ |
||
| 1964 | public function tagCEST(stdClass $std) |
||
| 1997 | |||
| 1998 | /** |
||
| 1999 | * tag NFe/infNFe/det[item]/prod/nRECOPI |
||
| 2000 | * @param stdClass $std |
||
| 2001 | * @return DOMElement |
||
| 2002 | */ |
||
| 2003 | public function tagRECOPI(stdClass $std) |
||
| 2011 | |||
| 2012 | /** |
||
| 2013 | * Declaração de Importação I8 pai I01 |
||
| 2014 | * tag NFe/infNFe/det[]/prod/DI |
||
| 2015 | * @param stdClass $std |
||
| 2016 | * @return DOMElement |
||
| 2017 | */ |
||
| 2018 | public function tagDI(stdClass $std) |
||
| 2119 | |||
| 2120 | /** |
||
| 2121 | * Adições I25 pai I18 |
||
| 2122 | * tag NFe/infNFe/det[]/prod/DI/adi |
||
| 2123 | * @param stdClass $std |
||
| 2124 | * @return DOMElement |
||
| 2125 | */ |
||
| 2126 | public function tagadi(stdClass $std) |
||
| 2182 | |||
| 2183 | /** |
||
| 2184 | * Grupo de informações de exportação para o item I50 pai I01 |
||
| 2185 | * tag NFe/infNFe/det[]/prod/detExport |
||
| 2186 | * @param stdClass $std |
||
| 2187 | * @return DOMElement |
||
| 2188 | */ |
||
| 2189 | public function tagdetExport(stdClass $std) |
||
| 2208 | |||
| 2209 | /** |
||
| 2210 | * Grupo de informações de exportação para o item I52 pai I52 |
||
| 2211 | * tag NFe/infNFe/det[]/prod/detExport |
||
| 2212 | * @param stdClass $std |
||
| 2213 | * @return DOMElement |
||
| 2214 | */ |
||
| 2215 | public function tagdetExportInd(stdClass $std) |
||
| 2258 | |||
| 2259 | /** |
||
| 2260 | * Rastreabilidade do produto podem ser até 500 por item TAG I80 pai I01 |
||
| 2261 | * NOTA: Ajustado para NT2016_002_v1.00 |
||
| 2262 | * tag NFe/infNFe/det[]/prod/rastro |
||
| 2263 | * @param stdClass $std |
||
| 2264 | * @return DOMElement |
||
| 2265 | */ |
||
| 2266 | public function tagRastro(stdClass $std) |
||
| 2317 | |||
| 2318 | /** |
||
| 2319 | * Detalhamento de Veículos novos J01 pai I90 |
||
| 2320 | * tag NFe/infNFe/det[]/prod/veicProd (opcional) |
||
| 2321 | * @param stdClass $std |
||
| 2322 | * @return DOMElement |
||
| 2323 | */ |
||
| 2324 | public function tagveicProd(stdClass $std) |
||
| 2527 | |||
| 2528 | /** |
||
| 2529 | * Detalhamento de medicamentos K01 pai I90 |
||
| 2530 | * NOTA: Ajustado para NT2018.005 |
||
| 2531 | * tag NFe/infNFe/det[]/prod/med (opcional) |
||
| 2532 | * @param stdClass $std |
||
| 2533 | * @return DOMElement |
||
| 2534 | */ |
||
| 2535 | public function tagmed(stdClass $std) |
||
| 2570 | |||
| 2571 | /** |
||
| 2572 | * Detalhamento de armas L01 pai I90 |
||
| 2573 | * tag NFe/infNFe/det[]/prod/arma (opcional) |
||
| 2574 | * @param stdClass $std |
||
| 2575 | * @return DOMElement |
||
| 2576 | */ |
||
| 2577 | public function tagarma(stdClass $std) |
||
| 2623 | |||
| 2624 | /** |
||
| 2625 | * Detalhamento de combustiveis L101 pai I90 |
||
| 2626 | * tag NFe/infNFe/det[]/prod/comb (opcional) |
||
| 2627 | * LA|cProdANP|pMixGN|CODIF|qTemp|UFCons| |
||
| 2628 | * |
||
| 2629 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
| 2630 | * LA|cProdANP|descANP|pGLP|pGNn|pGNi|vPart|CODIF|qTemp|UFCons| |
||
| 2631 | * @param stdClass $std |
||
| 2632 | * @return DOMElement |
||
| 2633 | */ |
||
| 2634 | public function tagcomb(stdClass $std) |
||
| 2635 | { |
||
| 2636 | $possible = [ |
||
| 2637 | 'item', |
||
| 2638 | 'cProdANP', |
||
| 2639 | 'descANP', |
||
| 2640 | 'pGLP', |
||
| 2641 | 'pGNn', |
||
| 2642 | 'pGNi', |
||
| 2643 | 'vPart', |
||
| 2644 | 'CODIF', |
||
| 2645 | 'qTemp', |
||
| 2756 | |||
| 2757 | /** |
||
| 2758 | * informações relacionadas com as operações de combustíveis, subgrupo de |
||
| 2759 | * encerrante que permite o controle sobre as operações de venda de combustíveis |
||
| 2760 | * LA11 pai LA01 |
||
| 2761 | * tag NFe/infNFe/det[]/prod/comb/encerrante (opcional) |
||
| 2762 | * @param stdClass $std |
||
| 2763 | * @return DOMElement |
||
| 2764 | */ |
||
| 2765 | public function tagencerrante(stdClass $std) |
||
| 2816 | |||
| 2817 | /** |
||
| 2818 | * Impostos com o valor total tributado M01 pai H01 |
||
| 2819 | * tag NFe/infNFe/det[]/imposto |
||
| 2820 | * @param stdClass $std |
||
| 2821 | * @return DOMElement |
||
| 2822 | */ |
||
| 2823 | public function tagimposto(stdClass $std) |
||
| 2841 | |||
| 2842 | /** |
||
| 2843 | * Informações do ICMS da Operação própria e ST N01 pai M01 |
||
| 2844 | * tag NFe/infNFe/det[]/imposto/ICMS |
||
| 2845 | * @param stdClass $std |
||
| 2846 | * @return DOMElement |
||
| 2847 | */ |
||
| 2848 | public function tagICMS(stdClass $std) |
||
| 3833 | |||
| 3834 | /** |
||
| 3835 | * Grupo de Partilha do ICMS entre a UF de origem e UF de destino ou |
||
| 3836 | * a UF definida na legislação. N10a pai N01 |
||
| 3837 | * tag NFe/infNFe/det[]/imposto/ICMS/ICMSPart |
||
| 3838 | * @param stdClass $std |
||
| 3839 | * @return DOMElement |
||
| 3840 | */ |
||
| 3841 | public function tagICMSPart(stdClass $std) |
||
| 3982 | |||
| 3983 | /** |
||
| 3984 | * Grupo de Repasse de ICMSST retido anteriormente em operações |
||
| 3985 | * interestaduais com repasses através do Substituto Tributário |
||
| 3986 | * NOTA: ajustado NT 2018.005 |
||
| 3987 | * tag NFe/infNFe/det[]/imposto/ICMS/ICMSST N10b pai N01 |
||
| 3988 | * @param stdClass $std |
||
| 3989 | * @return DOMElement |
||
| 3990 | */ |
||
| 3991 | public function tagICMSST(stdClass $std) |
||
| 4128 | |||
| 4129 | /** |
||
| 4130 | * Tributação ICMS pelo Simples Nacional N10c pai N01 |
||
| 4131 | * tag NFe/infNFe/det[]/imposto/ICMS/ICMSSN N10c pai N01 |
||
| 4132 | * @param stdClass $std |
||
| 4133 | * @return DOMElement |
||
| 4134 | */ |
||
| 4135 | public function tagICMSSN(stdClass $std) |
||
| 4659 | |||
| 4660 | /** |
||
| 4661 | * Grupo ICMSUFDest NA01 pai M01 |
||
| 4662 | * tag NFe/infNFe/det[]/imposto/ICMSUFDest (opcional) |
||
| 4663 | * Grupo a ser informado nas vendas interestaduais para consumidor final, |
||
| 4664 | * não contribuinte do ICMS |
||
| 4665 | * @param stdClass $std |
||
| 4666 | * @return DOMElement |
||
| 4667 | */ |
||
| 4668 | public function tagICMSUFDest(stdClass $std) |
||
| 4753 | |||
| 4754 | /** |
||
| 4755 | * Grupo IPI O01 pai M01 |
||
| 4756 | * tag NFe/infNFe/det[]/imposto/IPI (opcional) |
||
| 4757 | * @param stdClass $std |
||
| 4758 | * @return DOMElement |
||
| 4759 | */ |
||
| 4760 | public function tagIPI(stdClass $std) |
||
| 4876 | |||
| 4877 | /** |
||
| 4878 | * Grupo Imposto de Importação P01 pai M01 |
||
| 4879 | * tag NFe/infNFe/det[]/imposto/II |
||
| 4880 | * @param stdClass $std |
||
| 4881 | * @return DOMElement |
||
| 4882 | */ |
||
| 4883 | public function tagII(stdClass $std) |
||
| 4927 | |||
| 4928 | /** |
||
| 4929 | * Grupo PIS Q01 pai M01 |
||
| 4930 | * tag NFe/infNFe/det[]/imposto/PIS |
||
| 4931 | * @param stdClass $std |
||
| 4932 | * @return DOMElement |
||
| 4933 | */ |
||
| 4934 | public function tagPIS(stdClass $std) |
||
| 5108 | |||
| 5109 | /** |
||
| 5110 | * Grupo PIS Substituição Tributária R01 pai M01 |
||
| 5111 | * tag NFe/infNFe/det[]/imposto/PISST (opcional) |
||
| 5112 | * @param stdClass $std |
||
| 5113 | * @return DOMElement |
||
| 5114 | */ |
||
| 5115 | public function tagPISST(stdClass $std) |
||
| 5168 | |||
| 5169 | /** |
||
| 5170 | * Grupo COFINS S01 pai M01 |
||
| 5171 | * tag det[item]/imposto/COFINS (opcional) |
||
| 5172 | * @param stdClass $std |
||
| 5173 | * @return DOMElement |
||
| 5174 | */ |
||
| 5175 | public function tagCOFINS(stdClass $std) |
||
| 5271 | |||
| 5272 | /** |
||
| 5273 | * Grupo COFINS Substituição Tributária T01 pai M01 |
||
| 5274 | * tag NFe/infNFe/det[]/imposto/COFINSST (opcional) |
||
| 5275 | * @param stdClass $std |
||
| 5276 | * @return DOMElement |
||
| 5277 | */ |
||
| 5278 | public function tagCOFINSST(stdClass $std) |
||
| 5331 | |||
| 5332 | /** |
||
| 5333 | * Grupo ISSQN U01 pai M01 |
||
| 5334 | * tag NFe/infNFe/det[]/imposto/ISSQN (opcional) |
||
| 5335 | * @param stdClass $std |
||
| 5336 | * @return DOMElement |
||
| 5337 | */ |
||
| 5338 | public function tagISSQN(stdClass $std) |
||
| 5476 | |||
| 5477 | /** |
||
| 5478 | * Informação do Imposto devolvido U50 pai H01 |
||
| 5479 | * tag NFe/infNFe/det[]/impostoDevol (opcional) |
||
| 5480 | * @param stdClass $std |
||
| 5481 | * @return DOMElement |
||
| 5482 | */ |
||
| 5483 | public function tagimpostoDevol(stdClass $std) |
||
| 5513 | |||
| 5514 | /** |
||
| 5515 | * Grupo Totais referentes ao ICMS W02 pai W01 |
||
| 5516 | * tag NFe/infNFe/total/ICMSTot |
||
| 5517 | * @param stdClass $std |
||
| 5518 | * @return DOMElement |
||
| 5519 | */ |
||
| 5520 | public function tagICMSTot(stdClass $std) |
||
| 5732 | |||
| 5733 | /** |
||
| 5734 | * Grupo Totais referentes ao ISSQN W17 pai W01 |
||
| 5735 | * tag NFe/infNFe/total/ISSQNTot (opcional) |
||
| 5736 | * @param stdClass $std |
||
| 5737 | * @return DOMElement |
||
| 5738 | */ |
||
| 5739 | public function tagISSQNTot(stdClass $std) |
||
| 5845 | |||
| 5846 | /** |
||
| 5847 | * Grupo Retenções de Tributos W23 pai W01 |
||
| 5848 | * tag NFe/infNFe/total/reTrib (opcional) |
||
| 5849 | * @param stdClass $std |
||
| 5850 | * @return DOMElement |
||
| 5851 | */ |
||
| 5852 | public function tagretTrib(stdClass $std) |
||
| 5917 | |||
| 5918 | /** |
||
| 5919 | * Grupo Informações do Transporte X01 pai A01 |
||
| 5920 | * tag NFe/infNFe/transp (obrigatório) |
||
| 5921 | * @param stdClass $std |
||
| 5922 | * @return DOMElement |
||
| 5923 | */ |
||
| 5924 | public function tagtransp(stdClass $std) |
||
| 5936 | |||
| 5937 | /** |
||
| 5938 | * Grupo Transportador X03 pai X01 |
||
| 5939 | * tag NFe/infNFe/transp/tranporta (opcional) |
||
| 5940 | * @param stdClass $std |
||
| 5941 | * @return DOMElement |
||
| 5942 | */ |
||
| 5943 | public function tagtransporta(stdClass $std) |
||
| 6013 | |||
| 6014 | /** |
||
| 6015 | * Grupo Retenção ICMS transporte X11 pai X01 |
||
| 6016 | * tag NFe/infNFe/transp/retTransp (opcional) |
||
| 6017 | * @param stdClass $std |
||
| 6018 | * @return DOMElement |
||
| 6019 | */ |
||
| 6020 | public function tagretTransp(stdClass $std) |
||
| 6081 | |||
| 6082 | /** |
||
| 6083 | * Grupo Veículo Transporte X18 pai X17.1 |
||
| 6084 | * tag NFe/infNFe/transp/veicTransp (opcional) |
||
| 6085 | * @param stdClass $std |
||
| 6086 | * @return DOMElement |
||
| 6087 | */ |
||
| 6088 | public function tagveicTransp(stdClass $std) |
||
| 6125 | |||
| 6126 | /** |
||
| 6127 | * Grupo Reboque X22 pai X17.1 |
||
| 6128 | * tag NFe/infNFe/transp/reboque (opcional) |
||
| 6129 | * @param stdClass $std |
||
| 6130 | * @return DOMElement |
||
| 6131 | */ |
||
| 6132 | public function tagreboque(stdClass $std) |
||
| 6169 | |||
| 6170 | /** |
||
| 6171 | * Campo Vagao X25a pai X01 |
||
| 6172 | * tag NFe/infNFe/transp/vagao (opcional) |
||
| 6173 | * @param stdClass $std |
||
| 6174 | */ |
||
| 6175 | public function tagvagao(stdClass $std) |
||
| 6189 | |||
| 6190 | /** |
||
| 6191 | * Campo Balsa X25b pai X01 |
||
| 6192 | * tag NFe/infNFe/transp/balsa (opcional) |
||
| 6193 | * @param stdClass $std |
||
| 6194 | */ |
||
| 6195 | public function tagbalsa(stdClass $std) |
||
| 6209 | |||
| 6210 | /** |
||
| 6211 | * Grupo Volumes X26 pai X01 |
||
| 6212 | * tag NFe/infNFe/transp/vol (opcional) |
||
| 6213 | * @param stdClass $std |
||
| 6214 | * @return DOMElement |
||
| 6215 | */ |
||
| 6216 | public function tagvol(stdClass $std) |
||
| 6274 | |||
| 6275 | /** |
||
| 6276 | * Grupo Lacres X33 pai X26 |
||
| 6277 | * tag NFe/infNFe/transp/vol/lacres (opcional) |
||
| 6278 | * @param stdClass $std |
||
| 6279 | * @return DOMElement |
||
| 6280 | */ |
||
| 6281 | public function taglacres(stdClass $std) |
||
| 6294 | |||
| 6295 | /** |
||
| 6296 | * Node vol |
||
| 6297 | */ |
||
| 6298 | protected function buildVol() |
||
| 6304 | |||
| 6305 | /** |
||
| 6306 | * Grupo Pagamento Y pai A01 |
||
| 6307 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
| 6308 | * tag NFe/infNFe/pag (obrigatorio na NT2016_002_v1.30) |
||
| 6309 | * Obrigatório para 55 e 65 |
||
| 6310 | * @param stdClass $std |
||
| 6311 | * @return DOMElement |
||
| 6312 | */ |
||
| 6313 | public function tagpag($std) |
||
| 6330 | |||
| 6331 | /** |
||
| 6332 | * Grupo de Formas de Pagamento YA01a pai YA01 |
||
| 6333 | * NOTA: Ajuste NT_2016_002_v1.30 |
||
| 6334 | * NOTA: Ajuste NT_2016_002_v1 51 |
||
| 6335 | * NOTA: Ajuste NT_2020_006 |
||
| 6336 | * tag NFe/infNFe/pag/detPag |
||
| 6337 | * @param stdClass $std |
||
| 6338 | * @return DOMElement |
||
| 6339 | */ |
||
| 6340 | public function tagdetPag($std) |
||
| 6425 | |||
| 6426 | /** |
||
| 6427 | * Dados do intermediador |
||
| 6428 | * |
||
| 6429 | * @param stdClass $std |
||
| 6430 | * @return \DomElement |
||
| 6431 | */ |
||
| 6432 | public function tagIntermed(stdClass $std) |
||
| 6457 | |||
| 6458 | /** |
||
| 6459 | * Grupo Fatura Y02 pai Y01 |
||
| 6460 | * tag NFe/infNFe/cobr/fat (opcional) |
||
| 6461 | * @param stdClass $std |
||
| 6462 | * @return DOMElement |
||
| 6463 | */ |
||
| 6464 | public function tagfat(stdClass $std) |
||
| 6506 | |||
| 6507 | /** |
||
| 6508 | * Grupo Duplicata Y07 pai Y02 |
||
| 6509 | * tag NFe/infNFe/cobr/fat/dup (opcional) |
||
| 6510 | * É necessário criar a tag fat antes de criar as duplicatas |
||
| 6511 | * @param stdClass $std |
||
| 6512 | * @return DOMElement |
||
| 6513 | */ |
||
| 6514 | public function tagdup(stdClass $std) |
||
| 6548 | |||
| 6549 | /** |
||
| 6550 | * Grupo de Informações Adicionais Z01 pai A01 |
||
| 6551 | * tag NFe/infNFe/infAdic (opcional) |
||
| 6552 | * @param stdClass $std |
||
| 6553 | * @return DOMElement |
||
| 6554 | */ |
||
| 6555 | public function taginfAdic(stdClass $std) |
||
| 6576 | |||
| 6577 | /** |
||
| 6578 | * Grupo Campo de uso livre do contribuinte Z04 pai Z01 |
||
| 6579 | * tag NFe/infNFe/infAdic/obsCont (opcional) |
||
| 6580 | * O método taginfAdic deve ter sido carregado antes |
||
| 6581 | * @param stdClass $std |
||
| 6582 | * @return DOMElement |
||
| 6583 | */ |
||
| 6584 | public function tagobsCont(stdClass $std) |
||
| 6601 | |||
| 6602 | /** |
||
| 6603 | * Grupo Campo de uso livre do Fisco Z07 pai Z01 |
||
| 6604 | * tag NFe/infNFe/infAdic/obsFisco (opcional) |
||
| 6605 | * O método taginfAdic deve ter sido carregado antes |
||
| 6606 | * @param stdClass $std |
||
| 6607 | * @return DOMElement |
||
| 6608 | */ |
||
| 6609 | public function tagobsFisco(stdClass $std) |
||
| 6626 | |||
| 6627 | /** |
||
| 6628 | * Grupo Processo referenciado Z10 pai Z01 (NT2012.003) |
||
| 6629 | * tag NFe/infNFe/procRef (opcional) |
||
| 6630 | * O método taginfAdic deve ter sido carregado antes |
||
| 6631 | * @param stdClass $std |
||
| 6632 | * @return DOMElement |
||
| 6633 | */ |
||
| 6634 | public function tagprocRef($std) |
||
| 6657 | |||
| 6658 | /** |
||
| 6659 | * Grupo Exportação ZA01 pai A01 |
||
| 6660 | * tag NFe/infNFe/exporta (opcional) |
||
| 6661 | * @param stdClass $std |
||
| 6662 | * @return DOMElement |
||
| 6663 | */ |
||
| 6664 | public function tagexporta(stdClass $std) |
||
| 6692 | |||
| 6693 | /** |
||
| 6694 | * Grupo Compra ZB01 pai A01 |
||
| 6695 | * tag NFe/infNFe/compra (opcional) |
||
| 6696 | * @param stdClass $std |
||
| 6697 | * @return DOMElement |
||
| 6698 | */ |
||
| 6699 | public function tagcompra(stdClass $std) |
||
| 6727 | |||
| 6728 | /** |
||
| 6729 | * Grupo Cana ZC01 pai A01 |
||
| 6730 | * tag NFe/infNFe/cana (opcional) |
||
| 6731 | * @param stdClass $std |
||
| 6732 | * @return DOMElement |
||
| 6733 | */ |
||
| 6734 | public function tagcana(stdClass $std) |
||
| 6806 | |||
| 6807 | /** |
||
| 6808 | * Grupo Fornecimento diário de cana ZC04 pai ZC01 |
||
| 6809 | * tag NFe/infNFe/cana/forDia |
||
| 6810 | * @param stdClass $std |
||
| 6811 | * @return DOMElement |
||
| 6812 | */ |
||
| 6813 | public function tagforDia(stdClass $std) |
||
| 6828 | |||
| 6829 | /** |
||
| 6830 | * Grupo Deduções – Taxas e Contribuições ZC10 pai ZC01 |
||
| 6831 | * tag NFe/infNFe/cana/deduc (opcional) |
||
| 6832 | * @param stdClass $std |
||
| 6833 | * @return DOMElement |
||
| 6834 | */ |
||
| 6835 | public function tagdeduc(stdClass $std) |
||
| 6858 | |||
| 6859 | /** |
||
| 6860 | * Informações suplementares da Nota Fiscal |
||
| 6861 | * @param stdClass $std |
||
| 6862 | * @return DOMElement |
||
| 6863 | */ |
||
| 6864 | public function taginfNFeSupl(stdClass $std) |
||
| 6884 | |||
| 6885 | /** |
||
| 6886 | * Informações do Responsável técnico ZD01 pai A01 |
||
| 6887 | * tag NFe/infNFe/infRespTec (opcional) |
||
| 6888 | * @param stdClass $std |
||
| 6889 | * @return DOMElement |
||
| 6890 | * @throws RuntimeException |
||
| 6891 | */ |
||
| 6892 | public function taginfRespTec(stdClass $std) |
||
| 6957 | |||
| 6958 | /** |
||
| 6959 | * Tag raiz da NFe |
||
| 6960 | * tag NFe DOMNode |
||
| 6961 | * Função chamada pelo método [ monta ] |
||
| 6962 | * |
||
| 6963 | * @return DOMElement |
||
| 6964 | */ |
||
| 6965 | protected function buildNFe() |
||
| 6973 | |||
| 6974 | /** |
||
| 6975 | * Informação de Documentos Fiscais referenciados BA01 pai B01 |
||
| 6976 | * tag NFe/infNFe/ide/NFref |
||
| 6977 | * Podem ser criados até 500 desses Nodes por NFe |
||
| 6978 | * Função chamada pelos métodos |
||
| 6979 | * [tagrefNFe] [tagrefNF] [tagrefNFP] [tagCTeref] [tagrefECF] |
||
| 6980 | */ |
||
| 6981 | protected function buildNFref() |
||
| 6986 | |||
| 6987 | /** |
||
| 6988 | * Insere dentro dentro das tags imposto o ICMS IPI II PIS COFINS ISSQN |
||
| 6989 | * tag NFe/infNFe/det[]/imposto |
||
| 6990 | * @return void |
||
| 6991 | */ |
||
| 6992 | protected function buildImp() |
||
| 7025 | |||
| 7026 | /** |
||
| 7027 | * Grupo COFINS tributado pela alíquota S02 pai S01 |
||
| 7028 | * tag det/imposto/COFINS/COFINSAliq (opcional) |
||
| 7029 | * Função chamada pelo método [ tagCOFINS ] |
||
| 7030 | * @param stdClass $std |
||
| 7031 | * @return DOMElement |
||
| 7032 | */ |
||
| 7033 | protected function buildCOFINSAliq($std) |
||
| 7066 | |||
| 7067 | /** |
||
| 7068 | * Grupo COFINS não tributado S04 pai S01 |
||
| 7069 | * tag NFe/infNFe/det[]/imposto/COFINS/COFINSNT (opcional) |
||
| 7070 | * Função chamada pelo método [ tagCOFINS ] |
||
| 7071 | * @param stdClass $std |
||
| 7072 | * @return DOMElement |
||
| 7073 | */ |
||
| 7074 | protected function buildCOFINSNT(stdClass $std) |
||
| 7086 | |||
| 7087 | /** |
||
| 7088 | * Grupo COFINS Outras Operações S05 pai S01 |
||
| 7089 | * tag NFe/infNFe/det[]/imposto/COFINS/COFINSoutr (opcional) |
||
| 7090 | * Função chamada pelo método [ tagCOFINS ] |
||
| 7091 | * @param stdClass $std |
||
| 7092 | * @return DOMElement |
||
| 7093 | */ |
||
| 7094 | protected function buildCOFINSoutr(stdClass $std) |
||
| 7141 | |||
| 7142 | /** |
||
| 7143 | * Insere dentro da tag det os produtos |
||
| 7144 | * tag NFe/infNFe/det[] |
||
| 7145 | * @return array|string |
||
| 7146 | */ |
||
| 7147 | protected function buildDet() |
||
| 7300 | |||
| 7301 | /** |
||
| 7302 | * Insere a tag pag, os detalhamentos dos pagamentos e cartoes |
||
| 7303 | * NOTA: Ajustado para NT2016_002_v1.30 |
||
| 7304 | * tag NFe/infNFe/pag/ |
||
| 7305 | * tag NFe/infNFe/pag/detPag[] |
||
| 7306 | * tag NFe/infNFe/pag/detPag[]/Card |
||
| 7307 | */ |
||
| 7308 | protected function buildTagPag() |
||
| 7312 | |||
| 7313 | /** |
||
| 7314 | * Grupo Totais da NF-e W01 pai A01 |
||
| 7315 | * tag NFe/infNFe/total |
||
| 7316 | */ |
||
| 7317 | protected function buildTotal() |
||
| 7357 | |||
| 7358 | /** |
||
| 7359 | * Grupo Cobrança Y01 pai A01 |
||
| 7360 | * tag NFe/infNFe/cobr (opcional) |
||
| 7361 | * Depende de fat |
||
| 7362 | */ |
||
| 7363 | protected function buildCobr() |
||
| 7369 | |||
| 7370 | /** |
||
| 7371 | * Grupo de Informações Adicionais Z01 pai A01 |
||
| 7372 | * tag NFe/infNFe/infAdic (opcional) |
||
| 7373 | * Função chamada pelos metodos |
||
| 7374 | * [taginfAdic] [tagobsCont] [tagobsFisco] [tagprocRef] |
||
| 7375 | * @return DOMElement |
||
| 7376 | */ |
||
| 7377 | protected function buildInfAdic() |
||
| 7384 | |||
| 7385 | /** |
||
| 7386 | * Remonta a chave da NFe de 44 digitos com base em seus dados |
||
| 7387 | * já contidos na NFE. |
||
| 7388 | * Isso é útil no caso da chave informada estar errada |
||
| 7389 | * se a chave estiver errada a mesma é substituida |
||
| 7390 | * @param Dom $dom |
||
| 7391 | * @return void |
||
| 7392 | */ |
||
| 7393 | protected function checkNFeKey(Dom $dom) |
||
| 7444 | |||
| 7445 | /** |
||
| 7446 | * Retorna os erros detectados |
||
| 7447 | * @return array |
||
| 7448 | */ |
||
| 7449 | public function getErrors() |
||
| 7453 | |||
| 7454 | /** |
||
| 7455 | * Includes missing or unsupported properties in stdClass |
||
| 7456 | * Replace all unsuported chars |
||
| 7457 | * @param stdClass $std |
||
| 7458 | * @param array $possible |
||
| 7459 | * @return stdClass |
||
| 7460 | */ |
||
| 7461 | 7 | protected function equilizeParameters(stdClass $std, $possible) |
|
| 7478 | |||
| 7479 | /** |
||
| 7480 | * Calcula hash sha1 retornando Base64Binary |
||
| 7481 | * @param string $CSRT |
||
| 7482 | * @return string |
||
| 7483 | */ |
||
| 7484 | protected function hashCSRT($CSRT) |
||
| 7489 | |||
| 7490 | /** |
||
| 7491 | * Formatação numerica condicional |
||
| 7492 | * @param string|float|int|null $value |
||
| 7493 | * @param int $decimal |
||
| 7494 | * @return string |
||
| 7495 | */ |
||
| 7496 | protected function conditionalNumberFormatting($value = null, $decimal = 2) |
||
| 7503 | |||
| 7504 | /* |
||
| 7505 | protected function conditionalNumberFormatting($value = null, array $decimal): string |
||
| 7506 | { |
||
| 7507 | if (!is_numeric($value)) { |
||
| 7508 | return null; |
||
| 7509 | } |
||
| 7510 | $num = (float) $value; |
||
| 7511 | $l = explode('.', $num); |
||
| 7512 | $declen = 0; |
||
| 7513 | if (!empty($l[1])) { |
||
| 7514 | $declen = strlen($l[1]); |
||
| 7515 | } |
||
| 7516 | if ($declen < $decimal[0]) { |
||
| 7517 | return number_format($num, $decimal[0], '.', ''); |
||
| 7518 | } elseif ($declen > $decimal[1]) { |
||
| 7519 | return number_format($num, $decimal[1], '.', ''); |
||
| 7520 | } |
||
| 7521 | return $num; |
||
| 7522 | }*/ |
||
| 7523 | } |
||
| 7524 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.