Skip to content

Commit

Permalink
tag imposto sendo inserida junto com ICMS (falta outras tributacoes) …
Browse files Browse the repository at this point in the history
…e tag totais com ICMSTot
  • Loading branch information
Marcus Vinicius Balbi committed Apr 17, 2014
1 parent a747679 commit 5c116cf
Showing 1 changed file with 52 additions and 6 deletions.
58 changes: 52 additions & 6 deletions exemplos/MakeNFePHP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,20 @@ public function montaNFe()
if (isset($this->aProd)) {
$this->tagdet();
}



if (isset($this->aDet)) {
foreach ($this->aDet as $det) {

$this->infNFe->appendChild($det);
}
}

if(isset($this->aImposto) && isset($this->aDet)){
$this->tagImp();
}

//tag NFe/infNFe/total
if (isset($this->ICMSTot)) {
$this->tagtotal();
Expand Down Expand Up @@ -844,13 +851,37 @@ public function tagdet()
$det = $this->dom->createElement("det");
$nItem = $key;
$det->setAttribute("nItem", $nItem);
$det->appendChild($prod);
$det->appendChild($prod);
$this->aDet[] = $det;
$det = null;
}
}
}

//tag NFe/infNFe/det/imposto
/**
* Insere dentro dentro das tags det os seus respectivos impostos
*
*/
public function tagImp()
{
foreach ($this->aImposto as $key => $imp) {
$nItem = $key;
$imp->appendChild($this->aICMS[$nItem]);
}

// COLOCA TAG imposto dentro do DET
foreach ($this->aDet as $det) {

$det->appendChild($this->aImposto[$det->getAttribute('nItem')]);

}



}


//tag NFe/infNFe/det/prod array de DOMNodes
public function tagprod(
$nItem = '',
Expand Down Expand Up @@ -1158,10 +1189,11 @@ public function tagICMS(
$nItem = '',
$orig = '',
$CST = '',
$modBC = '',
$vBC = '',
$pICMS = '',
$vICMS = ''
) {
) {
switch ($CST) {
case '00':
$ICMS = $this->dom->createElement("ICMS00");
Expand Down Expand Up @@ -1192,10 +1224,24 @@ public function tagICMS(
break;
case '90':
$ICMS = $this->dom->createElement("ICMS40");
break;


break;
}

$this->addChild($ICMS, 'orig', $orig);
$this->addChild($ICMS, 'CST', $CST);
$this->addChild($ICMS, 'modBC', $modBC);
$this->addChild($ICMS, 'vBC', $vBC);
$this->addChild($ICMS, 'pICMS', $pICMS);
$this->addChild($ICMS, 'vICMS', $vICMS);

$tagIcms = $this->dom->createElement('ICMS');

$tagIcms->appendChild($ICMS);

$this->aICMS[$nItem] = $tagIcms;

return $tagIcms;

}

//tag det/imposto/IPI (opcional) array de DOMNodes
Expand Down Expand Up @@ -1235,7 +1281,7 @@ public function tagCOFINS()
//tag NFe/infNFe/total DOMNode
public function tagtotal()
{
if (isset($this->total)) {
if (!isset($this->total)) {
$this->total = $this->dom->createElement("total");
}
}
Expand Down

0 comments on commit 5c116cf

Please sign in to comment.