Skip to content

Commit

Permalink
Integrar ajustes do fork andre_bts para MDFe no repositório original …
Browse files Browse the repository at this point in the history
…da biblioteca DFe.NET (#1519)

* Removido modificador static das propriedades de MDFeConfiguracao e implementado singleton na mesma;
* Implementado INotifyPropertyChanged em MDFeConfiguracao;
* Adicionado parametro opcional do tipo MDFeConfiguracao a classes do pacote MDFe que utilizam valores de MDFeConfiguracao como EventoCancelar, EventoEncerramento, EventoInclusaoCondutor, EventoInclusaoDFe, EventoPagamentoOperacao, ServicoMDFeEvento, ServicoMDFeRecepcao, ServicoMDFeRetRecepcao, ServicoMDFeStatusServico, etc;
* Renomeadas propriedades e classes afim de manter compatibilidade do estilo utilizado no pacote MDFe;
* Corrigido typo em namespace "Extencoes" para "Extensoes";
* Adicionado tratamento para obtenção do valor do campo dhIniViagem em MDFeIde a depender da versão do leiaute;
* Alterada versão do leiaute específico para o Modal (VersaoModal) no construtor de MDFeInfModal da versão 1.00 para a versão 3.00;
* Movida classe infViagens dentro de evPagtoOperMDFe.cs para a classe MDFeInfViagens em arquivo separado
* Ajustado campo UF de MDFeVeicTracao para permitir valores nulos conforme Nota Tecnica 2021.001
* Adicionados campos de margem em ConfiguracaoDamdfe;
* Adicionado tratamento para set da propriedade ProxyUF quando o valor informado for vazio ou nulo.
  • Loading branch information
andrebts authored and Valmir-Cunha committed Jul 4, 2024
1 parent 54ec211 commit 91d31e5
Show file tree
Hide file tree
Showing 144 changed files with 2,367 additions and 1,042 deletions.
2 changes: 1 addition & 1 deletion CTe.Servicos/ConsultaProtocolo/ConsultaProtcoloServico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
using CTe.Classes;
using CTe.Classes.Servicos.Consulta;
using CTe.Servicos.Factory;
using CTe.Utils.Extencoes;
using CTe.Utils.Extensoes;

namespace CTe.Servicos.ConsultaProtocolo
{
Expand Down
2 changes: 1 addition & 1 deletion CTe.Servicos/ConsultaRecibo/ConsultaReciboServico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
using CTe.Classes;
using CTe.Classes.Servicos.Recepcao.Retorno;
using CTe.Servicos.Factory;
using CTe.Utils.Extencoes;
using CTe.Utils.Extensoes;

namespace CTe.Servicos.ConsultaRecibo
{
Expand Down
2 changes: 1 addition & 1 deletion CTe.Servicos/ConsultaStatus/StatusServico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
using CTe.Classes;
using CTe.Classes.Servicos.Status;
using CTe.Servicos.Factory;
using CTe.Utils.Extencoes;
using CTe.Utils.Extensoes;

namespace CTe.Servicos.ConsultaStatus
{
Expand Down
2 changes: 1 addition & 1 deletion CTe.Servicos/Inutilizacao/InutilizacaoServico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
using CTe.Classes;
using CTe.Classes.Servicos.Inutilizacao;
using CTe.Servicos.Factory;
using CTe.Utils.Extencoes;
using CTe.Utils.Extensoes;
using CTe.Utils.Inutilizacao;
using DFe.Classes.Flags;

Expand Down
2 changes: 1 addition & 1 deletion CTe.Utils/Evento/Extevento.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
using CTe.Classes;
using CTe.Classes.Servicos.Evento;
using CTe.Classes.Servicos.Tipos;
using CTe.Utils.Extencoes;
using CTe.Utils.Extensoes;
using CTe.Utils.Validacao;
using DFe.Utils;
using DFe.Utils.Assinatura;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
using CTe.Utils.Validacao;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtConsReciCTe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
using CTe.Utils.Validacao;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtconsSitCTe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
using CTe.Utils.Validacao;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtconsStatServCte
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
using CTe.Classes.Servicos.Evento;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtevCCeCTe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
using CTe.Classes.Servicos.Evento;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtevCancCTe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
using CTe.Classes.Servicos.Evento;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtevPrestDesacordo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
using DFe.Utils;
using DFe.Utils.Assinatura;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtinutCTe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
using CTe.Classes.Servicos.Consulta;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtretConsSitCTe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
using CTe.Classes.Servicos.Status;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtretConsStatServ
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
using CTe.Classes.Servicos.Status;
using DFe.Utils;

namespace CTe.Utils.Extencoes
namespace CTe.Utils.Extensoes
{
public static class ExtretConsStatServCte
{
Expand Down
19 changes: 12 additions & 7 deletions DFe.Utils/ChaveFiscal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@ public static DadosChaveFiscal ObterChave(Estado ufEmitente, DateTimeOffset data
{
var chave = new StringBuilder();

if (cnpjEmitente.Length < 14)
{
cnpjEmitente = cnpjEmitente.PadLeft(14, '0');
}

chave.Append(((int)ufEmitente).ToString("D2"))
.Append(dataEmissao.ToString("yyMM"))
.Append(cnpjEmitente)
.Append(((int)modelo).ToString("D2"))
.Append(serie.ToString("D3"))
.Append(numero.ToString("D9"))
.Append(tipoEmissao.ToString())
.Append(cNf.ToString("D8"));
.Append(dataEmissao.ToString("yyMM"))
.Append(cnpjEmitente)
.Append(((int)modelo).ToString("D2"))
.Append(serie.ToString("D3"))
.Append(numero.ToString("D9"))
.Append(tipoEmissao.ToString())
.Append(cNf.ToString("D8"));

var digitoVerificador = ObterDigitoVerificador(chave.ToString());

Expand Down
2 changes: 1 addition & 1 deletion DFe.Utils/StringExtencoes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Shared.DFe.Utils
{
public static class StringExtencoes
public static class StringExtensoes
{
public static string RemoverAcentos(this string valor)
{
Expand Down
75 changes: 38 additions & 37 deletions MDFe.AppTeste/MDFeTesteModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
/* http://www.zeusautomacao.com.br/ */
/* Rua Comendador Francisco josé da Cunha, 111 - Itabaiana - SE - 49500-000 */
/********************************************************************************/

using DFe.Classes.Entidades;
using DFe.Classes.Flags;
using DFe.Utils;
using MDFe.AppTeste.Dao;
using MDFe.AppTeste.Entidades;
using MDFe.AppTeste.ModelBase;
using MDFe.Classes.Extencoes;
using MDFe.Classes.Extensoes;
using MDFe.Classes.Flags;
using MDFe.Classes.Informacoes;
using MDFe.Classes.Informacoes.Evento.CorpoEvento;
Expand Down Expand Up @@ -612,7 +613,7 @@ public void CriarEnviar()
#endregion dados emitente (emit)

#region modal
if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao100)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao100)
{
mdfe.InfMDFe.InfModal.Modal = new MDFeRodo
{
Expand Down Expand Up @@ -640,16 +641,16 @@ public void CriarEnviar()
}


if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
{
mdfe.InfMDFe.InfModal.Modal = new MDFeRodo
{
infANTT = new MDFeInfANTT
InfANTT = new MDFeInfANTT
{
RNTRC = config.Empresa.RNTRC,

// não é obrigatorio
infCIOT = new List<infCIOT>
InfCIOT = new List<infCIOT>
{
new infCIOT
{
Expand Down Expand Up @@ -692,7 +693,7 @@ public void CriarEnviar()
TpCar = MDFeTpCar.NaoAplicavel
},

lacRodo = new List<MDFeLacre>
LacRodo = new List<MDFeLacre>
{
new MDFeLacre
{
Expand Down Expand Up @@ -722,7 +723,7 @@ public void CriarEnviar()
};


if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
{
mdfe.InfMDFe.InfDoc.InfMunDescarga[0].InfCTe[0].Peri = new List<MDFePeri>
{
Expand All @@ -738,7 +739,7 @@ public void CriarEnviar()

#region seg

if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
{
mdfe.InfMDFe.Seg = new List<MDFeSeg>();

Expand Down Expand Up @@ -766,19 +767,19 @@ public void CriarEnviar()

#region Produto Predominante

if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
{
mdfe.InfMDFe.prodPred = new prodPred
mdfe.InfMDFe.ProdPred = new MDFeProdPred
{
tpCarga = tpCarga.CargaGeral,
xProd = "aaaaaaaaaaaaaaaaaaaaa",
infLotacao = new infLotacao
TpCarga = MDFeTpCarga.CargaGeral,
XProd = "aaaaaaaaaaaaaaaaaaaaa",
InfLotacao = new MDFeInfLotacao
{
infLocalCarrega = new infLocalCarrega
InfLocalCarrega = new MDFeInfLocalCarrega
{
CEP = "75950000"
},
infLocalDescarrega = new infLocalDescarrega
InfLocalDescarrega = new MDFeInfLocalDescarrega
{
CEP = "75950000"
}
Expand All @@ -804,12 +805,12 @@ public void CriarEnviar()

#region dados responsavel tecnico

mdfe.InfMDFe.infRespTec = new infRespTec
mdfe.InfMDFe.InfRespTec = new MDFeInfRespTec
{
CNPJ = "21025760000123",
email = "robertoalvespereira18@gmail.com",
fone = "64981081602",
xContato = "roberto alves"
Email = "robertoalvespereira18@gmail.com",
Fone = "64981081602",
XContato = "roberto alves"
};
#endregion

Expand Down Expand Up @@ -898,7 +899,7 @@ public void GerarESalvar()
#endregion dados emitente (emit)

#region modal
if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao100)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao100)
{
mdfe.InfMDFe.InfModal.VersaoModal = MDFeVersaoModal.Versao100;
mdfe.InfMDFe.InfModal.Modal = new MDFeRodo
Expand Down Expand Up @@ -927,25 +928,25 @@ public void GerarESalvar()
}


if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
{
mdfe.InfMDFe.InfModal.VersaoModal = MDFeVersaoModal.Versao300;
mdfe.InfMDFe.InfModal.Modal = new MDFeRodo
{
infANTT = new MDFeInfANTT
InfANTT = new MDFeInfANTT
{
RNTRC = config.Empresa.RNTRC,

// não é obrigatorio
infCIOT = new List<infCIOT>
InfCIOT = new List<infCIOT>
{
new infCIOT
{
CIOT = "123456789123",
CNPJ = "21025760000123"
}
},
valePed = new MDFeValePed
ValePed = new MDFeValePed
{
Disp = new List<MDFeDisp>
{
Expand All @@ -954,7 +955,7 @@ public void GerarESalvar()
CNPJForn = "21025760000123",
CNPJPg = "21025760000123",
NCompra = "838388383",
vValePed = 100.33m
VValePed = 100.33m
}
}
}
Expand All @@ -980,7 +981,7 @@ public void GerarESalvar()
TpCar = MDFeTpCar.NaoAplicavel
},

lacRodo = new List<MDFeLacre>
LacRodo = new List<MDFeLacre>
{
new MDFeLacre
{
Expand Down Expand Up @@ -1011,7 +1012,7 @@ public void GerarESalvar()
};


if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
{
mdfe.InfMDFe.InfDoc.InfMunDescarga[0].InfCTe[0].Peri = new List<MDFePeri>
{
Expand All @@ -1027,7 +1028,7 @@ public void GerarESalvar()

#region seg

if (MDFeConfiguracao.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
if (MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout == VersaoServico.Versao300)
{
mdfe.InfMDFe.Seg = new List<MDFeSeg>();

Expand Down Expand Up @@ -1379,17 +1380,17 @@ private static void CarregarConfiguracoesMDFe(Configuracao config)
ManterDadosEmCache = config.CertificadoDigital.ManterEmCache,
};

MDFeConfiguracao.ConfiguracaoCertificado = configuracaoCertificado;
MDFeConfiguracao.CaminhoSchemas = config.ConfigWebService.CaminhoSchemas;
MDFeConfiguracao.CaminhoSalvarXml = config.DiretorioSalvarXml;
MDFeConfiguracao.IsSalvarXml = config.IsSalvarXml;
MDFeConfiguracao.Instancia.ConfiguracaoCertificado = configuracaoCertificado;
MDFeConfiguracao.Instancia.CaminhoSchemas = config.ConfigWebService.CaminhoSchemas;
MDFeConfiguracao.Instancia.CaminhoSalvarXml = config.DiretorioSalvarXml;
MDFeConfiguracao.Instancia.IsSalvarXml = config.IsSalvarXml;

MDFeConfiguracao.VersaoWebService.VersaoLayout = config.ConfigWebService.VersaoLayout;
MDFeConfiguracao.Instancia.VersaoWebService.VersaoLayout = config.ConfigWebService.VersaoLayout;

MDFeConfiguracao.VersaoWebService.TipoAmbiente = config.ConfigWebService.Ambiente;
MDFeConfiguracao.VersaoWebService.UfEmitente = config.ConfigWebService.UfEmitente;
MDFeConfiguracao.VersaoWebService.TimeOut = config.ConfigWebService.TimeOut;
MDFeConfiguracao.IsAdicionaQrCode = true;
MDFeConfiguracao.Instancia.VersaoWebService.TipoAmbiente = config.ConfigWebService.Ambiente;
MDFeConfiguracao.Instancia.VersaoWebService.UfEmitente = config.ConfigWebService.UfEmitente;
MDFeConfiguracao.Instancia.VersaoWebService.TimeOut = config.ConfigWebService.TimeOut;
MDFeConfiguracao.Instancia.IsAdicionaQrCode = true;
}

protected virtual void OnSucessoSync(RetornoEEnvio e)
Expand Down
Loading

0 comments on commit 91d31e5

Please sign in to comment.