Skip to content

Commit

Permalink
Merge pull request #1080 from robmachado/master
Browse files Browse the repository at this point in the history
Retirada de validações sobre NCM e CRT=4 e CSONSN, tais vallidações d…
  • Loading branch information
robmachado authored Oct 16, 2024
2 parents ab887d6 + 3fba45e commit e5420b6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
36 changes: 23 additions & 13 deletions src/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,15 +791,25 @@ public function tagide(stdClass $std): DOMElement
/**
* Chave de acesso da NF-e referenciada BA02 pai BA01
* tag NFe/infNFe/ide/NFref/refNFe
* @param stdClass $std
* @return DOMElement
* @throws \DOMException
*/
public function tagrefNFe(stdClass $std): DOMElement
{
$possible = ['refNFe'];
$possible = ['refNFe', 'refNFeSig'];
$std = $this->equilizeParameters($std, $possible);

if (empty($std->refNFe) && empty($std->refNFe)) {
return $this->dom->createElement("refNFe", '');
}
$num = $this->buildNFref();
$refNFe = $this->dom->createElement("refNFe", $std->refNFe);
$this->dom->appChild($this->aNFref[$num - 1], $refNFe);
if (!empty($std->refNFe)) {
$refNFe = $this->dom->createElement("refNFe", $std->refNFe);
$this->dom->appChild($this->aNFref[$num - 1], $refNFe);
} else {
$refNFe = $this->dom->createElement("refNFeSig", $std->refNFeSig);
$this->dom->appChild($this->aNFref[$num - 1], $refNFe);
}
return $refNFe;
}

Expand Down Expand Up @@ -1864,6 +1874,7 @@ public function tagprod(stdClass $std): DOMElement
}
}

/*
$CRT = null;
if (!empty($this->emit->getElementsByTagName("CRT")->item(0))) {
$CRT = (int) $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue;
Expand All @@ -1879,7 +1890,7 @@ public function tagprod(stdClass $std): DOMElement
if ($allowEmptyNcm && empty($std->NCM)) {
$std->NCM = '00000000';
}

*/
$identificador = 'I01 <prod> - ';
$prod = $this->dom->createElement("prod");
$this->dom->addChild(
Expand Down Expand Up @@ -4785,6 +4796,7 @@ public function tagICMSSN(stdClass $std): DOMElement
$this->stdTot->vFCPST += (float) !empty($std->vFCPST) ? $std->vFCPST : 0;
$this->stdTot->vFCPSTRet += (float) !empty($std->vFCPSTRet) ? $std->vFCPSTRet : 0;

/*
$CRT = null;
if (!empty($this->emit->getElementsByTagName("CRT")->item(0))) {
$CRT = (int) $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue;
Expand All @@ -4793,7 +4805,7 @@ public function tagICMSSN(stdClass $std): DOMElement
$allowEmptyOrig = $CRT == 4 && in_array($std->CSOSN, [
'102', '103', '300', '400', '900',
]);

*/
switch ($std->CSOSN) {
case '101':
$icmsSN = $this->dom->createElement("ICMSSN101");
Expand Down Expand Up @@ -4835,10 +4847,9 @@ public function tagICMSSN(stdClass $std): DOMElement
$this->dom->addChild(
$icmsSN,
'orig',
$std->orig,
!$allowEmptyOrig,
"[item $std->item] Origem da mercadoria",
$allowEmptyOrig,
$std->orig ?? null, //poderá ser null caso CRT=4 e 102
false,
"[item $std->item] Origem da mercadoria"
);
$this->dom->addChild(
$icmsSN,
Expand Down Expand Up @@ -5141,10 +5152,9 @@ public function tagICMSSN(stdClass $std): DOMElement
$this->dom->addChild(
$icmsSN,
'orig',
$std->orig,
!$allowEmptyOrig,
$std->orig ?? null, //poderá ser null caso CRT=4 e 900
false,
"[item $std->item] Origem da mercadoria",
$allowEmptyOrig,
);
$this->dom->addChild(
$icmsSN,
Expand Down
6 changes: 4 additions & 2 deletions tests/MakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,7 @@ public function test_tagICMSSNShouldAcceptEmptyOrig_whenCrtIs4AndCsosnInAllowedL
$this->validarExistenciaCampos($std, $result);
}

/*
public function test_tagICMSSNShouldNotAcceptEmptyOrig_whenCrtIs1(): void
{
$std = new \stdClass();
Expand Down Expand Up @@ -1500,7 +1501,7 @@ public function test_tagICMSSNShouldNotAcceptEmptyOrig_whenCrtIs1(): void
$this->make->getErrors()
);
$this->validarExistenciaCampos($std, $result);
}
}*/

public function test_tagICMSSNShouldNotAcceptEmptyOrig_whenCrtIs4AndCsosnIsNotInAllowedList(): void
{
Expand Down Expand Up @@ -1540,6 +1541,7 @@ public function test_tagICMSSNShouldNotAcceptEmptyOrig_whenCrtIs4AndCsosnIsNotIn
);
}

/*
public function test_tagNCMShouldAcceptEmptyValue_andChangeToDefaultValue_whenCrtIs4AndIdDestIs1(): void
{
$std = new \stdClass();
Expand Down Expand Up @@ -1569,7 +1571,7 @@ public function test_tagNCMShouldAcceptEmptyValue_andChangeToDefaultValue_whenCr
$prod = $this->make->tagprod($std);
$this->assertEquals('00000000', $prod->getElementsByTagName('NCM')->item(0)->nodeValue);
}
}*/

public function test_tagNCMShouldNotAcceptEmptyValue_whenCrtIs1(): void
{
Expand Down

0 comments on commit e5420b6

Please sign in to comment.