From 3ffcc8b7f0c7682402f4ed84c3355229e6960aad Mon Sep 17 00:00:00 2001 From: Jeferson Menegaldo Date: Fri, 23 Feb 2024 14:27:52 -0300 Subject: [PATCH 1/3] fix: remove obrigatoriede de campos com ocorrencia 0 --- src/NFe/Entity/Endereco.php | 10 +++++++--- src/NFe/Entity/Pagamento.php | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/NFe/Entity/Endereco.php b/src/NFe/Entity/Endereco.php index 5b1901f..692b0a1 100644 --- a/src/NFe/Entity/Endereco.php +++ b/src/NFe/Entity/Endereco.php @@ -279,7 +279,12 @@ public function loadNode($element, $name = null) 'Tag "nro" do campo "Numero" não encontrada' ) ); - $this->setComplemento(Util::loadNode($element, 'xCpl')); + $this->setComplemento( + Util::loadNode( + $element, + 'xCpl' + ) + ); $this->setBairro( Util::loadNode( $element, @@ -323,8 +328,7 @@ public function loadNode($element, $name = null) $this->getPais()->setNome( Util::loadNode( $element, - 'xPais', - 'Tag "xPais" do objeto "Pais" não encontrada' + 'xPais' ) ); return $element; diff --git a/src/NFe/Entity/Pagamento.php b/src/NFe/Entity/Pagamento.php index aa6adf1..5979b68 100644 --- a/src/NFe/Entity/Pagamento.php +++ b/src/NFe/Entity/Pagamento.php @@ -621,8 +621,7 @@ public function loadNode($element, $name = null) $this->setValor( '-' . Util::loadNode( $element, - 'vTroco', - 'Tag "vTroco" do campo "Valor" não encontrada' + 'vTroco' ) ); return $element; From 1e028a56d6ac9844c5751975cbc0a8c1b0bd5dd9 Mon Sep 17 00:00:00 2001 From: Jeferson Menegaldo Date: Fri, 8 Mar 2024 10:57:04 -0300 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20adiciona=20valores=20padr=C3=A3o=20a?= =?UTF-8?q?=20campos=20n=C3=A3o=20obrigatorios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/NFe/Entity/Endereco.php | 7 +++++-- src/NFe/Entity/Pagamento.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/NFe/Entity/Endereco.php b/src/NFe/Entity/Endereco.php index 692b0a1..7c47d79 100644 --- a/src/NFe/Entity/Endereco.php +++ b/src/NFe/Entity/Endereco.php @@ -37,6 +37,9 @@ */ class Endereco implements Node { + public const NOME_PAIS_DEFAULT = 'BRASIL'; + public const CODIGO_PAIS_DEFAULT = 1058; + private $pais; private $cep; private $municipio; @@ -323,13 +326,13 @@ public function loadNode($element, $name = null) Util::loadNode( $element, 'cPais' - ) + ) ?? $this::CODIGO_PAIS_DEFAULT ); $this->getPais()->setNome( Util::loadNode( $element, 'xPais' - ) + ) ?? $this::NOME_PAIS_DEFAULT ); return $element; } diff --git a/src/NFe/Entity/Pagamento.php b/src/NFe/Entity/Pagamento.php index 5979b68..df129a2 100644 --- a/src/NFe/Entity/Pagamento.php +++ b/src/NFe/Entity/Pagamento.php @@ -619,10 +619,10 @@ public function loadNode($element, $name = null) $name = is_null($name) ? 'detPag' : $name; if ($name == 'vTroco') { $this->setValor( - '-' . Util::loadNode( + '-' . (Util::loadNode( $element, 'vTroco' - ) + ) ?? 0) ); return $element; } From 046bac16738021904f44f320f48d9fbcf737a84a Mon Sep 17 00:00:00 2001 From: Jeferson Menegaldo Date: Thu, 14 Mar 2024 09:36:22 -0300 Subject: [PATCH 3/3] fix: utiliza constante com self --- src/NFe/Entity/Endereco.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NFe/Entity/Endereco.php b/src/NFe/Entity/Endereco.php index 7c47d79..195cc8b 100644 --- a/src/NFe/Entity/Endereco.php +++ b/src/NFe/Entity/Endereco.php @@ -326,13 +326,13 @@ public function loadNode($element, $name = null) Util::loadNode( $element, 'cPais' - ) ?? $this::CODIGO_PAIS_DEFAULT + ) ?? self::CODIGO_PAIS_DEFAULT ); $this->getPais()->setNome( Util::loadNode( $element, 'xPais' - ) ?? $this::NOME_PAIS_DEFAULT + ) ?? self::NOME_PAIS_DEFAULT ); return $element; }