Example #1
0
        void ConsultaLoteRPS(string protocolo)
        {
            var not = new NFEGerarXMLNotasServicos(this.lote.lote_id.ToString(), this.empresa.conf_cnpj, this.empresa.conf_inscricaoestadual);

            lote.lote_urlXmlConsulta = not.GerarArquivoXMLConsulta(protocolo);
            NTLoteBLL _lote = new NTLoteBLL();

            _lote.UpdateXmlConsulta(lote);
            var ulXmlConsultaRetorno = not.GerarArquivoXMLConsultaRetorno();
        }
        /// <summary>
        /// Cria novo lote para enviar a receita
        /// </summary>
        void CriarLoteNotaFiscal()
        {
            NTLoteBLL _lote = new NTLoteBLL();

            loteNota = new NTLoteBE
            {
                conf_id      = this.conf_id,
                lote_serie   = GlobaisSCM.NFeSerie,
                lote_modulo  = GlobaisSCM.Modulo,
                lote_emissao = DateTime.Now,
                lote_status  = StatusNotaNFe.LoteNovo.GetDescription()
            };
            loteNota = _lote.Insert(loteNota);
        }
Example #3
0
        public int EnviarNotaXML()
        {
            try
            {
                NTLoteBLL _lote = new NTLoteBLL();

                //Colocar o update no lote
                var not = new NFEGerarXMLNotasServicos(this.lote.lote_id.ToString(), this.empresa.conf_cnpj, this.empresa.conf_inscricaoestadual);
                lote.lote_urlXmlEnvio = not.GerarArquivoXML(this.lote);
                string fileXmlRetorno = not.GerarArquivoXMLRetorno();

                lote.lote_status = StatusNotaNFe.LoteGerado.GetDescription();
                _lote.UpdateStatus(lote);   //Atualiza Status
                _lote.UpdateXmlEnvio(lote); //Atualiza Campos XML Lote

                this.EnviarRPSNotas(lote.lote_urlXmlEnvio, fileXmlRetorno);

                var retorno = not.LerXMLLote(fileXmlRetorno);
                if (retorno.Erro)
                {
                    this.CriarLoteRetornoErro(retorno);
                    lote.lote_status = StatusNotaNFe.LoteErro.GetDescription();
                    return(0);
                }
                else
                {
                    lote.lote_status = StatusNotaNFe.LoteEnviado.GetDescription();
                    _lote.UpdateStatus(lote);
                    _lote.UpdateProtocolo(new NTLoteBE {
                        lote_id = lote.lote_id, lote_protocolo = retorno.Protocolo
                    });
                    this.ConsultaLoteRPS(retorno.Protocolo);
                    return(lote.lote_id);
                }
            }
            catch (Exception ex)
            {
                Common.TratarLogErro(ex);
                return(0);
            }
        }