diff --git a/lib/Sped/Gnre/Helper/GnreHelper.php b/lib/Sped/Gnre/Helper/GnreHelper.php index 6f522b5..920301f 100644 --- a/lib/Sped/Gnre/Helper/GnreHelper.php +++ b/lib/Sped/Gnre/Helper/GnreHelper.php @@ -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; @@ -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;