Exemplo n.º 1
0
        public IHttpActionResult FacturarPedido([FromBody] Producto producto)
        {
            try
            {
                ServiciosVentas servicio = new ServiciosVentas();
                DocumentoVenta  resp     = servicio.DocumentoVentaFacturarProducto(producto);

                if (resp == null)
                {
                    return(NotFound());
                }

                LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(resp));
                return(Ok(resp));
            }
            catch (ApplicationException ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest("El documento de venta no se pudo actualizar."));
            }
        }
Exemplo n.º 2
0
 public IHttpActionResult SaldoInicial(string fecha, int idCliente)
 {
     try
     {
         ServiciosVentas servicio = new ServiciosVentas();
         decimal         resp     = servicio.DocumentoVentaObtenerSaldoInicial(idCliente, fecha);
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
         return(BadRequest(ex.GetExceptionOriginal().Message));
     }
 }
Exemplo n.º 3
0
 public IHttpActionResult ListResumenSaldoCtaCte()
 {
     try
     {
         ServiciosVentas      servicio = new ServiciosVentas();
         List <ListadoCtaCte> resp     = servicio.ObenerResumenSaldosCtaCte();
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
         return(BadRequest(ex.GetExceptionOriginal().Message));
     }
 }
Exemplo n.º 4
0
 public IHttpActionResult ListPaginado(int numeroPagina, int cantidadRegistros, string fechaDesde, string fechaHasta, int idUsuario, int idCliente, string tipoListado)
 {
     try
     {
         ServiciosVentas    servicio = new ServiciosVentas();
         DocumentoVentaList resp     = servicio.DocumentosVentasListar(numeroPagina, cantidadRegistros, fechaDesde, fechaHasta, idUsuario, idCliente, tipoListado.ConvertirIntNulleable());
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
         return(BadRequest(ex.GetExceptionOriginal().Message));
     }
 }
Exemplo n.º 5
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         ServiciosVentas servicio = new ServiciosVentas();
         DocumentoVenta  resp     = servicio.DocumentoVentaObtener(id);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 6
0
 public IHttpActionResult TipoComprobante(int idTipoComprobante)
 {
     try
     {
         ServiciosVentas      servicio = new ServiciosVentas();
         VentaTipoComprobante resp     = servicio.ObtenerObjeto <VentaTipoComprobante>(idTipoComprobante);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
         return(BadRequest(ex.GetExceptionOriginal().Message));
     }
 }
Exemplo n.º 7
0
        public HttpResponseMessage ExportarResumenSaldoCsv()
        {
            HttpResponseMessage result = null;

            try
            {
                ServiciosVentas servicio = new ServiciosVentas();

                List <ListadoCtaCte> listado   = servicio.ObenerResumenSaldosCtaCte();
                StringBuilder        registros = new StringBuilder();

                registros.AppendLine("Cliente,Nombre Fantasia,Debitos,Creditos,Saldo");
                string _cli = string.Empty;
                listado.ForEach(delegate(ListadoCtaCte item)
                {
                    _cli = string.Format("({0}) - {1}", item.Campo1, item.Campo2);
                    registros.AppendLine(string.Format("{0},{1},{2},{3},{4}", _cli, item.Campo3, item.Campo4, item.Campo5, item.Campo6));
                });


                byte[]       byteArray    = Encoding.UTF8.GetBytes(registros.ToString());
                MemoryStream reportStream = new MemoryStream(byteArray);

                result = Request.CreateResponse(HttpStatusCode.OK);

                result.Content = new StreamContent(reportStream);
                //excel
                //result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                //csv
                result.Content.Headers.ContentType        = new MediaTypeHeaderValue("text/csv");
                result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = string.Format("ResumenSaldo_{0}.csv", DateTime.Now.ToString("yyyyMMdd"))
                };

                return(result);
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(Request.CreateResponse(HttpStatusCode.Gone));
            }
        }
Exemplo n.º 8
0
        public HttpResponseMessage ExportarCtaCteCsv(string fechaDesde, string fechaHasta, int idCliente)
        {
            HttpResponseMessage result = null;

            try
            {
                ServiciosVentas servicio = new ServiciosVentas();

                decimal            saldoInicial = servicio.DocumentoVentaObtenerSaldoInicial(idCliente, fechaDesde);
                List <ItemListado> listado      = servicio.ObtenerCtaCteCliente(fechaDesde, fechaHasta, idCliente, saldoInicial);
                StringBuilder      registros    = new StringBuilder();

                registros.AppendLine("Fecha,Comprobante,Pedido Facturado,Debito,Credito,Saldo");

                listado.ForEach(delegate(ItemListado item)
                {
                    registros.AppendLine(string.Format("{0},{1},{2},{3},{4},{5}", item.Campo1, item.Campo2, item.Campo3, item.Campo4, item.Campo5, item.Campo6));
                });


                byte[]       byteArray    = Encoding.UTF8.GetBytes(registros.ToString());
                MemoryStream reportStream = new MemoryStream(byteArray);

                result = Request.CreateResponse(HttpStatusCode.OK);

                result.Content = new StreamContent(reportStream);
                //excel
                //result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                //csv
                result.Content.Headers.ContentType        = new MediaTypeHeaderValue("text/csv");
                result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = string.Format("CtaCte_{0}_{1}.csv", idCliente.ToString(), DateTime.Now.ToString("yyyyMMdd"))
                };

                return(result);
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(Request.CreateResponse(HttpStatusCode.Gone));
            }
        }
Exemplo n.º 9
0
        public HttpResponseMessage ExportarCtaCtePdf(string fechaDesde, string fechaHasta, int idCliente)
        {
            HttpResponseMessage result = null;

            try
            {
                ServiciosVentas     servicio      = new ServiciosVentas();
                ProcesadorPlantilla procPlantilla = new ProcesadorPlantilla("ListadoCtaCte");
                List <string>       contenidoHTML = new List <string>();
                ProcesadorPDF       procesador    = new ProcesadorPDF();
                Document            _docPDF       = null;


                procPlantilla.DiccionarioDatos = servicio.ImprimirCtaCteCliente(fechaDesde, fechaHasta, idCliente);
                procPlantilla.ProcesarPlantilla();

                string nombreArchivo = string.Format("CtaCte_{0}_{1}.pdf", idCliente.ToString(), DateTime.Now.ToString("yyyyMMdd"));

                contenidoHTML.Add(procPlantilla.HTMLProcesado);

                procesador.MostrarEncabezado  = true;
                procesador.AltoEncabezado     = 30;
                procesador.MostrarPieDePagina = true;
                procesador.AltoPieDePagina    = 20;
                procesador.TextoPieDePagina   = true;

                _docPDF = procesador.ProcesarDocumentoPDF(contenidoHTML);
                byte[] outPdfBuffer = _docPDF.Save();

                result         = Request.CreateResponse(HttpStatusCode.OK);
                result.Content = new ByteArrayContent(outPdfBuffer);
                result.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                result.Content.Headers.ContentDisposition.FileName = nombreArchivo;

                return(result);
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(Request.CreateResponse(HttpStatusCode.Gone));
            }
        }