From 1e028a56d6ac9844c5751975cbc0a8c1b0bd5dd9 Mon Sep 17 00:00:00 2001 From: Jeferson Menegaldo Date: Fri, 8 Mar 2024 10:57:04 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20adiciona=20valores=20padr=C3=A3o=20a=20c?= =?UTF-8?q?ampos=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; }