diff --git a/CTe.Classes/Servicos/DistribuicaoDFe/Schemas/procEventoCTe.cs b/CTe.Classes/Servicos/DistribuicaoDFe/Schemas/procEventoCTe.cs index 88e3fc76d..f894ac9d6 100644 --- a/CTe.Classes/Servicos/DistribuicaoDFe/Schemas/procEventoCTe.cs +++ b/CTe.Classes/Servicos/DistribuicaoDFe/Schemas/procEventoCTe.cs @@ -31,7 +31,5 @@ public class procEventoCTe /// [XmlElement(Namespace = "http://www.portalfiscal.inf.br/cte")] public retEventoCTe retEventoCTe { get; set; } - - } } \ No newline at end of file diff --git a/CTe.Classes/Servicos/DistribuicaoDFe/Schemas/resCTe.cs b/CTe.Classes/Servicos/DistribuicaoDFe/Schemas/resCTe.cs new file mode 100644 index 000000000..638022f1a --- /dev/null +++ b/CTe.Classes/Servicos/DistribuicaoDFe/Schemas/resCTe.cs @@ -0,0 +1,123 @@ +using DFe.Utils; +using System; +using System.ComponentModel; +using System.Xml.Serialization; + +namespace CTe.Classes.Servicos.DistribuicaoDFe.Schemas +{ + /// + /// Resumo de CT-e retornado no docZip com schema resCTe_v1.03.xsd + /// Ref: NT 2015/002 - CTeDistribuicaoDFe + /// + [Serializable()] + [DesignerCategory("code")] + [XmlType(AnonymousType = true, Namespace = "http://www.portalfiscal.inf.br/cte")] + [XmlRoot(Namespace = "http://www.portalfiscal.inf.br/cte", IsNullable = false)] + public class resCTe + { + /// + /// Chave de acesso do CT-e (44 dígitos) + /// + [XmlElement("chCTe")] + public string chCTe { get; set; } + + /// + /// CNPJ do emitente (14 dígitos) + /// + [XmlElement("CNPJ")] + public string CNPJ { get; set; } + + /// + /// Razão social ou nome do emitente + /// + [XmlElement("xNome")] + public string xNome { get; set; } + + /// + /// Inscrição Estadual do emitente + /// + [XmlElement("IE")] + public string IE { get; set; } + + /// + /// Modal do CT-e + /// + /// 01=Rodoviário + /// 02=Aéreo + /// 03=Aquaviário + /// 04=Ferroviário + /// 05=Dutoviário + /// 06=Multimodal + /// + /// + [XmlElement("modal")] + public string modal { get; set; } + + /// + /// Data e hora de emissão do CT-e + /// + [XmlIgnore] + public DateTimeOffset dhEmi { get; set; } + + [XmlElement(ElementName = "dhEmi")] + public string ProxydhEmi + { + get { return dhEmi.ParaDataHoraStringUtc(); } + set { dhEmi = DateTimeOffset.Parse(value); } + } + + /// + /// Tipo do CT-e + /// + /// 0=CT-e Normal + /// 1=CT-e de Complemento de Valores + /// 2=CT-e de Anulação + /// 3=CT-e de Substituição + /// + /// + [XmlElement("tpCTe")] + public string tpCTe { get; set; } + + /// + /// Digest value da assinatura do CT-e + /// + [XmlElement("digVal")] + public string digVal { get; set; } + + /// + /// Data e hora do recebimento pelo Ambiente Nacional + /// + [XmlIgnore] + public DateTimeOffset dhRecbto { get; set; } + + [XmlElement(ElementName = "dhRecbto")] + public string ProxydhRecbto + { + get { return dhRecbto.ParaDataHoraStringUtc(); } + set { dhRecbto = DateTimeOffset.Parse(value); } + } + + /// + /// Número do protocolo de autorização + /// + [XmlElement("nProt")] + public string nProt { get; set; } + + /// + /// Valor a receber pelo transportador + /// + [XmlElement("vRec")] + public string vRec { get; set; } + + /// + /// Situação do CT-e + /// + /// 100=Autorizado o uso do CT-e + /// 101=Cancelamento de CT-e homologado + /// 110=Uso denegado + /// + /// + [XmlElement("cSitCTe")] + public string cSitCTe { get; set; } + } +} diff --git a/CTe.Classes/Servicos/DistribuicaoDFe/loteDistDFeInt.cs b/CTe.Classes/Servicos/DistribuicaoDFe/loteDistDFeInt.cs index ebb3c44df..4a545663c 100644 --- a/CTe.Classes/Servicos/DistribuicaoDFe/loteDistDFeInt.cs +++ b/CTe.Classes/Servicos/DistribuicaoDFe/loteDistDFeInt.cs @@ -1,3 +1,4 @@ +using CTe.Classes.Servicos.DistribuicaoDFe.Schemas; using System; using System.ComponentModel; using System.Xml.Serialization; @@ -36,5 +37,21 @@ public class loteDistDFeInt /// [XmlText(DataType = "base64Binary")] public byte[] XmlNfe { get; set; } + + #region Objetos possíveis para descompactar o conteúdo do campo XmlNfe, dependendo do valor do campo schema + [XmlIgnore] + public cteProc cteProc { get; set; } + + [XmlIgnore] + public resCTe resCTe { get; set; } + + [XmlIgnore] + public CTeOSDocumento.CTe.CTeOS.Retorno.cteOSProc cteOSProc { get; set; } + + [XmlIgnore] + public Classes.Servicos.DistribuicaoDFe.Schemas.procEventoCTe procEventoCTe { get; set; } + + //TO DO: Adicionar no futuro o procGTVe adicionando na versão 1.04 do schema de distribuição de DFe + #endregion } } \ No newline at end of file diff --git a/CTe.Servicos/DistribuicaoDFe/ServicoCTeDistribuicaoDFe.cs b/CTe.Servicos/DistribuicaoDFe/ServicoCTeDistribuicaoDFe.cs index 46924cd21..ef1e6f744 100644 --- a/CTe.Servicos/DistribuicaoDFe/ServicoCTeDistribuicaoDFe.cs +++ b/CTe.Servicos/DistribuicaoDFe/ServicoCTeDistribuicaoDFe.cs @@ -63,27 +63,33 @@ public RetornoCteDistDFeInt CTeDistDFeInteresse(string ufAutor, string documento { for (int i = 0; i < retConsulta.loteDistDFeInt.Length; i++) { - string conteudo = Compressao.Unzip(retConsulta.loteDistDFeInt[i].XmlNfe).RemoverDeclaracaoXml(); + var loteAtual = retConsulta.loteDistDFeInt[i]; + string conteudo = Compressao.Unzip(loteAtual.XmlNfe).RemoverDeclaracaoXml(); string chCTe = string.Empty; if (conteudo.StartsWith("(conteudo); - chCTe = retConteudo.protCTe.infProt.chCTe; + var cteConteudo = FuncoesXml.XmlStringParaClasse(conteudo); + chCTe = cteConteudo.protCTe.infProt.chCTe; + loteAtual.cteProc = cteConteudo; } else if (conteudo.StartsWith("(conteudo); chCTe = procEventoNFeConteudo.eventoCTe.infEvento.chCTe; + loteAtual.procEventoCTe = procEventoNFeConteudo; } else if (conteudo.StartsWith("(conteudo); - chCTe = retConteudo.protCTe.infProt.chCTe; + var cteOSConteudo = FuncoesXml.XmlStringParaClasse(conteudo); + chCTe = cteOSConteudo.protCTe.infProt.chCTe; + loteAtual.cteOSProc = cteOSConteudo; } - else + else if (conteudo.StartsWith("(conteudo); + chCTe = resCTeConteudo.chCTe; + loteAtual.resCTe = resCTeConteudo; } string[] schema = retConsulta.loteDistDFeInt[i].schema.Split('_');