From 8c50fe8504f8d032c0fae73594461e66900420e5 Mon Sep 17 00:00:00 2001 From: "Willian C. Klein" Date: Mon, 9 Sep 2024 19:42:22 -0300 Subject: [PATCH 1/3] Update Make.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Checa uma propriedade de emit como elemento dom, sem checar se ele ja foi setado ou não. Deveria criar um default como fiz no código ou subir um erro obrigando a ordem de preenchimento das tags. --- src/Make.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Make.php b/src/Make.php index cdcbaf0f..a21a3370 100755 --- a/src/Make.php +++ b/src/Make.php @@ -4770,7 +4770,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 = $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null; + $CRT = (isset($this->emit) && $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue) ?? null; $allowEmptyOrig = $CRT == 4 && in_array($std->CSOSN, [ '102', '103', '300', '400', '900', ]); From 1629887e4b6d933b25f8e2de28365f0e6cc5e72d Mon Sep 17 00:00:00 2001 From: "Willian C. Klein" Date: Wed, 11 Sep 2024 11:17:48 -0300 Subject: [PATCH 2/3] Update Make.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit chore: correção não iria retornar o valor e sim um 'true' --- src/Make.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Make.php b/src/Make.php index a21a3370..fe6acb31 100755 --- a/src/Make.php +++ b/src/Make.php @@ -4770,7 +4770,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 = (isset($this->emit) && $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue) ?? null; + $CRT = isset($this->emit) ? $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue : null; $allowEmptyOrig = $CRT == 4 && in_array($std->CSOSN, [ '102', '103', '300', '400', '900', ]); From 7a9ac05aae415165b549c96b2daaa8cbf79518f0 Mon Sep 17 00:00:00 2001 From: "Willian C. Klein" Date: Thu, 12 Sep 2024 14:31:24 -0300 Subject: [PATCH 3/3] Update Make.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit chore: validando se o item do objeto DOM está preenchido antes de pegar o valor do node --- src/Make.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Make.php b/src/Make.php index fe6acb31..b3b41d05 100755 --- a/src/Make.php +++ b/src/Make.php @@ -1857,8 +1857,17 @@ public function tagprod(stdClass $std): DOMElement $this->errors[] = "cEANTrib {$ceantrib} " . $e->getMessage(); } } - $CRT = $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null; - $idDest = $this->ide->getElementsByTagName("idDest")->item(0)->nodeValue ?? null; + + $CRT = null; + if (!empty($this->emit->getElementsByTagName("CRT")->item(0))) { + $CRT = (int) $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue; + } + + $idDest = null; + if (!empty($this->ide->getElementsByTagName("idDest")->item(0))) { + $idDest = (int) $this->ide->getElementsByTagName("idDest")->item(0)->nodeValue; + } + $allowEmptyNcm = $CRT == 4 && $idDest == 1; if ($allowEmptyNcm && empty($std->NCM)) { @@ -4770,7 +4779,11 @@ 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 = isset($this->emit) ? $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue : null; + $CRT = null; + if (!empty($this->emit->getElementsByTagName("CRT")->item(0))) { + $CRT = (int) $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue; + } + $allowEmptyOrig = $CRT == 4 && in_array($std->CSOSN, [ '102', '103', '300', '400', '900', ]);