示例#1
0
        public IHttpActionResult GetAnularNC(string usuario, int idCliente, int idVenta)
        {
            EDEDocumentoElectronico    objEDEDocumentoElectronicoResponse;
            EDEEnviarDocumentoResponse objEDERespuesta;
            FacturacionElectronicaBL   oFacturaElectronicaBL = new FacturacionElectronicaBL();

            try
            {
                VentaBL     oVentaBL = new VentaBL(idCliente);
                RespuestaBE rpta     = new RespuestaBE();
                VentaBE     obe      = new VentaBE();
                rpta = oVentaBL.AnularNC(usuario, idCliente, idVenta, out obe);

                if (rpta.codigo == 1 & rpta.isFactOnline)
                {
                    //Generar Estructura Nota de Crédito
                    objEDEDocumentoElectronicoResponse = new EDEDocumentoElectronico();
                    objEDEDocumentoElectronicoResponse = oFacturaElectronicaBL.GenerarEstructuraNotaCredito(obe);
                    //Procesar Nota de Crédito
                    HelperLog.PutLine("Inicio proceso Facturacion Electronica Nota de Crédito");
                    objEDERespuesta = oFacturaElectronicaBL.ProcesarNotaCredito(objEDEDocumentoElectronicoResponse);
                    string msg = "";
                    if (objEDERespuesta.Exito)
                    {
                        msg = "Se envío a SUNAT Correctamente.";
                        if (objEDERespuesta.Procesado)
                        {
                            HelperLog.PutLine(string.Format("Se han actualizado el registro."));
                        }
                        else
                        {
                            HelperLog.PutLine(string.Format("No existen registros para actualizar."));
                        }
                    }
                    else
                    {
                        msg = "Ocurrío un error al enviar a SUNAT.";
                        HelperLog.PutLineError(string.Format(string.Format("Se ha generado el siguiente error: {0}", objEDERespuesta.MensajeError)));
                    }
                    //Actualizar respuesta
                    ActualizarRespuesta(objEDERespuesta);
                    return(Ok(Models.Util.GetBodyResponse(200, rpta.descripcion + " " + msg)));
                }
                else if (rpta.codigo == 1)
                {
                    return(Ok(Models.Util.GetBodyResponse(200, rpta.descripcion)));
                }
                else
                {
                    return(Ok(Models.Util.GetBodyResponse(300, "Ocurrío un error inesperado.")));
                }
            }
            catch (Exception ex)
            {
                /*LogSA.GrabarLogError("SOL TR", user, "GetListarOrdOtrs", ex);*/
                return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
            }
        }
 public async Task <IHttpActionResult> PostGuardarArchivoVUE(List <ListaArchivosAdjuntos> model)
 {
     try
     {
         string msj  = "";
         bool   rpta = false;
         rpta = oArchivosAdjuntosBL.GuardarArchivoVUE(model, out msj);
         if (rpta)
         {
             return(Ok(Models.Util.GetBodyResponse(200, msj)));
         }
         else
         {
             return(Ok(Models.Util.GetBodyResponse(300, msj)));
         }
     }
     catch (Exception ex)
     {
         HelperLog.PutLineError(ex.Message);
         return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
     }
 }
示例#3
0
        public async Task <IHttpActionResult> VentaACuenta(VentaBE obe)
        {
            try
            {
                VentaBL     oVentaBL = new VentaBL(obe.IdCliente);
                RespuestaBE rpta     = new RespuestaBE();
                rpta = oVentaBL.VentaACuenta(obe);

                if (rpta.codigo == 2 & rpta.isFactOnline)
                {
                    EDEDocumentoElectronico    objEDEDocumentoElectronicoResponse;
                    EDEEnviarDocumentoResponse objEDERespuesta;
                    FacturacionElectronicaBL   oFacturaElectronicaBL = new FacturacionElectronicaBL();
                    //Generar Estructura Facturacion electronica
                    objEDEDocumentoElectronicoResponse = new EDEDocumentoElectronico();
                    objEDEDocumentoElectronicoResponse = oFacturaElectronicaBL.GenerarEstructuraBoletaFactura(obe);
                    //Procesar Facturacion electronica
                    HelperLog.PutLine("Inicio proceso Facturacion Electronica Boletas y Facturas");
                    objEDERespuesta = oFacturaElectronicaBL.ProcesarBoletaFactura(objEDEDocumentoElectronicoResponse);
                    string msg         = "";
                    string byteArchivo = "";
                    if (objEDERespuesta.Exito)
                    {
                        ImprimirComprobanteBL oImprimirComprobanteBL = new ImprimirComprobanteBL();
                        byteArchivo = oImprimirComprobanteBL.ImprimirVenta(obe);
                        msg         = "Se envío a SUNAT Correctamente.";
                        if (objEDERespuesta.Procesado)
                        {
                            HelperLog.PutLine(string.Format("Se han actualizado el registro."));
                        }
                        else
                        {
                            HelperLog.PutLine(string.Format("No existen registros para actualizar."));
                        }
                    }
                    else
                    {
                        msg = "Ocurrío un error al enviar a SUNAT.";
                        HelperLog.PutLineError(string.Format(string.Format("Se ha generado el siguiente error: {0}", objEDERespuesta.MensajeError)));
                    }
                    //Actualizar Respuesta
                    ActualizarRespuesta(objEDERespuesta);
                    return(Ok(Models.Util.GetBodyResponseF(200, rpta.descripcion + " " + msg, byteArchivo)));
                }
                else if (rpta.codigo == 1)
                {
                    string byteArchivo = "";
                    //ImprimirComprobanteBL oImprimirComprobanteBL = new ImprimirComprobanteBL();
                    //byteArchivo = oImprimirComprobanteBL.ImprimirVenta(obe);
                    return(Ok(Models.Util.GetBodyResponseF(200, rpta.descripcion, byteArchivo)));
                }
                else if (rpta.codigo == 2)
                {
                    string byteArchivo = "";
                    //ImprimirComprobanteBL oImprimirComprobanteBL = new ImprimirComprobanteBL();
                    //byteArchivo = oImprimirComprobanteBL.ImprimirVenta(obe);
                    return(Ok(Models.Util.GetBodyResponseF(200, rpta.descripcion, byteArchivo)));
                }
                else
                {
                    return(Ok(Models.Util.GetBodyResponse(300, rpta.descripcion)));
                }
            }
            catch (Exception ex)
            {
                //LogSA.GrabarLogError("SOL TR", model.user, "EditarTareas", ex);
                return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
            }
        }
示例#4
0
        public IHttpActionResult GetAnular(string usuario, int idCliente, int idVenta)
        {
            EDEComunicacionBaja        objEDEComunicacionBajaResponse;
            EDEDocumentoElectronico    objEDEDocumentoElectronico;
            EDEEnviarDocumentoResponse objEDERespuesta;
            FacturacionElectronicaBL   oFacturaElectronicaBL = new FacturacionElectronicaBL();

            try
            {
                VentaBL     oVentaBL = new VentaBL(idCliente);
                RespuestaBE rpta     = new RespuestaBE();
                VentaBE     obe      = new VentaBE();
                rpta = oVentaBL.Anular(usuario, idCliente, idVenta, out obe);

                if (rpta.codigo == 1 & rpta.isFactOnline)
                {
                    DateTime       fecha = DateTime.Now;
                    List <VentaBE> lobe  = new List <VentaBE>();
                    lobe.Add(obe);
                    //Generar Estructura Comunicación de Baja
                    objEDEComunicacionBajaResponse = new EDEComunicacionBaja();
                    objEDEDocumentoElectronico     = new EDEDocumentoElectronico();
                    objEDEComunicacionBajaResponse = oFacturaElectronicaBL.GenerarEstructuraComunicacionBaja(lobe, fecha);
                    //Procesar Comunicación de Baja
                    HelperLog.PutLine("Inicio proceso Facturacion Electronica Comunicación de Baja");
                    objEDEDocumentoElectronico.RUC            = obe.RUC;
                    objEDEDocumentoElectronico.UsuarioSOL     = obe.UsuarioSOL;
                    objEDEDocumentoElectronico.ClaveSOL       = obe.ClaveSOL;
                    objEDEDocumentoElectronico.URLCertificado = obe.URLCertificado;
                    objEDEDocumentoElectronico.ClaveDigital   = obe.ClaveDigital;
                    objEDERespuesta = oFacturaElectronicaBL.ProcesarComunicacionBaja(objEDEComunicacionBajaResponse, objEDEDocumentoElectronico);
                    string msg = "";
                    if (objEDERespuesta.Exito)
                    {
                        msg = "Se envío a SUNAT Correctamente.";
                        if (objEDERespuesta.Procesado)
                        {
                            HelperLog.PutLine(string.Format("Se han actualizado el registro."));
                        }
                        else
                        {
                            HelperLog.PutLine(string.Format("No existen registros para actualizar."));
                        }
                    }
                    else
                    {
                        msg = "Ocurrío un error al enviar a SUNAT.";
                        HelperLog.PutLineError(string.Format(string.Format("Se ha generado el siguiente error: {0}", objEDERespuesta.MensajeError)));
                    }
                    //Actualizar respuesta
                    //ActualizarRespuesta(objEDERespuesta);
                    return(Ok(Models.Util.GetBodyResponse(200, rpta.descripcion + " " + msg)));
                }
                else if (rpta.codigo == 1) //FACTURA - BOLETA (SIN FACTURACION ELECTRONICA)
                {
                    return(Ok(Models.Util.GetBodyResponse(200, rpta.descripcion)));
                }
                else if (rpta.codigo == 2) //NOTA DE VENTA
                {
                    return(Ok(Models.Util.GetBodyResponse(200, rpta.descripcion)));
                }
                else
                {
                    return(Ok(Models.Util.GetBodyResponse(300, "No se encontraron registros.")));
                }
            }
            catch (Exception ex)
            {
                /*LogSA.GrabarLogError("SOL TR", user, "GetListarOrdOtrs", ex);*/
                return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
            }
        }
 public IHttpActionResult PostGuardarArchivo(string Customer)
 {
     try
     {
         var    httpContext = HttpContext.Current;
         bool   FlagIsImage = false;
         string TypeFile    = string.Empty;
         string fileName    = string.Empty;
         if (httpContext.Request.Files.Count > 0)
         {
             for (int i = 0; i < httpContext.Request.Files.Count; i++)
             {
                 HttpPostedFile httpPostedFile = httpContext.Request.Files[i];
                 if (httpPostedFile != null)
                 {
                     //Obtener la extension del archivo
                     string extension = System.IO.Path.GetExtension(httpPostedFile.FileName);
                     //Obtener la ruta actual del directorio
                     var fileCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
                     //Navegar sobre la ruta de los arhivos
                     FileInfo      fileInfo      = new FileInfo(fileCurrentPath);
                     DirectoryInfo parentDir     = fileInfo.Directory.Parent;
                     string        parentDirName = parentDir.FullName;
                     string        filepath      = Path.Combine(parentDirName, "files");
                     //Crear la carpeta del cliente
                     Customer = string.Format("cliente_{0}", Customer);
                     filepath = Path.Combine(filepath, Customer);
                     //Validar extensiones para crear carpetas segun tipo de archivo
                     ValidateFolderExists(filepath);
                     if (extension.ToLower() == ".jpg" ||
                         extension.ToLower() == ".jpeg" ||
                         extension.ToLower() == ".pjpeg" ||
                         extension.ToLower() == ".png" ||
                         extension.ToLower() == ".x-png" ||
                         extension.ToLower() == ".tif" ||
                         extension.ToLower() == ".bmp" ||
                         extension.ToLower() == ".psd" ||
                         extension.ToLower() == ".gif")
                     {
                         FlagIsImage = true;
                         TypeFile    = "images";
                     }
                     else if (extension.ToLower() == ".doc" ||
                              extension.ToLower() == ".docx" ||
                              extension.ToLower() == ".docm")
                     {
                         TypeFile = "word";
                     }
                     else if (extension.ToLower() == ".xls" ||
                              extension.ToLower() == ".xlsx" ||
                              extension.ToLower() == ".xlsm")
                     {
                         TypeFile = "excel";
                     }
                     else if (extension.ToLower() == ".pdf")
                     {
                         TypeFile = "pdf";
                     }
                     else if (extension.ToLower() == ".xml")
                     {
                         TypeFile = "xml";
                     }
                     else if (extension.ToLower() == ".zip" ||
                              extension.ToLower() == ".rar" ||
                              extension.ToLower() == ".tar")
                     {
                         TypeFile = "zip";
                     }
                     else if (extension.ToLower() == ".pfx")
                     {
                         TypeFile = "certificado_digital";
                     }
                     else
                     {
                         TypeFile = "otros";
                     }
                     filepath = Path.Combine(filepath, TypeFile);
                     ValidateFolderExists(filepath);
                     //Crear el nombre de archivo
                     fileName = Guid.NewGuid().ToString() + extension.ToLower();
                     //Ruta completa para guardar el arhivo
                     filepath = Path.Combine(filepath, fileName);
                     //Guardar el archivo
                     if (FlagIsImage)
                     {
                         using (var image = System.Drawing.Image.FromStream(httpPostedFile.InputStream))
                             using (var newImage = ScaleImage(image, Common.Constants.Redimension.heigh, Common.Constants.Redimension.width))
                             {
                                 newImage.Save(filepath);
                             }
                     }
                     else
                     {
                         httpPostedFile.SaveAs(filepath);
                     }
                 }
             }
             //Crear ruta de respuesta
             string PathRespose = string.Format(ConfigurationManager.AppSettings["ResponseFile"] + "{0}/{1}/{2}", Customer, TypeFile, fileName);
             return(Ok(Models.Util.GetBodyResponse(200, PathRespose)));
         }
         else
         {
             return(Ok(Models.Util.GetBodyResponse(300, "No se adjunto ningun archivo.")));
         }
     }
     catch (Exception ex)
     {
         HelperLog.PutLineError(ex.Message);
         return(Ok(Models.Util.GetBodyResponse(400, ex.Message)));
     }
 }