Skip to content

Commit

Permalink
Merge pull request #16 from jefersonmenegaldo/fix/remove-obrigatoried…
Browse files Browse the repository at this point in the history
…ade-campos

fix: remove obrigatoriedade de campos com ocorrência 0
  • Loading branch information
mazinsw authored Mar 14, 2024
2 parents 48240c3 + 046bac1 commit 15b20a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 12 additions & 5 deletions src/NFe/Entity/Endereco.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -279,7 +282,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,
Expand Down Expand Up @@ -318,14 +326,13 @@ public function loadNode($element, $name = null)
Util::loadNode(
$element,
'cPais'
)
) ?? self::CODIGO_PAIS_DEFAULT
);
$this->getPais()->setNome(
Util::loadNode(
$element,
'xPais',
'Tag "xPais" do objeto "Pais" não encontrada'
)
'xPais'
) ?? self::NOME_PAIS_DEFAULT
);
return $element;
}
Expand Down
7 changes: 3 additions & 4 deletions src/NFe/Entity/Pagamento.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +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',
'Tag "vTroco" do campo "Valor" não encontrada'
)
'vTroco'
) ?? 0)
);
return $element;
}
Expand Down

0 comments on commit 15b20a6

Please sign in to comment.