Skip to content

Commit

Permalink
CTE insucesso de entrega - contrib. Ubiratan
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseQuintas committed Dec 18, 2024
1 parent b79c925 commit 9a7c38c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions sefazclass.hbp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ source/ze_sefaz_CTeEventoCancEntrega.prg
source/ze_sefaz_CTeEventoCarta.prg
source/ze_sefaz_CTeEventoDesacordo.prg
source/ze_sefaz_CTeEventoEntrega.prg
source/ze_sefaz_CTeEventoInsucessoEntrega.prg
source/ze_sefaz_CTeGeraAutorizado.prg
source/ze_sefaz_CTeGeraEventoAutorizado.prg
source/ze_sefaz_CTeInutiliza.prg
Expand Down
44 changes: 44 additions & 0 deletions source/ze_sefaz_CTeEventoInsucessoEntrega.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "sefazclass.ch"

FUNCTION ze_sefaz_CTeEventoInsucessoEntrega( Self, cChave, nSequencia, nProt, ;
dDataEntrega, cHoraEntrega, nTentativa, cMotivo, cJustificativa, nLatitude, ;
nLongitude, cStrImagem, aChaveNfeList, cCertificado, cAmbiente )

LOCAL cChaveNfe, cXml := "", cHash

hb_Default( @::cVersao, WS_CTE_DEFAULT )
cHash := hb_Sha1( cChave + hb_Base64Encode( cStrImagem ), .T. )
cHash := hb_Base64Encode( cHash )
cXml += [<detEvento versaoEvento="] + ::cVersao + [">]
cXml += [<evIECTe>]
cXml += XmlTag( "descEvento", "Insucesso na Entrega do CT-e" )
cXml += XmlTag( "nProt", Ltrim( Str( nProt ) ) )
cXml += XmlTag( "dhTentativaEntrega", DateTimeXml( dDataEntrega, cHoraEntrega, ::cUF ) )
cXml += XmlTag( "nTentativa", Ltrim( Str( nTentativa ) ) )
cXml += XmlTag( "tpMotivo", Ltrim( cMotivo ) )

if Alltrim(cMotivo) == '4'
cXml += XmlTag( "xJustMotivo", Ltrim( cJustificativa ) )
endif

IF nLatitude != 0 .AND. nLongitude != 0
cXml += XmlTag( "latitude", NumberXml( nLatitude, 16, 6 ) )
cXml += XmlTag( "longitude", NumberXml( nLongitude, 16, 6 ) )
ENDIF

cXml += XmlTag( "hashTentativaEntrega", cHash )
cXml += XmlTag( "dhHashTentativaEntrega", DateTimeXml( Date(), Time(), ::cUF ) )

FOR EACH cChaveNfe IN aChaveNfeList
cXml += "<infEntrega>"
cXml += XmlTag( "chNFe", cChaveNfe )
cXml += "</infEntrega>"
NEXT

cXml += [</evIECTe>]
cXml += [</detEvento>]

::CTeEvento( cChave, nSequencia, "110190", cXml, cCertificado, cAmbiente )

RETURN ::cXmlRetorno

0 comments on commit 9a7c38c

Please sign in to comment.