Beispiel #1
0
        public static Response <List <BaseEntity> > ListaClientesNC_Autocomplete(string TipoDocumento, string Value)
        {
            try
            {
                if (Value == "null")
                {
                    Value = string.Empty;
                }

                if (TipoDocumento != "06") // Caso: RUC.
                {
                    TipoDocumento = VentaLogic.TipoDocumentoHomologado(TipoDocumento).ToString();
                }

                var lista = NotaCreditoRepository.ListaClientesNC_Autocomplete(TipoDocumento, Value);

                if (lista.Count > 0)
                {
                    return(new Response <List <BaseEntity> >(true, lista, Message.MsgCorrectoListaClientesNC_Autocomplete, true));
                }
                else
                {
                    return(new Response <List <BaseEntity> >(false, lista, Message.MsgErrorListaClientesNC_Autocomplete, true));
                }
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(BaseLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <List <BaseEntity> >(false, null, Message.MsgExcListaClientesNC_Autocomplete, false));
            }
        }
        public static Response <bool> GrabarPasajero(List <ClientePasajeEntity> lista)
        {
            try
            {
                foreach (var entidad in lista)
                {
                    // Seteo el 'TipoDocumentoHomologado'
                    entidad.TipoDoc = VentaLogic.TipoDocumentoHomologado(entidad.TipoDoc).ToString();

                    if (entidad.IdCliente > 0)
                    {
                        // Modifica 'Pasajero'
                        ClientePasajeRepository.ModificarPasajero(entidad);
                    }
                    else
                    {
                        // Graba 'Pasajero'
                        ClientePasajeRepository.GrabarPasajero(entidad);
                    }

                    // Valida 'RucContacto'
                    if (string.IsNullOrEmpty(entidad.RucContacto))
                    {
                        continue;
                    }

                    // Busca 'Empresa'
                    var buscarEmpresa = ClientePasajeRepository.BuscarEmpresa(entidad.RucContacto);

                    var objEmpresa = new RucEntity
                    {
                        RucCliente  = entidad.RucContacto ?? string.Empty,
                        RazonSocial = entidad.RazonSocial ?? string.Empty,
                        Direccion   = entidad.Direccion ?? string.Empty,
                        Telefono    = string.Empty
                    };

                    if (!string.IsNullOrEmpty(buscarEmpresa.RucCliente))
                    {
                        // Modifica 'Empresa'
                        ClientePasajeRepository.ModificarEmpresa(objEmpresa);
                    }
                    else
                    {
                        // Graba 'Empresa'
                        ClientePasajeRepository.GrabarEmpresa(objEmpresa);
                    }
                }

                return(new Response <bool>(true, true, Message.MsgCorrectoGrabarClientePasaje, true));
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(ClientePasajeLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <bool>(false, false, Message.MsgExcGrabarClientePasaje, false));
            }
        }
Beispiel #3
0
        public static Response <List <BaseEntity> > ListaConceptosNC(string RucEmpresa, string TipoTerminalElectronico, string CodDoc, string ElectronicoEmpresa)
        {
            try
            {
                var lista = new List <BaseEntity>();

                if (TipoTerminalElectronico == "E" && ElectronicoEmpresa == "1")
                {
                    var obtenerRparametro = VentaLogic.ObtenerRparametro(RucEmpresa);

                    foreach (var objeto in obtenerRparametro.RDocumentNote)
                    {
                        if (objeto.CodDoc == CodDoc) // Motivo: Nota de crédito.
                        {
                            var entidad = new BaseEntity()
                            {
                                id    = objeto.CodMotivo,
                                label = objeto.Descripcion
                            };

                            lista.Add(entidad);
                        }
                    }
                }
                else
                {
                    lista = BaseRepository.ListaConceptosNC(CodDoc);
                }

                return(new Response <List <BaseEntity> >(true, lista, Message.MsgCorrectoListaConceptosNC, true));
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(BaseLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <List <BaseEntity> >(false, null, Message.MsgExcListaConceptosNC, false));
            }
        }
Beispiel #4
0
        public static void MatchPlano(PlanoEntity entidad, PlanoEntity item, PlanoRequest request)
        {
            entidad.NumeAsiento     = item.NumeAsiento;
            entidad.Nacionalidad    = item.Nacionalidad;
            entidad.PrecioVenta     = item.PrecioVenta;
            entidad.RecogeEn        = item.RecogeEn;
            entidad.FlagVenta       = item.FlagVenta;
            entidad.Sigla           = item.Sigla;
            entidad.Boleto          = item.Boleto;
            entidad.TipoBoleto      = item.TipoBoleto;
            entidad.CodiOrigen      = item.CodiOrigen;
            entidad.OrdenOrigen     = item.OrdenOrigen;
            entidad.CodiDestino     = item.CodiDestino;
            entidad.NomOrigen       = item.NomOrigen;
            entidad.NomDestino      = item.NomDestino;
            entidad.CodiPuntoVenta  = item.CodiPuntoVenta;
            entidad.NomPuntoVenta   = item.NomPuntoVenta;
            entidad.CodiUsuario     = item.CodiUsuario;
            entidad.NomUsuario      = item.NomUsuario;
            entidad.RucContacto     = item.RucContacto;
            entidad.NumeSolicitud   = item.NumeSolicitud;
            entidad.HoraVenta       = item.HoraVenta;
            entidad.EmbarqueCod     = item.EmbarqueCod;
            entidad.EmbarqueDir     = item.EmbarqueDir;
            entidad.EmbarqueHora    = item.EmbarqueHora;
            entidad.ImpManifiesto   = item.ImpManifiesto;
            entidad.CodiSucursal    = item.CodiSucursal;
            entidad.TipoDocumento   = item.TipoDocumento;
            entidad.NumeroDocumento = item.NumeroDocumento;
            entidad.Nombres         = item.SplitNombres[0];
            entidad.ApellidoPaterno = item.SplitNombres[1];
            entidad.ApellidoMaterno = item.SplitNombres[2];
            entidad.Sexo            = item.Sexo;
            entidad.TipoPago        = item.TipoPago;
            entidad.Edad            = item.Edad;
            entidad.Telefono        = item.Telefono;
            entidad.ValeRemoto      = item.ValeRemoto;
            entidad.CodiEsca        = item.CodiEsca;
            entidad.CodiEmpresa     = item.CodiEmpresa;

            // Busca 'Pasajero'
            if (!string.IsNullOrEmpty(entidad.TipoDocumento) && !string.IsNullOrEmpty(entidad.NumeroDocumento))
            {
                var buscaPasajero = ClientePasajeRepository.BuscaPasajero(VentaLogic.TipoDocumentoHomologado(entidad.TipoDocumento).ToString(), entidad.NumeroDocumento);
                entidad.FechaNacimiento = buscaPasajero.FechaNacimiento;
                entidad.Especial        = buscaPasajero.Especial;

                entidad.Correo = buscaPasajero.Correo;

                if (entidad.Edad == 0 && string.IsNullOrEmpty(entidad.Telefono))
                {
                    entidad.Edad     = buscaPasajero.Edad;     // La tabla 'Tb_Boleto_Ruta' no contiene 'Edad'
                    entidad.Telefono = buscaPasajero.Telefono; // La tabla 'Tb_Boleto_Ruta' no contiene 'Telefono'
                }
            }

            switch (entidad.FlagVenta)
            {
            case "X":     // Asiento bloqueado
            case "AB":    // Asiento bloqueado por módulo
                entidad.IdVenta    = string.Empty;
                entidad.Color      = string.Empty;
                entidad.FechaVenta = string.Empty;
                entidad.FechaViaje = string.Empty;
                break;

            default:
            {
                entidad.IdVenta    = item.IdVenta;
                entidad.Color      = item.Color;
                entidad.FechaVenta = item.FechaVenta;
                entidad.FechaViaje = item.FechaViaje;

                switch (entidad.FlagVenta)
                {
                case "VI":             // Venta intermedia
                    entidad.FechaVenta = "07/07/1777";
                    entidad.FechaViaje = string.Empty;
                    break;

                case "7":             // Pase de cortesía
                    entidad.Sigla = "PS";
                    entidad.Color = ColorVentaPaseCortesia;
                    break;

                case "1":             // Crédito
                    entidad.Sigla = "VC";
                    break;

                case "R":             // Reserva
                    entidad.Color = ColorVentaReserva;
                    break;
                }
                ;
            };
                break;
            }

            // Busca 'Empresa'
            if (!string.IsNullOrEmpty(entidad.RucContacto))
            {
                var buscarEmpresa = ClientePasajeRepository.BuscarEmpresa(entidad.RucContacto);
                entidad.RazonSocial = buscarEmpresa.RazonSocial;
                entidad.Direccion   = buscarEmpresa.Direccion;
            }
            else
            {
                entidad.RazonSocial = string.Empty;
                entidad.Direccion   = string.Empty;
            }

            // Busca 'Acompaniante'
            if (!string.IsNullOrEmpty(entidad.IdVenta))
            {
                entidad.ObjAcompaniante = PlanoRepository.BuscaAcompaniante(entidad.IdVenta);
            }

            // Consulta 'Reintegro'
            if (!string.IsNullOrEmpty(entidad.CodiEsca))
            {
                var consultaVentaReintegro = VentaRepository.ConsultaVentaReintegro(entidad.CodiEsca.Substring(1, 3), entidad.CodiEsca.Substring(5), entidad.CodiEmpresa.ToString(), entidad.CodiEsca.Substring(0, 1));
                entidad.ClavUsuarioReintegro = consultaVentaReintegro.CodiUsuario;
                entidad.SucVentaReintegro    = consultaVentaReintegro.SucVenta;
                entidad.PrecVentaReintegro   = consultaVentaReintegro.PrecioVenta;
                entidad.Nombres         = consultaVentaReintegro.SplitNombre[0];
                entidad.ApellidoPaterno = consultaVentaReintegro.SplitNombre[1];
                entidad.ApellidoMaterno = consultaVentaReintegro.SplitNombre[2];
                entidad.TipoDocumento   = consultaVentaReintegro.TipoDocumento;
                entidad.NumeroDocumento = consultaVentaReintegro.Dni;
                entidad.Edad            = consultaVentaReintegro.Edad;
                entidad.RucContacto     = consultaVentaReintegro.RucCliente;
                entidad.Telefono        = consultaVentaReintegro.Telefono;

                // Busca 'Pasajero'
                if (!string.IsNullOrEmpty(entidad.TipoDocumento) && !string.IsNullOrEmpty(entidad.NumeroDocumento))
                {
                    var buscaPasajero = ClientePasajeRepository.BuscaPasajero(VentaLogic.TipoDocumentoHomologado(entidad.TipoDocumento).ToString(), entidad.NumeroDocumento);
                    entidad.FechaNacimiento = buscaPasajero.FechaNacimiento;
                }

                // Busca 'Empresa'
                if (!string.IsNullOrEmpty(entidad.RucContacto))
                {
                    var buscarEmpresa = ClientePasajeRepository.BuscarEmpresa(entidad.RucContacto);
                    entidad.RazonSocial = buscarEmpresa.RazonSocial;
                    entidad.Direccion   = buscarEmpresa.Direccion;
                }
                else
                {
                    entidad.RazonSocial = string.Empty;
                    entidad.Direccion   = string.Empty;
                }
            }

            // Consulta 'FechaHoraReservacion'
            if (entidad.FlagVenta == "R")
            {
                var consultarFechaHoraReservacion = VentaRepository.ConsultarFechaHoraReservacion(int.Parse(entidad.IdVenta));
                entidad.FechaReservacion = consultarFechaHoraReservacion.FechaReservacion;
                entidad.HoraReservacion  = consultarFechaHoraReservacion.HoraReservacion;
            }

            // Seteo 'Info'
            entidad.Info = entidad.CodiUsuario + " " + entidad.NomUsuario + " - " + entidad.NomPuntoVenta + " - ";
            switch (entidad.FlagVenta)
            {
            case "7":
                entidad.Info += "(PS)" + " - ";
                break;

            case "1":
                entidad.Info += "(VC)" + " - ";
                break;
            }
            entidad.Info += entidad.NomOrigen + " - " + entidad.NomDestino;

            // Seteo 'Observacion'
            if (entidad.FlagVenta == "I")
            {
                var consultaUsrValeR = VentaRepository.ConsultaUsrValeR(int.Parse(entidad.IdVenta));

                entidad.Observacion = "USR VALE: " + consultaUsrValeR;
            }
            entidad.Observacion += entidad.CodiEsca;
        }
        public static Response <List <ClientePasajeEntity> > BuscarClientesPasaje(string campo, string nombres, string paterno, string materno, string TipoDocId)
        {
            try
            {
                var BuscarClientesPasaje = ClientePasajeRepository.BuscarClientesPasaje(campo, nombres, paterno, materno, VentaLogic.TipoDocumentoHomologado(TipoDocId).ToString());

                return(new Response <List <ClientePasajeEntity> >(true, BuscarClientesPasaje, Message.MsgCorrectoBuscarClientesPasaje, true));
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(VentaLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <List <ClientePasajeEntity> >(false, null, Message.MsgExcBuscarClientesPasaje, false));
            }
        }
        public static Response <ClientePasajeEntity> BuscaPasajero(string TipoDoc, string NumeroDoc)
        {
            try
            {
                var buscaPasajero = ClientePasajeRepository.BuscaPasajero(VentaLogic.TipoDocumentoHomologado(TipoDoc).ToString(), NumeroDoc);

                // Valida 'FechaNacimiento'
                if (buscaPasajero.FechaNacimiento == "01/01/1900")
                {
                    buscaPasajero.FechaNacimiento = string.Empty;
                    buscaPasajero.Edad            = 0;
                }

                var buscaEmpresa = new RucEntity();

                if (!string.IsNullOrEmpty(buscaPasajero.RucContacto))
                {
                    buscaEmpresa = ClientePasajeRepository.BuscarEmpresa(buscaPasajero.RucContacto);
                    buscaPasajero.RazonSocial = buscaEmpresa.RazonSocial;
                    buscaPasajero.Direccion   = buscaEmpresa.Direccion;
                }
                // Con esto nos aseguramos que estamos tomando solo la 'Direccion' de la empresa
                else
                {
                    buscaPasajero.Direccion = string.Empty;
                }

                // Consulta 'RENIEC'
                if (TipoDoc == "01" && string.IsNullOrEmpty(buscaPasajero.NumeroDoc))
                {
                    var resConsultaRENIEC = ConsultaRENIEC(NumeroDoc);
                    if (resConsultaRENIEC.EsCorrecto)
                    {
                        buscaPasajero.ApellidoPaterno = resConsultaRENIEC.Valor.ApellidoPaterno;
                        buscaPasajero.ApellidoMaterno = resConsultaRENIEC.Valor.ApellidoMaterno;
                        buscaPasajero.NombreCliente   = resConsultaRENIEC.Valor.Nombres;
                    }
                    else
                    {
                        return(new Response <ClientePasajeEntity>(false, buscaPasajero, resConsultaRENIEC.Mensaje, true));
                    }
                }

                // Consulta 'SUNAT'
                if (!string.IsNullOrEmpty(buscaPasajero.RucContacto) && buscaPasajero.RucContacto.Length == 11)
                {
                    if (string.IsNullOrEmpty(buscaEmpresa.RucCliente))
                    {
                        var resConsultaSUNAT = ConsultaSUNAT(buscaPasajero.RucContacto);
                        if (resConsultaSUNAT.EsCorrecto)
                        {
                            buscaPasajero.RazonSocial = resConsultaSUNAT.Valor.RazonSocial;
                            buscaPasajero.Direccion   = resConsultaSUNAT.Valor.Direccion;
                        }
                        else
                        {
                            return(new Response <ClientePasajeEntity>(false, buscaPasajero, resConsultaSUNAT.Mensaje, true));
                        }
                    }
                }

                return(new Response <ClientePasajeEntity>(true, buscaPasajero, Message.MsgCorrectoBuscaPasajero, true));
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(ClientePasajeLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <ClientePasajeEntity>(false, null, Message.MsgExcBuscaPasajero, false));
            }
        }
        public static Response <VentaResponse> VentaUpdatePostergacionEle(FechaAbiertaRequest filtro)
        {
            try
            {
                var valor = new VentaResponse();
                var listaVentasRealizadas = new List <VentaRealizadaEntity>();

                // Verifica 'CodiProgramacion'
                var objProgramacion = new ProgramacionEntity()
                {
                    NroViaje          = filtro.NroViaje,
                    FechaProgramacion = filtro.FechaProgramacion,
                    CodiProgramacion  = filtro.CodiProgramacion,
                    CodiEmpresa       = filtro.CodiEmpresa,
                    CodiSucursal      = filtro.CodiSucursal,
                    CodiRuta          = filtro.CodiRutaBus,
                    CodiBus           = filtro.CodiBus,
                    HoraProgramacion  = filtro.HoraProgramacion,
                    CodiServicio      = byte.Parse(filtro.CodiServicio.ToString()),

                    CodiUsuario    = filtro.CodiUsuario.ToString(),
                    NomUsuario     = filtro.NomUsuario,
                    CodiPuntoVenta = filtro.CodiPuntoVenta,
                    Terminal       = filtro.Terminal,
                    CodiOrigen     = filtro.CodiOrigen,
                    CodiDestino    = filtro.CodiDestino,
                    NomOrigen      = filtro.NomSucursal
                };
                var verificaCodiProgramacion = VentaLogic.VerificaCodiProgramacion(objProgramacion);
                if (verificaCodiProgramacion == 0)
                {
                    return(new Response <VentaResponse>(false, valor, Message.MsgErrorVerificaCodiProgramacion, false));
                }
                else
                {
                    filtro.CodiProgramacion = verificaCodiProgramacion;
                }

                // Seteo 'valor.CodiProgramacion'
                valor.CodiProgramacion = filtro.CodiProgramacion;

                var venta = VentaRepository.BuscarVentaById(filtro.IdVenta);
                if (venta.CodiProgramacion != 0)
                {
                    return(new Response <VentaResponse>(false, valor, Message.MsgExcSeEncontrabaEnFechaAbierta, false));
                }

                FechaAbiertaRepository.VentaUpdatePostergacionEle(filtro);
                FechaAbiertaRepository.VentaUpdateImpManifiesto(filtro.IdVenta);
                FechaAbiertaRepository.VentaDerivadaUpdateViaje(filtro.IdVenta, filtro.FechaViaje, filtro.HoraViaje, filtro.CodiServicio);

                var objAuditoria = new AuditoriaEntity
                {
                    CodiUsuario    = filtro.CodiUsuario, //
                    NomUsuario     = filtro.NomUsuario,  //
                    Tabla          = "VENTA",
                    TipoMovimiento = "CONFIRMA FECHA ABIERTA",
                    Boleto         = filtro.Serie.PadLeft(3, '0') + "-" + filtro.Numero.PadLeft(7, '0'),
                    NumeAsiento    = filtro.NumeAsiento.PadLeft(2, '0'),
                    NomOficina     = filtro.NomSucursal,                    //
                    NomPuntoVenta  = filtro.CodiPuntoVenta.PadLeft(3, '0'), //
                    Pasajero       = filtro.Nombre,
                    FechaViaje     = filtro.FechaViaje,
                    HoraViaje      = filtro.HoraViaje,
                    NomDestino     = filtro.NombDestino,
                    Precio         = decimal.Parse(filtro.Precio),
                    Obs1           = "CONFIRMACION FECHA ABIERTA",
                    Obs2           = string.Empty,
                    Obs3           = string.Empty,
                    Obs4           = string.Empty,
                    Obs5           = string.Empty
                };
                VentaRepository.GrabarAuditoria(objAuditoria);

                // Añado 'ventaRealizada'
                var ventaRealizada = new VentaRealizadaEntity
                {
                    NumeAsiento = filtro.NumeAsiento
                };
                listaVentasRealizadas.Add(ventaRealizada);

                // Seteo 'valor.ListaVentasRealizadas'
                valor.ListaVentasRealizadas = listaVentasRealizadas;

                return(new Response <VentaResponse>(true, valor, Message.MsgCorrectoVentaUpdatePostergacionEle, true));
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(FechaAbiertaLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <VentaResponse>(false, null, Message.MsgExcVentaUpdatePostergacionEle, false));
            }
        }
Beispiel #8
0
        public static Response <byte> AnularReintegro(AnularVentaRequest request)
        {
            try
            {
                var anularVentaReintegro = new byte();

                if (request.IdVenta > 0)
                {
                    // Valida 'AnularDocumentoSUNAT'
                    if (!request.Tipo.Equals("M") && request.ElectronicoEmpresa == "1")
                    {
                        // Anula 'DocumentoSUNAT'
                        var objVentaReintegro = new VentaEntity
                        {
                            CodiEmpresa = request.CodiEmpresa,
                            SerieBoleto = request.SerieBoleto,
                            NumeBoleto  = request.NumeBoleto,
                            Tipo        = request.Tipo,
                            FechaVenta  = request.FechaVenta,
                            RucEmpresa  = request.RucEmpresa
                        };

                        var resAnularDocumentoSUNAT = VentaLogic.AnularDocumentoSUNAT(objVentaReintegro);
                        if (!resAnularDocumentoSUNAT.Estado)
                        {
                            return(new Response <byte>(false, anularVentaReintegro, resAnularDocumentoSUNAT.MensajeError, false));
                        }
                    }

                    // Anula 'Reintegro'
                    anularVentaReintegro = VentaRepository.AnularVenta(request.IdVenta, request.CodiUsuario);
                    if (anularVentaReintegro > 0)
                    {
                        if (request.TipoPago == "03")
                        {
                            // Consulta 'PagoTarjetaVenta'
                            var consultaPagoTarjetaVenta = VentaRepository.ConsultaPagoTarjetaVenta(request.IdVenta);

                            // Actualiza 'CajaAnulacion'
                            VentaRepository.ActualizarCajaAnulacion(consultaPagoTarjetaVenta);
                        }

                        //Elimina Boleto x Contrato si es que tiene
                        ReintegroRepository.EliminarBoletoxContrato(request.IdVenta);

                        //Libera Venta del Reintegro
                        ReintegroRepository.LiberaReintegroEle(request.CodiEsca.Substring(1, 3), request.CodiEsca.Substring(5), request.CodiEmpresa.ToString(), request.CodiEsca.Substring(0, 1));

                        // Genera 'CorrelativoAuxiliar'
                        var generarCorrelativoAuxiliarReintegro = VentaRepository.GenerarCorrelativoAuxiliar("CAJA", request.CodiOficina, request.CodiPuntoVenta, string.Empty);
                        if (string.IsNullOrEmpty(generarCorrelativoAuxiliarReintegro))
                        {
                            return(new Response <byte>(false, anularVentaReintegro, Message.MsgErrorGenerarCorrelativoAuxiliarReintegro, false));
                        }

                        // Graba 'CajaReintegro'
                        var objCajaReintegro = new CajaEntity
                        {
                            NumeCaja       = generarCorrelativoAuxiliarReintegro.PadLeft(7, '0'),
                            CodiEmpresa    = request.CodiEmpresa,
                            CodiSucursal   = short.Parse(request.CodiOficina),
                            FechaCaja      = DataUtility.ObtenerFechaDelSistema(),
                            TipoVale       = "S",
                            Boleto         = String.Format("{0}-{1}", request.SerieBoleto.ToString().PadLeft(3, '0'), request.NumeBoleto.ToString().PadLeft(7, '0')),
                            NomUsuario     = String.Format("{0} {1}", request.CodiUsuario, request.NomUsuario),
                            CodiBus        = string.Empty,
                            CodiChofer     = string.Empty,
                            CodiGasto      = string.Empty,
                            ConcCaja       = String.Format("{0} {1}-{2}", "ANUL DE BOLETO REINT", request.SerieBoleto.ToString().PadLeft(3, '0'), request.NumeBoleto.ToString().PadLeft(7, '0')),
                            Monto          = request.PrecioVenta,
                            CodiUsuario    = short.Parse(request.CodiUsuario.ToString()),
                            IndiAnulado    = "F",
                            TipoDescuento  = "RE",
                            TipoDoc        = "16",
                            TipoGasto      = "P",
                            Liqui          = 0M,
                            Diferencia     = 0M,
                            Recibe         = "RE",
                            CodiDestino    = string.Empty,
                            FechaViaje     = "01/01/1900",
                            HoraViaje      = string.Empty,
                            CodiPuntoVenta = short.Parse(request.CodiPuntoVenta),
                            Voucher        = string.Empty,
                            Asiento        = string.Empty,
                            Ruc            = string.Empty,
                            IdVenta        = 0,
                            Origen         = "AR",
                            Modulo         = "PR",
                            Tipo           = request.Tipo,

                            IdCaja = 0
                        };
                        var grabarCajaReintegro = VentaRepository.GrabarCaja(objCajaReintegro);

                        //Graba Auditoria luego de Liberar Asiento
                        var objAuditoria = new AuditoriaEntity
                        {
                            CodiUsuario    = Convert.ToInt16(request.CodiUsuario),
                            NomUsuario     = request.NomUsuario,
                            Tabla          = "VENTA",
                            TipoMovimiento = "ANUL.REINTEGRO",
                            Boleto         = String.Format("{0}-{1}", request.SerieBoleto.ToString().PadLeft(3, '0'), request.NumeBoleto.ToString().PadLeft(7, '0')),
                            NumeAsiento    = "0",
                            NomOficina     = request.NomOficina,
                            NomPuntoVenta  = request.CodiPuntoVenta.PadLeft(3, '0'),
                            Pasajero       = "",
                            FechaViaje     = "01/01/1900",
                            HoraViaje      = "",
                            NomDestino     = "",
                            Precio         = 0M,
                            Obs1           = "LIBERACION AL BOLETO : " + request.CodiEsca,
                            Obs2           = "TERMINAL : " + request.Terminal.ToString().PadLeft(3, '0'),
                            Obs3           = "",
                            Obs4           = "CAJERO AFECTA " + request.CodiUsuario,
                            Obs5           = "NRO VALE SALIDA : " + generarCorrelativoAuxiliarReintegro.PadLeft(7, '0')
                        };
                        VentaRepository.GrabarAuditoria(objAuditoria);

                        //TODO: Falta implementar Usp_Tb_venta_AnulaReintegro_ele
                    }
                }
                return(new Response <byte>(true, anularVentaReintegro, "Se anuló el reintegro correctamente", true));
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(VentaLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <byte>(false, 0, Message.MsgExcAnulaReintegro, false));
            }
        }
Beispiel #9
0
        public static Response <ReintegroEntity> VentaConsultaF12(ReintegroRequest request)
        {
            try
            {
                var valor = ReintegroRepository.VentaConsultaF12(request);
                //Datos adicionales: 'FechaNacimiento'
                var clientePasaje = ClientePasajeRepository.BuscaPasajero(VentaLogic.TipoDocumentoHomologado(valor.TipoDocumento).ToString(), valor.Dni);
                valor.FechaNac = clientePasaje.FechaNacimiento;

                if (valor.IdVenta == 0)
                {
                    return(new Response <ReintegroEntity>(false, valor, Message.MsgExcF12NoExiste, true));
                }
                //Setea Razón Social y Dirección con el RUC
                if (!string.IsNullOrEmpty(valor.RucCliente))
                {
                    var buscarEmpresa = ClientePasajeRepository.BuscarEmpresa(valor.RucCliente);
                    valor.RazonSocial = buscarEmpresa.RazonSocial;
                    valor.Direccion   = buscarEmpresa.Direccion;
                }
                else
                {
                    valor.RazonSocial = string.Empty;
                    valor.Direccion   = string.Empty;
                }

                // Busca 'AgenciaEmpresa' (E -> GenerarAdicionales, M -> También se va a necesitar.)
                var buscarAgenciaEmpresa = new AgenciaEntity();
                buscarAgenciaEmpresa = VentaRepository.BuscarAgenciaEmpresa(valor.CodiEmpresa, valor.CodiPuntoVenta);
                valor.DirEmbarque    = buscarAgenciaEmpresa.Direccion;

                //Verifica si el boleto está en Fecha Abierta
                if (valor.CodiProgramacion != 0)
                {
                    var programacion = ReintegroRepository.DatosProgramacion(valor.CodiProgramacion);
                    //Verifica si no tiene Programación, caso contrario setea Ruta y Servicio
                    if (programacion.CodiRuta != 0 && programacion.CodiServicio != 00)
                    {
                        valor.CodiRuta     = programacion.CodiRuta;
                        valor.CodiServicio = programacion.CodiServicio;
                        valor.CodiBus      = programacion.CodiBus;
                    }
                    else
                    {
                        valor.CodiError = 2;
                        return(new Response <ReintegroEntity>(false, valor, Message.MsgExcF12SinProgramacion, true));
                    }
                    //Verfica si tiene Nota de Crédito
                    var notaCredito = VentaRepository.VerificaNC(valor.IdVenta);
                    if (Convert.ToInt32(notaCredito.id) > 0)
                    {
                        valor.CodiError = 3;
                        return(new Response <ReintegroEntity>(false, valor, Message.MsgExcF12NotaCredito + " " + notaCredito.label, true));
                    }
                    //Verfica si esta como Reintegro
                    if (valor.FlagVenta == "O")
                    {
                        valor.CodiError = 4;
                        return(new Response <ReintegroEntity>(false, valor, Message.MsgExcF12EsReintegro, true));
                    }
                    //Verfica si ya tiene adjunto un Reintegro
                    if (valor.CodiEsca != "")
                    {
                        valor.CodiError = 5;
                        return(new Response <ReintegroEntity>(false, valor, Message.MsgExcF12TieneReintegro, true));
                    }
                }
                else
                {
                    valor.CodiError = 1;
                    return(new Response <ReintegroEntity>(false, valor, Message.MsgExcF12EsFechaAbierta, true));
                }
                return(new Response <ReintegroEntity>(true, valor, Message.MsgCorrectoVentaConsultaF12, true));
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(FechaAbiertaLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <ReintegroEntity>(false, null, Message.MsgExcVentaConsultaF12, false));
            }
        }
Beispiel #10
0
        public static Response <VentaResponse> SaveReintegro(ReintegroVentaRequest filtro)
        {
            var valor = new VentaResponse();

            try
            {
                var ListarPanelControl    = CreditoRepository.ListarPanelControl();
                var listaVentasRealizadas = new List <VentaRealizadaEntity>();
                var buscarCorrelativo     = new CorrelativoEntity();

                SetInvoiceRequestBody bodyDocumentoSUNAT = null;

                // Modifica Empresa por Panel 223
                var objModificaEmpresa = ListarPanelControl.Find(x => x.CodiPanel == "223");
                if (objModificaEmpresa != null && objModificaEmpresa.Valor == "1")
                {
                    var NuevoCodiEmpresa = ReintegroRepository.ConsultaEmpresaPVentaYServicio(Convert.ToInt32(filtro.Punto_Venta), Convert.ToInt32(filtro.servicio));
                    filtro.Codi_Empresa__ = (NuevoCodiEmpresa == 0) ? filtro.Codi_Empresa : Convert.ToString(NuevoCodiEmpresa);
                }

                var auxBoletoOriginal = string.Format("{0}{1}", filtro.TipoOri, filtro.boleto_original);

                var entidad = new VentaEntity()
                {
                    CodiEmpresa    = byte.Parse(filtro.Codi_Empresa__), //verificar
                    UserWebSUNAT   = UserWebSUNAT,
                    TipoDocumento  = filtro.tipo_doc,
                    RucCliente     = filtro.NIT_CLIENTE,
                    NomEmpresaRuc  = filtro.NomEmpresaRuc,
                    DirEmpresaRuc  = filtro.DirEmpresaRuc,
                    Tipo           = filtro.Tipo,
                    SerieBoleto    = short.Parse(filtro.Serie),
                    NumeBoleto     = int.Parse(filtro.nume_boleto.PadLeft(8, '0')),
                    PrecioVenta    = Convert.ToDecimal(filtro.PRECIO_VENTA),
                    NomDestino     = filtro.NombDestino,
                    NomServicio    = filtro.NomServicio,
                    NumeAsiento    = byte.Parse(filtro.NUMERO_ASIENTO),
                    Dni            = filtro.Dni,
                    FechaViaje     = filtro.Fecha_viaje,
                    HoraViaje      = filtro.HORA_V,
                    FlagVenta      = filtro.FLAG_VENTA,
                    CodiUsuario    = short.Parse(filtro.Clav_Usuario),
                    CodiOficina    = short.Parse(filtro.CODI_SUCURSAL),
                    CodiPuntoVenta = short.Parse(filtro.Pventa__),
                    CodiTerminal   = filtro.CODI_TERMINAL__,
                    CodiBus        = filtro.CodiBus,
                    CodiEmbarque   = short.Parse(filtro.Sube_en),
                    Nombre         = filtro.NOMB,
                    TipoPago       = filtro.Tipo_Pago,

                    NomEmpresa              = filtro.NomEmpresa,
                    RucEmpresa              = filtro.RucEmpresa,
                    DireccionEmpresa        = filtro.DireccionEmpresa,
                    ElectronicoEmpresa      = filtro.ElectronicoEmpresa,
                    TipoTerminalElectronico = filtro.Tipo, //Solo para validar SUNAT
                    TipoImpresora           = filtro.TipoImpresora
                };

                // Seteo 'CodiDocumento'
                if (!string.IsNullOrEmpty(entidad.RucCliente))
                {
                    entidad.AuxCodigoBF_Interno = CodiCorrelativoVentaFactura;

                    // Correlativo '20'
                    switch (entidad.TipoTerminalElectronico)
                    {
                    case "M":
                    {
                        if (entidad.FlagVenta != "1")
                        {
                            var objPanelCorrelativoCredito02 = ListarPanelControl.Find(x => x.CodiPanel == "145");
                            if (objPanelCorrelativoCredito02 != null && objPanelCorrelativoCredito02.Valor == "1")
                            {
                                entidad.AuxCodigoBF_Interno = CodiCorrelativoCredito;

                                // Busca 'Correlativo'
                                buscarCorrelativo = VentaRepository.BuscarCorrelativo(entidad.CodiEmpresa, entidad.AuxCodigoBF_Interno, entidad.CodiOficina, entidad.CodiPuntoVenta, entidad.CodiTerminal, entidad.TipoTerminalElectronico);
                                if (buscarCorrelativo.SerieBoleto != 0)
                                {
                                    entidad.SerieBoleto = buscarCorrelativo.SerieBoleto;
                                    entidad.NumeBoleto  = buscarCorrelativo.NumeBoleto;
                                }
                                else
                                {
                                    return(new Response <VentaResponse>(false, valor, "Número de correlativo no esta configurado para el tipo " + entidad.AuxCodigoBF_Interno, false));
                                }
                            }
                        }
                    };
                        break;
                    }
                    ;

                    entidad.CodiDocumento = "01"; // Factura
                }
                else
                {
                    entidad.AuxCodigoBF_Interno = CodiCorrelativoVentaBoleta;
                    entidad.CodiDocumento       = "03"; // Boleta
                }

                // Busca 'Correlativo'
                if (entidad.AuxCodigoBF_Interno != CodiCorrelativoCredito)
                {
                    buscarCorrelativo   = VentaRepository.BuscarCorrelativo(entidad.CodiEmpresa, entidad.AuxCodigoBF_Interno, entidad.CodiOficina, entidad.CodiPuntoVenta, entidad.CodiTerminal, entidad.TipoTerminalElectronico);
                    entidad.SerieBoleto = buscarCorrelativo.SerieBoleto;
                    entidad.NumeBoleto  = buscarCorrelativo.NumeBoleto;
                }

                if (buscarCorrelativo.SerieBoleto == 0)
                {
                    switch (entidad.TipoTerminalElectronico)
                    {
                    case "M":
                    {
                        switch (entidad.CodiDocumento)
                        {
                        case "01":             // Factura
                        {
                            if (buscarCorrelativo.SerieBoleto == 0)
                            {
                                // Seteo 'CodiBF Interno'
                                entidad.AuxCodigoBF_Interno = CodiCorrelativoVentaBoleta;
                                // Seteo 'CodiDocumento'
                                entidad.CodiDocumento = "03";                 // Boleta

                                // Busca 'Correlativo'
                                buscarCorrelativo = VentaRepository.BuscarCorrelativo(entidad.CodiEmpresa, entidad.AuxCodigoBF_Interno, entidad.CodiOficina, entidad.CodiPuntoVenta, entidad.CodiTerminal, entidad.TipoTerminalElectronico);
                                if (buscarCorrelativo.SerieBoleto == 0)
                                {
                                    return(new Response <VentaResponse>(false, valor, Message.MsgErrorSerieBoleto, false));
                                }
                                else
                                {
                                    entidad.SerieBoleto = buscarCorrelativo.SerieBoleto;
                                    entidad.NumeBoleto  = buscarCorrelativo.NumeBoleto;
                                }
                            }
                        };
                            break;

                        case "03":             // Boleta
                        {
                            if (buscarCorrelativo.SerieBoleto == 0)
                            {
                                return(new Response <VentaResponse>(false, valor, Message.MsgErrorSerieBoleto, false));
                            }
                        };
                            break;
                        }
                        ;
                    };
                        break;

                    case "E":
                        return(new Response <VentaResponse>(false, valor, Message.MsgErrorSerieBoleto, false));
                    }
                    ;
                }

                // Seteo 'Tipo'
                switch (entidad.TipoTerminalElectronico)
                {
                case "M":
                    entidad.Tipo = "M";
                    break;

                case "E":
                {
                    if (!string.IsNullOrEmpty(entidad.RucCliente))
                    {
                        entidad.Tipo = "F";
                    }
                    else
                    {
                        entidad.Tipo = "B";
                    }
                };
                    break;
                }
                ;

                // Siempre '+ 1' al 'NumeBoleto'
                entidad.NumeBoleto = entidad.NumeBoleto + 1;

                //Para enviar a grabar
                filtro.Tipo = entidad.Tipo;

                // Busca 'AgenciaEmpresa' (E -> GenerarAdicionales, M -> También se va a necesitar.)
                var buscarAgenciaEmpresa = new AgenciaEntity();
                buscarAgenciaEmpresa  = VentaRepository.BuscarAgenciaEmpresa(entidad.CodiEmpresa, entidad.CodiPuntoVenta);
                entidad.EmpDirAgencia = buscarAgenciaEmpresa.Direccion;
                entidad.EmpTelefono1  = buscarAgenciaEmpresa.Telefono1;
                entidad.EmpTelefono2  = buscarAgenciaEmpresa.Telefono2;

                //Valida 'ConsultaPoliza'
                var consultaNroPoliza = new PolizaEntity()
                {
                    NroPoliza = string.Empty,
                    FechaReg  = "01/01/1900",
                    FechaVen  = "01/01/1900"
                };
                var objPanelPoliza = ListarPanelControl.Find(x => x.CodiPanel == "224");
                if (objPanelPoliza != null && objPanelPoliza.Valor == "1")
                {
                    consultaNroPoliza = VentaRepository.ConsultaNroPoliza(entidad.CodiEmpresa, entidad.CodiBus, entidad.FechaViaje);
                    if (string.IsNullOrEmpty(consultaNroPoliza.NroPoliza))
                    {
                        return(new Response <VentaResponse>(false, valor, Message.MsgErrorConsultaNroPoliza, false));
                    }
                }

                entidad.PolizaNum      = consultaNroPoliza.NroPoliza;
                entidad.PolizaFechaReg = consultaNroPoliza.FechaReg;
                entidad.PolizaFechaVen = consultaNroPoliza.FechaVen;

                // Valida 'DocumentoSUNAT'
                ResponseW resValidarDocumentoSUNAT = null;

                if (!filtro.Tipo.Equals("M"))
                {
                    resValidarDocumentoSUNAT = VentaLogic.ValidarDocumentoSUNAT(entidad, ref bodyDocumentoSUNAT);
                }


                if (resValidarDocumentoSUNAT != null || filtro.Tipo.Equals("M"))
                {
                    if ((resValidarDocumentoSUNAT != null && resValidarDocumentoSUNAT.Estado) || filtro.Tipo.Equals("M"))
                    {
                        //Setea CodiDocumento, Serie y Número.
                        filtro.Codi_Documento__   = entidad.AuxCodigoBF_Interno;
                        filtro.Serie              = entidad.SerieBoleto.ToString();
                        filtro.nume_boleto        = entidad.NumeBoleto.ToString();
                        filtro.NUME_CORRELATIVO__ = entidad.NumeBoleto.ToString();

                        var igv = ReintegroRepository.ConsultarIgv(entidad.AuxCodigoBF_Interno);
                        filtro.porcentaje = igv;
                        filtro.tota_ruta1 = filtro.PRECIO_VENTA / (1 + (igv / 100));
                        filtro.tota_ruta2 = filtro.PRECIO_VENTA - filtro.tota_ruta1;

                        //GRABA REINTEGRO
                        var res = ReintegroRepository.SaveReintegro(filtro);

                        var ventaRealizada = (res > 0) ? true : false;


                        if (ventaRealizada)
                        {
                            entidad.IdVenta = res;

                            var objAuditoria = new AuditoriaEntity
                            {
                                CodiUsuario    = Convert.ToInt16(filtro.Clav_Usuario),
                                NomUsuario     = filtro.NomUsuario,
                                Tabla          = "VENTA",
                                TipoMovimiento = "BOL-REINTEGRO",
                                Boleto         = filtro.BoletoAuditoria,
                                NumeAsiento    = filtro.NumAsientoAuditoria.PadLeft(2, '0'),
                                NomOficina     = filtro.NomSucursal,
                                NomPuntoVenta  = filtro.Punto_Venta.PadLeft(3, '0'),
                                Pasajero       = filtro.NOMB,
                                FechaViaje     = filtro.Fecha_viaje,
                                HoraViaje      = filtro.HORA_V,
                                NomDestino     = filtro.NombDestino,
                                Precio         = (decimal)filtro.PRECIO_VENTA,
                                Obs1           = "REINTEGRO DE PASAJES",
                                Obs2           = filtro.CODI_PROGRAMACION,
                                Obs3           = "BOL-" + filtro.Serie.PadLeft(3, '0') + "-" + filtro.nume_boleto.PadLeft(7, '0'),
                                Obs4           = filtro.NomMotivo,
                                Obs5           = string.Empty
                            };
                            //Graba Auditoria
                            VentaRepository.GrabarAuditoria(objAuditoria);

                            // Valida 'TipoPago'
                            switch (entidad.TipoPago)
                            {
                            case "02":     // Múltiple pago
                            case "03":     // Tarjeta de crédito
                            {
                                //  Genera 'CorrelativoAuxiliar'
                                var generarCorrelativoAuxiliar = VentaRepository.GenerarCorrelativoAuxiliar("CAJA", entidad.CodiOficina.ToString(), entidad.CodiPuntoVenta.ToString(), string.Empty);
                                if (string.IsNullOrEmpty(generarCorrelativoAuxiliar))
                                {
                                    return(new Response <VentaResponse>(false, valor, Message.MsgErrorGenerarCorrelativoAuxiliar, false));
                                }

                                var auxBoletoCompleto = VentaLogic.BoletoFormatoCompleto(entidad.TipoTerminalElectronico, entidad.AuxCodigoBF_Interno, entidad.SerieBoleto, entidad.NumeBoleto, "3", "7");

                                var auxCodiDestino = (filtro.CodMotivo.Equals("00003") || filtro.CodMotivo.Equals("00004")) ? filtro.CODI_SUBRUTA : "";

                                // Graba 'Caja'
                                var objCajaEntity = new CajaEntity
                                {
                                    NumeCaja       = generarCorrelativoAuxiliar.PadLeft(7, '0'),
                                    CodiEmpresa    = entidad.CodiEmpresa,
                                    CodiSucursal   = entidad.CodiOficina,
                                    FechaCaja      = DataUtility.ObtenerFechaDelSistema(),
                                    TipoVale       = "S",
                                    Boleto         = auxBoletoCompleto.Substring(1),
                                    NomUsuario     = filtro.NomUsuario,
                                    CodiBus        = string.Empty,
                                    CodiChofer     = string.Empty,
                                    CodiGasto      = string.Empty,
                                    ConcCaja       = auxBoletoCompleto.Substring(1),
                                    Monto          = entidad.PrecioVenta,
                                    CodiUsuario    = entidad.CodiUsuario,
                                    IndiAnulado    = "F",
                                    TipoDescuento  = string.Empty,
                                    TipoDoc        = "XX",
                                    TipoGasto      = "P",
                                    Liqui          = 0M,
                                    Diferencia     = 0M,
                                    Recibe         = string.Empty,
                                    CodiDestino    = auxCodiDestino,
                                    FechaViaje     = entidad.FechaViaje,
                                    HoraViaje      = entidad.HoraViaje,
                                    CodiPuntoVenta = entidad.CodiPuntoVenta,
                                    Voucher        = "PA",
                                    Asiento        = string.Empty,
                                    Ruc            = "N",
                                    IdVenta        = entidad.IdVenta,
                                    Origen         = "MT",
                                    Modulo         = "PM",
                                    Tipo           = entidad.Tipo,

                                    IdCaja = 0
                                };

                                var grabarCaja = VentaRepository.GrabarCaja(objCajaEntity);
                                if (grabarCaja > 0)
                                {
                                    // Seteo 'NumeCaja'
                                    var auxNumeCaja = entidad.CodiOficina.ToString("D3") + entidad.CodiPuntoVenta.ToString("D3") + generarCorrelativoAuxiliar.PadLeft(7, '0');

                                    // Graba 'PagoTarjetaCredito'
                                    var objTarjetaCreditoEntity = new TarjetaCreditoEntity
                                    {
                                        IdVenta            = entidad.IdVenta,
                                        Boleto             = auxBoletoCompleto.Substring(1),
                                        CodiTarjetaCredito = filtro.CodiTarjetaCredito,
                                        NumeTarjetaCredito = filtro.NumeTarjetaCredito,
                                        Vale   = auxNumeCaja,
                                        IdCaja = grabarCaja,
                                        Tipo   = entidad.Tipo
                                    };
                                    var grabarPagoTarjetaCredito = VentaRepository.GrabarPagoTarjetaCredito(objTarjetaCreditoEntity);
                                    if (!grabarPagoTarjetaCredito)
                                    {
                                        return(new Response <VentaResponse>(false, valor, Message.MsgErrorGrabarPagoTarjetaCredito, false));
                                    }
                                }
                                else
                                {
                                    return(new Response <VentaResponse>(false, valor, Message.MsgErrorGrabarCaja, false));
                                }
                            };
                                break;
                            }
                            ;


                            if (filtro.stReintegro.Equals("X"))
                            {
                                var objAuditoria2 = new AuditoriaEntity
                                {
                                    CodiUsuario    = Convert.ToInt16(filtro.Clav_Usuario),
                                    NomUsuario     = filtro.NomUsuario,
                                    Tabla          = "VENTA",
                                    TipoMovimiento = "BOL-REI-CRE",
                                    Boleto         = filtro.BoletoAuditoria,
                                    NumeAsiento    = filtro.NumAsientoAuditoria.PadLeft(2, '0'),
                                    NomOficina     = filtro.NomSucursal,
                                    NomPuntoVenta  = filtro.Punto_Venta.PadLeft(3, '0'),//
                                    Pasajero       = filtro.NOMB,
                                    FechaViaje     = filtro.Fecha_viaje,
                                    HoraViaje      = filtro.HORA_V,
                                    NomDestino     = filtro.NombDestino,
                                    Precio         = (decimal)filtro.PRECIO_VENTA,
                                    Obs1           = "REINTEGRO CON CREDITO",
                                    Obs2           = filtro.CODI_PROGRAMACION,
                                    Obs3           = "BOL-" + filtro.nume_boleto,
                                    Obs4           = filtro.NomMotivo,
                                    Obs5           = string.Empty
                                };
                                //Graba Auditoria Adicional
                                VentaRepository.GrabarAuditoria(objAuditoria2);
                            }

                            if (!filtro.Tipo.Equals("M") && entidad.ElectronicoEmpresa == "1")
                            {
                                //Registra 'DocumentoSUNAT'
                                var resRegistrarDocumentoSUNAT = VentaLogic.RegistrarDocumentoSUNAT(bodyDocumentoSUNAT);

                                if (resRegistrarDocumentoSUNAT.Estado)
                                {
                                    entidad.SignatureValue = resRegistrarDocumentoSUNAT.SignatureValue ?? string.Empty;
                                }
                                else
                                {
                                    return(new Response <VentaResponse>(false, valor, resRegistrarDocumentoSUNAT.MensajeError, false));
                                }
                            }
                        }

                        //Se crea esta entidad para la parte de impresión
                        var auxVentaRealizada = new VentaRealizadaEntity
                        {
                            // Para la vista 'BoletosVendidos'
                            BoletoCompleto = VentaLogic.BoletoFormatoCompleto(entidad.TipoTerminalElectronico, entidad.AuxCodigoBF_Interno, entidad.SerieBoleto, entidad.NumeBoleto, "3", "8"),//ok
                            NumeAsiento    = entidad.NumeAsiento.ToString("D2"),
                            // Para el método 'ConvertirVentaToBase64'
                            IdVenta                 = res,//entidad.IdVenta,
                            BoletoTipo              = entidad.Tipo,
                            BoletoSerie             = entidad.SerieBoleto.ToString("D3"),
                            BoletoNum               = entidad.NumeBoleto.ToString("D8"),
                            CodDocumento            = entidad.CodiDocumento,
                            EmisionFecha            = DataUtility.ObtenerFechaDelSistema(),
                            EmisionHora             = DataUtility.Obtener12HorasDelSistema(),
                            CajeroCod               = entidad.CodiUsuario,
                            CajeroNom               = filtro.NomUsuario,
                            PasNombreCom            = entidad.SplitNombre[0] + " " + entidad.SplitNombre[1] + " " + entidad.SplitNombre[2],
                            PasRuc                  = entidad.RucCliente,
                            PasRazSocial            = entidad.NomEmpresaRuc,
                            PasDireccion            = entidad.DirEmpresaRuc,
                            NomOriPas               = filtro.NomOrigen,
                            NomDesPas               = entidad.NomDestino,
                            DocTipo                 = VentaLogic.TipoDocumentoHomologado(entidad.TipoDocumento),
                            DocNumero               = entidad.Dni,
                            PrecioCan               = entidad.PrecioVenta,
                            PrecioDes               = DataUtility.MontoSolesALetras(DataUtility.ConvertDecimalToStringWithTwoDecimals(entidad.PrecioVenta)),
                            NomServicio             = entidad.NomServicio,
                            FechaViaje              = entidad.FechaViaje,
                            EmbarqueDir             = filtro.DirEmbarque,
                            EmbarqueHora            = filtro.Hora_Emb,
                            CodigoX_FE              = entidad.SignatureValue ?? string.Empty,
                            TipoTerminalElectronico = entidad.TipoTerminalElectronico,
                            TipoImpresora           = entidad.TipoImpresora,

                            EmpDirAgencia  = entidad.EmpDirAgencia,
                            EmpTelefono1   = entidad.EmpTelefono1,
                            EmpTelefono2   = entidad.EmpTelefono2,
                            PolizaNum      = entidad.PolizaNum,
                            PolizaFechaReg = entidad.PolizaFechaReg,
                            PolizaFechaVen = entidad.PolizaFechaVen,

                            //NEW
                            EmpRuc         = filtro.RucEmpresa,
                            EmpRazSocial   = filtro.NomEmpresa,
                            EmpDireccion   = filtro.DireccionEmpresa,
                            EmpElectronico = filtro.ElectronicoEmpresa,

                            // Parámetros extras
                            EmpCodigo    = entidad.CodiEmpresa,
                            PVentaCodigo = entidad.CodiPuntoVenta,
                            BusCodigo    = entidad.CodiBus,
                            EmbarqueCod  = entidad.CodiEmbarque,

                            //NEW
                            TipoPago  = entidad.TipoPago,
                            FlagVenta = entidad.FlagVenta,

                            CodiEsca = auxBoletoOriginal
                        };
                        listaVentasRealizadas.Add(auxVentaRealizada);

                        valor.ListaVentasRealizadas = listaVentasRealizadas;
                        valor.CodiProgramacion      = Convert.ToInt32(filtro.CODI_PROGRAMACION);

                        return((ventaRealizada) ? new Response <VentaResponse>(true, valor, string.Empty, true) : new Response <VentaResponse>(true, null, Message.MsgNoVentaReintegro, true));
                    }
                    else
                    {
                        return(new Response <VentaResponse>(true, valor, resValidarDocumentoSUNAT.MensajeError, false));
                    }
                }
                else
                {
                    return(new Response <VentaResponse>(false, valor, Message.MsgErrorWebServiceFacturacionElectronica, false));
                }
            }
            catch (Exception ex)
            {
                Log.Instance(typeof(BaseLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(new Response <VentaResponse>(false, null, Message.MsgExcVentaReintegro, false));
            }
        }