private XmlNode XML_infNFe(XmlDocument xml, Pedido p) { // Regra para montar a chave //33 + ano(2) + mes(2) + cnpj(14) + modelo(2) + serie(3) + NF(9) + codigo //codigo = mes(2) + cnpj (2 primeiros numeros iniciais) + cnpj (ultimo numero) + NF (1 numero inicial) + ano(2) //EXEMPLO: //33 16 08 01578493000295 55 002 000001237 10 59 1 0 11 73 Monta_cNF(); ChaveNFe = "33" + p.datanfiscal.ToString().Substring(8, 2) + p.datanfiscal.ToString().Substring(3, 2) + Emitente.getInstance.cnpj + p.modelo + (p.serienfiscal).ToString("000") + (string.IsNullOrEmpty(p.nfiscal) ? "0" : String.Format(@"{0:000000000}", Convert.ToInt32(p.nfiscal))) + "1" + cNF; cDV = DigitoVerificador.DigitoModulo11(ChaveNFe); ChaveNFe = ChaveNFe + cDV.ToString(); _strChave = ChaveNFe; XmlNode infNFe = xml.CreateElement("infNFe"); infNFe.Attributes.Append(atributo(xml, "Id", "NFe" + ChaveNFe)); infNFe.Attributes.Append(atributo(xml, "versao", "4.00")); return(infNFe); }