How to use std class

Best Atoum code snippet using std

Make.php

Source:Make.php Github

copy

Full Screen

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

Full Screen

Full Screen

Parser.php

Source:Parser.php Github

copy

Full Screen

...13 * @link http://github.com/nfephp-org/sped-nfe for the canonical source repository14 */15use NFePHP\NFe\Make;16use NFePHP\NFe\Exception\DocumentsException;17use stdClass;18class Parser19{20 const LOCAL = "LOCAL";21 const LOCAL_V12 = "LOCAL_V12";22 const SEBRAE = "SEBRAE";23 /**24 * @var array25 */26 protected $structure;27 /**28 * @var Make29 */30 protected $make;31 /**32 * @var int33 */34 protected $item = 0;35 /**36 * @var int37 */38 protected $nDI = 0;39 /**40 * @var int41 */42 protected $volId = -1;43 /**44 * @var stdClass|null45 */46 protected $stdNFP;47 /**48 * @var stdClass|null49 */50 protected $stdEmit;51 /**52 * @var stdClass|null53 */54 protected $stdDest;55 /**56 * @var stdClass|null57 */58 protected $stdRetirada;59 /**60 * @var stdClass|null61 */62 protected $stdEntrega;63 /**64 * @var stdClass|null65 */66 protected $stdAutXML;67 /**68 * @var stdClass69 */70 protected $stdComb;71 /**72 * @var stdClass73 */74 protected $stdIPI;75 /**76 * @var stdClass77 */78 protected $stdPIS;79 /**80 * @var stdClass81 */82 protected $stdPISST;83 /**84 * @var stdClass85 */86 protected $stdII;87 /**88 * @var stdClass89 */90 protected $stdCOFINS;91 /**92 * @var stdClass93 */94 protected $stdCOFINSST;95 /**96 * @var stdClass|null97 */98 protected $stdTransporta;99 /**100 * @var string101 */102 protected $baselayout;103 /**104 * Configure environment to correct NFe layout105 * @param string $version106 * @param string $baselayout107 */108 public function __construct($version = '4.00', $baselayout = self::LOCAL)109 {110 $ver = str_replace('.', '', $version);111 $comp = "";112 if ($baselayout === 'SEBRAE') {113 $comp = "_sebrae";114 } elseif ($baselayout == 'LOCAL_V12') {115 $comp = "_v1.2";116 }117 $this->baselayout = $baselayout;118 $path = realpath(__DIR__."/../../storage/txtstructure$ver" . $comp . ".json");119 $this->structure = json_decode(file_get_contents($path), true);120 $this->make = new Make();121 }122 /**123 * Convert txt to XML124 * @param array $nota125 * @return string|null126 */127 public function toXml($nota)128 {129 $this->array2xml($nota);130 if ($this->make->monta()) {131 return $this->make->getXML();132 }133 return null;134 }135 /**136 * Retorna erros na criacao do DOM137 * @return array138 */139 public function getErrors()140 {141 return $this->make->errors;142 }143 /**144 * Converte txt array to xml145 * @param array $nota146 * @return void147 */148 protected function array2xml($nota)149 {150 foreach ($nota as $lin) {151 $fields = explode('|', $lin);152 if (empty($fields)) {153 continue;154 }155 $metodo = strtolower(str_replace(' ', '', $fields[0])).'Entity';156 if (!method_exists(__CLASS__, $metodo)) {157 throw DocumentsException::wrongDocument(16, $lin); //campo não definido158 }159 $struct = $this->structure[strtoupper($fields[0])];160 $std = $this->fieldsToStd($fields, $struct);161 $this->$metodo($std);162 }163 }164 /**165 * Creates stdClass for all tag fields166 * @param array $dfls167 * @param string $struct168 * @return stdClass169 */170 protected static function fieldsToStd($dfls, $struct)171 {172 $sfls = explode('|', $struct);173 $len = count($sfls)-1;174 $std = new \stdClass();175 for ($i = 1; $i < $len; $i++) {176 $name = $sfls[$i];177 $data = $dfls[$i];178 if (!empty($name) && $data !== '') {179 $std->$name = $data;180 }181 }182 return $std;183 }184 /**185 * Create tag infNFe [A]186 * A|versao|Id|pk_nItem|187 * @param stdClass $std188 * @return void189 */190 protected function aEntity($std)191 {192 $this->make->taginfNFe($std);193 }194 /**195 * Create tag ide [B]196 * B|cUF|cNF|natOp|mod|serie|nNF|dhEmi|dhSaiEnt|tpNF|idDest|cMunFG|tpImp197 * |tpEmis|cDV|tpAmb|finNFe|indFinal|indPres|procEmi|verProc|dhCont|xJust|198 * @param stdClass $std199 * @return void200 */201 protected function bEntity($std)202 {203 $this->make->tagide($std);204 }205 /**206 * Create tag nfref [BA]207 * BA|208 * @param stdClass $std209 * @return void210 */211 protected function baEntity($std)212 {213 //fake não faz nada214 $field = null;215 }216 /**217 * Create tag refNFe [BA02]218 * BA02|refNFe|219 * @param stdClass $std220 * @return void221 */222 protected function ba02Entity($std)223 {224 $this->make->tagrefNFe($std);225 }226 /**227 * Create tag refNF [BA03]228 * BA03|cUF|AAMM|CNPJ|mod|serie|nNF|229 * @param stdClass $std230 * @return void231 */232 protected function ba03Entity($std)233 {234 $this->make->tagrefNF($std);235 }236 /**237 * Load fields for tag refNFP [BA10]238 * BA10|cUF|AAMM|IE|mod|serie|nNF|239 * @param stdClass $std240 * @return void241 */242 protected function ba10Entity($std)243 {244 $this->stdNFP = $std;245 $this->stdNFP->CNPJ = null;246 $this->stdNFP->CPF = null;247 }248 /**249 * Create tag refNFP [BA13], with CNPJ belongs to [BA10]250 * BA13|CNPJ|251 * @param stdClass $std252 * @return void253 */254 protected function ba13Entity($std)255 {256 $this->stdNFP->CNPJ = $std->CNPJ;257 $this->buildBA10Entity();258 $this->stdNFP = null;259 }260 /**261 * Create tag refNFP [BA14], with CPF belongs to [BA10]262 * BA14|CPF|263 * @param stdClass $std264 * @return void265 */266 protected function ba14Entity($std)267 {268 $this->stdNFP->CPF = $std->CPF;269 $this->buildBA10Entity();270 $this->stdNFP = null;271 }272 /**273 * Create tag refNFP [BA10]274 * @return void275 */276 protected function buildBA10Entity()277 {278 $this->make->tagrefNFP($this->stdNFP);279 }280 /**281 * Create tag refCTe [BA19]282 * B19|refCTe|283 * @param stdClass $std284 * @return void285 */286 protected function ba19Entity($std)287 {288 $this->make->tagrefCTe($std);289 }290 /**291 * Create tag refECF [BA20]292 * BA20|mod|nECF|nCOO|293 * @param stdClass $std294 * @return void295 */296 protected function ba20Entity($std)297 {298 $this->make->tagrefECF($std);299 }300 /**301 * Load fields for tag emit [C]302 * C|XNome|XFant|IE|IEST|IM|CNAE|CRT|303 * @param stdClass $std304 * @return void305 */306 protected function cEntity($std)307 {308 $this->stdEmit = $std;309 $this->stdEmit->CNPJ = null;310 $this->stdEmit->CPF = null;311 }312 /**313 * Create tag emit [C02], with CNPJ belongs to [C]314 * C02|CNPJ|315 * @param stdClass $std316 * @return void317 */318 protected function c02Entity($std)319 {320 $this->stdEmit->CNPJ = $std->CNPJ;321 $this->buildCEntity();322 $this->stdEmit = null;323 }324 /**325 * Create tag emit [C02a], with CPF belongs to [C]326 * C02a|CPF|327 * @param stdClass $std328 * @return void329 */330 protected function c02aEntity($std)331 {332 $this->stdEmit->CPF = $std->CPF;333 $this->buildCEntity();334 $this->stdEmit = null;335 }336 protected function dEntity($std)337 {338 //nada339 }340 /**341 * Create tag emit [C]342 * @return void343 */344 protected function buildCEntity()345 {346 $this->make->tagemit($this->stdEmit);347 }348 /**349 * Create tag enderEmit [C05]350 * C05|xLgr|nro|xCpl|xBairro|cMun|xMun|UF|CEP|cPais|xPais|fone|351 * @param stdClass $std352 * @return void353 */354 protected function c05Entity($std)355 {356 $this->make->tagenderEmit($std);357 }358 /**359 * Load fields for tag dest [E]360 * E|xNome|indIEDest|IE|ISUF|IM|email|361 * @param stdClass $std362 * @return void363 */364 protected function eEntity($std)365 {366 $this->stdDest = $std;367 $this->stdDest->CNPJ = null;368 $this->stdDest->CPF = null;369 $this->stdDest->idEstrangeiro = null;370 }371 /**372 * Create tag dest [E02], with CNPJ belongs to [E]373 * E02|CNPJ|374 * @param stdClass $std375 * @return void376 */377 protected function e02Entity($std)378 {379 $this->stdDest->CNPJ = $std->CNPJ;380 $this->buildEEntity();381 $this->stdDest = null;382 }383 /**384 * Create tag dest [E03], with CPF belongs to [E]385 * E03|CPF|386 * @param stdClass $std387 * @return void388 */389 protected function e03Entity($std)390 {391 $this->stdDest->CPF = $std->CPF;392 $this->buildEEntity();393 $this->stdDest = null;394 }395 /**396 * Create tag dest [E03a], with idEstrangeiro belongs to [E]397 * E03a|idEstrangeiro|398 * @param stdClass $std399 * @return void400 */401 protected function e03aEntity($std)402 {403 $this->stdDest->idEstrangeiro = !empty($std->idEstrangeiro) ? $std->idEstrangeiro : '';404 $this->buildEEntity();405 $this->stdDest = null;406 }407 /**408 * Create tag dest [E]409 * @return void410 */411 protected function buildEEntity()412 {413 $this->make->tagdest($this->stdDest);414 }415 /**416 * Create tag enderDest [E05]417 * E05|xLgr|nro|xCpl|xBairro|cMun|xMun|UF|CEP|cPais|xPais|fone|418 * @param stdClass $std419 * @return void420 */421 protected function e05Entity($std)422 {423 $this->make->tagenderDest($std);424 }425 /**426 * Load fields for tag retirada [F]427 * F|xLgr|nro|xCpl|xBairro|cMun|xMun|UF|CEP|cPais|xPais|fone|email|IE|428 * @param stdClass $std429 * @return void430 */431 protected function fEntity($std)432 {433 $this->stdRetirada = null;434 $this->stdRetirada = $std;435 $this->stdRetirada->CNPJ = null;436 $this->stdRetirada->CPF = null;437 $this->stdRetirada->xNome = null;438 }439 /**440 * Create tag retirada [F02], with CNPJ belongs to [F]441 * F02|CNPJ|442 * @param stdClass $std443 * @return void444 */445 protected function f02Entity($std)446 {447 $this->stdRetirada->CNPJ = $std->CNPJ;448 $this->buildFEntity();449 }450 /**451 * Create tag retirada [F02a], with CPF belongs to [F]452 * F02a|CPF|453 * @param stdClass $std454 * @return void455 */456 protected function f02aEntity($std)457 {458 $this->stdRetirada->CPF = $std->CPF;459 $this->buildFEntity();460 }461 462 /**463 * Create tag retirada [F02b], with xNome belongs to [F]464 * F02a|xNome|465 * @param stdClass $std466 * @return void467 */468 protected function f02bEntity($std)469 {470 $this->stdRetirada->xNome = $std->xNome;471 $this->buildFEntity();472 }473 /**474 * Create tag retirada [F]475 * @return void476 */477 protected function buildFEntity()478 {479 $this->make->tagretirada($this->stdRetirada);480 }481 /**482 * Load fields for tag entrega [G]483 * G|xLgr|nro|xCpl|xBairro|cMun|xMun|UF|CEP|cPais|xPais|fone|email|IE|484 * @param stdClass $std485 * @return void486 */487 protected function gEntity($std)488 {489 $this->stdEntrega = null;490 $this->stdEntrega = $std;491 $this->stdEntrega->CNPJ = null;492 $this->stdEntrega->CPF = null;493 $this->stdEntrega->xNome = null;494 }495 /**496 * Create tag entrega [G02], with CNPJ belongs to [G]497 * G02|CNPJ|498 * @param stdClass $std499 * @return void500 */501 protected function g02Entity($std)502 {503 $this->stdEntrega->CNPJ = $std->CNPJ;504 $this->buildGEntity();505 }506 /**507 * Create tag entrega [G02a], with CPF belongs to [G]508 * G02a|CPF|509 * @param stdClass $std510 * @return void511 */512 protected function g02aEntity($std)513 {514 $this->stdEntrega->CPF = $std->CPF;515 $this->buildGEntity();516 }517 518 /**519 * Create tag entrega [G02b], with xNome belongs to [G]520 * G02b|xNome|521 * @param stdClass $std522 * @return void523 */524 protected function g02bEntity($std)525 {526 $this->stdEntrega->xNome = $std->xNome;527 $this->buildGEntity();528 }529 530 /**531 * Create tag entrega [G]532 * @return void533 */534 protected function buildGEntity()535 {536 $this->make->tagentrega($this->stdEntrega);537 }538 /**539 * Create tag autXML [GA]540 * GA|541 * @param stdClass $std542 * @return void543 */544 protected function gaEntity($std)545 {546 //fake não faz nada547 $std->CNPJ = null;548 $std->CPF = null;549 $this->stdAutXML = $std;550 }551 /**552 * Create tag autXML with CNPJ [GA02], belongs to [GA]553 * GA02|CNPJ|554 * @param stdClass $std555 * @return void556 */557 protected function ga02Entity($std)558 {559 $this->stdAutXML->CNPJ = $std->CNPJ;560 $this->make->tagautXML($this->stdAutXML);561 $this->stdAutXML = null;562 }563 /**564 * Create tag autXML with CPF [GA03], belongs to GA565 * GA03|CPF|566 * @param stdClass $std567 * @return void568 */569 protected function ga03Entity($std)570 {571 $this->stdAutXML->CPF = $std->CPF;572 $this->make->tagautXML($this->stdAutXML);573 $this->stdAutXML = null;574 }575 /**576 * Create tag det/infAdProd [H]577 * H|item|infAdProd|578 * @param stdClass $std579 */580 protected function hEntity($std)581 {582 if (!empty($std->infAdProd)) {583 $this->make->taginfAdProd($std);584 }585 $this->item = (integer) $std->item;586 }587 /**588 * Create tag prod [I]589 * LOCAL590 * I|cProd|cEAN|xProd|NCM|cBenef|EXTIPI|CFOP|uCom|qCom|vUnCom|vProd|cEANTrib|uTrib|qTrib|vUnTrib|vFrete|vSeg|vDesc|vOutro|indTot|xPed|nItemPed|nFCI|591 * SEBRAE592 * I|cProd|cEAN|xProd|NCM|EXTIPI|CFOP|uCom|qCom|vUnCom|vProd|cEANTrib|uTrib|qTrib|vUnTrib|vFrete|vSeg|vDesc|vOutro|indTot|xPed|nItemPed|nFCI|593 * @param stdClass $std594 * @return void595 */596 protected function iEntity($std)597 {598 $std->item = $this->item;599 $this->make->tagprod($std);600 }601 /**602 * Create tag NVE [I05A]603 * I05A|NVE|604 * @param stdClass $std605 * @return void606 */607 protected function i05aEntity($std)608 {609 $std->item = $this->item;610 $this->make->tagNVE($std);611 }612 /**613 * Create tag CEST [I05C]614 * I05C|CEST|indEscala|CNPJFab|615 * SEBRAE616 * I05C|CEST|indEscala|CNPJFab|cBenef|617 * @param stdClass $std618 * @return void619 */620 protected function i05cEntity($std)621 {622 $std->item = $this->item;623 $this->make->tagCEST($std);624 }625 /**626 * Create tag DI [I18]627 * I18|nDI|dDI|xLocDesemb|UFDesemb|dDesemb|tpViaTransp|vAFRMM|tpIntermedio|CNPJ|UFTerceiro|cExportador|628 * @param stdClass $std629 * @return void630 */631 protected function i18Entity($std)632 {633 $std->item = $this->item;634 $this->make->tagDI($std);635 $this->nDI = $std->nDI;636 }637 /**638 * Create tag adi [I25], belongs to [I18]639 * I25|nAdicao|nSeqAdicC|cFabricante|vDescDI|nDraw|640 * @param stdClass $std641 * @return void642 */643 protected function i25Entity($std)644 {645 $std->item = $this->item;646 $std->nDI = $this->nDI;647 $this->make->tagadi($std);648 }649 /**650 * Load fields for tag detExport [I50]651 * I50|nDraw|652 * @param stdClass $std653 * @return void654 */655 protected function i50Entity($std)656 {657 $std->item = $this->item;658 $this->make->tagdetExport($std);659 }660 /**661 * Create tag detExport/exportInd [I52], belongs to [I50]662 * I52|nRE|chNFe|qExport|663 * @param stdClass $std664 * @return void665 */666 protected function i52Entity($std)667 {668 $std->item = $this->item;669 $this->make->tagdetExportInd($std);670 }671 /**672 * Create tag RASTRO [I80]673 * I80|nLote|qLote|dFab|dVal|cAgreg|674 * @param stdClass $std675 * @return void676 */677 protected function i80Entity($std)678 {679 $std->item = $this->item;680 $this->make->tagRastro($std);681 }682 /**683 * Create tag veicProd [JA]684 * JA|tpOp|chassi|cCor|xCor|pot|cilin|pesoL|pesoB|nSerie|tpComb|nMotor|CMT|dist|anoMod|anoFab|tpPint|tpVeic|espVeic|VIN|condVeic|cMod|cCorDENATRAN|lota|tpRest|685 * @param stdClass $std686 * @return void687 */688 protected function jaEntity($std)689 {690 $std->item = $this->item;691 $this->make->tagveicProd($std);692 }693 /**694 * Create tag med [K]695 * K|cProdANVISA|vPMC|xMotivoIsencao|696 * @param stdClass $std697 * @return void698 */699 protected function kEntity($std)700 {701 $std->item = $this->item;702 $std->nLote = !empty($std->nLote) ? $std->nLote : null;703 $std->qLote = !empty($std->qLote) ? $std->qLote : null;704 $std->dFab = !empty($std->dFab) ? $std->dFab : null;705 $std->dVal = !empty($std->dVal) ? $std->dVal : null;706 $std->cProdANVISA = !empty($std->cProdANVISA) ? $std->cProdANVISA : null;707 $std->xMotivoIsencao = !empty($std->xMotivoIsencao) ? $std->xMotivoIsencao : null;708 $this->make->tagmed($std);709 }710 /**711 * Create tag arma [L]712 * L|tpArma|nSerie|nCano|descr|713 * @param stdClass $std714 * @return void715 */716 protected function lEntity($std)717 {718 $std->item = $this->item;719 $this->make->tagarma($std);720 }721 /**722 * Load fields for tag comb [LA]723 * LA|cProdANP|descANP|pGLP|pGNn|pGNi|vPart|CODIF|qTemp|UFCons|724 * @param stdClass $std725 * @return void726 */727 protected function laEntity($std)728 {729 $std->item = $this->item;730 $this->stdComb = $std;731 }732 /**733 * Load fields for tag comb [LA07], belongs to [LA]734 * LA07|qBCProd|vAliqProd|vCIDE|735 * @param stdClass $std736 * @return void737 */738 protected function la07Entity($std)739 {740 $this->stdComb->qBCProd = $std->qBCProd;741 $this->stdComb->vAliqProd = $std->vAliqProd;742 $this->stdComb->vCIDE = $std->vCIDE;743 }744 /**745 * Load fields for tag encerrante [LA11]746 * LA11|nBico|nBomba|nTanque|vEncIni|vEncFin|747 * @param stdClass $std748 * @return void749 */750 protected function la11Entity($std)751 {752 $std->item = $this->item;753 $this->make->tagencerrante($std);754 }755 /**756 * Create tag comb [LA]757 * @return void758 */759 protected function buildLAEntity()760 {761 if (!empty($this->stdComb)) {762 $this->make->tagcomb($this->stdComb);763 }764 }765 /**766 * Create tag RECOPI [LB]767 * LB|nRECOPI|768 * @param stdClass $std769 * @return void770 */771 protected function lbEntity($std)772 {773 $std->item = $this->item;774 $this->make->tagRECOPI($std);775 }776 /**777 * Create tag imposto [M]778 * M|vTotTrib|779 * @param stdClass $std780 * @return void781 */782 protected function mEntity($std)783 {784 //create tag comb [LA]785 $this->buildLAEntity();786 $std->item = $this->item;787 $this->make->tagimposto($std);788 }789 /**790 * Carrega a tag ICMS [N]791 * N|792 * @param stdClass $std793 * @return void794 */795 protected function nEntity($std)796 {797 //fake não faz nada798 $field = null;799 }800 /**801 * Load fields for tag ICMS [N02]802 * N02|orig|CST|modBC|vBC|pICMS|vICMS|pFCP|vFCP|803 * @param stdClass $std804 * @return void805 */806 protected function n02Entity($std)807 {808 $this->buildNEntity($std);809 }810 /**811 * Load fields for tag ICMS [N03]812 * N03|orig|CST|modBC|vBC|pICMS|vICMS|vBCFCP|pFCP|vFCP|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCFCPST|pFCPST|vFCPST|813 * @param stdClass $std814 * @return void815 */816 protected function n03Entity($std)817 {818 $this->buildNEntity($std);819 }820 /**821 * Load fields for tag ICMS [N04]822 * N04|orig|CST|modBC|pRedBC|vBC|pICMS|vICMS|BCFCP|pFCP|vFCP|vICMSDeson|motDesICMS|823 * @param stdClass $std824 * @return void825 */826 protected function n04Entity($std)827 {828 $this->buildNEntity($std);829 }830 /**831 * Load fields for tag ICMS [N05]832 * N05|orig|CST|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCFCPST|pFCPST|vFCPST|vICMSDeson|motDesICMS|833 * @param stdClass $std834 * @return void835 */836 protected function n05Entity($std)837 {838 $this->buildNEntity($std);839 }840 /**841 * Load fields for tag ICMS [N06]842 * N06|orig|CST|vICMSDeson|motDesICMS|843 * @param stdClass $std844 * @return void845 */846 protected function n06Entity($std)847 {848 $this->buildNEntity($std);849 }850 /**851 * Load fields for tag ICMS [N07]852 * N07|orig|CST|modBC|pRedBC|vBC|pICMS|vICMSOp|pDif|vICMSDif|vICMS|vBCFCP|pFCP|vFCP|853 * @param stdClass $std854 * @return void855 */856 protected function n07Entity($std)857 {858 $this->buildNEntity($std);859 }860 /**861 * Load fields for tag ICMS [N08]862 * N08|orig|CST|vBCSTRet|pST|vICMSSTRet|vBCFCPSTRet|pFCPSTRet|vFCPSTRet|863 * @param stdClass $std864 * @return void865 */866 protected function n08Entity($std)867 {868 $this->buildNEntity($std);869 }870 /**871 * Load fields for tag ICMS [N09]872 * N09|orig|CST|modBC|pRedBC|vBC|pICMS|vICMS|vBCFCP|pFCP|vFCP|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCFCPST|pFCPST|vFCPST|vICMSDeson|motDesICMS|873 * @param stdClass $std874 * @return void875 */876 protected function n09Entity($std)877 {878 $this->buildNEntity($std);879 }880 /**881 * Load fields for tag ICMS [N10]882 * N10|orig|CST|modBC|vBC|pRedBC|pICMS|vICMS|vBCFCP|pFCP|vFCP|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCFCPST|pFCPST|vFCPST|vICMSDeson|motDesICMS|883 * @param stdClass $std884 * @return void885 */886 protected function n10Entity($std)887 {888 $this->buildNEntity($std);889 }890 /**891 * Create tag ICMS [N]892 * NOTE: adjusted for NT2016_002_v1.30893 * @param \stdClass $std894 * @return void895 */896 protected function buildNEntity($std)897 {898 $std->item = $this->item;899 $this->make->tagICMS($std);900 }901 /**902 * Create tag ICMSPart [N10a]903 * N10a|orig|CST|modBC|vBC|pRedBC|pICMS|vICMS|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|pBCOp|UFST|904 * @param stdClass $std905 * @return void906 */907 protected function n10aEntity($std)908 {909 $std->item = $this->item;910 $this->make->tagICMSPart($std);911 }912 /**913 * Create tag ICMSST [N10b]914 * N10b|orig|CST|vBCSTRet|vICMSSTRet|vBCSTDest|vICMSSTDest|vBCFCPSTRet|pFCPSTRet|vFCPSTRet|915 * @param stdClass $std916 * @return void917 */918 protected function n10bEntity($std)919 {920 $std->item = $this->item;921 $this->make->tagICMSST($std);922 }923 /**924 * Carrega e Create tag ICMSSN [N10c]925 * N10c|orig|CSOSN|pCredSN|vCredICMSSN|926 * @param stdClass $std927 * @return void928 */929 protected function n10cEntity($std)930 {931 $this->buildNSNEntity($std);932 }933 /**934 * Carrega e Create tag ICMSSN [N10d]935 * N10d|orig|CSOSN|936 * @param stdClass $std937 * @return void938 */939 protected function n10dEntity($std)940 {941 $this->buildNSNEntity($std);942 }943 /**944 * Carrega e Create tag ICMSSN [N10e]945 * N10e|orig|CSOSN|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCFCPST|pFCPST|vFCPST|pCredSN|vCredICMSSN|pCredSN|vCredICMSSN|946 * @param stdClass $std947 * @return void948 */949 protected function n10eEntity($std)950 {951 $this->buildNSNEntity($std);952 }953 /**954 * Carrega e Create tag ICMSSN [N10f]955 * N10f|orig|CSOSN|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCFCPST|pFCPST|vFCPST|956 * @param stdClass $std957 * @return void958 */959 protected function n10fEntity($std)960 {961 $this->buildNSNEntity($std);962 }963 /**964 * Carrega e Create tag ICMSSN [N10g]965 * N10g|orig|CSOSN|vBCSTRet|pST|vICMSSTRet|vBCFCPSTRet|pFCPSTRet|vFCPSTRet|966 * @param stdClass $std967 * @return void968 */969 protected function n10gEntity($std)970 {971 $this->buildNSNEntity($std);972 }973 /**974 * Carrega e Create tag ICMSSN [N10h]975 * N10h|orig|CSOSN|modBC|vBC|pRedBC|pICMS|vICMS|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCFCPST|pFCPST|vFCPST|pCredSN|vCredICMSSN|976 * @param stdClass $std977 * @return void978 */979 protected function n10hEntity($std)980 {981 $this->buildNSNEntity($std);982 }983 /**984 * Create tag ICMSSN [NS]985 * Nsn|orig|CSOSN|modBC|vBC|pRedBC|pICMS|vICMS|pCredSN|vCredICMSSN|modBCST|pMVAST|pRedBCST|vBCST|pICMSST|vICMSST|vBCSTRet|vICMSSTRet|vBCFCPST|pFCPST|vFCPST|986 * @param stdClass $std987 * @return void988 */989 protected function buildNSNEntity($std)990 {991 $std->item = $this->item;992 $this->make->tagICMSSN($std);993 }994 /**995 * Load field fot tag ICMSUFDest [NA]996 * NA|vBCUFDest|pFCPUFDest|pICMSUFDest|pICMSInter|pICMSInterPart|vFCPUFDest|vICMSUFDest|vICMSFRemet|997 * @param stdClass $std998 * @return void999 */1000 protected function naEntity($std)1001 {1002 $this->buildNAEntity($std);1003 }1004 /**1005 * Create tag ICMSUFDest [NA]1006 * @param stdClass $std1007 * @return void1008 */1009 protected function buildNAEntity($std)1010 {1011 $std->item = $this->item;1012 $this->make->tagICMSUFDest($std);1013 }1014 /**1015 * Load fields for tag IPI [O]1016 * O|clEnq|CNPJProd|cSelo|qSelo|cEnq|1017 * @param stdClass $std1018 * @return void1019 */1020 protected function oEntity($std)1021 {1022 $std->item = $this->item;1023 $this->stdIPI = $std;1024 $this->stdIPI->CST = null;1025 $this->stdIPI->vIPI = null;1026 $this->stdIPI->vBC = null;1027 $this->stdIPI->pIPI = null;1028 $this->stdIPI->qUnid = null;1029 $this->stdIPI->vUnid = null;1030 }1031 /**1032 * Load fields for tag IPI [O07], belongs to [O]1033 * O07|CST|vIPI|1034 * @param stdClass $std1035 * @return void1036 */1037 protected function o07Entity($std)1038 {1039 $this->stdIPI->CST = $std->CST;1040 $this->stdIPI->vIPI = $std->vIPI;1041 }1042 /**1043 * Load fields for tag IPI [O08], belongs to [O]1044 * O08|CST|1045 * @param stdClass $std1046 * @return void1047 */1048 protected function o08Entity($std)1049 {1050 $this->stdIPI->CST = $std->CST;1051 $this->buildOEntity();1052 }1053 /**1054 * Load fields for tag IPI [O10], belongs to [O]1055 * O10|vBC|pIPI|1056 * @param stdClass $std1057 * @return void1058 */1059 protected function o10Entity($std)1060 {1061 $this->stdIPI->vBC = $std->vBC;1062 $this->stdIPI->pIPI = $std->pIPI;1063 $this->buildOEntity();1064 }1065 /**1066 * Load fields for tag IPI [O11], belongs to [O]1067 * O11|qUnid|vUnid|1068 * @param stdClass $std1069 * @return void1070 */1071 protected function o11Entity($std)1072 {1073 $this->stdIPI->qUnid = $std->qUnid;1074 $this->stdIPI->vUnid = $std->vUnid;1075 $this->buildOEntity();1076 }1077 /**1078 * Create tag IPI [O]1079 * Oxx|cst|clEnq|cnpjProd|cSelo|qSelo|cEnq|vBC|pIPI|qUnid|vUnid|vIPI|1080 * @return void1081 */1082 protected function buildOEntity()1083 {1084 $this->make->tagIPI($this->stdIPI);1085 }1086 /**1087 * Create tag II [P]1088 * P|vBC|vDespAdu|vII|vIOF|1089 * @param stdClass $std1090 * @return void1091 */1092 protected function pEntity($std)1093 {1094 $std->item = $this->item;1095 $this->make->tagII($std);1096 }1097 /**1098 * Load fields for tag PIS [Q]1099 * Q|1100 * @param stdClass $std1101 * @return void1102 */1103 protected function qEntity($std)1104 {1105 //carrega numero do item1106 $std->item = $this->item;1107 $this->stdPIS = $std;1108 $this->stdPIS->vBC = null;1109 $this->stdPIS->pPIS = null;1110 $this->stdPIS->vPIS = null;1111 $this->stdPIS->qBCProd = null;1112 $this->stdPIS->vAliqProd = null;1113 }1114 /**1115 * Load fields for tag PIS [Q02], belongs to [Q]1116 * Q02|CST|vBC|pPIS|vPIS|1117 * @param stdClass $std1118 * @return void1119 */1120 protected function q02Entity($std)1121 {1122 $this->stdPIS->CST = $std->CST;1123 $this->stdPIS->vBC = $std->vBC;1124 $this->stdPIS->pPIS = $std->pPIS;1125 $this->stdPIS->vPIS = $std->vPIS;1126 $this->buildQEntity();1127 }1128 /**1129 * Load fields for tag PIS [Q03], belongs to [Q]1130 * Q03|CST|qBCProd|vAliqProd|vPIS|1131 * @param stdClass $std1132 * @return void1133 */1134 protected function q03Entity($std)1135 {1136 $this->stdPIS->CST = $std->CST;1137 $this->stdPIS->vPIS = $std->vPIS;1138 $this->stdPIS->qBCProd = $std->qBCProd;1139 $this->stdPIS->vAliqProd = $std->vAliqProd;1140 $this->buildQEntity();1141 }1142 /**1143 * Load fields for tag PIS [Q04], belongs to [Q]1144 * Q04|CST|1145 * @param stdClass $std1146 * @return void1147 */1148 protected function q04Entity($std)1149 {1150 $this->stdPIS->CST = $std->CST;1151 $this->buildQEntity();1152 }1153 /**1154 * Load fields for tag PIS [Q05], belongs to [Q]1155 * Q05|CST|vPIS|1156 * @param stdClass $std1157 * @return void1158 */1159 protected function q05Entity($std)1160 {1161 $this->stdPIS->CST = $std->CST;1162 $this->stdPIS->vPIS = $std->vPIS;1163 $this->buildQEntity();1164 }1165 /**1166 * Load fields for tag PIS [Q07], belongs to [Q]1167 * Q07|vBC|pPIS|1168 * @param stdClass $std1169 * @return void1170 */1171 protected function q07Entity($std)1172 {1173 $this->stdPIS->vBC = $std->vBC;1174 $this->stdPIS->pPIS = $std->pPIS;1175 $this->buildQEntity();1176 }1177 /**1178 * Load fields for tag PIS [Q10], belongs to [Q]1179 * Q10|qBCProd|vAliqProd|1180 * @param stdClass $std1181 * @return void1182 */1183 protected function q10Entity($std)1184 {1185 $this->stdPIS->qBCProd = $std->qBCProd;1186 $this->stdPIS->vAliqProd = $std->vAliqProd;1187 $this->buildQEntity();1188 }1189 /**1190 * Create tag PIS [Q]1191 * Qxx|CST|vBC|pPIS|vPIS|qBCProd|vAliqProd|1192 * @return void1193 */1194 protected function buildQEntity()1195 {1196 $this->make->tagPIS($this->stdPIS);1197 }1198 /**1199 * Load fields for tag PISST [R]1200 * R|vPIS|1201 * @param stdClass $std1202 * @return void1203 */1204 protected function rEntity($std)1205 {1206 //carrega numero do item1207 $std->item = $this->item;1208 $this->stdPISST = $std;1209 $this->stdPISST->vBC = null;1210 $this->stdPISST->pPIS = null;1211 $this->stdPISST->vPIS = null;1212 $this->stdPISST->qBCProd = null;1213 $this->stdPISST->vAliqProd = null;1214 }1215 /**1216 * Load fields for tag PISST [R02], belongs to [R]1217 * R02|vBC|pPIS|1218 * @param stdClass $std1219 * @return void1220 */1221 protected function r02Entity($std)1222 {1223 $this->stdPISST->vBC = $std->vBC;1224 $this->stdPISST->pPIS = $std->pPIS;1225 $this->buildREntity();1226 }1227 /**1228 * Load fields for tag PISST [R04], belongs to [R]1229 * R04|qBCProd|vAliqProd|vPIS|1230 * @param stdClass $std1231 * @return void1232 */1233 protected function r04Entity($std)1234 {1235 $this->stdPISST->qBCProd = $std->qBCProd;1236 $this->stdPISST->vAliqProd = $std->vAliqProd;1237 $this->stdPISST->vPIS = $std->vPIS;1238 $this->buildREntity();1239 }1240 /**1241 * Create tag PISST1242 * Rxx|vBC|pPIS|qBCProd|vAliqProd|vPIS|1243 * @return void1244 */1245 protected function buildREntity()1246 {1247 $this->make->tagPISST($this->stdPISST);1248 }1249 /**1250 * Load fields for tag COFINS [S]1251 * S|1252 * @param stdClass $std1253 * @return void1254 */1255 protected function sEntity($std)1256 {1257 //carrega numero do item1258 $std->item = $this->item;1259 $this->stdCOFINS = $std;1260 $this->stdCOFINS->vBC = null;1261 $this->stdCOFINS->pCOFINS = null;1262 $this->stdCOFINS->vCOFINS = null;1263 $this->stdCOFINS->qBCProd = null;1264 $this->stdCOFINS->vAliqProd = null;1265 }1266 /**1267 * Load fields for tag COFINS [S02], belongs to [S]1268 * S02|CST|vBC|pCOFINS|vCOFINS|1269 * @param stdClass $std1270 * @return void1271 */1272 protected function s02Entity($std)1273 {1274 $this->stdCOFINS->CST = $std->CST;1275 $this->stdCOFINS->vBC = $std->vBC;1276 $this->stdCOFINS->pCOFINS = $std->pCOFINS;1277 $this->stdCOFINS->vCOFINS = $std->vCOFINS;1278 $this->buildSEntity();1279 }1280 /**1281 * Load fields for tag COFINS [S03], belongs to [S]1282 * S03|CST|qBCProd|vAliqProd|vCOFINS|1283 * @param stdClass $std1284 * @return void1285 */1286 protected function s03Entity($std)1287 {1288 $this->stdCOFINS->CST = $std->CST;1289 $this->stdCOFINS->qBCProd = $std->qBCProd;1290 $this->stdCOFINS->vAliqProd = $std->vAliqProd;1291 $this->stdCOFINS->vCOFINS = $std->vCOFINS;1292 $this->buildSEntity();1293 }1294 /**1295 * Load fields for tag COFINS [S04], belongs to [S]1296 * S04|CST|1297 * @param stdClass $std1298 * @return void1299 */1300 protected function s04Entity($std)1301 {1302 $this->stdCOFINS->CST = $std->CST;1303 $this->buildSEntity();1304 }1305 /**1306 * Load fields for tag COFINS [S05], belongs to [S]1307 * S05|CST|vCOFINS|1308 * @param stdClass $std1309 * @return void1310 */1311 protected function s05Entity($std)1312 {1313 $this->stdCOFINS->CST = $std->CST;1314 $this->stdCOFINS->vCOFINS = $std->vCOFINS;1315 }1316 /**1317 * Load fields for tag COFINS [S07], belongs to [S]1318 * S07|vBC|pCOFINS|1319 * @param stdClass $std1320 * @return void1321 */1322 protected function s07Entity($std)1323 {1324 $this->stdCOFINS->vBC = $std->vBC;1325 $this->stdCOFINS->pCOFINS = $std->pCOFINS;1326 $this->buildSEntity();1327 }1328 /**1329 * Load fields for tag COFINS [S09], belongs to [S]1330 * S09|qBCProd|vAliqProd|1331 * @param stdClass $std1332 * @return void1333 */1334 protected function s09Entity($std)1335 {1336 $this->stdCOFINS->qBCProd = $std->qBCProd;1337 $this->stdCOFINS->vAliqProd = $std->vAliqProd;1338 $this->buildSEntity();1339 }1340 /**1341 * Create tag COFINS [S]1342 * Sxx|CST|vBC|pCOFINS|vCOFINS|qBCProd|vAliqProd|1343 * @return void1344 */1345 protected function buildSEntity()1346 {1347 $this->make->tagCOFINS($this->stdCOFINS);1348 }1349 /**1350 * Load fields for tag COFINSST [T]1351 * T|vCOFINS|1352 * @param stdClass $std1353 * @return void1354 */1355 protected function tEntity($std)1356 {1357 //carrega numero do item1358 $std->item = $this->item;1359 $this->stdCOFINSST = $std;1360 $this->stdCOFINSST->vBC = null;1361 $this->stdCOFINSST->pCOFINS = null;1362 $this->stdCOFINSST->vCOFINS = null;1363 $this->stdCOFINSST->qBCProd = null;1364 $this->stdCOFINSST->vAliqProd = null;1365 }1366 /**1367 * Load fields for tag COFINSST [T02], belongs to [T]1368 * T02|vBC|pCOFINS|1369 * @param stdClass $std1370 * @return void1371 */1372 protected function t02Entity($std)1373 {1374 $this->stdCOFINSST->vBC = $std->vBC;1375 $this->stdCOFINSST->pCOFINS = $std->pCOFINS;1376 $this->buildTEntity();1377 }1378 /**1379 * Load fields for tag COFINSST [T04], belongs to [T]1380 * T04|qBCProd|vAliqProd|1381 * @param stdClass $std1382 * @return void1383 */1384 protected function t04Entity($std)1385 {1386 $this->stdCOFINSST->qBCProd = $std->qBCProd;1387 $this->stdCOFINSST->vAliqProd = $std->vAliqProd;1388 $this->buildTEntity();1389 }1390 /**1391 * Create tag COFINSST [T]1392 * Txx|vBC|pCOFINS|qBCProd|vAliqProd|vCOFINS|1393 * @return void1394 */1395 protected function buildTEntity()1396 {1397 $this->stdCOFINSST->item = $this->item;1398 $this->make->tagCOFINSST($this->stdCOFINSST);1399 }1400 /**1401 * Create tag ISSQN [U]1402 * U|vBC|vAliq|vISSQN|cMunFG|cListServ|vDeducao|vOutro|vDescIncond1403 * |vDescCond|vISSRet|indISS|cServico|cMun|cPais|nProcesso|indIncentivo|1404 * @param stdClass $std1405 * @return void1406 */1407 protected function uEntity($std)1408 {1409 $std->item = $this->item;1410 $this->make->tagISSQN($std);1411 }1412 /**1413 * Create tag tagimpostoDevol [UA]1414 * UA|pDevol|vIPIDevol|1415 * @param stdClass $std1416 * @return void1417 */1418 protected function uaEntity($std)1419 {1420 $std->item = $this->item;1421 $this->make->tagimpostoDevol($std);1422 }1423 /**1424 * Linha W [W]1425 * W|1426 * @param stdClass $std1427 * @return void1428 */1429 protected function wEntity($std)1430 {1431 //fake não faz nada1432 $field = null;1433 }1434 /**1435 * Cria tag ICMSTot [W02], belongs to [W]1436 * W02|vBC|vICMS|vICMSDeson|vFCP|vBCST|vST|vFCPST|vFCPSTRet|vProd|vFrete|vSeg|vDesc|vII|vIPI|vIPIDevol|vPIS|vCOFINS|vOutro|vNF|vTotTrib|vFCPUFDest|vICMSUFDest|vICMSUFRemet|1437 * @param stdClass $std1438 * @return void1439 */1440 protected function w02Entity($std)1441 {1442 $this->make->tagICMSTot($std);1443 }1444 protected function w04cEntity($std)1445 {1446 }1447 protected function w04eEntity($std)1448 {1449 }1450 protected function w04gEntity($std)1451 {1452 }1453 /**1454 * Create tag ISSQNTot [W17], belongs to [W]1455 * W17|vServ|vBC|vISS|vPIS|vCOFINS|dCompet|vDeducao|vOutro|vDescIncond1456 * |vDescCond|vISSRet|cRegTrib|1457 * @param stdClass $std1458 * @return void1459 */1460 protected function w17Entity($std)1461 {1462 $this->make->tagISSQNTot($std);1463 }1464 /**1465 * Create tag retTrib [W23], belongs to [W]1466 * W23|vRetPIS|vRetCOFINS|vRetCSLL|vBCIRRF|vIRRF|vBCRetPrev|vRetPrev|1467 * @param stdClass $std1468 * @return void1469 */1470 protected function w23Entity($std)1471 {1472 $this->make->tagretTrib($std);1473 }1474 /**1475 * Create tag transp [X]1476 * X|modFrete|1477 * @param stdClass $std1478 * @return void1479 */1480 protected function xEntity($std)1481 {1482 $this->make->tagtransp($std);1483 }1484 /**1485 * Load fields for tag transporta [X03], belongs to [X]1486 * X03|xNome|IE|xEnder|xMun|UF|1487 * @param stdClass $std1488 * @return void1489 */1490 protected function x03Entity($std)1491 {1492 $this->stdTransporta = $std;1493 }1494 /**1495 * Load fields for tag transporta [X04], with CNPJ, belonsgs to [X03]1496 * X04|CNPJ|1497 * @param stdClass $std1498 * @return void1499 */1500 protected function x04Entity($std)1501 {1502 $this->stdTransporta->CNPJ = $std->CNPJ;1503 $this->stdTransporta->CPF = null;1504 $this->make->tagtransporta($this->stdTransporta);1505 $this->stdTransporta = null;1506 }1507 /**1508 * Load fields for tag transporta [X05], with CPF, belonsgs to [X03]1509 * X05|CPF|1510 * @param stdClass $std1511 * @return void1512 */1513 protected function x05Entity($std)1514 {1515 $this->stdTransporta->CPF = $std->CPF;1516 $this->stdTransporta->CNPJ = null;1517 $this->make->tagtransporta($this->stdTransporta);1518 $this->stdTransporta = null;1519 }1520 /**1521 * Load fields for tag retTransp [X11], belongs to [X]1522 * X11|vServ|vBCRet|pICMSRet|vICMSRet|CFOP|cMunFG|1523 * @param stdClass $std1524 * @return void1525 */1526 protected function x11Entity($std)1527 {1528 $this->make->tagretTransp($std);1529 }1530 /**1531 * Create tag veicTransp [X18], belongs to [X]1532 * X18|placa|UF|RNTC|1533 * @param stdClass $std1534 * @return void1535 */1536 protected function x18Entity($std)1537 {1538 $this->make->tagveicTransp($std);1539 }1540 /**1541 * Create tag reboque [X22], belogns to [X]1542 * X22|placa|UF|RNTC|1543 * @param stdClass $std1544 * @return void1545 */1546 protected function x22Entity($std)1547 {1548 $this->make->tagreboque($std);1549 }1550 /**1551 * Create tag vagao [X25a], belogns to [X01]1552 * X25a|vagao|1553 * @param stdClass $std1554 * @return void1555 */1556 protected function x25aEntity($std)1557 {1558 $this->make->tagvagao($std);1559 }1560 /**1561 * Create tag balsa [X25b], belogns to [X01]1562 * X25b|balsa|1563 * @param stdClass $std1564 * @return void1565 */1566 protected function x25bEntity($std)1567 {1568 $this->make->tagbalsa($std);1569 }1570 /**1571 * Create tag vol [X26], belongs to [X]1572 * X26|qVol|esp|marca|nVol|pesoL|pesoB|1573 * @param stdClass $std1574 * @return void1575 */1576 protected function x26Entity($std)1577 {1578 $this->volId += 1;1579 $std->item = $this->volId;1580 $this->make->tagvol($std);1581 }1582 /**1583 * Create tag lacre [X33], belongs to [X]1584 * X33|nLacre|1585 * @param stdClass $std1586 * @return void1587 */1588 protected function x33Entity($std)1589 {1590 $std->item = $this->volId;1591 $this->make->taglacres($std);1592 }1593 /**1594 * Create tag vol1595 * @param stdClass $std1596 * @return void1597 */1598 protected function buildVolEntity($std)1599 {1600 $this->make->tagvol($std);1601 }1602 /**1603 * yEntity [Y]1604 *1605 * LOCAL1606 * Y|vTroco|1607 * @param stdClass $std1608 * @return void1609 */1610 protected function yEntity($std)1611 {1612 if ($this->baselayout !== 'SEBRAE') {1613 $this->make->tagpag($std);1614 }1615 }1616 /**1617 * Create tag fat [Y02]1618 * Y02|nFat|vOrig|vDesc|vLiq|1619 * @param stdClass $std1620 * @return void1621 */1622 protected function y02Entity($std)1623 {1624 $this->make->tagfat($std);1625 }1626 /**1627 * Create tag dup [Y07]1628 * Y07|nDup|dVenc|vDup|1629 * @param stdClass $std1630 * @return void1631 */1632 protected function y07Entity($std)1633 {1634 $this->make->tagdup($std);1635 }1636 /**1637 * Creates tag detPag and card [YA]1638 * YA|tPag|vPag|CNPJ|tBand|cAut|tpIntegra|1639 * SEBRAE1640 * YA|troco|1641 * @param stdClass $std1642 * @return void1643 */1644 protected function yaEntity($std)1645 {1646 if ($this->baselayout === 'SEBRAE') {1647 $this->make->tagpag($std);1648 } else {1649 $this->make->tagdetPag($std);1650 }1651 }1652 /**1653 * Creates tag detPag and card [YA]1654 * SEBRAE1655 * YA01|indPag|tPag|vPag|",1656 * @param stdClass $std1657 */1658 protected function ya01Entity($std)1659 {1660 $this->make->tagdetPag($std);1661 }1662 /**1663 * Create a tag infAdic [Z]1664 * Z|infAdFisco|infCpl|1665 * @param stdClass $std1666 * @return void1667 */1668 protected function zEntity($std)1669 {1670 $this->make->taginfAdic($std);1671 }1672 /**1673 * Create tag obsCont [Z04]1674 * Z04|xCampo|xTexto|1675 * @param stdClass $std1676 * @return void1677 */1678 protected function z04Entity($std)1679 {1680 $this->make->tagobsCont($std);1681 }1682 /**1683 * Create tag obsFisco [Z07]1684 * Z07|xCampo|xTexto|1685 * @param stdClass $std1686 * @return void1687 */1688 protected function z07Entity($std)1689 {1690 $this->make->tagobsFisco($std);1691 }1692 /**1693 * Create tag procRef [Z10]1694 * Z10|nProc|indProc|1695 * @param stdClass $std1696 * @return void1697 */1698 protected function z10Entity($std)1699 {1700 $this->make->tagprocRef($std);1701 }1702 /**1703 * Create tag exporta [ZA]1704 * ZA|UFSaidaPais|xLocExporta|xLocDespacho|1705 * @param stdClass $std1706 * @return void1707 */1708 protected function zaEntity($std)1709 {1710 $this->make->tagexporta($std);1711 }1712 /**1713 * Create tag compra [ZB]1714 * ZB|xNEmp|xPed|xCont|1715 * @param stdClass $std1716 * @return void1717 */1718 protected function zbEntity($std)1719 {1720 $this->make->tagcompra($std);1721 }1722 /**1723 * Create tag cana [ZC]1724 * ZC|safra|ref|qTotMes|qTotAnt|qTotGer|vFor|vTotDed|vLiqFor|1725 * @param stdClass $std1726 * @return void1727 */1728 protected function zcEntity($std)1729 {1730 $this->make->tagcana($std);1731 }1732 /**1733 * Create tag forDia [ZC04]1734 * ZC04|dia|qtde|1735 * @param stdClass $std1736 * @return void1737 */1738 protected function zc04Entity($std)1739 {1740 $this->make->tagforDia($std);1741 }1742 /**1743 * Create tag deduc [ZC10]1744 * ZC10|xDed|vDed|1745 * @param stdClass $std1746 * @return void1747 */1748 protected function zc10Entity($std)1749 {1750 $this->make->tagdeduc($std);1751 }1752 1753 /**1754 * Create tag infRespTec [ZD01]1755 * ZD|CNPJ|xContato|email|fone|CSRTidCSRT|1756 * @param stdClass $std1757 * @return void1758 */1759 protected function zdEntity($std)1760 {1761 $this->make->taginfRespTec($std);1762 }1763 /**1764 * Create tag infNFeSupl com o qrCode para impressão da DANFCE [ZX01]1765 * ZX01|qrcode|urlChave|1766 * @param stdClass $std1767 * @return void1768 */1769 protected function zx01Entity($std)1770 {1771 $this->make->taginfNFeSupl($std);1772 }1773}...

Full Screen

Full Screen

serialization_objects_013.phpt

Source:serialization_objects_013.phpt Github

copy

Full Screen

...28 $uobj->c = "obj->c.changed";29 var_dump($uobj); 30}31echo "\n\n--- a refs b:\n";32$obj = new stdClass;33$obj->a = &$obj->b;34$obj->b = 1;35$obj->c = 1;36check($obj);37echo "\n\n--- a refs c:\n";38$obj = new stdClass;39$obj->a = &$obj->c;40$obj->b = 1;41$obj->c = 1;42check($obj);43echo "\n\n--- b refs a:\n";44$obj = new stdClass;45$obj->a = 1;46$obj->b = &$obj->a;47$obj->c = 1;48check($obj);49echo "\n\n--- b refs c:\n";50$obj = new stdClass;51$obj->a = 1;52$obj->b = &$obj->c;53$obj->c = 1;54check($obj);55echo "\n\n--- c refs a:\n";56$obj = new stdClass;57$obj->a = 1;58$obj->b = 1;59$obj->c = &$obj->a;60check($obj);61echo "\n\n--- c refs b:\n";62$obj = new stdClass;63$obj->a = 1;64$obj->b = 1;65$obj->c = &$obj->b;66check($obj);67echo "\n\n--- a,b refs c:\n";68$obj = new stdClass;69$obj->a = &$obj->c;70$obj->b = &$obj->c;71$obj->c = 1;72check($obj);73echo "\n\n--- a,c refs b:\n";74$obj = new stdClass;75$obj->a = &$obj->b;76$obj->b = 1;77$obj->c = &$obj->b;78check($obj);79echo "\n\n--- b,c refs a:\n";80$obj = new stdClass;81$obj->a = 1;82$obj->b = &$obj->a;83$obj->c = &$obj->a;84check($obj);85echo "Done";86?>87--EXPECTF--88--- a refs b:89object(stdClass)#%d (3) {90 ["b"]=>91 &int(1)92 ["a"]=>93 &int(1)94 ["c"]=>95 int(1)96}97string(55) "O:8:"stdClass":3:{s:1:"b";i:1;s:1:"a";R:2;s:1:"c";i:1;}"98object(stdClass)#%d (3) {99 ["b"]=>100 &int(1)101 ["a"]=>102 &int(1)103 ["c"]=>104 int(1)105}106object(stdClass)#%d (3) {107 ["b"]=>108 &string(14) "obj->a.changed"109 ["a"]=>110 &string(14) "obj->a.changed"111 ["c"]=>112 int(1)113}114object(stdClass)#%d (3) {115 ["b"]=>116 &string(14) "obj->b.changed"117 ["a"]=>118 &string(14) "obj->b.changed"119 ["c"]=>120 int(1)121}122object(stdClass)#%d (3) {123 ["b"]=>124 &string(14) "obj->b.changed"125 ["a"]=>126 &string(14) "obj->b.changed"127 ["c"]=>128 string(14) "obj->c.changed"129}130--- a refs c:131object(stdClass)#%d (3) {132 ["c"]=>133 &int(1)134 ["a"]=>135 &int(1)136 ["b"]=>137 int(1)138}139string(55) "O:8:"stdClass":3:{s:1:"c";i:1;s:1:"a";R:2;s:1:"b";i:1;}"140object(stdClass)#%d (3) {141 ["c"]=>142 &int(1)143 ["a"]=>144 &int(1)145 ["b"]=>146 int(1)147}148object(stdClass)#%d (3) {149 ["c"]=>150 &string(14) "obj->a.changed"151 ["a"]=>152 &string(14) "obj->a.changed"153 ["b"]=>154 int(1)155}156object(stdClass)#%d (3) {157 ["c"]=>158 &string(14) "obj->a.changed"159 ["a"]=>160 &string(14) "obj->a.changed"161 ["b"]=>162 string(14) "obj->b.changed"163}164object(stdClass)#%d (3) {165 ["c"]=>166 &string(14) "obj->c.changed"167 ["a"]=>168 &string(14) "obj->c.changed"169 ["b"]=>170 string(14) "obj->b.changed"171}172--- b refs a:173object(stdClass)#%d (3) {174 ["a"]=>175 &int(1)176 ["b"]=>177 &int(1)178 ["c"]=>179 int(1)180}181string(55) "O:8:"stdClass":3:{s:1:"a";i:1;s:1:"b";R:2;s:1:"c";i:1;}"182object(stdClass)#%d (3) {183 ["a"]=>184 &int(1)185 ["b"]=>186 &int(1)187 ["c"]=>188 int(1)189}190object(stdClass)#%d (3) {191 ["a"]=>192 &string(14) "obj->a.changed"193 ["b"]=>194 &string(14) "obj->a.changed"195 ["c"]=>196 int(1)197}198object(stdClass)#%d (3) {199 ["a"]=>200 &string(14) "obj->b.changed"201 ["b"]=>202 &string(14) "obj->b.changed"203 ["c"]=>204 int(1)205}206object(stdClass)#%d (3) {207 ["a"]=>208 &string(14) "obj->b.changed"209 ["b"]=>210 &string(14) "obj->b.changed"211 ["c"]=>212 string(14) "obj->c.changed"213}214--- b refs c:215object(stdClass)#%d (3) {216 ["a"]=>217 int(1)218 ["c"]=>219 &int(1)220 ["b"]=>221 &int(1)222}223string(55) "O:8:"stdClass":3:{s:1:"a";i:1;s:1:"c";i:1;s:1:"b";R:3;}"224object(stdClass)#%d (3) {225 ["a"]=>226 int(1)227 ["c"]=>228 &int(1)229 ["b"]=>230 &int(1)231}232object(stdClass)#%d (3) {233 ["a"]=>234 string(14) "obj->a.changed"235 ["c"]=>236 &int(1)237 ["b"]=>238 &int(1)239}240object(stdClass)#%d (3) {241 ["a"]=>242 string(14) "obj->a.changed"243 ["c"]=>244 &string(14) "obj->b.changed"245 ["b"]=>246 &string(14) "obj->b.changed"247}248object(stdClass)#%d (3) {249 ["a"]=>250 string(14) "obj->a.changed"251 ["c"]=>252 &string(14) "obj->c.changed"253 ["b"]=>254 &string(14) "obj->c.changed"255}256--- c refs a:257object(stdClass)#%d (3) {258 ["a"]=>259 &int(1)260 ["b"]=>261 int(1)262 ["c"]=>263 &int(1)264}265string(55) "O:8:"stdClass":3:{s:1:"a";i:1;s:1:"b";i:1;s:1:"c";R:2;}"266object(stdClass)#%d (3) {267 ["a"]=>268 &int(1)269 ["b"]=>270 int(1)271 ["c"]=>272 &int(1)273}274object(stdClass)#%d (3) {275 ["a"]=>276 &string(14) "obj->a.changed"277 ["b"]=>278 int(1)279 ["c"]=>280 &string(14) "obj->a.changed"281}282object(stdClass)#%d (3) {283 ["a"]=>284 &string(14) "obj->a.changed"285 ["b"]=>286 string(14) "obj->b.changed"287 ["c"]=>288 &string(14) "obj->a.changed"289}290object(stdClass)#%d (3) {291 ["a"]=>292 &string(14) "obj->c.changed"293 ["b"]=>294 string(14) "obj->b.changed"295 ["c"]=>296 &string(14) "obj->c.changed"297}298--- c refs b:299object(stdClass)#%d (3) {300 ["a"]=>301 int(1)302 ["b"]=>303 &int(1)304 ["c"]=>305 &int(1)306}307string(55) "O:8:"stdClass":3:{s:1:"a";i:1;s:1:"b";i:1;s:1:"c";R:3;}"308object(stdClass)#%d (3) {309 ["a"]=>310 int(1)311 ["b"]=>312 &int(1)313 ["c"]=>314 &int(1)315}316object(stdClass)#%d (3) {317 ["a"]=>318 string(14) "obj->a.changed"319 ["b"]=>320 &int(1)321 ["c"]=>322 &int(1)323}324object(stdClass)#%d (3) {325 ["a"]=>326 string(14) "obj->a.changed"327 ["b"]=>328 &string(14) "obj->b.changed"329 ["c"]=>330 &string(14) "obj->b.changed"331}332object(stdClass)#%d (3) {333 ["a"]=>334 string(14) "obj->a.changed"335 ["b"]=>336 &string(14) "obj->c.changed"337 ["c"]=>338 &string(14) "obj->c.changed"339}340--- a,b refs c:341object(stdClass)#%d (3) {342 ["c"]=>343 &int(1)344 ["a"]=>345 &int(1)346 ["b"]=>347 &int(1)348}349string(55) "O:8:"stdClass":3:{s:1:"c";i:1;s:1:"a";R:2;s:1:"b";R:2;}"350object(stdClass)#%d (3) {351 ["c"]=>352 &int(1)353 ["a"]=>354 &int(1)355 ["b"]=>356 &int(1)357}358object(stdClass)#%d (3) {359 ["c"]=>360 &string(14) "obj->a.changed"361 ["a"]=>362 &string(14) "obj->a.changed"363 ["b"]=>364 &string(14) "obj->a.changed"365}366object(stdClass)#%d (3) {367 ["c"]=>368 &string(14) "obj->b.changed"369 ["a"]=>370 &string(14) "obj->b.changed"371 ["b"]=>372 &string(14) "obj->b.changed"373}374object(stdClass)#%d (3) {375 ["c"]=>376 &string(14) "obj->c.changed"377 ["a"]=>378 &string(14) "obj->c.changed"379 ["b"]=>380 &string(14) "obj->c.changed"381}382--- a,c refs b:383object(stdClass)#%d (3) {384 ["b"]=>385 &int(1)386 ["a"]=>387 &int(1)388 ["c"]=>389 &int(1)390}391string(55) "O:8:"stdClass":3:{s:1:"b";i:1;s:1:"a";R:2;s:1:"c";R:2;}"392object(stdClass)#%d (3) {393 ["b"]=>394 &int(1)395 ["a"]=>396 &int(1)397 ["c"]=>398 &int(1)399}400object(stdClass)#%d (3) {401 ["b"]=>402 &string(14) "obj->a.changed"403 ["a"]=>404 &string(14) "obj->a.changed"405 ["c"]=>406 &string(14) "obj->a.changed"407}408object(stdClass)#%d (3) {409 ["b"]=>410 &string(14) "obj->b.changed"411 ["a"]=>412 &string(14) "obj->b.changed"413 ["c"]=>414 &string(14) "obj->b.changed"415}416object(stdClass)#%d (3) {417 ["b"]=>418 &string(14) "obj->c.changed"419 ["a"]=>420 &string(14) "obj->c.changed"421 ["c"]=>422 &string(14) "obj->c.changed"423}424--- b,c refs a:425object(stdClass)#%d (3) {426 ["a"]=>427 &int(1)428 ["b"]=>429 &int(1)430 ["c"]=>431 &int(1)432}433string(55) "O:8:"stdClass":3:{s:1:"a";i:1;s:1:"b";R:2;s:1:"c";R:2;}"434object(stdClass)#%d (3) {435 ["a"]=>436 &int(1)437 ["b"]=>438 &int(1)439 ["c"]=>440 &int(1)441}442object(stdClass)#%d (3) {443 ["a"]=>444 &string(14) "obj->a.changed"445 ["b"]=>446 &string(14) "obj->a.changed"447 ["c"]=>448 &string(14) "obj->a.changed"449}450object(stdClass)#%d (3) {451 ["a"]=>452 &string(14) "obj->b.changed"453 ["b"]=>454 &string(14) "obj->b.changed"455 ["c"]=>456 &string(14) "obj->b.changed"457}458object(stdClass)#%d (3) {459 ["a"]=>460 &string(14) "obj->c.changed"461 ["b"]=>462 &string(14) "obj->c.changed"463 ["c"]=>464 &string(14) "obj->c.changed"465}466Done...

Full Screen

Full Screen

std

Using AI Code Generation

copy

Full Screen

1require_once 'vendor/autoload.php';2use atoum\atoum;3{4 public function test1()5 {6 $this->assert->boolean(true)->isTrue();7 }8}9require_once 'vendor/autoload.php';10{11 public function test1()12 {13 $this->assertTrue(true);14 }15}16require_once 'vendor/autoload.php';17{18 public function test1()19 {20 $this->assertTrue(true);21 }22}23require_once 'vendor/autoload.php';24{25 public function test1()26 {27 $this->assertTrue(true);28 }29}30require_once 'vendor/autoload.php';31{32 public function test1()33 {34 $this->assertTrue(true);35 }36}37require_once 'vendor/autoload.php';38{39 public function test1()40 {41 $this->assertTrue(true);42 }43}44require_once 'vendor/autoload.php';45{46 public function test1()47 {48 $this->assertTrue(true);49 }50}51require_once 'vendor/autoload.php';52{53 public function test1()54 {55 $this->assertTrue(true);56 }57}58require_once 'vendor/autoload.php';59{60 public function test1()61 {62 $this->assertTrue(true);63 }64}65require_once 'vendor/autoload.php';

Full Screen

Full Screen

std

Using AI Code Generation

copy

Full Screen

1$test->class('stdclass')2->hasInterface('Iterator');3$test->class('stdclass')4->hasInterface('IteratorAggregate');5$test->class('stdclass')6->hasInterface('Traversable');7$test->class('stdclass')8->hasInterface('ArrayAccess');9$test->class('stdclass')10->hasInterface('Serializable');11$test->class('stdclass')12->hasInterface('Countable');13$test->class('stdclass')14->hasInterface('stdClass');15$test->class('stdclass')16->hasInterface('JsonSerializable');17$test->class('stdclass')18->hasInterface('Throwable');19$test->class('stdclass')20->hasInterface('Exception');21$test->class('stdclass')22->hasInterface('Error');23$test->class('stdclass')24->hasInterface('ArithmeticError');25$test->class('stdclass')26->hasInterface('AssertionError');27$test->class('stdclass')28->hasInterface('DivisionByZeroError');29$test->class('stdclass')30->hasInterface('ParseError');31$test->class('stdclass')32->hasInterface('TypeError');33$test->class('stdclass')34->hasInterface('ArgumentCountError');35$test->class('stdclass')36->hasInterface('CompileError');37$test->class('stdclass')38->hasInterface('Closure');39$test->class('stdclass')40->hasInterface('Generator');41$test->class('stdclass')42->hasInterface('Closure');

Full Screen

Full Screen

std

Using AI Code Generation

copy

Full Screen

1use \mageekguy\atoum\test;2{3 public function testMyFirstTest()4 {5 $this->assert->string('Hello')->isEqualTo('Hello');6 }7}8use \mageekguy\atoum\test;9{10 public function testMySecondTest()11 {12 $this->assert->string('Hello')->isEqualTo('Hello');13 }14}15use \mageekguy\atoum\test;16{17 public function testMyThirdTest()18 {19 $this->assert->string('Hello')->isEqualTo('Hello');20 }21}22use \mageekguy\atoum\test;23{24 public function testMyFourthTest()25 {26 $this->assert->string('Hello')->isEqualTo('Hello');27 }28}29use \mageekguy\atoum\test;30{31 public function testMyFifthTest()32 {33 $this->assert->string('Hello')->isEqualTo('Hello');34 }35}36use \mageekguy\atoum\test;37{38 public function testMySixthTest()39 {40 $this->assert->string('Hello')->isEqualTo('Hello');41 }42}43use \mageekguy\atoum\test;44{45 public function testMySeventhTest()46 {47 $this->assert->string('Hello')->isEqualTo('Hello');48 }49}50use \mageekguy\atoum\test;51{

Full Screen

Full Screen

std

Using AI Code Generation

copy

Full Screen

1$test = new \mageekguy\atoum\test();2$test->setTestNamespace('test');3$test->run();4namespace test;5{6 public function test1()7 {8 $this->assert(true);9 }10}

Full Screen

Full Screen

std

Using AI Code Generation

copy

Full Screen

1$test->class('\Atoum\test');2$test->class('\Atoum\Test');3$test->class('\Atoum\Test\Test');4$test->class('\Atoum\Test\Test');5$test->class('\Atoum\Test\Test');6$test->class('\Atoum\Test\Test');7$test->class('\Atoum\Test\Test');8$test->class('\Atoum\Test\Test');9$test->class('\Atoum\Test\Test');10$test->class('\Atoum\Test\Test');11$test->class('\Atoum\Test\Test');12$test->class('\Atoum\Test\Test');13$test->class('\Atoum\Test\Test');14$test->class('\Atoum\Test\Test');15$test->class('\Atoum\Test\Test');16$test->class('\Atoum\Test\Test');

Full Screen

Full Screen

std

Using AI Code Generation

copy

Full Screen

1use atoum\test;2{3 public function test()4 {5 ->given($a = new \stdclass())6 ->if($a->b = 1)7 ->object($a)8 ->isInstanceOf('stdclass')9 ->integer($a->b)10 ->isEqualTo(1)11 ;12 }13}14use atoum\test;15{16 public function test()17 {18 ->given($a = new \stdclass())19 ->if($a->b = 1)20 ->object($a)21 ->isInstanceOf('stdclass')22 ->integer($a->b)23 ->isEqualTo(1)24 ;25 }26}27use atoum\atoum;28$runner = new atoum\runner();29$runner->addTestsFromDirectory(__DIR__ . '/tests/');30$report = $runner->run();31use atoum\test;32{33 public function test()34 {35 ->given($a = new \stdclass())36 ->if($a->b = 1)37 ->object($a)38 ->isInstanceOf('stdclass')39 ->integer($a->b)40 ->isEqualTo(1)41 ;42 }43}44use atoum\test;45{46 public function test()47 {48 ->given($a = new \stdclass())49 ->if($a->b = 1)50 ->object($a)51 ->isInstanceOf('stdclass')52 ->integer($a->b)53 ->isEqualTo(1)54 ;55 }56}57use atoum\atoum;58$runner = new atoum\runner();59$runner->addTestsFromDirectory(__DIR__);60$report = $runner->run();

Full Screen

Full Screen

std

Using AI Code Generation

copy

Full Screen

1namespace Atoum\std;2{3 public function __construct()4 {5 echo "I am std class";6 }7}8namespace Atoum\std;9require_once "1.php";10new stdClass();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful