diff --git a/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobr.cs b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobr.cs new file mode 100644 index 000000000..528bc808e --- /dev/null +++ b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobr.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Xml.Serialization; +using System; +using CTe.CTeOSDocumento.CTe.CTeOS.Informacoes.InfCTeNormal.cobrancas; + +namespace CTe.CTeOSDocumento.CTe.CTeOS.Informacoes.InfCTeNormal +{ + [Serializable] + public class cobr + { + [XmlElement("fat", Order = 1)] + public fat fat { get; set; } + + [XmlElement("dup", Order = 2)] + public List dup; + } +} \ No newline at end of file diff --git a/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobrancas/dup.cs b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobrancas/dup.cs new file mode 100644 index 000000000..fb09d57e4 --- /dev/null +++ b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobrancas/dup.cs @@ -0,0 +1,36 @@ +using System; +using System.Xml.Serialization; +using DFe.Classes; +using DFe.Utils; + +namespace CTe.CTeOSDocumento.CTe.CTeOS.Informacoes.InfCTeNormal.cobrancas +{ + public class dup + { + private decimal? _vDup; + public string nDup { get; set; } + + [XmlIgnore] + public DateTime? dVenc { get; set; } + + [XmlElement(ElementName = "dVenc")] + public string ProxydVenc + { + get + { + if (dVenc == null) return null; + + return dVenc.Value.ParaDataString(); + } + set { dVenc = Convert.ToDateTime(value); } + } + + public decimal? vDup + { + get { return _vDup.Arredondar(2); } + set { _vDup = value.Arredondar(2); } + } + + public bool vDupSpecified { get { return vDup.HasValue; } } + } +} \ No newline at end of file diff --git a/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobrancas/fat.cs b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobrancas/fat.cs new file mode 100644 index 000000000..077921f91 --- /dev/null +++ b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/cobrancas/fat.cs @@ -0,0 +1,35 @@ +using DFe.Classes; + +namespace CTe.CTeOSDocumento.CTe.CTeOS.Informacoes.InfCTeNormal.cobrancas +{ + public class fat + { + private decimal? _vOrig; + private decimal? _vDesc; + private decimal? _vLiq; + public string nFat { get; set; } + + public decimal? vOrig + { + get { return _vOrig.Arredondar(2); } + set { _vOrig = value.Arredondar(2); } + } + + public decimal? vDesc + { + get { return _vDesc.Arredondar(2); } + set { _vDesc = value.Arredondar(2); } + } + + public decimal? vLiq + { + get { return _vLiq.Arredondar(2); } + set { _vLiq = value.Arredondar(2); } + } + + + public bool vOrigSpecified { get { return vOrig.HasValue; } } + public bool vDescSpecified { get { return vDesc.HasValue; } } + public bool vLiqSpecified { get { return vLiq.HasValue; } } + } +} \ No newline at end of file diff --git a/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/infCTeNormOs.cs b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/infCTeNormOs.cs index 298b1e2b5..5af2ef283 100644 --- a/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/infCTeNormOs.cs +++ b/CTe.Classes/CTeOutrosServicos/Informacoes/InfCTeOutrosServicosNormal/infCTeNormOs.cs @@ -19,5 +19,8 @@ public class infCTeNormOs [XmlElement("infCteSub")] public infCteSubOs infCteSub { get; set; } + + [XmlElement("cobr")] + public cobr cobr { get; set; } } } \ No newline at end of file diff --git a/CTe.Classes/Informacoes/Tipos/tpCTe.cs b/CTe.Classes/Informacoes/Tipos/tpCTe.cs index 74ab411ed..25e6f4e4e 100644 --- a/CTe.Classes/Informacoes/Tipos/tpCTe.cs +++ b/CTe.Classes/Informacoes/Tipos/tpCTe.cs @@ -35,7 +35,7 @@ namespace CTe.Classes.Informacoes.Tipos { /// - /// Tipo do Documento Fiscal (0 - CT-e Normal; 1 - CT-e de Complemento de Valores; 2 - CT-e de Anulação; 3 - CT-e Substituto) + /// Tipo do Documento Fiscal (0 - CT-e Normal; 1 - CT-e de Complemento de Valores; 2 - CT-e de Anulação; 3 - CT-e Substituto; 5 - Simplificado; 6 - Substitudo Simplificado) /// public enum tpCTe { @@ -46,6 +46,10 @@ public enum tpCTe [XmlEnum("2")] Anulacao, [XmlEnum("3")] - Substituto + Substituto, + [XmlEnum("5")] + Simplificado, + [XmlEnum("6")] + SubstitutoSimplificado } } \ No newline at end of file diff --git a/CTe.Classes/Simplificado/Carga/comp.cs b/CTe.Classes/Simplificado/Carga/comp.cs new file mode 100644 index 000000000..e2a190422 --- /dev/null +++ b/CTe.Classes/Simplificado/Carga/comp.cs @@ -0,0 +1,22 @@ +using System.Xml.Serialization; + +namespace CTe.Classes.Simplificado.Carga +{ + /// + /// Componente do valor da prestação. + /// + public class comp + { + /// + /// Nome do componente (ex: "Frete Valor", "Vr Icms"). + /// + [XmlElement(ElementName = "xNome")] + public string xNome { get; set; } + + /// + /// Valor do componente. + /// + [XmlElement(ElementName = "vComp")] + public decimal vComp { get; set; } + } +} diff --git a/CTe.Classes/Simplificado/Carga/det.cs b/CTe.Classes/Simplificado/Carga/det.cs new file mode 100644 index 000000000..e3fc85556 --- /dev/null +++ b/CTe.Classes/Simplificado/Carga/det.cs @@ -0,0 +1,66 @@ +using CTe.Classes.Simplificado.Informacoes; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace CTe.Classes.Simplificado.Carga +{ + /// + /// Detalhamento de cada entrega/prestação do CT-e Simplificado. + /// + public class det + { + /// + /// Número do item na lista de detalhamento. + /// + [XmlAttribute(AttributeName = "nItem")] + public int nItem { get; set; } + + /// + /// Código do Município de início da prestação (IBGE). + /// + [XmlElement(ElementName = "cMunIni")] + public int cMunIni { get; set; } + + /// + /// Nome do Município do início da prestação. + /// + [XmlElement(ElementName = "xMunIni")] + public string xMunIni { get; set; } + + /// + /// Código do Município de término da prestação (IBGE). + /// + [XmlElement(ElementName = "cMunFim")] + public int cMunFim { get; set; } + + /// + /// Nome do Município do término da prestação. + /// + [XmlElement(ElementName = "xMunFim")] + public string xMunFim { get; set; } + + /// + /// Valor da Prestação do Serviço. + /// + [XmlElement(ElementName = "vPrest")] + public decimal vPrest { get; set; } + + /// + /// Valor a Receber. + /// + [XmlElement(ElementName = "vRec")] + public decimal vRec { get; set; } + + /// + /// Componentes do valor da prestação. + /// + [XmlElement(ElementName = "Comp")] + public List Comp { get; set; } + + /// + /// Informações das NF-e vinculadas à entrega. + /// + [XmlElement(ElementName = "infNFe")] + public List infNFe { get; set; } + } +} diff --git a/CTe.Classes/Simplificado/Carga/infCarga.cs b/CTe.Classes/Simplificado/Carga/infCarga.cs new file mode 100644 index 000000000..263202581 --- /dev/null +++ b/CTe.Classes/Simplificado/Carga/infCarga.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace CTe.Classes.Simplificado.Carga +{ + /// + /// Informações da carga do CT-e. + /// + public class infCarga + { + /// + /// Valor total da carga. + /// + [XmlElement(ElementName = "vCarga")] + public decimal vCarga { get; set; } + + /// + /// Produto predominante. + /// + [XmlElement(ElementName = "proPred")] + public string proPred { get; set; } + + /// + /// Detalhamento dos itens da carga. + /// + [XmlElement(ElementName = "det")] + public List det { get; set; } + } +} diff --git a/CTe.Classes/Simplificado/Informacoes/infCte.cs b/CTe.Classes/Simplificado/Informacoes/infCte.cs new file mode 100644 index 000000000..23b96646b --- /dev/null +++ b/CTe.Classes/Simplificado/Informacoes/infCte.cs @@ -0,0 +1,273 @@ +using CTe.Classes.Simplificado.Carga; +using DFe.Utils; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace CTe.Classes.Simplificado.Informacoes +{ + /// + /// Informações do CT-e. + /// + public class infCte + { + /// + /// Código da UF do emitente do CT-e. Utilizar a Tabela do IBGE. + /// + [XmlElement(ElementName = "cUF")] + public int cUf { get; set; } + + /// + /// Código numérico que compõe a Chave de Acesso. + /// Número aleatório gerado pelo emitente para cada CT-e, com o objetivo de evitar acessos indevidos ao documento. + /// + [XmlElement(ElementName = "cCT")] + public string cCt { get; set; } + + /// + /// Código Fiscal de Operações e Prestações. + /// + [XmlElement(ElementName = "CFOP")] + public string cfop { get; set; } + + /// + /// Natureza da Operação. + /// + [XmlElement(ElementName = "natOp")] + public string natOp { get; set; } + + /// + /// Modelo do documento fiscal. Utilizar o código 57 para identificação do CT-e. + /// + [XmlElement(ElementName = "mod")] + public int mod { get; set; } + + /// + /// Série do CT-e. Preencher com "0" no caso de série única. + /// + [XmlElement(ElementName = "serie")] + public int serie { get; set; } + + /// + /// Número do CT-e. + /// + [XmlElement(ElementName = "nCT")] + public string nCt { get; set; } + + /// + /// Data e hora de emissão do CT-e. + /// + [XmlIgnore] + public DateTimeOffset? dhEmi { get; set; } + + /// + /// Data e hora de emissão do CT-e. Formato AAAA-MM-DDTHH:MM:DD TZD. + /// + [XmlElement(ElementName = "dhEmi")] + public string DhEmi + { + get { return dhEmi.ParaDataHoraStringUtc(); } + set { dhEmi = DateTimeOffset.Parse(value); } + } + + /// + /// Formato de impressão do DACTE. Preencher com: 1 - Retrato; 2 - Paisagem. + /// + [XmlElement(ElementName = "tpImp")] + public int tpImp { get; set; } + + /// + /// Forma de emissão do CT-e. + /// + [XmlElement(ElementName = "tpEmis")] + public int tpEmis { get; set; } + + /// + /// Dígito Verificador da chave de acesso do CT-e. + /// + [XmlElement(ElementName = "cDV")] + public int cDv { get; set; } + + /// + /// Tipo do Ambiente. Preencher com: 1 - Produção; 2 - Homologação. + /// + [XmlElement(ElementName = "tpAmb")] + public int tpAmb { get; set; } + + /// + /// Tipo do CT-e Simplificado. Preencher com: + /// 5 - CTe Simplificado; + /// 6 - Substituição CTe Simplificado. + /// + [XmlElement(ElementName = "tpCTe")] + public int tpCte { get; set; } + + /// + /// Identificador do processo de emissão do CT-e. + /// + [XmlElement(ElementName = "procEmi")] + public int procEmi { get; set; } + + /// + /// Versão do processo de emissão. + /// + [XmlElement(ElementName = "verProc")] + public string verProc { get; set; } + + /// + /// Código do Município de envio do CT-e (de onde o documento foi transmitido). Utilizar a tabela do IBGE. + /// + [XmlElement(ElementName = "cMunEnv")] + public int cMunEnv { get; set; } + + /// + /// Nome do Município de envio do CT-e (de onde o documento foi transmitido). + /// + [XmlElement(ElementName = "xMunEnv")] + public string xMunEnv { get; set; } + + /// + /// Sigla da UF de envio do CT-e (de onde o documento foi transmitido). + /// + [XmlElement(ElementName = "UFEnv")] + public string ufEnv { get; set; } + + /// + /// Modal. Preencher com: + /// 01-Rodoviário; + /// 02-Aéreo; + /// 03-Aquaviário. + /// + [XmlElement(ElementName = "modal")] + public string modal { get; set; } + + /// + /// Tipo do Serviço. Preencher com: + /// 0 - Normal; + /// 1 - Subcontratação; + /// 2 - Redespacho. + /// + [XmlElement(ElementName = "tpServ")] + public int tpServ { get; set; } + + /// + /// UF do início da prestação. + /// + [XmlElement(ElementName = "UFIni")] + public string ufIni { get; set; } + + /// + /// UF do término da prestação. + /// + [XmlElement(ElementName = "UFFim")] + public string ufFim { get; set; } + + /// + /// Indicador se o Recebedor retira no Aeroporto, Filial, Porto ou Estação de Destino. + /// Preencher com: 0 - sim; 1 - não. + /// + [XmlElement(ElementName = "retira")] + public int retira { get; set; } + + /// + /// Detalhes do retira. + /// + [XmlElement(ElementName = "detRetira")] + public string detRetira { get; set; } + + /// + /// Data e Hora da entrada em contingência. + /// + [XmlIgnore] + public DateTimeOffset? dhCont { get; set; } + + /// + /// Data e Hora da entrada em contingência. Formato AAAA-MM-DDTHH:MM:SS. + /// + [XmlElement(ElementName = "dhCont")] + public string DhCont + { + get { return dhCont.ParaDataHoraStringUtc(); } + set { dhCont = DateTimeOffset.Parse(value); } + } + + /// + /// Justificativa da entrada em contingência. + /// + [XmlElement(ElementName = "xJust")] + public string xJust { get; set; } + + /// + /// Característica adicional do transporte. + /// + [XmlElement(ElementName = "caracAd")] + public string caracAd { get; set; } + + /// + /// Característica adicional do serviço. + /// + [XmlElement(ElementName = "caracSer")] + public string caracSer { get; set; } + + /// + /// Detalhamento das entregas/prestações do CT-e Simplificado. + /// + [XmlElement(ElementName = "detEntrega")] + public List detEntrega { get; set; } + + + /// + /// Detalhamento das entregas/prestações do CT-e Simplificado. + /// + [XmlElement(ElementName = "det")] + public List det { get; set; } + + /// + /// Informações da carga do CT-e. + /// + [XmlElement(ElementName = "infCarga")] + public infCarga infCarga { get; set; } + } + + /// + /// Detalhamento das entregas/prestações do CT-e Simplificado. + /// + public class DetEntrega + { + /// + /// Código do Município de início da prestação. Utilizar a tabela do IBGE. + /// + [XmlElement(ElementName = "cMunIni")] + public int cMunIni { get; set; } + + /// + /// Nome do Município do início da prestação. + /// + [XmlElement(ElementName = "xMunIni")] + public string xMunIni { get; set; } + + /// + /// Código do Município de término da prestação. Utilizar a tabela do IBGE. + /// + [XmlElement(ElementName = "cMunFim")] + public int cMunFim { get; set; } + + /// + /// Nome do Município do término da prestação. + /// + [XmlElement(ElementName = "xMunFim")] + public string xMunFim { get; set; } + + /// + /// Valor da Prestação do Serviço. + /// + [XmlElement(ElementName = "vPrest")] + public decimal vPrest { get; set; } + + /// + /// Valor a Receber. + /// + [XmlElement(ElementName = "vRec")] + public decimal vRec { get; set; } + } +} diff --git a/CTe.Classes/Simplificado/Informacoes/infNFe.cs b/CTe.Classes/Simplificado/Informacoes/infNFe.cs new file mode 100644 index 000000000..38de8c6a1 --- /dev/null +++ b/CTe.Classes/Simplificado/Informacoes/infNFe.cs @@ -0,0 +1,33 @@ +using System; +using System.Xml.Serialization; + +namespace CTe.Classes.Simplificado.Informacoes +{ + /// + /// Informações da NF-e vinculada à entrega. + /// + public class infNFe + { + /// + /// Chave de acesso da NF-e. + /// + [XmlElement(ElementName = "chNFe")] + public string chNFe { get; set; } + + /// + /// Data prevista de entrega. + /// + [XmlIgnore] + public DateTimeOffset? dPrev { get; set; } + + /// + /// Data prevista de entrega (formato AAAA-MM-DD). + /// + [XmlElement(ElementName = "dPrev")] + public string DPrev + { + get { return dPrev?.ToString("yyyy-MM-dd"); } + set { dPrev = DateTimeOffset.Parse(value); } + } + } +} diff --git a/CTe.Classes/Simplificado/cteSimp.cs b/CTe.Classes/Simplificado/cteSimp.cs new file mode 100644 index 000000000..6b80ebfe9 --- /dev/null +++ b/CTe.Classes/Simplificado/cteSimp.cs @@ -0,0 +1,30 @@ +using CTe.Classes.Simplificado.Informacoes; +using System.Xml.Serialization; + +namespace CTe.Classes.Simplificado +{ + /// + /// Tipo Conhecimento de Transporte Eletrônico (Modelo 57) - Modelo Simplificado + /// + [XmlRoot("CTeSimp", Namespace = "http://www.portalfiscal.inf.br/cte")] + public class cteSimp + { + /// + /// Informações do CT-e + /// + [XmlElement("infCte")] + public infCte infCte { get; set; } + + /// + /// Versão do leiaute + /// + [XmlAttribute("versao")] + public string versao { get; set; } + + /// + /// Identificador da tag a ser assinada + /// + [XmlAttribute("Id")] + public string id { get; set; } + } +} diff --git a/CTe.Classes/cteSimpProc.cs b/CTe.Classes/cteSimpProc.cs new file mode 100644 index 000000000..e290cd05c --- /dev/null +++ b/CTe.Classes/cteSimpProc.cs @@ -0,0 +1,69 @@ +using CTe.Classes.Protocolo; +using CTe.Classes.Simplificado; +using DFe.Utils; +using System; +using System.Xml.Serialization; + +namespace CTe.Classes +{ + /// + /// CT-e Simplificado processado + /// + [XmlRoot("cteSimpProc", Namespace = "http://www.portalfiscal.inf.br/cte")] + public class cteSimpProc + { + /// + /// Representa o CT-e Simplificado + /// + [XmlElement("CTeSimp")] + public cteSimp cteSimp { get; set; } + + /// + /// Representa o protocolo do CT-e + /// + [XmlElement("protCTe")] + public protCTe protCTe { get; set; } + + /// + /// Versão do CT-e + /// + [XmlAttribute("versao")] + public string versao { get; set; } + + /// + /// IP do transmissor do documento fiscal para o ambiente autorizador + /// + [XmlAttribute("ipTransmissor")] + public string ipTransmissor { get; set; } + + /// + /// Porta de origem utilizada na conexão (De 0 a 65535) + /// + [XmlAttribute("nPortaCon")] + public string nPortaCon { get; set; } + + + [XmlIgnore] + public DateTimeOffset? dhConexao { get; set; } + + /// + /// Data e Hora da Conexão de Origem + /// + [XmlElement(ElementName = "dhConexao")] + public string DhConexao + { + get { return dhConexao.ParaDataHoraStringUtc(); } + set { dhConexao = DateTimeOffset.Parse(value); } + } + + public static cteSimpProc LoadXmlString(string xml) + { + return FuncoesXml.XmlStringParaClasse(xml); + } + + public static cteSimpProc LoadXmlArquivo(string caminhoArquivoXml) + { + return FuncoesXml.ArquivoXmlParaClasse(caminhoArquivoXml); + } + } +} diff --git a/NFe.Classes/Informacoes/Agropecuario/agropecuario.cs b/NFe.Classes/Informacoes/Agropecuario/agropecuario.cs index 367f3e09a..d5a311bb4 100644 --- a/NFe.Classes/Informacoes/Agropecuario/agropecuario.cs +++ b/NFe.Classes/Informacoes/Agropecuario/agropecuario.cs @@ -1,4 +1,7 @@ -namespace NFe.Classes.Informacoes.Agropecuario +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace NFe.Classes.Informacoes.Agropecuario { public class agropecuario { @@ -7,34 +10,34 @@ public class agropecuario #nullable enable /// - /// ZF02 - serieGuia + /// ZF02 - Defensivos Agrícolas /// - public defensivo? defensivo { get; set; } + [XmlElement("defensivo")] + public List? defensivo { get; set; } /// /// ZF04 - Guia de Trânsito /// + [XmlElement("guiaTransito")] public guiaTransito? guiaTransito { get; set; } #nullable disable - public bool ShouldSerializedefensivo() - { - return defensivo != null; - } public bool ShouldSerializeguiaTransito() { return guiaTransito != null; } #else /// - /// ZF02 - serieGuia + /// ZF02 - Defensivos Agrícolas /// - public defensivo defensivo { get; set; } + [XmlElement("defensivo")] + public List defensivo { get; set; } /// /// ZF04 - Guia de Trânsito /// + [XmlElement("guiaTransito")] public guiaTransito guiaTransito { get; set; } #endif } diff --git a/NFe.Classes/Informacoes/Detalhe/Tributacao/Extensions.cs b/NFe.Classes/Informacoes/Detalhe/Tributacao/Extensions.cs index d44b8c242..2b9e1f412 100644 --- a/NFe.Classes/Informacoes/Detalhe/Tributacao/Extensions.cs +++ b/NFe.Classes/Informacoes/Detalhe/Tributacao/Extensions.cs @@ -47,6 +47,11 @@ public static decimal GetIcmsValue(this ICMSBasico icms) return GetPropDecimalValue(icms, "vICMS"); } + public static decimal GetIcmsStValue(this ICMSBasico icms) + { + return GetPropDecimalValue(icms, "vICMSST"); + } + public static decimal GetIpiPercent(this IPIBasico ipi) { return GetPropDecimalValue(ipi, "pIPI"); diff --git a/NFe.Classes/Informacoes/Pagamento/pagTipos.cs b/NFe.Classes/Informacoes/Pagamento/pagTipos.cs index fb83aeb7c..430c798b8 100644 --- a/NFe.Classes/Informacoes/Pagamento/pagTipos.cs +++ b/NFe.Classes/Informacoes/Pagamento/pagTipos.cs @@ -146,7 +146,7 @@ public enum FormaPagamento /// 16 - Depósito Bancário /// [Description("=Depósito Bancário")] - [XmlEnum("16")] fpDepositoBancario= 16, + [XmlEnum("16")] fpDepositoBancario = 16, /// /// 17 - Pagamento Instantâneo (PIX) dinâmico diff --git a/NFe.Classes/Informacoes/Total/ICMSTot.cs b/NFe.Classes/Informacoes/Total/ICMSTot.cs index 45898cd54..bbdcfdc73 100644 --- a/NFe.Classes/Informacoes/Total/ICMSTot.cs +++ b/NFe.Classes/Informacoes/Total/ICMSTot.cs @@ -49,7 +49,7 @@ public class ICMSTot private decimal _vCofins; private decimal _vOutro; private decimal _vNf; - private decimal _vTotTrib; + private decimal? _vTotTrib; private decimal? _vFcpufDest; private decimal? _vIcmsufDest; private decimal? _vIcmsufRemet; @@ -393,11 +393,15 @@ public decimal vNF /// /// W16a - Valor aproximado total de tributos federais, estaduais e municipais. /// - public decimal vTotTrib + public decimal? vTotTrib { get { return _vTotTrib.Arredondar(2); } set { _vTotTrib = value.Arredondar(2); } } + public bool ShouldSerializevTotTrib() + { + return vTotTrib.HasValue; + } } } \ No newline at end of file diff --git a/NFe.Danfe.Base/NFCe/NFCe.frx b/NFe.Danfe.Base/NFCe/NFCe.frx index 6f59fb368..411252337 100644 --- a/NFe.Danfe.Base/NFCe/NFCe.frx +++ b/NFe.Danfe.Base/NFCe/NFCe.frx @@ -16,7 +16,7 @@ using FastReport.Utils; using NFe.Classes.Informacoes.Pagamento; using NFe.Utils; using DFe.Utils; -using NFe.Classes.Informacoes.Destinatario; +using NFe.Classes.Informacoes.Destinatario; using NFe.Classes.Informacoes.Identificacao.Tipos; using DFe.Classes.Flags; using NFe.Danfe.Base; @@ -28,13 +28,13 @@ namespace FastReport { public class ReportScript { - + private void txtDescPagto_BeforePrint(object sender, EventArgs e) { if(Report.GetColumnValue("NFCe.NFe.infNFe.pag.tPag") != null) - txtDescPagto.Text = ((FormaPagamento)Report.GetColumnValue("NFCe.NFe.infNFe.pag.tPag")).Descricao(); + txtDescPagto.Text = ((FormaPagamento)Report.GetColumnValue("NFCe.NFe.infNFe.pag.tPag")).Descricao(); } - + private void txtDescDetPagto_BeforePrint(object sender, EventArgs e) { if(Report.GetDataSource("NFCe.NFe.infNFe.pag.detPag").RowCount != 0 && Report.GetColumnValue("NFCe.NFe.infNFe.pag.detPag.tPag") != null) @@ -43,75 +43,75 @@ namespace FastReport private void txtEmitCnpj_BeforePrint(object sender, EventArgs e) { - var cnpj = (string)Report.GetColumnValue("NFCe.NFe.infNFe.emit.CNPJ"); + var cnpj = (string)Report.GetColumnValue("NFCe.NFe.infNFe.emit.CNPJ"); if (!string.IsNullOrEmpty(cnpj)) txtEmitCnpj.Text = "CNPJ: " + String.Format(@"{0:00\.000\.000\/0000\-00}", long.Parse(cnpj)); } private void memChaveNfe_BeforePrint(object sender, EventArgs e) - { + { var chave = Substring( ((String)Report.GetColumnValue("NFCe.NFe.infNFe.Id")), 3); if (!string.IsNullOrEmpty(chave) & chave.Length == 44) { var chaveFormatada = ""; - for (int i = 0; i < chave.Length; i += 4) - chaveFormatada = chaveFormatada + chave.Substring(i, 4) + " "; - memChaveNfe.Text = chaveFormatada; - } + for (int i = 0; i < chave.Length; i += 4) + chaveFormatada = chaveFormatada + chave.Substring(i, 4) + " "; + memChaveNfe.Text = chaveFormatada; + } } private void Destinatario_BeforePrint(object sender, EventArgs e) - { + { TrataCamposDestinatario(); dbDestinatario.Visible = ((NfceLayoutQrCode) Report.GetParameterValue("NfceLayoutQrCode") == NfceLayoutQrCode.Abaixo); } - + private void TrataCamposDestinatario(){ if ( ((dest)Report.GetColumnValue("NFCe.NFe.infNFe.dest")) == null ) //Destinatário não informado { txtConsumidor.Text = "CONSUMIDOR NÃO IDENTIFICADO"; - txtConsumidor2.Text = txtConsumidor.Text; + txtConsumidor2.Text = txtConsumidor.Text; txtDestEndereco.Text = ""; txtDestEndereco2.Text = txtDestEndereco.Text; txtDestNome.Text = ""; txtDestNome2.Text = txtDestNome.Text; } else - { + { txtDestNome.Text = ObterDocumentoDest() + ((String)Report.GetColumnValue("NFCe.NFe.infNFe.dest.xNome")); txtDestNome2.Text = txtDestNome.Text; - } + } //Endereço do destinatário é opcional para NFCe - txtDestEndereco.Visible = ((enderDest)Report.GetColumnValue("NFCe.NFe.infNFe.dest.enderDest")) != null; + txtDestEndereco.Visible = ((enderDest)Report.GetColumnValue("NFCe.NFe.infNFe.dest.enderDest")) != null; txtDestEndereco2.Visible = txtDestEndereco.Visible; } - + private string ObterDocumentoDest(){ var documentoDest = ""; var cnpj = (String)Report.GetColumnValue("NFCe.NFe.infNFe.dest.CNPJ"); var cpf = (String)Report.GetColumnValue("NFCe.NFe.infNFe.dest.CPF"); var idEstrangeiro = (String)Report.GetColumnValue("NFCe.NFe.infNFe.dest.idEstrangeiro"); - if ( !String.IsNullOrEmpty(cnpj)) documentoDest = "CNPJ: " + String.Format(@"{0:00\.000\.000\/0000\-00}", long.Parse(cnpj)) + " "; - if ( !String.IsNullOrEmpty(cpf)) documentoDest = "CPF: " + String.Format(@"{0:000\.000\.000\-00}", long.Parse(cpf)) + " "; - if ( !String.IsNullOrEmpty(idEstrangeiro)) documentoDest = "Id. Estrangeiro: " + idEstrangeiro + " "; + if ( !String.IsNullOrEmpty(cnpj)) documentoDest = "CNPJ: " + String.Format(@"{0:00\.000\.000\/0000\-00}", long.Parse(cnpj)) + " "; + if ( !String.IsNullOrEmpty(cpf)) documentoDest = "CPF: " + String.Format(@"{0:000\.000\.000\-00}", long.Parse(cpf)) + " "; + if ( !String.IsNullOrEmpty(idEstrangeiro)) documentoDest = "Id. Estrangeiro: " + idEstrangeiro + " "; return documentoDest; } private void dbProdutosUmaLinha_BeforePrint(object sender, EventArgs e) { //Conforme Manual de Padrões Padrões Técnicos do DANFE-NFC-e e QR Code, página 8. "No caso de emissão em contingência, é obrigatória a impressão do Detalhe da Venda e do DANFE NFC-e" - if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) + if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) dbProdutosUmaLinha.Visible = ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.UmaLinha; else dbProdutosUmaLinha.Visible = ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.UmaLinha; - + //Mostrar/Ocultar desconto concedido no item txtProdutoUmaLinhaValorUnit.Text = "[NFCe.NFe.infNFe.det.prod.vUnCom]"; txtProdutoUmaLinhaValorTotal.Text = "[NFCe.NFe.infNFe.det.prod.vProd]"; dbProdutosUmaLinha.Border.Lines = BorderLines.Bottom; var imprimeDesconto = dbProdutosUmaLinha.Visible & ((Boolean)Report.GetParameterValue("NfceImprimeDescontoItem")) & - ((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.det.prod.vDesc")) > 0; - cbDescontoItemUmaLinha.Visible = imprimeDesconto; + ((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.det.prod.vDesc")) > 0; + cbDescontoItemUmaLinha.Visible = imprimeDesconto; if (imprimeDesconto) dbProdutosUmaLinha.Border.Lines = BorderLines.None; } @@ -119,45 +119,45 @@ namespace FastReport private void ghbProdutosDuasLinhas_BeforePrint(object sender, EventArgs e) { //Conforme Manual de Padrões Padrões Técnicos do DANFE-NFC-e e QR Code, página 8. "No caso de emissão em contingência, é obrigatória a impressão do Detalhe da Venda e do DANFE NFC-e" - if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) - ghbProdutosDuasLinhas.Visible = ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.DuasLinhas || + if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) + ghbProdutosDuasLinhas.Visible = ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.DuasLinhas || ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.Completo; else - ghbProdutosDuasLinhas.Visible = ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.DuasLinhas || + ghbProdutosDuasLinhas.Visible = ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.DuasLinhas || ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.Completo; } - + private void dbProdutosDuasLinhas_BeforePrint(object sender, EventArgs e) { //Conforme Manual de Padrões Padrões Técnicos do DANFE-NFC-e e QR Code, página 8. "No caso de emissão em contingência, é obrigatória a impressão do Detalhe da Venda e do DANFE NFC-e" - if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) - dbProdutosDuasLinhas.Visible = ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.DuasLinhas || + if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) + dbProdutosDuasLinhas.Visible = ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.DuasLinhas || ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.Completo; else - dbProdutosDuasLinhas.Visible = ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.DuasLinhas || - ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.Completo; ; - + dbProdutosDuasLinhas.Visible = ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.DuasLinhas || + ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.Completo; ; + //Mostrar/Ocultar desconto concedido no item txtProdutoDuasLinhasValorUnit.Text = "[NFCe.NFe.infNFe.det.prod.vUnCom]"; txtProdutoDuasLinhasValorTotal.Text = "[NFCe.NFe.infNFe.det.prod.vProd]"; dbProdutosDuasLinhas.Border.Lines = BorderLines.Bottom; var imprimeDesconto = dbProdutosDuasLinhas.Visible & ((Boolean)Report.GetParameterValue("NfceImprimeDescontoItem")) & - ((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.det.prod.vDesc")) > 0; - cbDescontoItemDuasLinhas.Visible = imprimeDesconto; + ((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.det.prod.vDesc")) > 0; + cbDescontoItemDuasLinhas.Visible = imprimeDesconto; if (imprimeDesconto) - dbProdutosDuasLinhas.Border.Lines = BorderLines.None; + dbProdutosDuasLinhas.Border.Lines = BorderLines.None; //Se possuir desconto, e estiver configurado para não exibi-lo, exibe os valores líquidos nos campos abaixo: - if (((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.det.prod.vDesc")) > 0 & !imprimeDesconto) + if (((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.det.prod.vDesc")) > 0 & !imprimeDesconto) { txtProdutoDuasLinhasValorUnit.Text = "[([NFCe.NFe.infNFe.det.prod.vProd] - [NFCe.NFe.infNFe.det.prod.vDesc]) / [NFCe.NFe.infNFe.det.prod.qCom]]"; - txtProdutoDuasLinhasValorTotal.Text = "[[NFCe.NFe.infNFe.det.prod.vProd] - [NFCe.NFe.infNFe.det.prod.vDesc]]"; + txtProdutoDuasLinhasValorTotal.Text = "[[NFCe.NFe.infNFe.det.prod.vProd] - [NFCe.NFe.infNFe.det.prod.vDesc]]"; } - } + } private void ghbProdutosUmaLinha_BeforePrint(object sender, EventArgs e) { //Conforme Manual de Padrões Padrões Técnicos do DANFE-NFC-e e QR Code, página 8. "No caso de emissão em contingência, é obrigatória a impressão do Detalhe da Venda e do DANFE NFC-e" - if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) + if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) ghbProdutosUmaLinha.Visible = ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.UmaLinha; else ghbProdutosUmaLinha.Visible = ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.UmaLinha; @@ -171,8 +171,8 @@ namespace FastReport string msgContigencia = ""; if ( ((TipoAmbiente)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpAmb")) == TipoAmbiente.Homologacao ) msgHomologacao = "EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO – SEM VALOR FISCAL" + Environment.NewLine; - if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) != TipoEmissao.teNormal ) - msgContigencia = "EMITIDA EM CONTINGÊNCIA" + Environment.NewLine; + if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) != TipoEmissao.teNormal ) + msgContigencia = "EMITIDA EM CONTINGÊNCIA" + Environment.NewLine; memMsgFiscal.Text = msgHomologacao + msgContigencia + memMsgFiscal.Text; } @@ -186,41 +186,41 @@ namespace FastReport private void PgNfce_StartPage(object sender, EventArgs e) { phbCancelado.Visible = ((Boolean)Report.GetParameterValue("NfceCancelado")); - - if (!Engine.FinalPass) - return; + + if (!Engine.FinalPass) + return; if ( (NfceModoImpressao) ((Int32)Report.GetParameterValue("NfceModoImpressao")) != NfceModoImpressao.UnicaPagina) - return; - - PgNfce.PaperHeight = - (rtbEmitLogoHeight + - phbEmitenteHeight + + return; + + PgNfce.PaperHeight = + (rtbEmitLogoHeight + + phbEmitenteHeight + ((Boolean)Report.GetParameterValue("NfceCancelado") ? phbCancelado.Height : 0)+ - ghbProdutosUmaLinhaHeight + - dbProdutosUmaLinhaHeight + - ghbProdutosDuasLinhasHeight + - dbProdutosDuasLinhasHeight + + ghbProdutosUmaLinhaHeight + + dbProdutosUmaLinhaHeight + + ghbProdutosDuasLinhasHeight + + dbProdutosDuasLinhasHeight + gfbProdutosHeight + - dbPagamentoHeight + + dbPagamentoHeight + dbDetPagamentoHeight + - dbTributosHeight + - dbObservacaoHeight + - dbInfoFiscalHeight + + dbTributosHeight + + dbObservacaoHeight + + dbInfoFiscalHeight + dbNumeroSerieDhHeight + dbConsultaHeight + - dbDestinatarioHeight + + dbDestinatarioHeight + dbQrCodeNormalHeight + dbQrCodeLateralHeight + dbProtocoloHeigth ) / - Units.Millimeters + PgNfce.TopMargin + PgNfce.BottomMargin; + Units.Millimeters + PgNfce.TopMargin + PgNfce.BottomMargin; } float dbProdutosUmaLinhaHeight; private void dbProdutosUmaLinha_AfterPrint(object sender, EventArgs e) { - dbProdutosUmaLinhaHeight += (dbProdutosUmaLinha.Visible ? dbProdutosUmaLinha.Height : 0) + (cbDescontoItemUmaLinha.Visible ? cbDescontoItemUmaLinha.Height : 0); + dbProdutosUmaLinhaHeight += (dbProdutosUmaLinha.Visible ? dbProdutosUmaLinha.Height : 0) + (cbDescontoItemUmaLinha.Visible ? cbDescontoItemUmaLinha.Height : 0); } float dbProdutosDuasLinhasHeight; @@ -234,13 +234,13 @@ namespace FastReport { dbInfoFiscalHeight = (dbInfoFiscal.Visible ? dbInfoFiscal.Height : 0); } - + float dbNumeroSerieDhHeight; private void dbNumeroSerieDh_AfterPrint(object sender, EventArgs e) { dbNumeroSerieDhHeight = (dbNumeroSerieDh.Visible ? dbNumeroSerieDh.Height : 0); } - + float dbConsultaHeight; private void dbConsulta_AfterPrint(object sender, EventArgs e) { @@ -274,15 +274,15 @@ namespace FastReport float gfbProdutosHeight; private void gfbProdutos_AfterPrint(object sender, EventArgs e) { - gfbProdutosHeight = (gfbProdutos.Visible ? gfbProdutos.Height : 0); + gfbProdutosHeight = (gfbProdutos.Visible ? gfbProdutos.Height : 0); } float dbPagamentoHeight; private void dbPagamento_AfterPrint(object sender, EventArgs e) { - dbPagamentoHeight = (dbPagamento.Visible ? dbPagamento.Height : 0); + dbPagamentoHeight = (dbPagamento.Visible ? dbPagamento.Height : 0); } - + float dbDetPagamentoHeight; private void dbDetPagamento_AfterPrint(object sender, EventArgs e) { @@ -316,12 +316,12 @@ namespace FastReport private void cbDesconto_BeforePrint(object sender, EventArgs e) { cbDesconto.Visible = ((Decimal)Report.GetColumnValue("NFCe.NFe.infNFe.total.ICMSTot.vDesc")) > 0; - } + } private void txtValorTotal_BeforePrint(object sender, EventArgs e) { var vServ = ((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.total.ISSQNtot.vServ")) == null ? 0 : ((Nullable<Decimal>)Report.GetColumnValue("NFCe.NFe.infNFe.total.ISSQNtot.vServ")); - txtValorTotal.Text = (((Decimal)Report.GetColumnValue("NFCe.NFe.infNFe.total.ICMSTot.vProd")) + vServ).ToString(); + txtValorTotal.Text = (((Decimal)Report.GetColumnValue("NFCe.NFe.infNFe.total.ICMSTot.vProd")) + vServ).ToString(); } private void dbPagamento_BeforePrint(object sender, EventArgs e) @@ -333,7 +333,7 @@ namespace FastReport { dbDetPagamento.Visible = Report.GetDataSource("NFCe.NFe.infNFe.pag.detPag").RowCount != 0 && Report.GetColumnValue("NFCe.NFe.infNFe.pag.detPag.tPag") != null; } - + private void dbTroco_BeforePrint(object sender, EventArgs e) { dbTroco.Visible = Report.GetColumnValue("NFCe.NFe.infNFe.pag.vTroco") != null; @@ -343,7 +343,7 @@ namespace FastReport private void dbQrCodeLateral_BeforePrint(object sender, EventArgs e) { TrataCamposDestinatario(); - dbQrCodeLateral.Visible = ((NfceLayoutQrCode) Report.GetParameterValue("NfceLayoutQrCode") == NfceLayoutQrCode.Lateral); + dbQrCodeLateral.Visible = ((NfceLayoutQrCode) Report.GetParameterValue("NfceLayoutQrCode") == NfceLayoutQrCode.Lateral); } float dbQrCodeLateralHeight; @@ -355,7 +355,7 @@ namespace FastReport float dbProtocoloHeigth; private void dbProtocolo_AfterPrint(object sender, EventArgs e) { - dbProtocoloHeigth = (dbProtocolo.Visible ? dbProtocolo.Height : 0); + dbProtocoloHeigth = (dbProtocolo.Visible ? dbProtocolo.Height : 0); } private void dbQrCodeNormal_BeforePrint(object sender, EventArgs e) @@ -370,19 +370,19 @@ namespace FastReport private void dbNumeroSerieDh_BeforePrint(object sender, EventArgs e) { - dbNumeroSerieDh.Visible = ((NfceLayoutQrCode) Report.GetParameterValue("NfceLayoutQrCode") == NfceLayoutQrCode.Abaixo); + dbNumeroSerieDh.Visible = ((NfceLayoutQrCode) Report.GetParameterValue("NfceLayoutQrCode") == NfceLayoutQrCode.Abaixo); } private void txtProdutoDuasLinhasDescricaoProduto_BeforePrint(object sender, EventArgs e) { bool nfceDetalheVendaNormalCompleto = ((NfceDetalheVendaNormal)((Int32)Report.GetParameterValue("NfceDetalheVendaNormal"))) == NfceDetalheVendaNormal.Completo; bool nfceDetalheVendaContingenciaCompleto = ((NfceDetalheVendaContigencia)((Int32)Report.GetParameterValue("NfceDetalheVendaContigencia"))) == NfceDetalheVendaContigencia.Completo; - - if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) + + if ( ((TipoEmissao)Report.GetColumnValue("NFCe.NFe.infNFe.ide.tpEmis")) == TipoEmissao.teNormal ) txtProdutoDuasLinhasDescricaoProduto.WordWrap = nfceDetalheVendaNormalCompleto; else - txtProdutoDuasLinhasDescricaoProduto.WordWrap = nfceDetalheVendaContingenciaCompleto; - + txtProdutoDuasLinhasDescricaoProduto.WordWrap = nfceDetalheVendaContingenciaCompleto; + if (nfceDetalheVendaNormalCompleto || nfceDetalheVendaContingenciaCompleto) txtProdutoDuasLinhasDescricaoProduto.LineHeight = txtProdutoDuasLinhasDescricaoProduto.Height; // Ajuste de espaçamento entre linhas } @@ -705,7 +705,7 @@ namespace FastReport - + diff --git a/NFe.Danfe.Base/NFe/NFeEvento.frx b/NFe.Danfe.Base/NFe/NFeEvento.frx index 1353240cc..eaec65e2b 100644 --- a/NFe.Danfe.Base/NFe/NFeEvento.frx +++ b/NFe.Danfe.Base/NFe/NFeEvento.frx @@ -29,28 +29,28 @@ namespace FastReport { case 'c': //CEP if (valor.Length == 8) - valor = valor.Substring(0,2) + "." + valor.Substring(2,3) + "-" + valor.Substring(5,3); + valor = valor.Substring(0,2) + "." + valor.Substring(2,3) + "-" + valor.Substring(5,3); break; - case 'f': //Telefone /celular + case 'f': //Telefone /celular if (valor.Length == 10) valor = "(" +valor.Substring(0,2) + ")" + valor.Substring(2,4) + "-" + valor.Substring(6,4); else if (valor.Length == 11) - valor = "(" +valor.Substring(0,2) + ")" + valor.Substring(2,5) + "-" + valor.Substring(7,4); + valor = "(" +valor.Substring(0,2) + ")" + valor.Substring(2,5) + "-" + valor.Substring(7,4); break; case 'd': //cpf / cnpj if (valor.Length == 11) valor = valor.Substring(0,3)+"."+valor.Substring(3,3)+"."+valor.Substring(6,3)+"-"+valor.Substring(9,2); else if (valor.Length == 14) valor = valor.Substring(0,2)+"."+valor.Substring(2,3)+"."+valor.Substring(5,3)+"/"+valor.Substring(8,4)+"-"+valor.Substring(12,2); - break; + break; case 'p': if (valor.Length == 7) valor = valor.Substring(0,3)+"-"+valor.Substring(3,4); break; - } + } return valor; } - + private void Memo47_BeforePrint(object sender, EventArgs e) { @@ -59,10 +59,10 @@ namespace FastReport try { var value = (DateTimeOffset)Report.GetColumnValue("NFe.NFe.infNFe.ide.dhEmi"); Memo49.Text = value.Date.Month.ToString().PadLeft(2, '0')+"/"+value.Date.Year.ToString().PadLeft(4, '0'); - } catch { + } catch { throw new Exception("Erro - dhEmi em formato incorreto."); } - try { + try { Memo53.Text = DateTime.Parse(Report.GetColumnValue("procEventoNFe.evento.infEvento.dhEvento").ToString()).ToString(); } catch{ Memo53.Text=""; @@ -77,7 +77,7 @@ namespace FastReport Memo40.Text="CARTA DE CORREÇÃO ELETRÔNICA"; BandCondicoesUso.Visible=true; } - try { + try { Memo60.Text = DateTime.Parse(Report.GetColumnValue("procEventoNFe.retEvento.infEvento.dhRegEvento").ToString()).ToString(); } catch{ Memo60.Text=""; @@ -90,14 +90,14 @@ namespace FastReport private void memJustificativaCorrecao_BeforePrint(object sender, EventArgs e) { // if (Report.GetColumnValue("procEventoNFe.evento.infEvento.tpEvento").ToString() == "110111") -// -// TITULO_CONTEXTO := 'JUSTIFICATIVA'; -// TEXTO_EVENTO := <Eventos."xJust">; -// end +// +// TITULO_CONTEXTO := 'JUSTIFICATIVA'; +// TEXTO_EVENTO := <Eventos."xJust">; +// end // else -// begin +// begin // TITULO_CONTEXTO := 'CORREÇÃO'; -// TEXTO_EVENTO := <Eventos."xCorrecao">; +// TEXTO_EVENTO := <Eventos."xCorrecao">; // end; } } @@ -475,7 +475,7 @@ namespace FastReport - + diff --git a/NFe.Danfe.Base/NFe/NFeRetrato.frx b/NFe.Danfe.Base/NFe/NFeRetrato.frx index 799aedef4..19d2e8cca 100644 --- a/NFe.Danfe.Base/NFe/NFeRetrato.frx +++ b/NFe.Danfe.Base/NFe/NFeRetrato.frx @@ -29,16 +29,16 @@ using NFe.Danfe.Base.NFe; using NFe.Classes.Informacoes.Total; namespace FastReport -{ +{ public class ReportScript - { + { private void Emitente_BeforePrint(object sender, EventArgs e) { var chave = Substring(((String)Report.GetColumnValue("NFe.NFe.infNFe.Id")), 3); - TextChaveAcesso.Text = Regex.Replace(chave, ".{4}", "$0 "); + TextChaveAcesso.Text = Regex.Replace(chave, ".{4}", "$0 "); BarcodeChave.Text = chave; poEmitLogo.Image = ObterLogo(); - + var contigenciaId = (string)Report.GetParameterValue("ContingenciaID"); BarCodeContigencia.Visible = !string.IsNullOrEmpty(contigenciaId); if(BarCodeContigencia.Visible) BarCodeContigencia.Text = contigenciaId; @@ -46,11 +46,11 @@ namespace FastReport DadosRetencoes.Visible = (bool)Report.GetParameterValue("ExibeRetencoes"); prodRow.AutoSize = (bool)Report.GetParameterValue("DuasLinhas"); if(prodRow.AutoSize == false) prodNomeCell.WordWrap = false; - + if (Report.GetColumnValue("NFe.NFe.infNFe.emit.enderEmit.fone") != null) { Text209.Text = FormatarCampo(Report.GetColumnValue("NFe.NFe.infNFe.emit.enderEmit.fone").ToString(), 'f'); } - + if ((FinalidadeNFe)(Report.GetColumnValue("NFe.NFe.infNFe.ide.finNFe")) == FinalidadeNFe.fnDevolucao) { var ipi = ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.total.ICMSTot.vIPI")) ?? 0M; @@ -60,8 +60,8 @@ namespace FastReport Text163.Text = FormatNumber(ipiDevolvido,2); } } - - //Trato o campo de Frete + + //Trato o campo de Frete switch((int)((ModalidadeFrete)Report.GetColumnValue("NFe.NFe.infNFe.transp.modFrete"))) { case 0: Memo92.Text = "0 - Emit/Remet"; break; @@ -70,28 +70,28 @@ namespace FastReport case 3: Memo92.Text = "3 - Prop Remetente"; break; case 4: Memo92.Text = "4 - Prop Destinatário"; break; case 9: Memo92.Text = "9 - Sem Frete"; break; - } - + } + var vol = Report.GetDataSource("NFe.NFe.infNFe.transp.vol"); vol.Init(); - int qtdeVol = 0; - + int qtdeVol = 0; + int volumes = 0; decimal pesoL = 0; decimal pesoB = 0; while (vol.HasMoreRows) - { + { Memo106.Text = ((String)Report.GetColumnValue("NFe.NFe.infNFe.transp.vol.esp")); Memo108.Text = ((String)Report.GetColumnValue("NFe.NFe.infNFe.transp.vol.marca")); Memo110.Text = ((String)Report.GetColumnValue("NFe.NFe.infNFe.transp.vol.nVol")); - + volumes += ((Nullable<int>)Report.GetColumnValue("NFe.NFe.infNFe.transp.vol.qVol")) ?? 0; pesoL += ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.transp.vol.pesoL")) ?? 0M; - pesoB += ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.transp.vol.pesoB")) ?? 0M; - qtdeVol++; + pesoB += ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.transp.vol.pesoB")) ?? 0M; + qtdeVol++; vol.Next(); } - + if (qtdeVol >= 1) { if (qtdeVol > 1) @@ -100,20 +100,20 @@ namespace FastReport Memo108.Text = ""; Memo110.Text = ""; } - + Memo104.Text = volumes.ToString(); Memo112.Text = FormatNumber(pesoB,3) + " KG"; Memo114.Text = FormatNumber(pesoL,3) + " KG"; - } - + } + if(Engine.FinalPass) - { + { var vBC = ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.total.ISSQNtot.vBC")) ?? 0; var vISS = ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.total.ISSQNtot.vISS")) ?? 0; var vServ = ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.total.ISSQNtot.vServ")) ?? 0; - + DadosISSQN.Visible = !(vBC == 0 && vISS == 0 && vServ == 0); - + var retiradaCPF = (string)Report.GetColumnValue("NFe.NFe.infNFe.retirada.CPF"); var retiradaCNPJ = (string)Report.GetColumnValue("NFe.NFe.infNFe.retirada.CNPJ"); var retiradaEndereco = (string)Report.GetColumnValue("NFe.NFe.infNFe.retirada.xLgr"); @@ -121,12 +121,12 @@ namespace FastReport var retiradaBairro = (string)Report.GetColumnValue("NFe.NFe.infNFe.retirada.xBairro"); var retiradaMunicipio = (string)Report.GetColumnValue("NFe.NFe.infNFe.retirada.xMun"); var retiradaUf = (string)Report.GetColumnValue("NFe.NFe.infNFe.retirada.UF"); - + LocalRetirada.Visible = !string.IsNullOrEmpty(retiradaCPF) || !string.IsNullOrEmpty(retiradaCNPJ) || !string.IsNullOrEmpty(retiradaEndereco) || !string.IsNullOrEmpty(retiradaNro) || !string.IsNullOrEmpty(retiradaBairro) || !string.IsNullOrEmpty(retiradaMunicipio) || !string.IsNullOrEmpty(retiradaUf); - + var entregaCPF = (string)Report.GetColumnValue("NFe.NFe.infNFe.entrega.CPF"); var entregaCNPJ = (string)Report.GetColumnValue("NFe.NFe.infNFe.entrega.CNPJ"); var entregaEndereco = (string)Report.GetColumnValue("NFe.NFe.infNFe.entrega.xLgr"); @@ -134,34 +134,34 @@ namespace FastReport var entregaBairro = (string)Report.GetColumnValue("NFe.NFe.infNFe.entrega.xBairro"); var entregaMunicipio = (string)Report.GetColumnValue("NFe.NFe.infNFe.entrega.xMun"); var entregaUf = (string)Report.GetColumnValue("NFe.NFe.infNFe.entrega.UF"); - + LocalEntrega.Visible = !string.IsNullOrEmpty(entregaCPF) || !string.IsNullOrEmpty(entregaCNPJ) || !string.IsNullOrEmpty(entregaEndereco) || !string.IsNullOrEmpty(entregaNro) || !string.IsNullOrEmpty(entregaBairro) || !string.IsNullOrEmpty(entregaMunicipio) || !string.IsNullOrEmpty(entregaUf); - - + + var indPagto = (IndicadorPagamento?)Report.GetColumnValue("NFe.NFe.infNFe.ide.indPag"); - var fatnFat = (string)Report.GetColumnValue("NFe.NFe.infNFe.cobr.fat.nFat"); + var fatnFat = (string)Report.GetColumnValue("NFe.NFe.infNFe.cobr.fat.nFat"); var fatvOrig = ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.cobr.fat.vOrig")) ?? 0M; var fatvDesc = ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.cobr.fat.vDesc")) ?? 0M; var fatvLiq = ((Nullable<decimal>)Report.GetColumnValue("NFe.NFe.infNFe.cobr.fat.vLiq")) ?? 0M; - - Fatura.Visible = (bool)Report.GetParameterValue("ExibeCampoFatura"); + + Fatura.Visible = (bool)Report.GetParameterValue("ExibeCampoFatura"); MemoFatura.Visible = !string.IsNullOrEmpty(fatnFat); if(MemoFatura.Visible) MemoFatura.Text = string.Format("Número: {0} - Valor Original: {1:c} - Valor Desconto: {2:c} - ValorLíquido: {3:c}", fatnFat, fatvOrig, fatvDesc, fatvLiq); - + switch(indPagto) { case IndicadorPagamento.ipVista: Memo146.Text = "PAGAMENTO À VISTA"; break; - + case IndicadorPagamento.ipPrazo: Memo146.Text = "PAGAMENTO A PRAZO"; break; - + case IndicadorPagamento.ipOutras: Memo146.Text = "OUTROS"; break; @@ -227,35 +227,35 @@ namespace FastReport prodIPICell.Text = "0,00"; prodAlqIPICell.Text = "0,00"; } - + var imprimirUnidQtdeValor = (ImprimirUnidQtdeValor)Report.GetParameterValue("ImprimirUnidQtdeValor"); - var imprimirDescPorc = (bool)Report.GetParameterValue("ImprimirDescPorc"); + var imprimirDescPorc = (bool)Report.GetParameterValue("ImprimirDescPorc"); var imprimirTotalLiquido = (bool)Report.GetParameterValue("ImprimirTotalLiquido"); - + var uCom = ((String)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.uCom")); var uTrib = ((String)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.uTrib")); - + var qCom = ((Decimal)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.qCom")); var qTrib = ((Decimal)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.qTrib")); - + var vUnCom = ((Decimal)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.vUnCom")); var vUnTrib = ((Decimal)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.vUnTrib")); - + var vProd = ((Decimal)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.vProd")); var vDesc = (((Nullable<Decimal>)Report.GetColumnValue("NFe.NFe.infNFe.det.prod.vDesc")) ?? 0); - - if(imprimirTotalLiquido) vProd = vProd - vDesc; + + if(imprimirTotalLiquido) vProd = vProd - vDesc; if(vDesc > 0 && imprimirDescPorc) { vDesc = ((vDesc*100)/(vUnCom*qCom)); - } - + } + prodValorCell.Text = FormatNumber(vProd,2); prodDescontoCell.Text = FormatNumber(vDesc, 2); - + var decimaisQuantidadeItem = (int)Report.GetParameterValue("DecimaisQuantidadeItem"); var decimaisValorUnitario = (int)Report.GetParameterValue("DecimaisValorUnitario"); - + switch(imprimirUnidQtdeValor) { case ImprimirUnidQtdeValor.Comercial: @@ -263,26 +263,26 @@ namespace FastReport prodQtdCell.Text = FormatNumber(qCom, decimaisQuantidadeItem); prodValorUnitarioCell.Text = FormatNumber(vUnCom, decimaisValorUnitario); break; - + case ImprimirUnidQtdeValor.Tributavel: prodUnidadeCell.Text = uTrib; prodQtdCell.Text = FormatNumber(qTrib, decimaisQuantidadeItem); prodValorUnitarioCell.Text = FormatNumber(vUnTrib, decimaisValorUnitario); break; - + case ImprimirUnidQtdeValor.Ambos: - + var qTribFormatado = FormatNumber(qTrib, decimaisQuantidadeItem); var qComFormatado = FormatNumber(qCom, decimaisQuantidadeItem); var vUnComFormatado = FormatNumber(vUnCom, decimaisValorUnitario); var vUnTribFormatado = FormatNumber(vUnTrib, decimaisValorUnitario); - + prodUnidadeCell.Text = string.Format("{0}{2}{1}", uCom, uTrib, Environment.NewLine); prodQtdCell.Text = string.Format("{0}{2}{1}", qComFormatado, qTribFormatado, Environment.NewLine); prodValorUnitarioCell.Text = string.Format("{0}{2}{1}", vUnComFormatado, vUnTribFormatado, Environment.NewLine); break; } - + if ((FinalidadeNFe)(Report.GetColumnValue("NFe.NFe.infNFe.ide.finNFe")) == FinalidadeNFe.fnDevolucao) { if(ipiBasico == null) @@ -295,242 +295,242 @@ namespace FastReport prodAlqIPICell.Text = FormatNumber(DevolvidoPercentual,2); } } - } + } } - + private string FormatarCampo(string valor, char format) { if (valor == null) return string.Empty; - + switch (format) { case 'c': //CEP if (valor.Length == 8) - valor = valor.Substring(0,2) + "." + valor.Substring(2,3) + "-" + valor.Substring(5,3); + valor = valor.Substring(0,2) + "." + valor.Substring(2,3) + "-" + valor.Substring(5,3); break; - - case 'f': //Telefone /celular + + case 'f': //Telefone /celular if (valor.Length == 10) valor = "(" +valor.Substring(0,2) + ") " + valor.Substring(2,4) + "-" + valor.Substring(6,4); else if (valor.Length == 11) - valor = "(" +valor.Substring(0,2) + ") " + valor.Substring(2,5) + "-" + valor.Substring(7,4); + valor = "(" +valor.Substring(0,2) + ") " + valor.Substring(2,5) + "-" + valor.Substring(7,4); break; - + case 'd': //cpf / cnpj if (valor.Length == 11) valor = valor.Substring(0,3)+"."+valor.Substring(3,3)+"."+valor.Substring(6,3)+"-"+valor.Substring(9,2); else if (valor.Length == 14) valor = valor.Substring(0,2)+"."+valor.Substring(2,3)+"."+valor.Substring(5,3)+"/"+valor.Substring(8,4)+"-"+valor.Substring(12,2); - break; - + break; + case 'p': if (valor.Length == 7) valor = valor.Substring(0,3)+"-"+valor.Substring(3,4); break; - } + } return valor; } - + public Image ObterLogo() { byte[] logomarca = Report.GetParameterValue("Logo") as byte[]; - + if (logomarca == null) return null; - + using(var ms = new MemoryStream(logomarca)) { var image = Image.FromStream(ms); return image; } - } + } private void Imposto_BeforePrint(object sender, EventArgs e) { bool exibirIbpt = ((Boolean?)Report.GetParameterValue("ExibirTotalTributos")) ?? false; - + QuadroVTOTTRIB.Visible = exibirIbpt; txtIbptValor.Visible = exibirIbpt; - + if (exibirIbpt) - { + { //Base ICMS QuadroVBC.Width = 100f; Text170.Width = QuadroVBC.Width; - + //Valor ICMS QuadroVICMS.Width = 100f; QuadroVICMS.Left = 100f; Text169.Width = QuadroVICMS.Width; Text169.Left = QuadroVICMS.Left; - + //Base Calc ICMS ST QuadroVBCST.Text = "BASE CÁLC. ICMS SUBST."; QuadroVBCST.Width = 100f; QuadroVBCST.Left = 200f; Text168.Width = QuadroVBCST.Width; - Text168.Left = QuadroVBCST.Left; - + Text168.Left = QuadroVBCST.Left; + //ICMS ST QuadrovST.Width = 100f; QuadrovST.Left = 300f; Text162.Width = QuadrovST.Width; Text162.Left = QuadrovST.Left; - + //PIS QuadroPIS.Width = 100f; QuadroPIS.Left = 400f; Text160.Width = QuadroPIS.Width; Text160.Left = QuadroPIS.Left; - + //TOTAL TRIBUTOS QuadroVTOTTRIB.Width = 100f; QuadroVTOTTRIB.Left = 500f; txtIbptValor.Width = QuadroVTOTTRIB.Width; txtIbptValor.Left = QuadroVTOTTRIB.Left; - + //Total produtos Memo67.Left = 600f; Memo67.Width = 144.5f; Text159.Width = Memo67.Width; - Text159.Left = Memo67.Left; - + Text159.Left = Memo67.Left; + //Frete Memo77.Left = 0f; Memo77.Width = 100f; Text167.Width = Memo77.Width; - Text167.Left = Memo77.Left; - + Text167.Left = Memo77.Left; + //Seguro Memo75.Left = 100f; Memo75.Width = 100f; Text166.Width = Memo75.Width; - Text166.Left = Memo75.Left; - + Text166.Left = Memo75.Left; + //Desconto Memo73.Left = 200f; Memo73.Width = 100f; Text165.Width = Memo73.Width; - Text165.Left = Memo73.Left; - + Text165.Left = Memo73.Left; + //Despesas Memo71.Left = 300f; Memo71.Width = 100f; Text164.Width = Memo71.Width; - Text164.Left = Memo71.Left; - + Text164.Left = Memo71.Left; + //IPI Memo69.Left = 400f; Memo69.Width = 100f; Text163.Width = Memo69.Width; - Text163.Left = Memo69.Left; - + Text163.Left = Memo69.Left; + //Valor Cofins Text158.Left = 500f; Text158.Width = 100f; Text161.Width = Text158.Width; - Text161.Left = Text158.Left; - + Text161.Left = Text158.Left; + //Total Contábil Memo79.Left = 600f; Memo79.Width = 144.5f; Memo80.Width = Memo79.Width; Memo80.Left = Memo79.Left; - } + } } - - private int contadorDuplicatas =0; + + private int contadorDuplicatas =0; private float _TamanhoDuplicatas = 0; private void DuplicatasHeader_BeforePrint(object sender, EventArgs e) { contadorDuplicatas = 0; _TamanhoDuplicatas = 0; - } - + } + private void Duplicatas_BeforePrint(object sender, EventArgs e) { contadorDuplicatas++; if (contadorDuplicatas == 6) - { + { _TamanhoDuplicatas += Duplicatas.Height; contadorDuplicatas = 0; } } - + private float _Tamanho = 0; private float _TamanhoItens = 0; - + private void DadosProdutosHeader_BeforePrint(object sender, EventArgs e) { - + if (((CRT)Report.GetColumnValue("NFe.NFe.infNFe.emit.CRT")) == CRT.SimplesNacional || ((CRT)Report.GetColumnValue("NFe.NFe.infNFe.emit.CRT")) == CRT.SimplesNacionalMei) { Memo119.Text = "O/CSOSN"; } - + _Tamanho = 0; - _TamanhoItens = 0; - + _TamanhoItens = 0; + if (Canhoto.Visible) _Tamanho += Canhoto.Height; - + if (Emitente.Visible) _Tamanho += Emitente.Height; - + if (Destinatario.Visible) _Tamanho += Destinatario.Height; - + if (LocalRetirada.Visible) _Tamanho += LocalRetirada.Height; - + if (LocalEntrega.Visible) _Tamanho += LocalEntrega.Height; - + if (Fatura.Visible) _Tamanho += Fatura.Height; - + if (DuplicatasHeader.Visible) _Tamanho += DuplicatasHeader.Height; - + _Tamanho += _TamanhoDuplicatas; - + if (Imposto.Visible) _Tamanho += Imposto.Height; - + if (TransportadorVolumes.Visible) _Tamanho += TransportadorVolumes.Height; - + if (DadosProdutosHeader.Visible) _Tamanho += DadosProdutosHeader.Height; - + //_Tamanho += _TamanhoItens; - + if (DadosProdutosFooter.Visible) _Tamanho += DadosProdutosFooter.Height; - + if (DadosISSQN.Visible) _Tamanho += DadosISSQN.Height; - + if (DadosRetencoes.Visible) _Tamanho += DadosRetencoes.Height; - + DadosAdicionais.CalcHeight(); - + if (DadosAdicionais.Visible) _Tamanho += DadosAdicionais.Height; - + if (Rodape.Visible) - _Tamanho += Rodape.Height; - + _Tamanho += Rodape.Height; + } - + private void DadosProdutos_AfterPrint(object sender, EventArgs e) - { + { DadosProdutos.StartNewPage = false; - + if (Engine.PageNo == 1) { _TamanhoItens += DadosProdutos.Height; - + if (_Tamanho + _TamanhoItens >= Engine.PageHeight) { DadosProdutos.StartNewPage = true; @@ -538,9 +538,9 @@ namespace FastReport } } } - - + + } } @@ -913,7 +913,7 @@ namespace FastReport - + diff --git a/NFe.Danfe.Base/NFe/NFeSimplificado.frx b/NFe.Danfe.Base/NFe/NFeSimplificado.frx index b60de21d6..fe7e4e83c 100644 --- a/NFe.Danfe.Base/NFe/NFeSimplificado.frx +++ b/NFe.Danfe.Base/NFe/NFeSimplificado.frx @@ -38,10 +38,10 @@ namespace FastReport { case 'c': //CEP if (valor.Length == 8) - valor = valor.Substring(0,2) + "." + valor.Substring(2,3) + "-" + valor.Substring(5,3); + valor = valor.Substring(0,2) + "." + valor.Substring(2,3) + "-" + valor.Substring(5,3); break; - - case 'f': //Telefone /celular + + case 'f': //Telefone /celular if (valor.Length == 10) valor = "(" +valor.Substring(0,2) + ")" + valor.Substring(2,4) + "-" + valor.Substring(6,4); else if (valor.Length == 11) @@ -51,63 +51,63 @@ namespace FastReport else if (valor.Length == 11) //55+11 valor = "(" +valor.Substring(2,2) + ")" + valor.Substring(4,5) + "-" + valor.Substring(9,4); break; - + case 'd': //cpf / cnpj if (valor.Length == 11) valor = valor.Substring(0,3)+"."+valor.Substring(3,3)+"."+valor.Substring(6,3)+"-"+valor.Substring(9,2); else if (valor.Length == 14) valor = valor.Substring(0,2)+"."+valor.Substring(2,3)+"."+valor.Substring(5,3)+"/"+valor.Substring(8,4)+"-"+valor.Substring(12,2); - break; - + break; + case 'p': if (valor.Length == 7) valor = valor.Substring(0,3)+"-"+valor.Substring(3,4); break; - } - - + } + + return valor; } - + private void Data1_BeforePrint(object sender, EventArgs e) { TheLogotipo.Image = ObterLogo(); - + var chave = (((String)Report.GetColumnValue("NFe.NFe.infNFe.Id"))).Substring(3); - Text1.Text = Regex.Replace(chave, ".{4}", "$0 "); - + Text1.Text = Regex.Replace(chave, ".{4}", "$0 "); + Text38.Visible = ((Boolean?)Report.GetParameterValue("EsconderValor")) != true; Text36.Visible = ((Boolean?)Report.GetParameterValue("EsconderValor")) != true; - + var emissao = ((TipoEmissao)Report.GetColumnValue("NFe.NFe.infNFe.ide.tpEmis")); switch (emissao) { - case TipoEmissao.teNormal: Text33.Text = "Tipo: Normal"; break; + case TipoEmissao.teNormal: Text33.Text = "Tipo: Normal"; break; case TipoEmissao.teEPEC: Text33.Text = "Tipo: EPEC"; break; case TipoEmissao.teFSDA: Text33.Text = "Tipo: FS-DA"; break; - case TipoEmissao.teFSIA: Text33.Text = "Tipo: FS-IA"; break; + case TipoEmissao.teFSIA: Text33.Text = "Tipo: FS-IA"; break; case TipoEmissao.teSCAN: Text33.Text = "Tipo: SCAN"; break; case TipoEmissao.teSVCAN: Text33.Text = "Tipo: SVC-AN"; break; - case TipoEmissao.teSVCRS: Text33.Text = "Tipo: SVC-RS"; break; - case TipoEmissao.teOffLine: Text33.Text = "Tipo: Offline"; break; - default: throw new ArgumentException("tpEmis não implementado"); - } - - var operacao = ((TipoNFe)Report.GetColumnValue("NFe.NFe.infNFe.ide.tpNF")); + case TipoEmissao.teSVCRS: Text33.Text = "Tipo: SVC-RS"; break; + case TipoEmissao.teOffLine: Text33.Text = "Tipo: Offline"; break; + default: throw new ArgumentException("tpEmis não implementado"); + } + + var operacao = ((TipoNFe)Report.GetColumnValue("NFe.NFe.infNFe.ide.tpNF")); switch (operacao) { case TipoNFe.tnEntrada : Text37.Text = "Operação: Entrada"; break; case TipoNFe.tnSaida : Text37.Text = "Operação: Saída"; break; default: throw new ArgumentException("tpNF não implementado"); - } + } } - + public Image ObterLogo() { byte[] logomarca = Report.GetParameterValue("Logo") as byte[]; - + if (logomarca == null) return null; - + using(var ms = new MemoryStream(logomarca)) { var image = Image.FromStream(ms); @@ -290,7 +290,7 @@ namespace FastReport - + diff --git a/NFe.Danfe.Html/DanfeNfeHtml2.cs b/NFe.Danfe.Html/DanfeNfeHtml2.cs index 9751b1a9c..e1e98a834 100644 --- a/NFe.Danfe.Html/DanfeNfeHtml2.cs +++ b/NFe.Danfe.Html/DanfeNfeHtml2.cs @@ -576,9 +576,9 @@ private string MontarLinhaTabelaProduto(Produto produto) list["[code]"] = produto.Codigo; list["[nome]"] = produto.Descricao.Truncar(120); list["[ncm]"] = produto.Ncm; - list["[cst]"] = produto.Cfop; - list["[cfop]"] = produto.Unidade; - list["[und]"] = produto.ValorUnitario.FormatarNumero(); + list["[cst]"] = produto.Origem; + list["[cfop]"] = produto.Cfop; + list["[und]"] = produto.Unidade; list["[qtd]"] = produto.Quantidade.FormatarNumeroQuantidadeDanfe(); list["[valorUnit]"] = produto.ValorUnitario.FormatarNumero(); list["[valorTot]"] = produto.ValorTotal.FormatarNumero(); diff --git a/NFe.Danfe.Nativo/NFCe/DanfeNativoNfce.cs b/NFe.Danfe.Nativo/NFCe/DanfeNativoNfce.cs index af0ad4c1e..1342c5e05 100644 --- a/NFe.Danfe.Nativo/NFCe/DanfeNativoNfce.cs +++ b/NFe.Danfe.Nativo/NFCe/DanfeNativoNfce.cs @@ -151,7 +151,7 @@ public byte[] GerarImagem() } // Obtive o tamanho real na posição y agora vou fazer um com tamanho exato - using (Bitmap bmpFinal = new Bitmap(300, _y)) + using (Bitmap bmpFinal = new Bitmap(300, _y)) using (var streamer = new MemoryStream()) { using (Graphics g = Graphics.FromImage(bmpFinal)) @@ -607,7 +607,7 @@ private void GerarNfCe(Graphics graphics) _y += 5; - var tributosIncidentes = _nfe.infNFe.total.ICMSTot.vTotTrib; + var tributosIncidentes = _nfe.infNFe.total.ICMSTot.vTotTrib ?? 0; if (tributosIncidentes != 0) { diff --git a/NFe.Danfe.QuestPdf/ImpressaoNfce/DanfeNfceDocument.cs b/NFe.Danfe.QuestPdf/ImpressaoNfce/DanfeNfceDocument.cs index 5e1d361f6..adde1b3a6 100644 --- a/NFe.Danfe.QuestPdf/ImpressaoNfce/DanfeNfceDocument.cs +++ b/NFe.Danfe.QuestPdf/ImpressaoNfce/DanfeNfceDocument.cs @@ -413,6 +413,24 @@ private void Rodape(IContainer container) column.Item().LineHorizontal(1); + if (_nfe.infNFe.infAdic != null && !string.IsNullOrEmpty(_nfe.infNFe.infAdic.infCpl)) + { + column.Item().Row(r => + { + r.RelativeItem().AlignLeft().Column(c => + { + c.Item().Text("Informações Adicionais").FontSize(_tamanhoFontePadrao).ExtraBlack(); + }); + }); + column.Item().Row(r => + { + r.RelativeItem().AlignLeft().Column(c => + { + c.Item().Text(_nfe.infNFe.infAdic.infCpl).FontSize(_tamanhoFontePadrao); + }); + }); + } + column.Item().Row(r => { r.RelativeItem().AlignCenter().Column(c => @@ -552,6 +570,11 @@ private string EnderecoEmitente() enderecoEmitenteBuilder.Append(enderEmit.xMun); enderecoEmitenteBuilder.Append(", "); enderecoEmitenteBuilder.Append(enderEmit.UF); + if (enderEmit.CEP != null) + { + enderecoEmitenteBuilder.Append(" - CEP: "); + enderecoEmitenteBuilder.Append(enderEmit.CEP); + } enderecoEmitenteBuilder.Append(foneEmit); return enderecoEmitenteBuilder.ToString(); diff --git a/NFe.Utils/Enderecos/Enderecador.cs b/NFe.Utils/Enderecos/Enderecador.cs index f0c826296..dd269030d 100644 --- a/NFe.Utils/Enderecos/Enderecador.cs +++ b/NFe.Utils/Enderecos/Enderecador.cs @@ -1101,7 +1101,7 @@ private static List CarregarEnderecosServicos() addServico(new[] { ServicoNFe.NfeInutilizacao }, versao4, prod, emissao, Estado.RS, nfe, "https://nfe.sefazrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx"); addServico(new[] { ServicoNFe.NfeConsultaProtocolo }, versao4, prod, emissao, Estado.RS, nfe, "https://nfe.sefazrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx"); addServico(new[] { ServicoNFe.NfeStatusServico }, versao4, prod, emissao, Estado.RS, nfe, "https://nfe.sefazrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx"); - addServico(new[] { ServicoNFe.NfeConsultaCadastro }, versao4, prod, emissao, Estado.RS, nfe, "https://cad.sefazrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"); + addServico(new[] { ServicoNFe.NfeConsultaCadastro }, versao4, prod, emissao, Estado.RS, nfe, "https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx"); addServico(eventoCceCanc, versao4, prod, emissao, Estado.RS, nfe, "https://nfe.sefazrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx"); addServico(new[] { ServicoNFe.NFeAutorizacao }, versao4, prod, emissao, Estado.RS, nfe, "https://nfe.sefazrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx"); addServico(new[] { ServicoNFe.NFeRetAutorizacao }, versao4, prod, emissao, Estado.RS, nfe, "https://nfe.sefazrs.rs.gov.br/ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx"); diff --git a/NFe.Utils/InformacoesSuplementares/ExtinfNFeSupl.cs b/NFe.Utils/InformacoesSuplementares/ExtinfNFeSupl.cs index f22074a7d..2599c50b7 100644 --- a/NFe.Utils/InformacoesSuplementares/ExtinfNFeSupl.cs +++ b/NFe.Utils/InformacoesSuplementares/ExtinfNFeSupl.cs @@ -527,11 +527,11 @@ public static string ObterUrlQrCode2ComParametro(this infNFeSupl infNFeSupl, Tip /// /// Obtém a URL para uso no QR-Code, versão 3.0 - leiaute 4.00+ /// - public static string ObterUrlQrCode3(this infNFeSupl infNFeSupl, Classes.NFe nfe, VersaoServico versaoServico, ConfiguracaoCertificado cfgCertificado, Encoding encoding = null) + private static string ObterUrlQrCode3(this infNFeSupl infNFeSupl, Classes.NFe nfe, VersaoServico versaoServico, ConfiguracaoCertificado cfgCertificado, Encoding encoding = null) { - if (cfgCertificado == null || (string.IsNullOrWhiteSpace(cfgCertificado.Serial) && cfgCertificado.TipoCertificado != TipoCertificado.A1Arquivo)) - throw new ArgumentNullException("CertificadoDigital", "Para gerar a assinatura do QR-Code versão 3.0 EM CONTINGENCIA é necessário informar o certificado digital utilizado na assinatura da NFC-e, verificar Número de Série e Senha."); - + if (cfgCertificado == null) + throw new ArgumentNullException(nameof(cfgCertificado), "Para gerar a assinatura do QR-Code versão 3.0 EM CONTINGÊNCIA é necessário informar o certificado digital utilizado na assinatura da NFC-e"); + const string pipe = "|"; string chave = nfe.infNFe.Id.Substring(3); diff --git a/NFe.Utils/NFe/ExtNFe.cs b/NFe.Utils/NFe/ExtNFe.cs index 30cac4dcb..cdc60f787 100644 --- a/NFe.Utils/NFe/ExtNFe.cs +++ b/NFe.Utils/NFe/ExtNFe.cs @@ -49,10 +49,10 @@ public static class ExtNFe /// /// arquivo XML /// Retorna uma NFe carregada com os dados do XML - public static Classes.NFe CarregarDeArquivoXml(this Classes.NFe nfe, string arquivoXml) + public static Classes.NFe CarregarDeArquivoXml(this Classes.NFe nfe, string arquivoXml, bool ignorarOrdenacaoElementos = false) { var s = FuncoesXml.ObterNodeDeArquivoXml(typeof (Classes.NFe).Name, arquivoXml); - return FuncoesXml.XmlStringParaClasse(s); + return FuncoesXml.XmlStringParaClasse(s, ignorarOrdenacaoElementos); } /// @@ -71,10 +71,10 @@ public static string ObterXmlString(this Classes.NFe nfe) /// /// /// Retorna um objeto do tipo NFe - public static Classes.NFe CarregarDeXmlString(this Classes.NFe nfe, string xmlString) + public static Classes.NFe CarregarDeXmlString(this Classes.NFe nfe, string xmlString, bool ignorarOrdenacaoElementos = false) { var s = FuncoesXml.ObterNodeDeStringXml(typeof (Classes.NFe).Name, xmlString); - return FuncoesXml.XmlStringParaClasse(s); + return FuncoesXml.XmlStringParaClasse(s, ignorarOrdenacaoElementos); } /// @@ -97,7 +97,7 @@ public static Classes.NFe Valida(this Classes.NFe nfe, ConfiguracaoServico cfgSe { if (nfe == null) throw new ArgumentNullException("nfe"); - var versao = (Decimal.Parse(nfe.infNFe.versao, CultureInfo.InvariantCulture)); + var versao = Decimal.Parse(nfe.infNFe.versao, CultureInfo.InvariantCulture); var xmlNfe = nfe.ObterXmlString(); var config = cfgServico ?? ConfiguracaoServico.Instancia; @@ -125,7 +125,7 @@ public static Classes.NFe Assina(this Classes.NFe nfe, ConfiguracaoServico cfgSe #region Define cNF var tamanhocNf = 9; - var versao = (decimal.Parse(nfeLocal.infNFe.versao, CultureInfo.InvariantCulture)); + var versao = decimal.Parse(nfeLocal.infNFe.versao, CultureInfo.InvariantCulture); if (versao >= 2) tamanhocNf = 8; nfeLocal.infNFe.ide.cNF = Convert.ToInt32(nfeLocal.infNFe.ide.cNF).ToString().PadLeft(tamanhocNf, '0');