public static Response <List <PaseLoteResponse> > UpdatePostergacion(UpdatePostergacionRequest request) { try { var res = PaseLoteRepository.UpdatePostergacion(request.Lista.Replace('\'', '"')); if (res.Count > 0) { foreach (var obj in res) { var objAuditoria = new AuditoriaEntity { CodiUsuario = Convert.ToInt16(request.CodiUsuario), NomUsuario = request.NomUsuario, Tabla = "VENTA", TipoMovimiento = "POS-LOTE", Boleto = obj.Boleto, NumeAsiento = obj.NumeAsiento.PadLeft(2, '0'), NomOficina = request.NomSucursal, NomPuntoVenta = request.PuntoVenta.PadLeft(3, '0'), Pasajero = obj.Pasajero, FechaViaje = obj.FechaViaje, HoraViaje = obj.HoraViaje, NomDestino = string.Empty, Precio = 0.00m, Obs1 = "ID " + obj.IdVenta + " PROGRAMACION: " + obj.CodiProgramacion, Obs2 = "TERMINAL: " + request.Terminal.PadLeft(3, '0'), Obs3 = string.Empty, Obs4 = string.Empty, Obs5 = string.Empty }; VentaRepository.GrabarAuditoria(objAuditoria); } } return(new Response <List <PaseLoteResponse> >(true, res, string.Empty, true)); } catch (Exception ex) { Log.Instance(typeof(BaseLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex); return(new Response <List <PaseLoteResponse> >(false, null, Message.MsgExcPaseLote, false)); } }
public static Response <bool> EliminarMensaje(MensajeriaRequest request) { try { BaseRepository.EliminarMensaje(request.IdMensaje); var objAuditoria = new AuditoriaEntity { CodiUsuario = request.CajeroCod, NomUsuario = request.CajeroNom, Tabla = "MENSAJES", TipoMovimiento = "MENSAJE", Boleto = string.Empty, NumeAsiento = "0", NomOficina = request.CajeroNomSuc, NomPuntoVenta = request.CajeroCodPven.ToString(), Pasajero = string.Empty, FechaViaje = "01/01/1900", HoraViaje = string.Empty, NomDestino = string.Empty, Precio = 0, Obs1 = "USR ENVIA " + request.CodiUsuario, Obs2 = "SUCURSAL ENVIA " + request.CodiSucursal, Obs3 = "TERMINAL QUE ENVIA : " + request.Terminal, Obs4 = "TERMINAL " + request.CajeroTer, Obs5 = string.Empty }; VentaRepository.GrabarAuditoria(objAuditoria); return(new Response <bool>(true, true, Message.MsgCorrectoEliminarMensaje, true)); } catch (Exception ex) { Log.Instance(typeof(BaseLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex); return(new Response <bool>(false, false, Message.MsgExcEliminarMensaje, 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)); } }
public static Response <string> CambiarTipoPago(CambiarTPagoRequest request) { try { var response = ""; if (request.NewTipoPago == "01") { request.CodiTarjetaCredito = ""; request.NumeTarjetaCredito = ""; request.NomTarjetaCredito = ""; } // Resta al Vale de Caja el crédito ingresado, Elimina el Pago con Tarjeta // y Modificar el Tipo de Pago var NumeroCaja = CambiarTPagoRepository.CambiarTipoPago(request); var auxBoletoCompleto = string.Format("{0}{1}-{2}", request.Tipo, request.Serie.ToString().PadLeft(3, '0'), request.Numero.ToString().PadLeft(7, '0')); if (request.NewTipoPago == "03") { // Genera 'CorrelativoAuxiliar' var generarCorrelativoAuxiliar = VentaRepository.GenerarCorrelativoAuxiliar("CAJA", request.CodiOficina.ToString(), request.CodiPuntoVenta.ToString(), string.Empty); if (string.IsNullOrEmpty(generarCorrelativoAuxiliar)) { return(new Response <string>(false, string.Empty, string.Empty, false)); } // Graba 'Caja' var objCajaEntity = new CajaEntity { NumeCaja = generarCorrelativoAuxiliar.PadLeft(7, '0'), CodiEmpresa = Convert.ToByte(request.CodiEmpresa), CodiSucursal = request.CodiOficina, FechaCaja = DataUtility.ObtenerFechaDelSistema(), TipoVale = "S", Boleto = auxBoletoCompleto.Substring(1), NomUsuario = request.NomUsuario, CodiBus = string.Empty, CodiChofer = string.Empty, CodiGasto = string.Empty, ConcCaja = auxBoletoCompleto.Substring(1), Monto = request.PrecioVenta, CodiUsuario = request.CodiUsuario, IndiAnulado = "F", TipoDescuento = string.Empty, TipoDoc = "XX", TipoGasto = "P", Liqui = 0M, Diferencia = 0M, Recibe = string.Empty, CodiDestino = request.CodiDestino, FechaViaje = request.FechaViaje, HoraViaje = request.HoraViaje, CodiPuntoVenta = request.CodiPuntoVenta, Voucher = "PA", Asiento = string.Empty, Ruc = "N", IdVenta = request.IdVenta, Origen = "MT", Modulo = "PM", Tipo = request.Tipo, IdCaja = 0 }; var grabarCaja = VentaRepository.GrabarCaja(objCajaEntity); if (grabarCaja > 0) { // Seteo 'NumeCaja' var auxNumeCaja = request.CodiOficina.ToString("D3") + request.CodiPuntoVenta.ToString("D3") + generarCorrelativoAuxiliar.PadLeft(7, '0'); response = auxNumeCaja; // Graba 'PagoTarjetaCredito' var objTarjetaCreditoEntity = new TarjetaCreditoEntity { IdVenta = request.IdVenta, Boleto = auxBoletoCompleto.Substring(1), CodiTarjetaCredito = request.CodiTarjetaCredito, NumeTarjetaCredito = request.NumeTarjetaCredito, Vale = auxNumeCaja, IdCaja = grabarCaja, Tipo = request.Tipo }; var grabarPagoTarjetaCredito = VentaRepository.GrabarPagoTarjetaCredito(objTarjetaCreditoEntity); if (!grabarPagoTarjetaCredito) { return(new Response <string>(false, string.Empty, string.Empty, false)); } } else { return(new Response <string>(false, string.Empty, string.Empty, false)); } } var objAuditoria = new AuditoriaEntity { CodiUsuario = Convert.ToInt16(request.CodiUsuario), NomUsuario = request.NomUsuario, Tabla = "VENTA", TipoMovimiento = "MODIFICACION DE TIPO DE PAGO", Boleto = auxBoletoCompleto.Substring(1), NumeAsiento = request.NumeAsiento, NomOficina = request.NomSucursal, NomPuntoVenta = request.CodiPuntoVenta.ToString().PadLeft(3, '0'), Pasajero = request.Nombre, FechaViaje = request.FechaViaje, HoraViaje = request.HoraViaje, NomDestino = request.NombDestino, Precio = request.PrecioVenta, Obs1 = "MODIFICACION T PAGO", Obs2 = string.Format("{0} {1}", request.NewTipoPago, request.NomNewTipoPago), Obs3 = request.NomTarjetaCredito, Obs4 = request.NumeTarjetaCredito, Obs5 = string.Empty }; VentaRepository.GrabarAuditoria(objAuditoria); return(new Response <string>(true, response, string.Empty, true));; } catch (Exception ex) { Log.Instance(typeof(CambiarTPagoLogic)).Error(System.Reflection.MethodBase.GetCurrentMethod().Name, ex); return(new Response <string>(false, string.Empty, "Error", false)); } }
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)); } }
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)); } }