Esempio n. 1
0
 public void Consultar(out List<eFact_Entidades.Lote> Lotes, eFact_Entidades.Lote.TipoConsulta TipoConsulta, DateTime FechaDsd, DateTime FechaHst, string CuitVendedor, string NumeroLote, string PuntoVenta, bool VerPendientes)
 {
     StringBuilder commandText = new StringBuilder();
     //Query PF
     commandText.Append("select ");
     commandText.Append("Lotes.*, WF_Op.IdFlow ,WF_Op.IdCircuito, WF_Op.IdNivSeg, WF_Op.IdEstado, WF_Op.DescrOp, WF_Op.UltActualiz, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito , WF_NivSeg.DescrNivSeg, WF_Estado.DescrEstado ");
     commandText.Append("INTO #Lotes ");
     commandText.Append("from Lotes ");
     commandText.Append("inner join WF_Op on Lotes.IdOp = WF_Op.IdOp ");
     commandText.Append("inner join WF_Flow on WF_Op.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("inner join WF_Circuito on WF_Op.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("inner join WF_NivSeg on WF_Op.IdNivSeg=WF_NivSeg.IdNivSeg ");
     commandText.Append("inner join WF_Estado on WF_Op.IdEstado=WF_Estado.IdEstado ");
     if (TipoConsulta == eFact_Entidades.Lote.TipoConsulta.FechaAlta)
     {
         commandText.Append("where (Lotes.FechaAlta >= '" + FechaDsd.ToString("yyyyMMdd") + "' and Lotes.FechaAlta < Dateadd ( Day, 1, '" + FechaHst.ToString("yyyyMMdd") + "') ");
     }
     else if (TipoConsulta == eFact_Entidades.Lote.TipoConsulta.FechaEnvio)
     {
         commandText.Append("where (Lotes.FechaEnvio >= '" + FechaDsd.ToString("yyyyMMdd") + "' and Lotes.FechaEnvio <= Dateadd ( Day, 1, '" + FechaHst.ToString("yyyyMMdd") + "') ");
     }
     else
     {
         commandText.Append("where (1=1 ");
     }
     //Otros Filtros
     string queryOtrosFiltros = ""; 
     if (CuitVendedor != "")
     {
         queryOtrosFiltros += "and Lotes.CuitVendedor = '" + CuitVendedor + "' ";
         commandText.Append(queryOtrosFiltros);
     }
     if (NumeroLote != "")
     {
         queryOtrosFiltros += "and Lotes.NumeroLote = '" + NumeroLote + "' ";
         commandText.Append(queryOtrosFiltros);
     }
     if (PuntoVenta != "")
     {
         queryOtrosFiltros += "and Lotes.PuntoVenta = '" + PuntoVenta + "' ";
         commandText.Append(queryOtrosFiltros);
     }
     commandText.Append(") ");
     if (VerPendientes)
     {
         commandText.Append(" or (WF_Op.IdEstado in ('PteEnvio', 'PteRespIF', 'PteRespAFIP') " + queryOtrosFiltros + ") ");
     }
     commandText.Append("select * from #Lotes order by IdLote Desc ");
     commandText.Append("IF @@ROWCOUNT > 0 ");
     commandText.Append("BEGIN ");
     //Select Comprobantes
     commandText.Append("select Comprobantes.* from #Lotes ");
     commandText.Append("inner join Comprobantes on Comprobantes.IdLote = #Lotes.IdLote ");
     //Select ComprobantesC (Compras)
     commandText.Append("select ComprobantesC.* from #Lotes ");
     commandText.Append("inner join ComprobantesC on ComprobantesC.IdLote = #Lotes.IdLote ");
     //Select ComprobantesD (Compras - Despachos de Importación)
     commandText.Append("select ComprobantesD.* from #Lotes ");
     commandText.Append("inner join ComprobantesD on ComprobantesD.IdLote = #Lotes.IdLote ");
     //Select WF_LOG
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Log.Fecha, WF_Evento.DescrEvento as Evento, WF_Estado.DescrEstado as Estado, WCUsuarios.Nombre+' ('+WF_Log.IdUsuario+')' as Responsable, WCUsuarios.Nombre as Nombre, ");
     commandText.Append("WF_Log.Comentario, WF_Log.IdLog, WF_Log.IdFlow, WF_Log.IdCircuito, WF_Log.IdNivSeg, WF_Log.IdGrupo, WF_Log.Supervisor, WF_Log.IdUsuario, ");
     commandText.Append("WF_Log.SupervisorNivel, WF_Log.IdEvento, WF_Log.IdEstado, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito, WCTbGrupos.Descr as DescrGrupo ");
     commandText.Append("from #Lotes, WF_Log, WCUsuarios, WF_Evento, WF_Estado, WF_Flow, WF_Circuito, WCTbGrupos ");
     commandText.Append("where WF_Log.IdOp = #Lotes.IdOp ");
     commandText.Append("and WF_Log.IdUsuario=WCUsuarios.IdUsuario ");
     commandText.Append("and WF_Log.IdFlow=WF_Evento.IdFlow ");
     commandText.Append("and WF_Log.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("and WF_Log.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("and WF_Log.IdGrupo=WCTbGrupos.IdGrupo ");
     commandText.Append("and WF_Log.IdEvento=WF_Evento.IdEvento ");
     commandText.Append("and WF_Log.IdEstado=WF_Estado.IdEstado ");
     //Select Eventos Posibles del WF    
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     //Select Eventos Posibles por lote
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow and WF_Evento.XLote=1 ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     commandText.Append("END ");
     commandText.Append("DROP TABLE #Lotes ");
     DataSet ds = new DataSet();
     ds = (DataSet)Ejecutar(commandText.ToString(), TipoRetorno.DS, Transaccion.Usa, sesion.CnnStr);
     List<eFact_Entidades.Lote> lotes = new List<eFact_Entidades.Lote>();
     if (ds.Tables.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             eFact_Entidades.Lote Lote = new eFact_Entidades.Lote();
             Copiar(ds, i, Lote);
             Lote.WF.EsquemaSegEventosPosibles = WF_EsquemaSegEventosPosibles_qry(Lote.WF);
             lotes.Add(Lote);
         }
     }
     Lotes = lotes;
 }
Esempio n. 2
0
        private void EnviarAIF()
        {
            try
            {
                Cursor=System.Windows.Forms.Cursors.WaitCursor;
                EventosComboBox.Enabled = false;
                if (BandejaSDataGridView.SelectedRows.Count != 0)
                {
                    eFact_Entidades.Lote l = new eFact_Entidades.Lote();
                    List<eFact_Entidades.Lote> llotes = new List<eFact_Entidades.Lote>();
                    for (int i = 0; i < BandejaSDataGridView.SelectedRows.Count; i++)
                    {
                        int renglon = BandejaSDataGridView.SelectedRows[i].Index;
                        l = dtBandejaSalida[renglon];
                        llotes.Add(l);
                    }
                    llotes = SortListaLotes(llotes);
                    for (int i = 0; i < llotes.Count; i++)
                    {
                        //Envio del lote a IF
                        eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
                        lote = llotes[i];
                        List<CedEntidades.Evento> eventosposibles = new List<CedEntidades.Evento>();
                        eventosposibles = lote.WF.EventosPosibles.FindAll((delegate(CedEntidades.Evento e1) { return e1.IdEstadoDsd.IdEstado.ToString() == "PteEnvio"; }));
                        if (eventosposibles.Count == 0)
                        {
                            MessageBox.Show("Imposible enviar el lote: " + lote.NumeroLote + " en el estado actual.", "Envio de Lotes", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                            break;
                        }
                        FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                        eFact_RN.Lote.DeserializarLc(out lc, lote, false);

                        //Antes de ejecutar el envio a Interfacturas, cambiar el estado.
                        EjecutarEventoBandejaS("EnviarAIF", "", lote);
                        //Actualizar el WF del lote.
                        eFact_RN.Lote.Leer(lote, Aplicacion.Sesion);

                        //Consultar si exite el lote en Interfacturas
                        FeaEntidades.InterFacturas.lote_comprobantes Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                        eFact_RN.IBK.error[] respErroresLote = new eFact_RN.IBK.error[0];
                        eFact_RN.IBK.error[] respErroresComprobantes = new eFact_RN.IBK.error[0];
                        eFact_RN.IBK.consulta_lote_responseErrores_consulta RespErroresLote = new eFact_RN.IBK.consulta_lote_responseErrores_consulta();
                        eFact_RN.IBK.consulta_lote_comprobantes_responseErrores_response RespErroresComprobantes = new eFact_RN.IBK.consulta_lote_comprobantes_responseErrores_response();
                        //Enviar a Interfacturas si el lote no existe.
                        eFact_RN.Comprobante eFact_RNComprobante = new eFact_RN.Comprobante();
                        eFact_RN.IBK.lote_response Lr = new eFact_RN.IBK.lote_response();
                        try
                        {
                            eFact_Entidades.Vendedor v = Aplicacion.Vendedores.Find(delegate(eFact_Entidades.Vendedor e1) { return e1.CuitVendedor == lc.cabecera_lote.cuit_vendedor.ToString(); });
                            if (v == null)
                            {
                                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Vendedor.Inexistente("CUIT " + lc.cabecera_lote.cuit_vendedor.ToString());
                            }
                            eFact_RNComprobante.EnviarIBK(out Lr, lc, v.NumeroSerieCertificado.ToString());
                            EjecutarEventoBandejaS("RegAceptIF", "", lote);
                        }
                        catch (Exception ex2)
                        {
                            //Si el lote tiene errores al ser enviado, grabar el rechazo.
                            string edescr = "";
                            if (Lr.estado == null && Lr.errores_lote == null && Lr.comprobante_response == null)
                            {
                                //Cuando el error es local, previo a la respuesta de IF se usa el código 99 (Cedeira) para mostrar el error.
                                //Ejemplo: cuando no está instalado el certificado.
                                Lr.estado = "99";
                                Lr.errores_lote = new eFact_RN.IBK.error[1];
                                Lr.errores_lote[0] = new eFact_RN.IBK.error();
                                Lr.errores_lote[0].codigo_error = 99;
                                edescr = ex2.Message.Replace("'", "''");
                                Lr.errores_lote[0].descripcion_error = edescr;
                                //------ Datos del lote, que genera el error ------
                                Lr.id_lote = Convert.ToInt64(lote.NumeroLote);
                                Lr.cuit_vendedor = Convert.ToInt64(lote.CuitVendedor);
                                Lr.punto_de_venta = Convert.ToInt32(lote.PuntoVenta);
                                Lr.cantidad_reg = lote.CantidadRegistros;
                                //-------------------------------------------------
                                if (edescr.IndexOf("500 - error") != -1)
                                {
                                    Lr.errores_lote[0].codigo_error = 500;
                                }
                                if (edescr.IndexOf("600 - error") != -1)
                                {
                                    Lr.errores_lote[0].codigo_error = 600;
                                }
                            }
                            eFact_RN.Lote.ActualizarDatosError(lote, Lr);
                            edescr = ex2.Message.Replace("'", "''");
                            EjecutarEventoBandejaS("RegRechIF", edescr, lote);
                            //Va a revertir el rechazo (si el error es "Timed Out" hasta 10 ocurrencias.
                            if (Lr.estado == "99" && Lr.errores_lote != null && Lr.errores_lote[0].descripcion_error.ToUpper().Trim() == "THE OPERATION HAS TIMED OUT")
                            {
                                eFact_Entidades.Lote loteAux = new eFact_Entidades.Lote();
                                loteAux.IdLote = lote.IdLote;
                                eFact_RN.Lote.Leer(loteAux, Aplicacion.Sesion);
                                List<CedEntidades.Log> log = loteAux.WF.Log.FindAll(delegate(CedEntidades.Log e1) { return e1.Comentario.ToUpper().Trim() == "THE OPERATION HAS TIMED OUT"; });
                                if (log != null && log.Count > 0 && log.Count < 10)
                                {
                                    //Actualizar el WF del lote.
                                    eFact_RN.Lote.Leer(lote, Aplicacion.Sesion);
                                    EjecutarEventoBandejaS("RevertirRechIFA", "", lote);
                                }
                            }
                            throw new Exception(ex2.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
            }
            finally
            {
                RefreshBandejaSalida();
                EventosComboBox.Enabled = true;
                Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
Esempio n. 3
0
 private void EventosWF(string Evento)
 {
     try
     {
         Cursor = System.Windows.Forms.Cursors.WaitCursor;
         EventosComboBox.Enabled = false;
         if (BandejaSDataGridView.SelectedRows.Count != 0)
         {
             for (int i = 0; i < BandejaSDataGridView.SelectedRows.Count; i++)
             {
                 eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
                 int renglon = BandejaSDataGridView.SelectedRows[i].Index;
                 lote = dtBandejaSalida[renglon];
                 EjecutarEventoBandejaS(Evento, "", lote);
             }
         }
     }
     catch (Exception ex)
     {
         Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
     }
     finally
     {
         EventosComboBox.Enabled = true;
         Cursor = System.Windows.Forms.Cursors.Default;
     }
 }
Esempio n. 4
0
 private void ConsultarLote()
 {
     try
     {
         Cursor = System.Windows.Forms.Cursors.WaitCursor;
         if (BandejaSDataGridView.SelectedRows.Count != 0)
         {
             eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
             int renglon = BandejaSDataGridView.SelectedRows[0].Index;
             lote = dtBandejaSalida[renglon];
             if (lote.IdNaturalezaLote != "Compra")
             {
                 ConsultaLote cl = new ConsultaLote(lote, ConsultaLote.Modo.Consulta);
                 cl.ShowDialog();
                 cl.Dispose();
             }
             else
             {
                 ConsultaLoteC cl = new ConsultaLoteC(lote);
                 cl.ShowDialog();
                 cl.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
         Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
     }
     finally
     {
         Cursor = System.Windows.Forms.Cursors.Default;
     }
 }
Esempio n. 5
0
 private void EnviarABandejaSButton_Click(object sender, EventArgs e)
 {
     Cursor = System.Windows.Forms.Cursors.WaitCursor;
     VerificarServicio();
     if (Aplicacion.Modalidad == "Automatica" && ServicioOK == true)
     {
         MessageBox.Show("No es posible enviar archivos a la bandeja de salida, mientras el Servicio-eFact se encuentre activo.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     EnviarABandejaSButton.Enabled = false;
     DescartarBandejaEButton.Enabled = false;
     try
     {
         if (BandejaEDataGridView.SelectedRows.Count != 0)
         {
             //Inicializar filtros para visualizar los archivos procesados.
             InicializarFiltrosTablero();
             for (int i = 0; i < BandejaEDataGridView.SelectedRows.Count; i++)
             {
                 int renglon = BandejaEDataGridView.SelectedRows[i].Index;
                 //Definir el nombre del archivo a guardar en el histórico como procesado, con o sin error.
                 //Mas adelante se le agraga el prefijo ( BAK o ERR ).
                 string NombreArchivo = dtBandejaEntrada[renglon].Nombre;
                 string FechaTexto = DateTime.Now.ToString("yyyyMMdd-hhmmss");
                 string ArchGuardarComoNombre = "";
                 eFact_RN.Engine.GenerarNombreArch(out ArchGuardarComoNombre, "", NombreArchivo);
                 //--------------------------------------
                 //Procesar el archivo seleccionado.
                 try
                 {
                     eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
                     eFact_RN.Archivo.Procesar(out lote, dtBandejaEntrada[renglon], Aplicacion.Aplic, Aplicacion.Sesion);
                     //Agregar datos del proceso a la entidad Archivo
                     ArchGuardarComoNombre = "BAK-" + ArchGuardarComoNombre;
                     dtBandejaEntrada[renglon].NombreProcesado = ArchGuardarComoNombre;
                     dtBandejaEntrada[renglon].FechaProceso = DateTime.Now;
                     string handler = eFact_RN.Archivo.Insertar(dtBandejaEntrada[renglon], true, Aplicacion.Sesion);
                     //Ejecutar el insert local del "Lote".
                     CedEntidades.Evento evento = new CedEntidades.Evento();
                     if (lote.IdNaturalezaLote == "")
                     {
                         evento.Id = "EnvBandSalida";
                         evento.Flow.IdFlow = "eFact";
                         //evento.Flow.DescrFlow = "Facturación Electrónica";
                         Cedeira.SV.WF.LeerEvento(evento, Aplicacion.Sesion);
                         lote.WF = Cedeira.SV.WF.Nueva("eFact", "Fact", 0, "Facturacion Electrónica", Aplicacion.Sesion);
                     }
                     else
                     {
                         evento.Id = "EnvBandSalidaV";
                         evento.Flow.IdFlow = "eFact";
                         //evento.Flow.DescrFlow = "Comprobantes";
                         Cedeira.SV.WF.LeerEvento(evento, Aplicacion.Sesion);
                         lote.WF = Cedeira.SV.WF.Nueva("eFact", "Fact", 0, "Comprobantes", Aplicacion.Sesion);
                     }
                     eFact_RN.Lote.VerificarEnviosPosteriores(true, lote.CuitVendedor, lote.NumeroLote, lote.PuntoVenta, lote.NumeroEnvio, eFact_R.Aplicacion.Sesion);
                     //Generar nombre de archivo procesado para ser enviado al histórico.
                     eFact_RN.Lote.Ejecutar(lote, evento, handler, Aplicacion.Aplic, Aplicacion.Sesion);
                 }
                 catch (Exception ex)
                 {
                     Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
                     dtBandejaEntrada[renglon].Comentario = ex.Message;
                     if (ex.InnerException != null)
                     {
                         dtBandejaEntrada[renglon].Comentario += "\r\n" + ex.InnerException.Message;
                     }
                     //Agregar datos del proceso a la entidad Archivo
                     ArchGuardarComoNombre = "ERR-" + ArchGuardarComoNombre;
                     dtBandejaEntrada[renglon].NombreProcesado = ArchGuardarComoNombre;
                     dtBandejaEntrada[renglon].FechaProceso = DateTime.Now;
                     eFact_RN.Archivo.Insertar(dtBandejaEntrada[renglon], false, Aplicacion.Sesion);
                 }
                 //Remover archivo ----------------------
                 Directory.Move(Aplicacion.Aplic.ArchPath + "\\" + NombreArchivo, Aplicacion.Aplic.ArchPathHis + ArchGuardarComoNombre);
                 //--------------------------------------
             }
         }
     }
     catch (Exception ex2)
     {
         Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex2);
     }
     //Actualizar Bandeja de entrada.
     try
     {
         LimpiarBandejaEntrada();
         ActualizarBandejaE();
         RefreshBandejaSalida();
     }
     catch (Exception ex)
     {
         Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
     }
     finally
     {
         EnviarABandejaSButton.Enabled = true;
         DescartarBandejaEButton.Enabled = true;
         Cursor = System.Windows.Forms.Cursors.Default;
     }
 }
Esempio n. 6
0
        private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try 
            {
                bool EncontreArchivos = false;
                timer1.Stop();

                CultureInfo cedeiraCultura = new CultureInfo(System.Configuration.ConfigurationManager.AppSettings["Cultura"], false);
                cedeiraCultura.DateTimeFormat = new CultureInfo(System.Configuration.ConfigurationManager.AppSettings["CulturaDateTimeFormat"], false).DateTimeFormat;
                Thread.CurrentThread.CurrentCulture = cedeiraCultura;
                
                //Solo la primera vez inicia la sesion
                if (Aplicacion == null)
                {
                    Inicializar();
                }

                //Actualizar Estado AFIP de los Lotes Ptes de Respuesta.
                ActualizarEstadoAFIPLotes();

                //Enviar a Interfacturas Lotes Ptes de Envío.
                EnviarAIFLotesPtesDeEnvio();

                string[] files = Directory.GetFiles(Aplicacion.ArchPath, "*.*");
                List<eFact_Entidades.Archivo> Archivos = new List<eFact_Entidades.Archivo>();
                foreach (string d in files)
                {
                    FileInfo ArchFileInfo = new FileInfo(d);
                    try
                    {
                        if (@System.Configuration.ConfigurationManager.AppSettings["ClearMemory"] == "SI")
                        {
                            Memory.ClearMemory();
                        }
                        eFact_Entidades.Archivo archivo = new eFact_Entidades.Archivo();
                        ActualizarBandejaEntrada(archivo, ArchFileInfo, Aplicacion.Sesion);
                        Archivos.Add(archivo);
                        EncontreArchivos = true;
                    }
                    catch (Exception ex)
                    {
                        Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
                    }
                }
                Archivos.Sort(ordenarPorNombre);
                foreach (eFact_Entidades.Archivo elem in Archivos)
                {
                    string NombreArchivo = elem.Nombre;
                    string FechaTexto = DateTime.Now.ToString("yyyyMMdd-hhmmss");
                    string ArchGuardarComoNombre = "";
                    eFact_RN.Engine.GenerarNombreArch(out ArchGuardarComoNombre, "", NombreArchivo);
                    //--------------------------------------
                    //Procesar el archivo seleccionado.
                    try
                    {
                        eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
                        eFact_RN.Archivo.Procesar(out lote, elem, Aplicacion, Aplicacion.Sesion);
                        //Agregar datos del proceso a la entidad Archivo
                        ArchGuardarComoNombre = "BAK-" + ArchGuardarComoNombre;
                        elem.NombreProcesado = ArchGuardarComoNombre;
                        elem.FechaProceso = DateTime.Now;
                        string handler = eFact_RN.Archivo.Insertar(elem, true, Aplicacion.Sesion);
                        //Ejecutar el insert local del "Lote".
                        CedEntidades.Evento evento = new CedEntidades.Evento();
                        evento.Id = "EnvBandSalida";
                        evento.Flow.IdFlow = "eFact";
                        evento.Flow.DescrFlow = "Facturación Electrónica";
                        Cedeira.SV.WF.LeerEvento(evento, Aplicacion.Sesion); 
                        lote.WF = Cedeira.SV.WF.Nueva("eFact", "FactServ", 0, "Facturacion Electrónica", Aplicacion.Sesion);
                        eFact_RN.Lote.VerificarEnviosPosteriores(true, lote.CuitVendedor, lote.NumeroLote, lote.PuntoVenta, lote.NumeroEnvio, Aplicacion.Sesion);
                        //Generar nombre de archivo procesado para ser enviado al histórico.
                        eFact_RN.Lote.Ejecutar(lote, evento, handler, Aplicacion, Aplicacion.Sesion);

                        //Leer el Lote procesado.
                        eFact_RN.Lote.Leer(lote, Aplicacion.Sesion);

                        //Enviar el Lote a IF.
                        EnviarAIF(lote);
                    }
                    catch (Exception ex)
                    {
                        Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
                        elem.Comentario = ex.Message;
                        if (ex.InnerException != null)
                        {
                            elem.Comentario += "\r\n" + ex.InnerException.Message;
                        }
                        if (ex.StackTrace != null)
                        {
                            string st = ex.StackTrace;
                            if (st.Length > 2000)
                            {
                                st = st.Substring(0, 2000);
                            }
                            elem.Comentario += "\r\n\r\n" + st;
                        }
                        //Agregar datos del proceso a la entidad Archivo
                        ArchGuardarComoNombre = "ERR-" + ArchGuardarComoNombre;
                        elem.NombreProcesado = ArchGuardarComoNombre;
                        elem.FechaProceso = DateTime.Now;
                        eFact_RN.Archivo.Insertar(elem, false, Aplicacion.Sesion);
                    }
                    
                    //Remover archivo ----------------------
                    Directory.Move(Aplicacion.ArchPath + "\\" + NombreArchivo, Aplicacion.ArchPathHis + ArchGuardarComoNombre);
                    //--------------------------------------

                    //Solo procesa un archivo y sale, para poder recibir posteriormente la respuesta AFIP. 
                    //Cuando se vuelve a iniciar el timer de servicio se ejecuta la funcion "ActualizarEstadoAFIPLotes()".
                    break;
                }
                if (EncontreArchivos)
                {
                    if (@System.Configuration.ConfigurationManager.AppSettings["ClearMemory"] == "SI")
                    {
                        Memory.ClearMemory();
                    }
                }
            }
            catch (Exception ex)
            {
                Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
            }
            finally
            {
                timer1.Start();
            }
        }
Esempio n. 7
0
 private void ExportarItf(object sender, EventArgs e)
 {
     try
     {
         if (((ComboBox)sender).SelectedIndex != 0)
         {
             Cursor = System.Windows.Forms.Cursors.WaitCursor;
             ExportarItfComboBox.Enabled = false;
             if (BandejaSDataGridView.SelectedRows.Count != 0)
             {
                 for (int i = 0; i < BandejaSDataGridView.SelectedRows.Count; i++)
                 {
                     int renglon = BandejaSDataGridView.SelectedRows[i].Index;
                     eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
                     lote = dtBandejaSalida[renglon];
                     string archivoProcesado = "";
                     bool IF = false;
                     if (((ComboBox)sender).SelectedIndex == 4 || ((ComboBox)sender).SelectedIndex == 5)
                     {
                         IF = true;
                     }
                     // 1 y 4 archivos TXT 
                     // 2, 3 y 5 archivos XML  
                     if (((ComboBox)sender).SelectedIndex == 1 || ((ComboBox)sender).SelectedIndex == 4)
                     {
                         eFact_RN.Lote.GuardarItfTXT(out archivoProcesado, lote, "ITF", Aplicacion.Aplic.ArchPathItf, IF);
                     }
                     else
                     {
                         if (((ComboBox)sender).SelectedIndex == 3)
                         {
                             eFact_RN.Lote.GuardarItfXML(out archivoProcesado, lote, "ITF", Aplicacion.Aplic.ArchPathItf, IF, true);
                         }
                         else
                         {
                             eFact_RN.Lote.GuardarItfXML(out archivoProcesado, lote, "ITF", Aplicacion.Aplic.ArchPathItf, IF, false);
                         }
                     }
                     MessageBox.Show("Interface generada satisfactoriamente con el nombre: " + archivoProcesado, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
     }
     finally
     {
         ExportarItfComboBox.Enabled = true;
         Cursor = System.Windows.Forms.Cursors.Default;
     }
 }
Esempio n. 8
0
 public ConsultaLote(Modo modo)
 {
     InitializeComponent();
     lote = null;
     modoActual = modo;
 }
Esempio n. 9
0
 private void Cancelar()
 {
     lote = new eFact_Entidades.Lote();
     IdLoteTextBox.Text = "";
     CuitVendedorTextBox.ReadOnly = false;
     NumeroLoteTextBox.ReadOnly = false;
     PuntoVentaTextBox.ReadOnly = false;
     CantidadRegistrosTextBox.Text = "";
     NumeroEnvioTextBox.Text = "";
     FechaAltaDTP.Text = "";
     FechaEnvioDTP.Text = "";
     NombreArchTextBox.Text = "";
     IdEstadoTextBox.Text = "";
     this.XMLWebBrowser.Navigate("about:blank");
     this.XMLIFWebBrowser.Navigate("about:blank");
     DetalleLoteDataGridView.DataSource = null;
     DetalleLoteDataGridView.Refresh();
     LogLoteDataGridView.DataSource = null;
     LogLoteDataGridView.Refresh();
     EsquemaSegEventosPosiblesTreeView.Nodes.Clear();
     EsquemaSegEventosPosiblesTreeView.Refresh();
     ActualizarButton.Visible = false;
     CancelarButton.Visible = false;
     ConsultarLoteIFButton.Enabled = true;
 }
Esempio n. 10
0
 public ConsultaLote(eFact_Entidades.Lote Lote, Modo modo)
 {
     InitializeComponent();
     lote = Lote;
     modoActual = modo;
 }
Esempio n. 11
0
        private void ProcesarComprobante(out CrystalDecisions.CrystalReports.Engine.ReportDocument ReporteDocumento, eFact_Entidades.Lote Lote, int Renglon)
        {
            try
            {
                Cursor = System.Windows.Forms.Cursors.WaitCursor;
                facturaRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                facturaRpt.Load("Facturacion\\Electronica\\Reportes\\Factura.rpt");

                //Crear un lote de un solo comprobante, para la impresion o exportacion del pdf.
                eFact_Entidades.Lote LoteConUnSoloComprobante = new eFact_Entidades.Lote();
                LoteConUnSoloComprobante.CuitVendedor = Lote.CuitVendedor;
                LoteConUnSoloComprobante.FechaAlta = Lote.FechaAlta;
                LoteConUnSoloComprobante.FechaEnvio = Lote.FechaEnvio;
                LoteConUnSoloComprobante.IdLote = Lote.IdLote;
                LoteConUnSoloComprobante.IdOp = Lote.IdOp;
                LoteConUnSoloComprobante.LoteXml = Lote.LoteXml;
                LoteConUnSoloComprobante.LoteXmlIF = Lote.LoteXmlIF;
                LoteConUnSoloComprobante.NumeroEnvio = Lote.NumeroEnvio;
                LoteConUnSoloComprobante.NumeroLote = Lote.NumeroLote;
                LoteConUnSoloComprobante.PuntoVenta = Lote.PuntoVenta;
                LoteConUnSoloComprobante.CantidadRegistros = 1;
                LoteConUnSoloComprobante.Comprobantes.Add(Lote.Comprobantes[Renglon]);
                LoteConUnSoloComprobante.WF = Lote.WF;
                FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                eFact_RN.Lote.DeserializarLc(out lc, LoteConUnSoloComprobante, true);
                //Entidad para reporte crystal. Al desserializar se pierden los descuentos de la entidad original.
                FeaEntidades.Reporte.lote_comprobantes lcReporte = new FeaEntidades.Reporte.lote_comprobantes();
                eFact_RN.Lote.DeserializarLc(out lcReporte, LoteConUnSoloComprobante);
                for (int i = 0; i < lc.comprobante.Length; i++)
                {
                    if (i == 0)
                    {
                        lc.comprobante[i] = lc.comprobante[Renglon];
                        lcReporte.comprobante[i] = lcReporte.comprobante[Renglon];
                        for (int l = 0; l < lc.comprobante[i].detalle.linea.Length; l++)
                        {
                            if (lc.comprobante[i].detalle.linea[l].lineaDescuentos != null)
                            {
                                lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos = new FeaEntidades.Reporte.lineaDescuentos[lc.comprobante[i].detalle.linea[l].lineaDescuentos.Length];
                                for (int d = 0; d < lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos.Length; d++)
                                {
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d] = new FeaEntidades.Reporte.lineaDescuentos();
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].descripcion_descuento = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].descripcion_descuento;
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento;
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origen = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origen;
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origenSpecified = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origenSpecified;
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].importe_descuento_moneda_origenSpecified = true;
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuento = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuento;
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuentoSpecified = lc.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuentoSpecified;
                                    lcReporte.comprobante[i].detalle.linea[l].lineaDescuentos[d].porcentaje_descuentoSpecified = true;
                                }
                            }
                            else
                            {
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos = new FeaEntidades.Reporte.lineaDescuentos[1];
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0] = new FeaEntidades.Reporte.lineaDescuentos();
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].descripcion_descuento = "";
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].importe_descuento = 0;
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].porcentaje_descuento = 0;
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].porcentaje_descuentoSpecified = true;
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].importe_descuento_moneda_origen = 0;
                                lcReporte.comprobante[0].detalle.linea[l].lineaDescuentos[0].importe_descuento_moneda_origenSpecified = true;
                            }
                        }
                    }
                    else
                    {
                        lc.comprobante[i] = null;
                        lcReporte.comprobante[i] = null;
                    }
                }
                
                AsignarCamposOpcionales(lcReporte);
                ReemplarResumenImportesMonedaExtranjera(lcReporte);
                DataSet ds = new DataSet();
                XmlSerializer objXS = new XmlSerializer(lcReporte.GetType());
                StringWriter objSW = new StringWriter();
                objXS.Serialize(objSW, lcReporte);
                StringReader objSR = new StringReader(objSW.ToString());
                ds.ReadXml(objSR);
                
                string pxsd = string.Format("{0}\\Facturacion\\Electronica\\Reportes\\lote_comprobantes.xsd",System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                System.IO.File.Copy(pxsd, @System.IO.Path.GetTempPath() + "lote_comprobantes.xsd", true);
                
                string imagen = string.Format("{0}\\Facturacion\\Electronica\\Reportes\\Imagen.xsd",System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                System.IO.File.Copy(imagen, @System.IO.Path.GetTempPath() + "Imagen.xsd", true);

                facturaRpt.SetDataSource(ds);

                facturaRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                facturaRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                IncrustarLogo();
                GenerarCodigoBarras(lcReporte.cabecera_lote.cuit_vendedor + lcReporte.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00") + lcReporte.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString("0000") + lcReporte.comprobante[0].cabecera.informacion_comprobante.cae + lcReporte.comprobante[0].cabecera.informacion_comprobante.fecha_vencimiento_cae);
                AsignarParametros(lcReporte.comprobante[0].resumen.importe_total_factura);

                ReporteDocumento = facturaRpt;
            }
            catch (Exception ex)
            {
                ReporteDocumento = null;
                //MessageBox.Show(ex.Message, "Problemas al procesar el comprobante", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Reporte.ProblemasProcesando(ex);
            }
            finally
            {
                Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
Esempio n. 12
0
 private void ConsultarLoteIFButton_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor = System.Windows.Forms.Cursors.WaitCursor;
         NumeroLoteTextBox.ReadOnly = true;
         CuitVendedorTextBox.ReadOnly = true;
         PuntoVentaTextBox.ReadOnly = true;
         FeaEntidades.InterFacturas.lote_comprobantes Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
         eFact_RN.IBK.error[] respErroresLote = new eFact_RN.IBK.error[0];
         eFact_RN.IBK.error[] respErroresComprobantes = new eFact_RN.IBK.error[0];
         eFact_Entidades.Vendedor v = Aplicacion.Vendedores.Find(delegate(eFact_Entidades.Vendedor e1) { return e1.CuitVendedor == CuitVendedorTextBox.Text; });
         if (v == null)
         {
             throw new Microsoft.ApplicationBlocks.ExceptionManagement.Vendedor.Inexistente("CUIT " + CuitVendedorTextBox.Text);
         }
         if (modoActual == Modo.Contingencia)
         {
             lote = new eFact_Entidades.Lote();
             if (NumeroLoteTextBox.Text == "")
             {
                 throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorNoInfo("Número de lote");
             }
             if (!(Cedeira.SV.Fun.IsNumeric(NumeroLoteTextBox.Text)))
             {
                 throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorInvalido("Número de lote");
             }
             lote.NumeroLote = NumeroLoteTextBox.Text;
             if (CuitVendedorTextBox.Text == "")
             {
                 throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorNoInfo("Cuit vendedor");
             }
             if (!(Cedeira.SV.Fun.IsNumeric(CuitVendedorTextBox.Text)))
             {
                 throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorInvalido("Cuit vendedor");
             }
             lote.CuitVendedor = CuitVendedorTextBox.Text;
             if (PuntoVentaTextBox.Text == "")
             {
                 throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorNoInfo("Punto de Venta");
             }
             if (!(Cedeira.SV.Fun.IsNumeric(PuntoVentaTextBox.Text)))
             {
                 throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ValorInvalido("Punto de Venta");
             }
             lote.PuntoVenta = PuntoVentaTextBox.Text;
             eFact_RN.Lote.ConsultarLoteIF(out Lc, out respErroresLote, out respErroresComprobantes, lote, v.NumeroSerieCertificado.ToString());
             
             //Verificar si existe en la base de datos como AceptadaAFIP
             eFact_Entidades.Lote loteAceptadoAFIP = new eFact_Entidades.Lote();
             List<eFact_Entidades.Lote> lotes = new List<eFact_Entidades.Lote>();
             eFact_RN.Lote.Consultar(out lotes, eFact_Entidades.Lote.TipoConsulta.SinAplicarFechas, DateTime.Today, DateTime.Today, CuitVendedorTextBox.Text, NumeroLoteTextBox.Text, PuntoVentaTextBox.Text, false, Aplicacion.Sesion);
             loteAceptadoAFIP = lotes.Find(delegate(eFact_Entidades.Lote e1) { return e1.IdEstado == "AceptadoAFIP" || e1.IdEstado == "AceptadoAFIPO" || e1.IdEstado == "AceptadoAFIPP"; });
             if (loteAceptadoAFIP != null && loteAceptadoAFIP.IdOp != 0)
             {
                 //Verificar si cambio el XML de respuesta
                 string loteXml = "";
                 eFact_RN.Lote.SerializarLc(out loteXml, Lc);
                 if (!(loteAceptadoAFIP.LoteXmlIF.Equals(loteXml)))
                 {
                     MessageBox.Show("El XML de respuesta actual, difiere del XML de respuesta obtenido en esta consulta. Si actualiza los datos, quedará registrado este último XML de respuesta.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                 }
                 lote = loteAceptadoAFIP;
                 lote.LoteXmlIF = loteXml;
                 for (int i = 0; i < lote.Comprobantes.Count; i++)
                 {
                     if (Lc.comprobante[i].cabecera.informacion_comprobante.cae != null)
                     {
                         lote.Comprobantes[i].NumeroCAE = Lc.comprobante[i].cabecera.informacion_comprobante.cae;
                         lote.Comprobantes[i].FechaCAE = eFact_RN.Archivo.ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.Trim());
                         lote.Comprobantes[i].FechaVtoCAE = eFact_RN.Archivo.ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.Trim());
                     }
                     lote.Comprobantes[i].EstadoIFoAFIP = Lc.comprobante[i].cabecera.informacion_comprobante.resultado;
                     lote.Comprobantes[i].ComentarioIFoAFIP = Lc.comprobante[i].cabecera.informacion_comprobante.motivo;
                 }
             }
             else
             {
                 eFact_RN.Lote.Lc2Lote(out lote, Lc, Aplicacion.Aplic, Aplicacion.Sesion);
                 eventoContingencia = new CedEntidades.Evento();
                 CedEntidades.Flow flow = new CedEntidades.Flow();
                 flow.IdFlow = "eFact";
                 eventoContingencia.Flow = flow;
                 string resultado = "";
                 string resultadoTexto = "";
                 if (Lc.cabecera_lote.resultado != null && Lc.cabecera_lote.resultado.ToString().Trim() != "")
                 {
                     resultado = Lc.cabecera_lote.resultado.ToString();
                     resultadoTexto = "\r\nEl lote consultado se encuentra en estado: " + Lc.cabecera_lote.resultado.ToString();
                 }
                 switch (resultado)
                 {
                     case "A":
                         eventoContingencia.Id = "RegContAFIP";
                         break;
                     case "O":
                         eventoContingencia.Id = "RegContAFIPO";
                         break;
                     case "P":
                         eventoContingencia.Id = "RegContAFIPP";
                         break;
                     default:
                         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.Lote.EstadoNoPermitido("Solo es posible operar en contingencia con lotes Aceptados por AFIP." + resultadoTexto);
                 }
                 Cedeira.SV.WF.LeerEvento(eventoContingencia, Aplicacion.Sesion);
                 lote.WF.EventosPosibles.Clear();
                 lote.WF.EventosPosibles.Add(eventoContingencia);
             }
             lote.WF.EsquemaSegEventosPosibles = Cedeira.SV.WF.EsquemaSegEventosPosibles(lote.WF);
             eFact_RN.Lote.MuestroEsquemaSegEventosPosibles(EsquemaSegEventosPosiblesTreeView, lote);
             BindingControles();
             DetalleLoteDataGridView.AutoGenerateColumns = false;
             DetalleLoteDataGridView.DataSource = new List<eFact_Entidades.Comprobante>();
             DetalleLoteDataGridView.DataSource = lote.Comprobantes;
             CancelarButton.Visible = true;
             ActualizarButton.Visible = true;
             ConsultarLoteIFButton.Enabled = false;
         }
         else
         {
             eFact_RN.Lote.ConsultarLoteIF(out Lc, out respErroresLote, out respErroresComprobantes, lote, v.NumeroSerieCertificado.ToString());
             MessageBox.Show("Lote de comprobantes número " + lote.NumeroLote + " encontrado satisfactoriamente en Interfacturas.", "Consulta de Lotes", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Consulta de Lotes", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
         if (modoActual == Modo.Contingencia)
         {
             Cancelar();
         }
     }
     finally
     {
         Cursor = System.Windows.Forms.Cursors.Default;
     }
 }
Esempio n. 13
0
 public static void Lc2Lote(out eFact_Entidades.Lote Lote, FeaEntidades.InterFacturas.lote_comprobantes Lc, eFact_Entidades.Aplicacion Aplicacion, CedEntidades.Sesion Sesion)
 {
     if (Lc.cabecera_lote.cuit_vendedor.ToString().Trim() != Aplicacion.OtrosFiltrosCuit.Trim() && Aplicacion.OtrosFiltrosCuit.Trim() != "")
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.CUITNoHabilitadoParaElUsuario(Lc.cabecera_lote.cuit_vendedor.ToString());
     }
     eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
     lote.CuitVendedor = Lc.cabecera_lote.cuit_vendedor.ToString();
     lote.PuntoVenta = Lc.cabecera_lote.punto_de_venta.ToString();
     lote.NumeroLote = Lc.cabecera_lote.id_lote.ToString();
     lote.FechaAlta = DateTime.Now;
     if (Lc.cabecera_lote.fecha_envio_lote != null)
     {
         lote.FechaEnvio = ConvertirStringToDateTime(Lc.cabecera_lote.fecha_envio_lote.ToString());
     }
     else
     {
         lote.FechaEnvio = Convert.ToDateTime("31/12/9998");
     }
     lote.CantidadRegistros = Convert.ToInt32(Lc.cabecera_lote.cantidad_reg.ToString());
     
     //Verificar bandeja de salida.
     //int numeroEnvioDisponible = 0;
     //eFact_RN.Lote.ObtenerNumeroEnvioDisponible(out numeroEnvioDisponible, lote.CuitVendedor, lote.NumeroLote, lote.PuntoVenta, eFact_Aplicacion.Sesion);
     
     string loteXml = "";
     eFact_RN.Lote.SerializarLc(out loteXml, Lc);
     lote.LoteXmlIF = loteXml;
     lote.NumeroEnvio = 0;
     lote.NombreArch = "";
     lote.WF = Cedeira.SV.WF.Nueva("eFact", "Fact", 0, "Facturacion Electrónica", Sesion);
     for (int i = 0; i < Lc.cabecera_lote.cantidad_reg; i++)
     {
         eFact_Entidades.Comprobante c = new eFact_Entidades.Comprobante();
         c.IdTipoComprobante = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprobante.tipo_de_comprobante.ToString());
         c.NumeroComprobante = Lc.comprobante[i].cabecera.informacion_comprobante.numero_comprobante.ToString();
         c.TipoDocComprador = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprador.codigo_doc_identificatorio.ToString());
         c.NroDocComprador = Lc.comprobante[i].cabecera.informacion_comprador.nro_doc_identificatorio.ToString();
         c.NombreComprador = Lc.comprobante[i].cabecera.informacion_comprador.denominacion;
         c.Fecha = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_emision.ToString());
         c.NumeroCAE = Convert.ToString(Lc.comprobante[i].cabecera.informacion_comprobante.cae);
         if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae != null && Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.ToString() != "")
         {
             c.FechaCAE = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.ToString());
         }
         if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae != null && Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.ToString() != "")
         {
             c.FechaVtoCAE = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.ToString());
         }
         c.IdMoneda = Convert.ToString(Lc.comprobante[i].resumen.codigo_moneda);
         c.Importe = Convert.ToDecimal(Lc.comprobante[i].resumen.importe_total_factura);
         if (Lc.comprobante[i].resumen.importes_moneda_origen != null)
         {
             c.ImporteMonedaOrigen = Convert.ToDecimal(Lc.comprobante[i].resumen.importes_moneda_origen.importe_total_factura);
         }
         if (Lc.comprobante[i].cabecera.informacion_comprobante.resultado != null)
         {
             c.EstadoIFoAFIP = Convert.ToString(Lc.comprobante[i].cabecera.informacion_comprobante.resultado);
         }
         if (Lc.comprobante[i].cabecera.informacion_comprobante.motivo != null)
         {
             c.ComentarioIFoAFIP = Convert.ToString(Lc.comprobante[i].cabecera.informacion_comprobante.motivo);
         }
         c.TipoCambio = Convert.ToDecimal(Lc.comprobante[i].resumen.tipo_de_cambio);
         lote.Comprobantes.Add(c);
     }
     Lote = lote;
 }
Esempio n. 14
0
 public static void Ejecutar(eFact_Entidades.Lote Lote, CedEntidades.Evento Evento, string Handler, eFact_Entidades.Aplicacion Aplicacion, CedEntidades.Sesion Sesion)
 {
     string handlerEvento = "";
     //VerificarAssemblyVersion();
     eFact_DB.Lote lote = new eFact_DB.Lote(Sesion);
     string nombreArchivoProcesado = "";
     switch (Lote.WF.IdFlow)
     {
         case "eFact":
             switch (Evento.Id)
             {
                 case "EnvBandSalida":
                     if (Lote.NumeroEnvio > 1)
                     { 
                         eFact_Entidades.Lote l = new eFact_Entidades.Lote();
                         l.CuitVendedor = Lote.CuitVendedor;
                         l.PuntoVenta = Lote.PuntoVenta;
                         l.NumeroLote = Lote.NumeroLote;
                         l.NumeroEnvio = Lote.NumeroEnvio - 1;
                         eFact_RN.Lote.Leer(l, Sesion);
                         //Busca el evento automático, para anular el envio anterior.
                         CedEntidades.Evento evento = l.WF.EventosPosibles.Find((delegate(CedEntidades.Evento e1) { return e1.Automatico == true && (e1.Id == "AnularRechIF" || e1.Id == "AnularCancel"); }));
                         handlerEvento = Cedeira.SV.WF.EjecutarEvento(l.WF, evento, true);
                         handlerEvento += " end ";
                     }
                     handlerEvento += Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.Insertar(Lote, handlerEvento, Handler);
                     break;
                 case "EnvBandSalidaV":
                     handlerEvento += Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.Insertar(Lote, handlerEvento, Handler);
                     break;
                 case "EnviarAIF":
                     handlerEvento += Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.ActualizarFechaEnvio(Lote, handlerEvento);
                     break;
                 case "RegAceptAFIP":
                 case "RegActAFIP":
                     handlerEvento = Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.ActualizarDatosCAE(Lote, handlerEvento);
                     if (Aplicacion.TipoItfAut == "XML")
                     {
                         GuardarItfXML(out nombreArchivoProcesado, Lote, "ROK", Aplicacion.ArchPathItfAut, true, false);
                     }
                     else if (Aplicacion.TipoItfAut == "TXT")
                     {
                         GuardarItfTXT(out nombreArchivoProcesado, Lote, "ROK", Aplicacion.ArchPathItfAut, true);
                     }
                     break;
                 case "RegAceptAFIPO":
                 case "RegActAFIPO":
                     handlerEvento = Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.ActualizarDatosCAE(Lote, handlerEvento);
                     if (Aplicacion.TipoItfAut == "XML")
                     {
                         GuardarItfXML(out nombreArchivoProcesado, Lote, "ROO", Aplicacion.ArchPathItfAut, true, false);
                     }
                     else if (Aplicacion.TipoItfAut == "TXT")
                     {
                         GuardarItfTXT(out nombreArchivoProcesado, Lote, "ROO", Aplicacion.ArchPathItfAut, true);
                     }
                     break;
                 case "RegAceptAFIPP":
                 case "RegActAFIPP":
                     handlerEvento = Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.ActualizarDatosCAE(Lote, handlerEvento);
                     if (Aplicacion.TipoItfAut == "XML")
                     {
                         GuardarItfXML(out nombreArchivoProcesado, Lote, "ROP", Aplicacion.ArchPathItfAut, true, false);
                     }
                     else if (Aplicacion.TipoItfAut == "TXT")
                     {
                         GuardarItfTXT(out nombreArchivoProcesado, Lote, "ROP", Aplicacion.ArchPathItfAut, true);
                     }
                     break;
                 case "RegContAFIP":
                 case "RegContAFIPO":
                 case "RegContAFIPP":
                     handlerEvento = Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     DataTable dt = lote.Insertar(Lote, handlerEvento, "");
                     Lote.IdLote = Convert.ToInt32(dt.Rows[0][0].ToString());
                     Leer(Lote, Sesion);
                     CedEntidades.Evento eventoAct = new CedEntidades.Evento();
                     eventoAct = Lote.WF.EventosPosibles[0];
                     handlerEvento = Cedeira.SV.WF.EjecutarEvento(Lote.WF, eventoAct, true);
                     lote.ActualizarDatosCAE(Lote, handlerEvento);
                     if (Aplicacion.TipoItfAut == "XML")
                     {
                         GuardarItfXML(out nombreArchivoProcesado, Lote, "ROK", Aplicacion.ArchPathItfAut, true, false);
                     }
                     else if (Aplicacion.TipoItfAut == "TXT")
                     {
                         GuardarItfTXT(out nombreArchivoProcesado, Lote, "ROK", Aplicacion.ArchPathItfAut, true);
                     }
                     break;
                 case "RegRechAFIP":
                     handlerEvento = Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.ActualizarDatosError(Lote, handlerEvento);
                     if (Aplicacion.TipoItfAut == "XML")
                     {
                         GuardarItfXML(out nombreArchivoProcesado, Lote, "RAF", Aplicacion.ArchPathItfAut, true, false);
                     }
                     else if (Aplicacion.TipoItfAut == "TXT")
                     {
                         GuardarItfTXTlr(out nombreArchivoProcesado, Lote, "RAF", Aplicacion.ArchPathItfAut, true);
                     }
                     break;
                 case "RegRechIF":
                     handlerEvento = Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, true);
                     lote.ActualizarDatosError(Lote, handlerEvento);
                     if (Aplicacion.TipoItfAut == "XML")
                     {
                         GuardarItfXML(out nombreArchivoProcesado, Lote, "RIF", Aplicacion.ArchPathItfAut, true, false);
                     }
                     else if (Aplicacion.TipoItfAut == "TXT")
                     {
                         GuardarItfTXTlr(out nombreArchivoProcesado, Lote, "RIF", Aplicacion.ArchPathItfAut, true);
                     }
                     break;
                 default:
                     Cedeira.SV.WF.EjecutarEvento(Lote.WF, Evento, false);
                     break;
             }
             break;
     }
 }
Esempio n. 15
0
 public void ConsultarNovedades(out List<eFact_Entidades.Lote> Lotes)
 {
     StringBuilder commandText = new StringBuilder();
     //Query PF
     commandText.Append("select Lotes.*, WF_Op.IdFlow ,WF_Op.IdCircuito, WF_Op.IdNivSeg, WF_Op.IdEstado, WF_Op.DescrOp, WF_Op.UltActualiz, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito , WF_NivSeg.DescrNivSeg, WF_Estado.DescrEstado ");
     commandText.Append("INTO #Lotes ");
     commandText.Append("from Lotes ");
     commandText.Append("inner join WF_Op on Lotes.IdOp = WF_Op.IdOp ");
     commandText.Append("inner join WF_Flow on WF_Op.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("inner join WF_Circuito on WF_Op.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("inner join WF_NivSeg on WF_Op.IdNivSeg=WF_NivSeg.IdNivSeg ");
     commandText.Append("inner join WF_Estado on WF_Op.IdEstado=WF_Estado.IdEstado ");
     commandText.Append("inner join WF_Log l on WF_Op.IdOp=l.IdOp ");
     commandText.Append("where l.IdLog in (select max(IdLog) from WF_Log where IdOp = l.IdOp group by IdOp) ");
     commandText.Append("and l.IdLog not in (select IdLog from Novedades where WF_Op.IdOp=Novedades.IdOp) ");
     commandText.Append("and WF_OP.IdEstado in ('AceptadoAFIP', 'AceptadoAFIPO', 'AceptadoAFIPP', 'RechazadoIF', 'RechazadoAFIP') ");
     commandText.Append("select * from #Lotes order by IdLote Desc ");
     commandText.Append("IF @@ROWCOUNT > 0 ");
     commandText.Append("BEGIN ");
     //Select Comprobantes
     commandText.Append("select Comprobantes.* from #Lotes ");
     commandText.Append("inner join Comprobantes on Comprobantes.IdLote = #Lotes.IdLote ");
     //Select WF_LOG
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Log.Fecha, WF_Evento.DescrEvento as Evento, WF_Estado.DescrEstado as Estado, WCUsuarios.Nombre+' ('+WF_Log.IdUsuario+')' as Responsable, WCUsuarios.Nombre as Nombre, ");
     commandText.Append("WF_Log.Comentario, WF_Log.IdLog, WF_Log.IdFlow, WF_Log.IdCircuito, WF_Log.IdNivSeg, WF_Log.IdGrupo, WF_Log.Supervisor, WF_Log.IdUsuario, ");
     commandText.Append("WF_Log.SupervisorNivel, WF_Log.IdEvento, WF_Log.IdEstado, WF_Flow.DescrFlow, WF_Circuito.DescrCircuito, WCTbGrupos.Descr as DescrGrupo ");
     commandText.Append("from #Lotes, WF_Log, WCUsuarios, WF_Evento, WF_Estado, WF_Flow, WF_Circuito, WCTbGrupos ");
     commandText.Append("where WF_Log.IdOp = #Lotes.IdOp ");
     commandText.Append("and WF_Log.IdUsuario=WCUsuarios.IdUsuario ");
     commandText.Append("and WF_Log.IdFlow=WF_Evento.IdFlow ");
     commandText.Append("and WF_Log.IdFlow=WF_Flow.IdFlow ");
     commandText.Append("and WF_Log.IdCircuito=WF_Circuito.IdCircuito ");
     commandText.Append("and WF_Log.IdGrupo=WCTbGrupos.IdGrupo ");
     commandText.Append("and WF_Log.IdEvento=WF_Evento.IdEvento ");
     commandText.Append("and WF_Log.IdEstado=WF_Estado.IdEstado ");
     commandText.Append("order by WF_Log.IdLog ");
     //Select Eventos Posibles del WF    
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     //Select Eventos Posibles por lote
     commandText.Append("Select #Lotes.IdLote, ");
     commandText.Append("WF_Evento.IdFlow, IdEvento, DescrEvento, TextoAccion, IdEstadoDsd, IdEstadoHst, Automatico, CXO, XLote, WF_Flow.DescrFlow, EstadoDsd.DescrEstado as DescrEstadoDsd, EstadoHst.DescrEstado as DescrEstadoHst ");
     commandText.Append("from #Lotes ");
     commandText.Append("inner join WF_Evento on WF_Evento.IdFlow = #Lotes.IdFlow and WF_Evento.XLote=1 ");
     commandText.Append("inner join WF_Flow on WF_Flow.IdFlow = #Lotes.IdFlow ");
     commandText.Append("inner join WF_Estado EstadoDsd on EstadoDsd.IdEstado=WF_Evento.IdEstadoDsd ");
     commandText.Append("inner join WF_Estado EstadoHst on EstadoHst.IdEstado=WF_Evento.IdEstadoHst ");
     commandText.Append("where WF_Evento.IdEvento in (select IdEvento from WF_EsquemaSeg where IdCircuito = #Lotes.IdCircuito and IdFlow = #Lotes.IdFlow ) ");
     commandText.Append("and WF_Evento.IdEstadoDsd = #Lotes.IdEstado or WF_Evento.IdEstadoDsd = '<EstadoNoFinal>' ");
     commandText.Append("END ");
     commandText.Append("DROP TABLE #Lotes ");
     DataSet ds = new DataSet();
     ds = (DataSet)Ejecutar(commandText.ToString(), TipoRetorno.DS, Transaccion.Usa, sesion.CnnStr);
     List<eFact_Entidades.Lote> lotes = new List<eFact_Entidades.Lote>();
     if (ds.Tables.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             eFact_Entidades.Lote Lote = new eFact_Entidades.Lote();
             Copiar(ds, i, Lote);
             Lote.WF.EsquemaSegEventosPosibles = WF_EsquemaSegEventosPosibles_qry(Lote.WF);
             lotes.Add(Lote);
         }
     }
     Lotes = lotes;
 }
Esempio n. 16
0
        public static void Procesar(out eFact_Entidades.Lote Lote, eFact_Entidades.Archivo Archivo, eFact_Entidades.Aplicacion Aplicacion, CedEntidades.Sesion Sesion)
        {
            //Antes de procesar el archivo grabamos los datos básicos del mismo.
            if (Archivo.Tipo.ToUpper() != ".TXT" && Archivo.Tipo.ToUpper() != ".XML" && Archivo.Tipo.ToUpper() != ".REC")
            {
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.TipoDeArchivoIncorrecto("Solo se aceptan archivo TXT o XML.");
            }
            FeaEntidades.InterFacturas.lote_comprobantes Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
            System.IO.MemoryStream ms;
            System.Xml.Serialization.XmlSerializer x;
            switch (Aplicacion.CodigoAplic.ToString())
            {
                case "eFactInterface":
                    {
                        if (Archivo.Tipo.ToUpper() == ".XML")
                        {
                            //StreamReader objReader = new StreamReader(Archivo.Path + "\\" + Archivo.Nombre, Encoding.GetEncoding("iso-8859-1"));
                            StreamReader objReader = new StreamReader(Archivo.Path + "\\" + Archivo.Nombre, Encoding.GetEncoding("utf-8"));
                            string cadena;
                            cadena = objReader.ReadToEnd();
                            objReader.Close();
                            byte[] a = new byte[cadena.Length];// esta es la declaracion de tu arreglo
                            System.Text.Encoding codificador;
                            //codificador = System.Text.Encoding.GetEncoding("iso-8859-1");
                            codificador = System.Text.Encoding.GetEncoding("utf-8");
                            cadena = cadena.Replace("&", "&amp;");
                            a = codificador.GetBytes(cadena);
                            ms = new System.IO.MemoryStream(a);
                            ms.Seek(0, System.IO.SeekOrigin.Begin);
                            Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                            x = new System.Xml.Serialization.XmlSerializer(Lc.GetType());
                            Lc = (FeaEntidades.InterFacturas.lote_comprobantes)x.Deserialize(ms);
                        }
                        else if (Archivo.Tipo.ToUpper() == ".TXT")
                        {
                            eFact_RN.Engine Engine = new eFact_RN.Engine();
                            Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                            Engine.LeerMultiRegistro(out Lc, Archivo.Path + "\\" + Archivo.Nombre, Sesion);
                        }
                        else if (Archivo.Tipo.ToUpper() == ".REC")
                        {
                            eFact_RN.Engine Engine = new eFact_RN.Engine();
                            Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
                            Engine.LeerRegistroRECE(out Lc, Archivo.Path + "\\" + Archivo.Nombre, Sesion);
                        }
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
            if (Lc.cabecera_lote.cuit_vendedor.ToString().Trim() != Aplicacion.OtrosFiltrosCuit.Trim() && Aplicacion.OtrosFiltrosCuit.Trim() != "")
            {
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.CUITNoHabilitadoParaElUsuario(Lc.cabecera_lote.cuit_vendedor.ToString());
            }
            eFact_Entidades.Lote lote = new eFact_Entidades.Lote();
            lote.CuitVendedor = Lc.cabecera_lote.cuit_vendedor.ToString();
            lote.PuntoVenta = Lc.cabecera_lote.punto_de_venta.ToString();
            lote.NumeroLote = Lc.cabecera_lote.id_lote.ToString();
            lote.CantidadRegistros = Convert.ToInt32(Lc.cabecera_lote.cantidad_reg.ToString());
            //Verificar bandeja de salida.-----------
            int numeroEnvioDisponible = 0;
            eFact_RN.Lote.ObtenerNumeroEnvioDisponible(out numeroEnvioDisponible, lote.CuitVendedor, lote.NumeroLote, lote.PuntoVenta, Sesion);
            lote.NumeroEnvio = numeroEnvioDisponible;
            //---------------------------------------
            lote.NombreArch = Archivo.Nombre;
            if (Lc.cabecera_lote.IdNaturalezaLoteFieldSpecified)
            {
                lote.IdNaturalezaLote = Lc.cabecera_lote.IdNaturalezaLoteField;
            }
            else
            {
                lote.IdNaturalezaLote = "";
            }
            int cantComprobantes = 0;
            for (int i = 0; i < Lc.comprobante.Length; i++)
            {
                if (Lc.comprobante[i] != null)
                {
                    cantComprobantes += 1;
                }
                else
                {
                    break;
                }
            }
            if (Lc.comprobanteDespacho != null)
            {
                for (int i = 0; i < Lc.comprobanteDespacho.Length; i++)
                {
                    if (Lc.comprobanteDespacho[i] != null)
                    {
                        cantComprobantes += 1;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (Lc.cabecera_lote.cantidad_reg != cantComprobantes)
            {
                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Problemas con la cantidad de registros declarada.");
            }
            List<eFact_Entidades.ComprobanteC> cCListVigentes = new List<eFact_Entidades.ComprobanteC>();
            List<eFact_Entidades.ComprobanteD> cDListVigentes = new List<eFact_Entidades.ComprobanteD>();
            if (Lc.cabecera_lote.IdNaturalezaLoteField != null && Lc.cabecera_lote.IdNaturalezaLoteField == "Compra")
            {
                //----- Consultar comprobantes de compras 'Vigentes' -----.
                if (Lc.comprobante[0] != null)
                {
                    cCListVigentes = eFact_RN.Comprobante.ConsultarComprobantesCVigentes(Lc.cabecera_lote.cuit_vendedor.ToString(), Sesion);
                }    
                //----- Consultar despachos 'Vigentes' -----.
                if (Lc.comprobanteDespacho[0] != null)
                {
                    cDListVigentes = eFact_RN.Comprobante.ConsultarComprobantesDVigentes(Lc.cabecera_lote.cuit_vendedor.ToString(), Sesion);
                }
            }
            List<eFact_Entidades.Comprobante> cVListVigentes = new List<eFact_Entidades.Comprobante>();
            if (Lc.cabecera_lote.IdNaturalezaLoteField != null && Lc.cabecera_lote.IdNaturalezaLoteField == "Venta")
            {
                //----- Consultar comprobantes de ventas 'Vigentes' -----.
                cVListVigentes = eFact_RN.Comprobante.ConsultarComprobantesVigentes(Lc.cabecera_lote.cuit_vendedor.ToString(), Sesion);
            }
            for (int i = 0; i < Lc.comprobante.Length; i++)
            {
                if (Lc.comprobante[i] != null)
                {
                    if (lote.IdNaturalezaLote != "Compra")
                    {
                        //Ventas
                        eFact_Entidades.Comprobante c = new eFact_Entidades.Comprobante();
                        c.IdTipoComprobante = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprobante.tipo_de_comprobante.ToString());
                        c.NumeroComprobante = Lc.comprobante[i].cabecera.informacion_comprobante.numero_comprobante.ToString();
                        c.TipoDocComprador = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprador.codigo_doc_identificatorio.ToString());
                        c.NroDocComprador = Lc.comprobante[i].cabecera.informacion_comprador.nro_doc_identificatorio.ToString();
                        c.NombreComprador = Lc.comprobante[i].cabecera.informacion_comprador.denominacion;
                        c.Fecha = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_emision.ToString());
                        c.NumeroCAE = Convert.ToString(Lc.comprobante[i].cabecera.informacion_comprobante.cae);
                        if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae != null && Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.ToString() != "")
                        {
                            c.FechaCAE = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_obtencion_cae.ToString());
                        }
                        if (Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae != null && Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.ToString() != "")
                        {
                            c.FechaVtoCAE = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_vencimiento_cae.ToString());
                        }
                        c.IdMoneda = Convert.ToString(Lc.comprobante[i].resumen.codigo_moneda);
                        c.Importe = Convert.ToDecimal(Lc.comprobante[i].resumen.importe_total_factura);
                        if (Lc.comprobante[i].resumen.importes_moneda_origen != null)
                        {
                            c.ImporteMonedaOrigen = Convert.ToDecimal(Lc.comprobante[i].resumen.importes_moneda_origen.importe_total_factura);
                        }
                        c.TipoCambio = Convert.ToDecimal(Lc.comprobante[i].resumen.tipo_de_cambio);
                        if (Lc.comprobante[i].extensiones != null)
                        {
                            if (Lc.comprobante[i].extensiones.extensiones_camara_facturas != null)
                            {
                                if (Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion != null)
                                {
                                    Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion = Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion.Trim();
                                    if (Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion.Length != 0 && Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion.Length != 32)
                                    {
                                        Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion = Cedeira.SV.Fun.CreateMD5Hash(Lc.comprobante[i].extensiones.extensiones_camara_facturas.clave_de_vinculacion);
                                    }
                                }
                            }
                        }
                        lote.Comprobantes.Add(c);
                        if (lote.IdNaturalezaLote == "Venta")
                        {
                            List<eFact_Entidades.Comprobante> listAux = cVListVigentes.FindAll((delegate(eFact_Entidades.Comprobante e1) { return e1.NroDocComprador == c.NroDocComprador && e1.PuntoVenta.ToString() == c.PuntoVenta && e1.IdTipoComprobante == c.IdTipoComprobante && e1.NumeroComprobante == c.NumeroComprobante; }));
                            if (listAux.Count != 0)
                            {
                                throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Comprobante existente. Cuit Comprador: " + c.NroDocComprador + " Punto Venta: " + c.PuntoVenta + " Tipo: " + c.IdTipoComprobante.ToString() + " Nro: " + c.NumeroComprobante);
                            }
                        }
                    }
                    else
                    {
                        //Compras
                        eFact_Entidades.ComprobanteC cC = new eFact_Entidades.ComprobanteC();
                        cC.PuntoVenta = Lc.comprobante[i].cabecera.informacion_comprobante.punto_de_venta.ToString();
                        cC.IdTipoComprobante = Convert.ToInt16(Lc.comprobante[i].cabecera.informacion_comprobante.tipo_de_comprobante.ToString());
                        cC.NumeroComprobante = Lc.comprobante[i].cabecera.informacion_comprobante.numero_comprobante.ToString();
                        cC.TipoDocVendedor = Convert.ToInt16("80");
                        cC.NroDocVendedor = Lc.comprobante[i].cabecera.informacion_vendedor.cuit.ToString();
                        cC.NombreVendedor = Lc.comprobante[i].cabecera.informacion_vendedor.razon_social;
                        cC.Fecha = ConvertirStringToDateTime(Lc.comprobante[i].cabecera.informacion_comprobante.fecha_emision.ToString());
                        cC.IdMoneda = Convert.ToString(Lc.comprobante[i].resumen.codigo_moneda);
                        cC.Importe = Convert.ToDecimal(Lc.comprobante[i].resumen.importe_total_factura);
                        if (Lc.comprobante[i].resumen.importes_moneda_origen != null)
                        {
                            cC.ImporteMonedaOrigen = Convert.ToDecimal(Lc.comprobante[i].resumen.importes_moneda_origen.importe_total_factura);
                        }
                        cC.TipoCambio = Convert.ToDecimal(Lc.comprobante[i].resumen.tipo_de_cambio);
                        lote.ComprobantesC.Add(cC);

                        List<eFact_Entidades.ComprobanteC> listAux = cCListVigentes.FindAll((delegate(eFact_Entidades.ComprobanteC e1) { return e1.NroDocVendedor == cC.NroDocVendedor && e1.PuntoVenta.ToString() == cC.PuntoVenta && e1.IdTipoComprobante == cC.IdTipoComprobante && e1.NumeroComprobante == cC.NumeroComprobante; }));
                        if (listAux.Count != 0)
                        {
                            throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Comprobante existente. Cuit Vendedor: " + cC.NroDocVendedor + " Punto Venta: " + cC.PuntoVenta + " Tipo: " + cC.IdTipoComprobante.ToString() + " Nro: " + cC.NumeroComprobante);
                        }
                    }
                }
                else
                {
                    break;
                }
            }
            if (Lc.comprobanteDespacho != null)
            {
                for (int i = 0; i < Lc.comprobanteDespacho.Length; i++)
                {
                    if (Lc.comprobanteDespacho[i] != null)
                    {
                        eFact_Entidades.ComprobanteD cD = new eFact_Entidades.ComprobanteD();
                        cD.IdTipoComprobante = Convert.ToInt16(Lc.comprobanteDespacho[i].DespachoCabecera.TipoComprobante.ToString());
                        cD.NumeroDespacho = Lc.comprobanteDespacho[i].DespachoCabecera.NumeroDespacho.ToString();
                        cD.TipoDocVendedor = Convert.ToInt16(Lc.comprobanteDespacho[i].DespachoCabecera.TipoDocVendedor);
                        cD.NroDocVendedor = Lc.comprobanteDespacho[i].DespachoCabecera.NroDocVendedor.ToString();
                        cD.NombreVendedor = Lc.comprobanteDespacho[i].DespachoCabecera.NombreVendedor;
                        cD.Fecha = ConvertirStringToDateTime(Lc.comprobanteDespacho[i].DespachoCabecera.Fecha.ToString());
                        cD.IdMoneda = Convert.ToString(Lc.comprobanteDespacho[i].DespachoResumen.Moneda);
                        cD.Importe = Convert.ToDecimal(Lc.comprobanteDespacho[i].DespachoResumen.ImporteTotal);
                        //cD.ImporteMonedaOrigen = Convert.ToDecimal(Lc.comprobante[i].resumen.importes_moneda_origen.importe_total_factura);
                        cD.TipoCambio = Convert.ToDecimal(Lc.comprobanteDespacho[i].DespachoResumen.TipoCambio);
                        lote.ComprobantesD.Add(cD);

                        List<eFact_Entidades.ComprobanteD> listAux = cDListVigentes.FindAll((delegate(eFact_Entidades.ComprobanteD e1) { return e1.NroDocVendedor == cD.NroDocVendedor && e1.IdTipoComprobante == cD.IdTipoComprobante && e1.NumeroDespacho == cD.NumeroDespacho; }));
                        if (listAux.Count != 0)
                        {
                            throw new Microsoft.ApplicationBlocks.ExceptionManagement.Archivo.ProcesarArchivo("Comprobante de Despacho existente. Cuit Vendedor: " + cD.NroDocVendedor + " Tipo: " + cD.IdTipoComprobante.ToString() + " Nro: " + cD.NumeroDespacho);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            string loteXml = "";
            eFact_RN.Lote.SerializarLc(out loteXml, Lc);
            lote.LoteXml = loteXml;
            Lote = lote;
        }
Esempio n. 17
0
 public List<eFact_Entidades.Lote> ConsutarLotesDeComprobantesDVigentesXFecha(string FechaDsd, string FechaHst, string CuitEmpresa)
 {
     StringBuilder commandText = new StringBuilder();
     commandText.Append("Select Lotes.* from Lotes where IdLote in (Select distinct(Lotes.IdLote) as IdLote from ComprobantesD, Lotes, WF_Op where ComprobantesD.IdLote=Lotes.IdLote and Lotes.IdOp=WF_Op.IdOp and WF_Op.IdEstado in ('Vigente') ");
     commandText.Append("and convert(varchar(8), ComprobantesD.Fecha, 112) >= '" + FechaDsd + "' and convert(varchar(8), ComprobantesD.Fecha, 112) <= '" + FechaHst + "' ");
     if (CuitEmpresa != "")
     {
         commandText.Append("and Lotes.CuitVendedor = '" + CuitEmpresa + "') ");
     }
     commandText.Append("order by Lotes.IdLote");
     DataSet ds = new DataSet();
     ds = (DataSet)Ejecutar(commandText.ToString(), TipoRetorno.DS, Transaccion.Acepta, sesion.CnnStr);
     List<eFact_Entidades.Lote> Lotes = new List<eFact_Entidades.Lote>();
     if (ds.Tables.Count == 0)
     {
         throw new Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.NoHayDatos();
     }
     else
     {
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             eFact_Entidades.Lote Lote = new eFact_Entidades.Lote();
             CopiarSimple(ds, i, Lote);
             Lotes.Add(Lote);
         }
     }
     return Lotes;
 }
Esempio n. 18
0
 public ConsultaLoteC(eFact_Entidades.Lote Lote)
 {
     InitializeComponent();
     lote = Lote;
 }