public function montaNFe()
{
if (count($this->erros) > 0) {
return false;
}
//cria a tag raiz da Nfe
$this->zTagNFe();
//processa nfeRef e coloca as tags na tag ide
foreach ($this->aNFref as $nfeRef) {
$this->dom->appChild($this->ide, $nfeRef, 'Falta tag "ide"');
}
//monta as tags det com os detalhes dos produtos
$this->zTagdet();
//[2] tag ide (5 B01)
$this->dom->appChild($this->infNFe, $this->ide, 'Falta tag "infNFe"');
//[8] tag emit (30 C01)
$this->dom->appChild($this->infNFe, $this->emit, 'Falta tag "infNFe"');
//[10] tag dest (62 E01)
$this->dom->appChild($this->infNFe, $this->dest, 'Falta tag "infNFe"');
//[12] tag retirada (80 F01)
$this->dom->appChild($this->infNFe, $this->retirada, 'Falta tag "infNFe"');
//[13] tag entrega (89 G01)
$this->dom->appChild($this->infNFe, $this->entrega, 'Falta tag "infNFe"');
//[14] tag autXML (97a.1 G50)
foreach ($this->aAutXML as $aut) {
$this->dom->appChild($this->infNFe, $aut, 'Falta tag "infNFe"');
}
//[14a] tag det (98 H01)
foreach ($this->aDet as $det) {
$this->dom->appChild($this->infNFe, $det, 'Falta tag "infNFe"');
}
//[28a] tag total (326 W01)
$this->dom->appChild($this->infNFe, $this->total, 'Falta tag "infNFe"');
//[32] tag transp (356 X01)
$this->dom->appChild($this->infNFe, $this->transp, 'Falta tag "infNFe"');
//[39a] tag cobr (389 Y01)
$this->dom->appChild($this->infNFe, $this->cobr, 'Falta tag "infNFe"');
//[42] tag pag (398a YA01)
//processa aPag e coloca as tags na tag pag
foreach ($this->aPag as $pag) {
$this->dom->appChild($this->infNFe, $pag, 'Falta tag "infNFe"');
}
//[44] tag infAdic (399 Z01)
$this->dom->appChild($this->infNFe, $this->infAdic, 'Falta tag "infNFe"');
//[48] tag exporta (402 ZA01)
$this->dom->appChild($this->infNFe, $this->exporta, 'Falta tag "infNFe"');
//[49] tag compra (405 ZB01)
$this->dom->appChild($this->infNFe, $this->compra, 'Falta tag "infNFe"');
//[50] tag cana (409 ZC01)
$this->dom->appChild($this->infNFe, $this->cana, 'Falta tag "infNFe"');
//[1] tag infNFe (1 A01)
$this->dom->appChild($this->NFe, $this->infNFe, 'Falta tag "NFe"');
//[0] tag NFe
$this->dom->appChild($this->dom, $this->NFe, 'Falta DOMDocument');
// testa da chave
$this->zTestaChaveXML($this->dom);
//convert DOMDocument para string
$this->xml = $this->dom->saveXML();
return true;
}