Exemplo n.º 1
0
        /// <summary>
        /// GerarDetImpostoIPI
        /// </summary>
        /// <param name="IPI"></param>
        /// <param name="nodeImposto"></param>
        private bool GerarDetImpostoIPI(NFe nfe, IPI IPI, XmlElement nodeImposto)
        {
            if (!string.IsNullOrEmpty(IPI.CST))
            {
                bool CST00495099;

                // variavel CST00495099 usada para Ignorar Tag <IPI>
                // se GerarTagIPIparaNaoTributado = False e CST00495099 = False

                CST00495099 = (IPI.CST == "00" || IPI.CST == "49" || IPI.CST == "50" || IPI.CST == "99");

                XmlElement e0 = doc.CreateElement("IPI");
                nodeImposto.AppendChild(e0);
                nodeCurrent = e0;

                wCampo(IPI.clEnq, TpcnTipoCampo.tcStr, TpcnResources.clEnq, ObOp.Opcional);
                wCampo(IPI.CNPJProd, TpcnTipoCampo.tcStr, TpcnResources.CNPJProd, ObOp.Opcional);
                wCampo(IPI.cSelo, TpcnTipoCampo.tcStr, TpcnResources.cSelo, ObOp.Opcional);
                wCampo(IPI.qSelo, TpcnTipoCampo.tcInt, TpcnResources.qSelo, ObOp.Opcional);
                if (IPI.cEnq.Trim() == "")
                    IPI.cEnq = "999";
                wCampo(IPI.cEnq, TpcnTipoCampo.tcStr, TpcnResources.cEnq);

                if (CST00495099)
                {
                    if ((IPI.vBC + IPI.pIPI > 0) && (IPI.qUnid + IPI.vUnid > 0))
                        this.cMensagemErro += "IPITrib: As TAG's <vBC> e <pIPI> não podem ser informadas em conjunto com as TAG <qUnid> e <vUnid>" + Environment.NewLine;

                    nodeCurrent = doc.CreateElement("IPITrib");
                    e0.AppendChild(nodeCurrent);

                    wCampo(IPI.CST, TpcnTipoCampo.tcStr, TpcnResources.CST);
                    if (IPI.qUnid + IPI.vUnid > 0)
                    {
                        wCampo(IPI.qUnid, TpcnTipoCampo.tcDec4, TpcnResources.qUnid);
                        wCampo(IPI.vUnid, TpcnTipoCampo.tcDec4, TpcnResources.vUnid);
                    }
                    else
                    {
                        wCampo(IPI.vBC, TpcnTipoCampo.tcDec2, TpcnResources.vBC);
                        wCampo(IPI.pIPI, this.nDecimaisPerc, TpcnResources.pIPI);
                    }
                    wCampo(IPI.vIPI, TpcnTipoCampo.tcDec2, TpcnResources.vIPI);
                }
                else //(* Quando CST/IPI for 01,02,03,04,51,52,53,54 ou 55 *)
                {
                    nodeCurrent = doc.CreateElement("IPINT");
                    e0.AppendChild(nodeCurrent);
                    wCampo(IPI.CST, TpcnTipoCampo.tcStr, TpcnResources.CST);
                }
                return true;
            }
            return false;
        }