Skip to content

Commit

Permalink
GNRE
Browse files Browse the repository at this point in the history
  • Loading branch information
luizkim committed Nov 3, 2023
1 parent 570e3bb commit f676ad9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/Sped/Gnre/Helper/GnreHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ public function __construct($xmlNf)
*/
public static function getGuiaGnre($xmlNf): Guia
{

$xml = self::parseNf($xmlNf);
$guia = new Guia();
$guia = new Guia();
$guia->c04_docOrigem = $xml->NrNf;
$guia->c28_tipoDocOrigem = $xml->TipoDoc;
$guia->c28_tipoDocOrigem = $xml->TipoDoc;
$guia->c21_cepEmitente = $xml->CEPEmpresa;
$guia->c16_razaoSocialEmitente = $xml->NmEmpresa;
$guia->c03_idContribuinteEmitente = $xml->NrDocumentoEmpresa;
$guia->c18_enderecoEmitente = $xml->EnderecoEmpresa;
$guia->c19_municipioEmitente = $xml->MunicipioEmpresa;
$guia->c20_ufEnderecoEmitente = $xml->UfEmpresa;
$guia->c17_inscricaoEstadualEmitente = $xml->NrIEEmpresa;
$guia->c22_telefoneEmitente = $xml->TelefoneEmpresa;
$guia->c01_UfFavorecida = $xml->IdUfCliente;
$guia->c35_idContribuinteDestinatario = $xml->NrDocumentoCliente;
$guia->c36_inscricaoEstadualDestinatario = $xml->NrIECliente;
$guia->c37_razaoSocialDestinatario = $xml->NmCliente;
$guia->c38_municipioDestinatario = $xml->MunicipioCliente;
Expand All @@ -76,24 +79,26 @@ public static function parseNf($xmlNf): stdClass
$xml = simplexml_load_string($xmlNf);
$parsed = new stdClass();


$parsed->CEPEmpresa = $xml->NFe->infNFe->emit->enderEmit->CEP;
$parsed->EnderecoEmpresa = $xml->NFe->infNFe->emit->enderEmit->xLgr;
$parsed->CdMunicipioEmpresa = $xml->NFe->infNFe->emit->enderEmit->cMun;
$parsed->MunicipioEmpresa = $xml->NFe->infNFe->emit->enderEmit->xMun;
$parsed->MunicipioEmpresa = $xml->NFe->infNFe->emit->enderEmit->xMun;
$parsed->UfEmpresa = $xml->NFe->infNFe->emit->enderEmit->UF;
$parsed->TelefoneEmpresa = $xml->NFe->infNFe->emit->enderEmit->fone;
$parsed->NrIEEmpresa = $xml->NFe->infNFe->emit->IE;
$parsed->NrIEEmpresa = $xml->NFe->infNFe->emit->IE;
$parsed->NmEmpresa = $xml->NFe->infNFe->emit->xNome;
$parsed->NrDocumentoCliente = $xml->NFe->infNFe->dest->CNPJ ?: $xml->NFe->infNFe->dest->CPF;
$parsed->NrDocumentoEmpresa = $xml->NFe->infNFe->emit->CNPJ;


$parsed->NrDocumentoCliente = $xml->NFe->infNFe->dest->CNPJ ?: $xml->NFe->infNFe->dest->CPF;
$parsed->NrIECliente = $xml->NFe->infNFe->dest->IE;
$parsed->NmCliente = $xml->NFe->infNFe->dest->xNome;
$parsed->NmCidade = $xml->NFe->infNFe->dest->enderDest->xMun;
$parsed->IdUfCliente = $xml->NFe->infNFe->dest->enderDest->UF;
$parsed->CdMunicipioCliente = $xml->NFe->infNFe->dest->enderDest->cMun;
$parsed->MunicipioCliente = $xml->NFe->infNFe->dest->enderDest->xMun;
$parsed->ISUFCliente = $xml->NFe->infNFe->dest->ISUF;
$parsed->ISUFCliente = $xml->NFe->infNFe->dest->ISUF;
$parsed->TipoDoc = $xml->NFe->infNFe->ide->tpDoc;
$parsed->NrChaveNFe = $xml->protNFe->infProt->chNFe;
$parsed->VlNf = $xml->NFe->infNFe->total->ICMSTot->vNF;
Expand Down

0 comments on commit f676ad9

Please sign in to comment.