Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CT-e 4.00 #1450

Merged
merged 8 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
332 changes: 332 additions & 0 deletions CTe.AppTeste/CTe.AppTeste.csproj

Large diffs are not rendered by default.

86 changes: 69 additions & 17 deletions CTe.AppTeste/CTeTesteModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ public void ConsultarStatusServico2()
CarregarConfiguracoes(config);

var statusServico = new StatusServico();
var retorno = statusServico.ConsultaStatus();
var retorno = statusServico.ConsultaStatusV4();

OnSucessoSync(new RetornoEEnvio(retorno));
}
Expand Down Expand Up @@ -662,10 +662,18 @@ public void ConsultaPorProtocolo()
CarregarConfiguracoes(config);

var servicoConsultaProtocolo = new ConsultaProtcoloServico();
var retorno = servicoConsultaProtocolo.ConsultaProtocolo(chave);


OnSucessoSync(new RetornoEEnvio(retorno));
if (config.ConfigWebService.Versao == versao.ve300 || config.ConfigWebService.Versao == versao.ve200)
{
var retorno = servicoConsultaProtocolo.ConsultaProtocolo(chave);
OnSucessoSync(new RetornoEEnvio(retorno));
}
else // versao 4.00
{
var retorno = servicoConsultaProtocolo.ConsultaProtocoloV4(chave);
OnSucessoSync(new RetornoEEnvio(retorno));
}

}

Expand Down Expand Up @@ -864,7 +872,12 @@ public void CriarEnviarCTe2e3()
#region infCte

cteEletronico.infCte = new infCte();
cteEletronico.infCte.versao = config.ConfigWebService.Versao;

if (config.ConfigWebService.Versao == versao.ve400 || config.ConfigWebService.Versao == versao.ve300)
{
cteEletronico.infCte.versao = versao.ve300;
}


#endregion

Expand Down Expand Up @@ -903,7 +916,7 @@ public void CriarEnviarCTe2e3()
cteEletronico.infCte.ide.UFFim = config.Empresa.SiglaUf;
cteEletronico.infCte.ide.retira = retira.Nao;

if (config.ConfigWebService.Versao == versao.ve300)
if (config.ConfigWebService.Versao == versao.ve300 || config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.ide.indIEToma = indIEToma.ContribuinteIcms;
}
Expand All @@ -916,7 +929,7 @@ public void CriarEnviarCTe2e3()
};
}

if (config.ConfigWebService.Versao == versao.ve300)
if (config.ConfigWebService.Versao == versao.ve300 || config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.ide.tomaBase3 = new toma3
{
Expand Down Expand Up @@ -946,6 +959,11 @@ public void CriarEnviarCTe2e3()
cteEletronico.infCte.emit.enderEmit.UF = config.Empresa.SiglaUf;
cteEletronico.infCte.emit.enderEmit.fone = config.Empresa.Telefone;

if (config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.emit.CRT = CRT.SimplesNacionalMei; // agora temos o simples nacional MEI , é diferente de simples nacional.
}

#endregion

// Remetente , no caso adicionei os mesmos dados do emitente.. mas seriam o do remente.
Expand Down Expand Up @@ -1006,7 +1024,7 @@ public void CriarEnviarCTe2e3()

cteEletronico.infCte.imp.ICMS.TipoICMS = icmsSimplesNacional;

if (config.ConfigWebService.Versao == versao.ve300)
if (config.ConfigWebService.Versao == versao.ve300 || config.ConfigWebService.Versao == versao.ve400)
{
icmsSimplesNacional.CST = CST.ICMS90;
}
Expand Down Expand Up @@ -1056,6 +1074,11 @@ public void CriarEnviarCTe2e3()
cteEletronico.infCte.infCTeNorm.infModal.versaoModal = versaoModal.veM300;
}

if (config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.infCTeNorm.infModal.versaoModal = versaoModal.veM400;
}

var rodoviario = new rodo();
rodoviario.RNTRC = config.Empresa.RNTRC;

Expand All @@ -1070,16 +1093,30 @@ public void CriarEnviarCTe2e3()
#endregion


var numeroLote = InputBoxTuche("Número Lote");


var servicoRecepcao = new ServicoCTeRecepcao();

// Evento executado antes do envio do CT-e para o WebService
// servicoRecepcao.AntesDeEnviar += AntesEnviarLoteCte;

var retornoEnvio = servicoRecepcao.CTeRecepcao(int.Parse(numeroLote), new List<CteEletronico> { cteEletronico });
if (config.ConfigWebService.Versao == versao.ve300)
{
var numeroLote = InputBoxTuche("Número Lote");
// Evento executado antes do envio do CT-e para o WebService
// servicoRecepcao.AntesDeEnviar += AntesEnviarLoteCte;

var retornoEnvio = servicoRecepcao.CTeRecepcao(int.Parse(numeroLote), new List<CteEletronico> { cteEletronico });

OnSucessoSync(new RetornoEEnvio(retornoEnvio));
}

if (config.ConfigWebService.Versao == versao.ve400)
{
var retornoEnvio = servicoRecepcao.CTeRecepcaoSincronoV4(cteEletronico);

OnSucessoSync(new RetornoEEnvio(retornoEnvio));

}

OnSucessoSync(new RetornoEEnvio(retornoEnvio));

config.ConfigWebService.Numeracao++;
new ConfiguracaoDao().SalvarConfiguracao(config);
Expand Down Expand Up @@ -1110,7 +1147,12 @@ public void CriarEnviarCTeConsultaReciboAutomatico2e3()
#region infCte

cteEletronico.infCte = new infCte();
cteEletronico.infCte.versao = config.ConfigWebService.Versao;

if (config.ConfigWebService.Versao == versao.ve400 || config.ConfigWebService.Versao == versao.ve300)
{
cteEletronico.infCte.versao = versao.ve300;
}


#endregion

Expand All @@ -1129,7 +1171,7 @@ public void CriarEnviarCTeConsultaReciboAutomatico2e3()
cteEletronico.infCte.ide.mod = ModeloDocumento.CTe;
cteEletronico.infCte.ide.serie = config.ConfigWebService.Serie;
cteEletronico.infCte.ide.nCT = config.ConfigWebService.Numeracao;
cteEletronico.infCte.ide.dhEmi = DateTime.Now;
cteEletronico.infCte.ide.dhEmi = DateTimeOffset.Now;
cteEletronico.infCte.ide.tpImp = tpImp.Retrado;
cteEletronico.infCte.ide.tpEmis = tpEmis.teNormal;
cteEletronico.infCte.ide.tpAmb = config.ConfigWebService.Ambiente; // o serviço adicionara automaticamente isso para você
Expand All @@ -1149,7 +1191,7 @@ public void CriarEnviarCTeConsultaReciboAutomatico2e3()
cteEletronico.infCte.ide.UFFim = config.Empresa.SiglaUf;
cteEletronico.infCte.ide.retira = retira.Nao;

if (config.ConfigWebService.Versao == versao.ve300)
if (config.ConfigWebService.Versao == versao.ve300 || config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.ide.indIEToma = indIEToma.ContribuinteIcms;
}
Expand All @@ -1162,7 +1204,7 @@ public void CriarEnviarCTeConsultaReciboAutomatico2e3()
};
}

if (config.ConfigWebService.Versao == versao.ve300)
if (config.ConfigWebService.Versao == versao.ve300 || config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.ide.tomaBase3 = new toma3
{
Expand Down Expand Up @@ -1192,6 +1234,11 @@ public void CriarEnviarCTeConsultaReciboAutomatico2e3()
cteEletronico.infCte.emit.enderEmit.UF = config.Empresa.SiglaUf;
cteEletronico.infCte.emit.enderEmit.fone = config.Empresa.Telefone;

if (config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.emit.CRT = CRT.SimplesNacionalMei; // agora temos o simples nacional MEI , é diferente de simples nacional.
}

#endregion

// Remetente , no caso adicionei os mesmos dados do emitente.. mas seriam o do remente.
Expand Down Expand Up @@ -1252,7 +1299,7 @@ public void CriarEnviarCTeConsultaReciboAutomatico2e3()

cteEletronico.infCte.imp.ICMS.TipoICMS = icmsSimplesNacional;

if (config.ConfigWebService.Versao == versao.ve300)
if (config.ConfigWebService.Versao == versao.ve300 || config.ConfigWebService.Versao == versao.ve400)
{
icmsSimplesNacional.CST = CST.ICMS90;
}
Expand Down Expand Up @@ -1302,6 +1349,11 @@ public void CriarEnviarCTeConsultaReciboAutomatico2e3()
cteEletronico.infCte.infCTeNorm.infModal.versaoModal = versaoModal.veM300;
}

if (config.ConfigWebService.Versao == versao.ve400)
{
cteEletronico.infCte.infCTeNorm.infModal.versaoModal = versaoModal.veM400;
}

var rodoviario = new rodo();
rodoviario.RNTRC = config.Empresa.RNTRC;

Expand Down
2 changes: 1 addition & 1 deletion CTe.AppTeste/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
</StackPanel>

</TabItem>
<TabItem Header="Exemplos">
<TabItem Header="Exemplos" Height="20" VerticalAlignment="Top">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="22*"/>
Expand Down
10 changes: 10 additions & 0 deletions CTe.AppTeste/schemas/GTVe_v3.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2008 (http://www.altova.com) by [email protected] (PROCERGS) -->
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/cte" targetNamespace="http://www.portalfiscal.inf.br/cte" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="cteTiposBasico_v3.00.xsd"/>
<xs:element name="GTVe" type="TGTVe">
<xs:annotation>
<xs:documentation>Guia de Trasnsporte Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
10 changes: 10 additions & 0 deletions CTe.AppTeste/schemas/GTVe_v4.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2008 (http://www.altova.com) by [email protected] (PROCERGS) -->
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/cte" targetNamespace="http://www.portalfiscal.inf.br/cte" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="cteTiposBasico_v4.00.xsd"/>
<xs:element name="GTVe" type="TGTVe">
<xs:annotation>
<xs:documentation>Guia de Trasnsporte Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
9 changes: 9 additions & 0 deletions CTe.AppTeste/schemas/consNSUFaltCTe_v3.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/cte" targetNamespace="http://www.portalfiscal.inf.br/cte" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteLoteRFBCTe_v3.00.xsd"/>
<xs:element name="consNSUFaltCTe" type="TConsNUFaltDFe">
<xs:annotation>
<xs:documentation>Schema XML de validação da área de dados da mensagem da consulta NSU Faltantes</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
9 changes: 9 additions & 0 deletions CTe.AppTeste/schemas/consProtFaltCTe_v3.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/cte" targetNamespace="http://www.portalfiscal.inf.br/cte" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteLoteRFBCTe_v3.00.xsd"/>
<xs:element name="consProtFaltCTe" type="TConsProtFalDFe">
<xs:annotation>
<xs:documentation>Pedido de consulta de Protocolos Faltantes de CT-e</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
2 changes: 1 addition & 1 deletion CTe.AppTeste/schemas/consSitCTeTiposBasico_v3.00.xsd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2008 (http://www.altova.com) by sas-[email protected] (PROCERGS) -->
<!-- edited with XMLSpy v2008 (http://www.altova.com) by sas.[email protected] (PROCERGS) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/cte" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/cte" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="tiposGeralCTe_v3.00.xsd"/>
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
Expand Down
123 changes: 123 additions & 0 deletions CTe.AppTeste/schemas/consSitCTeTiposBasico_v4.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2008 (http://www.altova.com) by [email protected] (PROCERGS) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/cte" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/cte" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="tiposGeralCTe_v4.00.xsd"/>
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
<xs:complexType name="TConsSitCTe">
<xs:annotation>
<xs:documentation>Tipo Pedido de Consulta da Situação Atual do Conhecimento de Transporte eletrônico</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xServ" type="TServ" fixed="CONSULTAR">
<xs:annotation>
<xs:documentation>Serviço Solicitado</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="chCTe" type="TChDFe">
<xs:annotation>
<xs:documentation>Chaves de acesso da CT-e</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="versao" use="required">
<xs:simpleType>
<xs:restriction base="TVerConsSitCTe"/>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="TRetConsSitCTe">
<xs:annotation>
<xs:documentation>Tipo Retorno de Pedido de Consulta da Situação Atual do Conhecimento de Transporte eletrônico</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="verAplic" type="TVerAplic">
<xs:annotation>
<xs:documentation>Versão do Aplicativo que processou o CT-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cStat" type="TStat">
<xs:annotation>
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xMotivo" type="TMotivo">
<xs:annotation>
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cUF" type="TCodUfIBGE">
<xs:annotation>
<xs:documentation>código da UF de atendimento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="protCTe" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:any processContents="skip">
<xs:annotation>
<xs:documentation>Retornar protCTe da versão correspondente do CT-e autorizado</xs:documentation>
</xs:annotation>
</xs:any>
</xs:sequence>
<xs:attribute name="versao" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="1.03"/>
<xs:enumeration value="1.04"/>
<xs:enumeration value="2.00"/>
<xs:enumeration value="3.00"/>
<xs:enumeration value="4.00"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="procEventoCTe" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:any>
<xs:annotation>
<xs:documentation>Retornar procEventoCTe da versão correspondente do evento CT-e autorizado</xs:documentation>
</xs:annotation>
</xs:any>
</xs:sequence>
<xs:attribute name="versao" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="1.04"/>
<xs:enumeration value="2.00"/>
<xs:enumeration value="3.00"/>
<xs:enumeration value="4.00"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="versao" type="TVerConsSitCTe" use="required"/>
</xs:complexType>
<xs:simpleType name="TVerConsSitCTe">
<xs:annotation>
<xs:documentation> Tipo Versão do Consulta situação de CT-e - 4.00</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="4\.00"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
10 changes: 10 additions & 0 deletions CTe.AppTeste/schemas/consSitCTe_v4.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2008 (http://www.altova.com) by [email protected] (PROCERGS) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/cte" targetNamespace="http://www.portalfiscal.inf.br/cte" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="consSitCTeTiposBasico_v4.00.xsd"/>
<xs:element name="consSitCTe" type="TConsSitCTe">
<xs:annotation>
<xs:documentation>Schema de validação XML dp Pedido de Consulta da Situação Atual do CT-e.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
Loading
Loading