<%@ WebService Language="VB" Class="WSApp" %> Option Explicit On Imports System.Data Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports Microsoft.Reporting.WebForms Imports Extensiones Imports Newtonsoft.Json Imports WebServiceAppModels2 Imports Modelos Imports System.IO Imports System Imports System.Globalization Imports Newtonsoft.Json.Linq ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' _ Public Class WSApp Inherits System.Web.Services.WebService #Region "G L O B A L - D T" Public ReadOnly Property UrlSitio As String Get Return ConfigurationManager.AppSettings("UrlSitio").ToString End Get End Property ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1, Optional Codigo As String = "-1") As DataTable Get Dim ObjPS As New ClsProductosServicios If ObjPS.GetPS(CvePS, -1, CveEmpresa, Codigo:=Codigo, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then GlobalDTPS = ObjPS.DtResultados Else GlobalDTPS = Nothing End If ObjPS.Dispose() End Get End Property #End Region Public Property CveEmpresa As Integer = 143 Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario) Dim ObjEmpresa As New ClsSisEmpresas() If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados Dim EmpresasFuncionalidades As New HybridDictionary For Each Row As Data.DataRow In dttmp.Rows EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString) Next ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades) End If UsuarioActual.Empresa = ObjEmpresa.Empresa Else End If ObjEmpresa.Dispose() End Sub #Region "M E T O D O S - S E R V I C I O" Public Function ValidaUsuario(CveUsuario As Integer) As Usuario Dim UsuarioActual As Usuario = Nothing Dim ObjUsuarios As New ClsSisUsuarioAutenticacion UsuarioActual = ObjUsuarios.GetUsuarioDetalle(CveUsuario) 'If UsuarioActual IsNot Nothing Then ' Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString() ' Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() ' UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia) 'End If ObjUsuarios.Dispose() Return UsuarioActual End Function Public Function Login(Usuario As String, Contrasenia As String) As String Dim retorno As String = "" Dim Salida As WSUSER = Nothing Dim ObjUsuarios As New ClsSisUsuarioAutenticacion Dim ObjClientes As New ClsClientes Try Dim UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Encripta(Contrasenia)) If UsuarioActual IsNot Nothing Then Salida = New WSUSER Salida.CveUsuario = UsuarioActual.CveUsuario Salida.CveEmpresa = UsuarioActual.CveEmpresa Salida.Empresa = ClsPaginas.GlobalDTUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("Empresa") Salida.CveCliente = UsuarioActual.CveCliente Salida.Usuario = UsuarioActual.Usuario Salida.Nombre = UsuarioActual.Nombre Salida.CveRol = UsuarioActual.CveRol Salida.Rol = UsuarioActual.Rol Salida.CveSubProyecto = UsuarioActual.CveSubProyecto Salida.Procesos = UsuarioActual.Procesos.Values.Cast(Of String).ToList() If UsuarioActual.CveCliente > 0 AndAlso ObjClientes.GetClientes(UsuarioActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then If ObjClientes.DtResultados.Rows.Count > 0 Then Salida.Cliente = ObjClientes.Nombre Salida.CvePrecioLista = ObjClientes.CvePrecioLista Salida.CveEstatusCliente = If(ObjClientes.Estatus, 1, 0) If ObjClientes.CveSubProyecto > 0 Then Salida.CveSubProyecto = ObjClientes.CveSubProyecto End If retorno = JsonConvert.SerializeObject(Salida) End If Else retorno = "{}" End If Else retorno = "{}" End If Catch ex As Exception retorno = "{}" OnError("Ocurrió un Error al iniciar sesión.", ex) Finally ObjUsuarios.Dispose() ObjClientes.Dispose() End Try Return retorno End Function Public Function LoginData(CveUsuario As Integer) As String Dim retorno As String = "" Dim Salida As WSUSER = Nothing Dim ObjClientes As New ClsClientes Try Dim UsuarioActual As Usuario = ValidaUsuario(CveUsuario) If UsuarioActual IsNot Nothing AndAlso UsuarioActual.CvePlataforma = 6 Then Salida = New WSUSER Salida.CveUsuario = UsuarioActual.CveUsuario Salida.CveEmpresa = UsuarioActual.CveEmpresa Salida.Empresa = ClsPaginas.GlobalDTUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("Empresa") Salida.CveCliente = UsuarioActual.CveCliente Salida.Usuario = UsuarioActual.Usuario Salida.Nombre = UsuarioActual.Nombre Salida.CveRol = UsuarioActual.CveRol Salida.Rol = UsuarioActual.Rol Salida.CveSubProyecto = UsuarioActual.CveSubProyecto Salida.Procesos = UsuarioActual.Procesos.Values.Cast(Of String).ToList() If ObjClientes.GetClientes(UsuarioActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then If ObjClientes.DtResultados.Rows.Count > 0 Then Salida.Cliente = ObjClientes.Nombre Salida.CvePrecioLista = ObjClientes.CvePrecioLista Salida.CveEstatusCliente = If(ObjClientes.Estatus, 1, 0) End If End If retorno = JsonConvert.SerializeObject(Salida) Else retorno = "{}" End If Catch ex As Exception retorno = "{}" OnError("Ocurrió un Error al iniciar sesión.", ex) Finally ObjClientes.Dispose() End Try Return retorno End Function Public Function GetPedido(CveVenta As Integer) As String Dim retorno As New JObject Dim TieneError = False Using ObjVentas As New ClsVentas If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then If ObjVentas.DtResultados.Rows.Count > 0 Then retorno.Add(New JProperty("Pedido", JArray.Parse(ObjVentas.DtResultados.ToJson())(0))) Else TieneError = True End If Else TieneError = True End If If Not TieneError Then If ObjVentas.GetVentaDetalle(CveVenta) Then If ObjVentas.DtResultados.Rows.Count > 0 Then retorno.Add(New JProperty("Productos", JArray.Parse(ObjVentas.DtResultados.ToJson()))) Else TieneError = True End If Else TieneError = True End If End If End Using Return If(TieneError, "{}", retorno.ToString()) End Function Public Function GetListaPedidos(CveCliente As Integer, CveUsuario As Integer,FechaI As String, FechaF As String) As String Dim retorno = "[]" Dim Serie As String = "-1" Dim Folio As Integer = -1 Dim Codigo As String = "-1" Dim Cliente As String = "-1" Dim FolioFiscal As String = "-1" Dim PeidoContrato As String = "-1" Dim OrdenCompra As String = "-1" Using ObjVentas As New ClsVentas If ObjVentas.GetVentas(CveEmpresa, "Rem", Serie, Folio, Codigo, CveCliente, -1, -1, -1, FechaI, FechaF, FolioFiscal, -1, -1, PedidoContrato:=PeidoContrato, OrdenCompra:=OrdenCompra, CveUsuarioConsulta:=100) Then If ObjVentas.DtResultados.Rows.Count > 0 Then retorno = ObjVentas.DtResultados.FiltraParametros("", "Fecha DESC").ToJson() End If End If End Using Return retorno End Function Public Function GetProductos(CvePrecioLista As Integer, CveClasificacion As Integer) As String Dim retorno As String = "[]" Dim CvePS As Integer = -1 Dim ObjPS As New ClsProductosServicios If ObjPS.GetPSExistenciasWS(CvePS, CvePrecioLista, -1, CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm")) Then If CveClasificacion > 0 Then retorno = ObjPS.DtResultados.FiltraParametros($"CveClasificacion = {CveClasificacion}").ToJson() Else retorno = ObjPS.DtResultados.ToJson() End If End If ObjPS.Dispose() Return retorno End Function Public Function GetClasificaciones() As String Return ClsPaginas.GlobalDTClasificaciones(CveEmpresa).ToJson() End Function Public Function GetPrecioLista() As String Dim retorno As String = "[]" Dim objInv As New ClsVentas If objInv.GetPrecioListas(CveEmpresa) Then retorno = objInv.DtResultados.ToJson() End If objInv.Dispose() Return retorno End Function Public Function GetUnidadesMedida() As String Return ClsPaginas.GlobalDTUnidadesMedida(CveEmpresa).ToJson() End Function Public Function AddPedido(CveCliente As Integer, CveSubProyecto As Integer, CveUsuario As Integer, Observaciones As String, Productos As String) As String Dim Retorno As New Modelos.Factura.MMensajeFactura() Try Dim UsuarioActual As Usuario = ValidaUsuario(CveUsuario) If UsuarioActual IsNot Nothing Then Dim ListaPS As List(Of MVentaProductos) = Nothing If Not String.IsNullOrEmpty(Productos) Then ListaPS = JsonConvert.DeserializeObject(Of List(Of MVentaProductos))(Productos) End If If ListaPS IsNot Nothing Then Dim Continuar As Boolean = False Dim ObjPS As New ClsProductosServicios Try For Each PS In ListaPS Dim CveTipoPS As Integer = ClsPaginas.GlobalDTPSSimplificado(CveEmpresa, CvePS:=PS.CvePS).FiltroPrimeroValor("CveTipoPS").ToEntero() If CveTipoPS > 0 Then If CveTipoPS = 2 Then If ObjPS.GetPSExistencias(PS.CvePS, -1, -1, CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm")) Then If ObjPS.DtResultados.Rows.Count > 0 Then Dim Existencia As Decimal = ObjPS.DtResultados.Rows(0)("Existencia").ToString().ToDecimal() 'Dim CveTipoPS As Integer = ObjPS.DtResultados.Rows(0)("CveTipoPS").ToString().ToEntero() Continuar = Existencia > 0 If Not Continuar Then Retorno.Mensajes.Add($"El producto/servicio {ObjPS.DtResultados.Rows(0)("PS")} no tiene existencia.") Exit For End If Else Continuar = False Retorno.Mensajes.Add("No se pudo comprobar la existencia.") Exit For End If End If ElseIf CveTipoPS = 1 Then Continuar = True End If Else Continuar = False Retorno.Mensajes.Add("No se pudo comprobar si es producto o servicio.") End If Next Catch ex As Exception OnError("Ocurrió un error al consultar la existencia", ex) Continuar = False End Try ObjPS.Dispose() If Continuar Then Dim Factura As Modelos.Factura = CreaFactura(Retorno, CveCliente, -1, CveSubProyecto, 1, UsuarioActual, Observaciones, ListaPS) If Factura IsNot Nothing AndAlso Retorno.Mensajes.Count = 0 Then Retorno = Factura.EmitirFactura() Else Retorno.Mensajes.Add("No se pudo generar la factura") End If If Retorno.CveVenta > 0 AndAlso CveSubProyecto.Contiene(11714, 11761, 11713) Then Dim Correo As String = If(CveSubProyecto.Contiene(11714, 11761), "mezclas.pescadito@gmail.com", "pedidosaguas@gmail.com") 'Dim Correo As String = "japmx95@gmail.com" Dim SerieFolio As String = Factura.SerieFolio Dim DireccionEnvio As String = "" Using ObjClientes As New ClsClientes If ObjClientes.DireccionEnvioGet(-1, CveCliente, -1) Then If ObjClientes.DtResultados.Rows.Count > 0 Then DireccionEnvio = ObjClientes.DtResultados.FiltroPrimeroValor("DireccionEnvioContacto") End If End If End Using Factura.Dispose() EnviarCorreo(Correo, Factura, Retorno, DireccionEnvio, UsuarioActual) Else Factura.Dispose() End If End If Else Retorno.Mensajes.Add("No se pudo procesar los productos") End If Else Retorno.Mensajes.Add("No se pudo comprobar el usuario") End If Catch ex As Exception Retorno.Mensajes.Add(ex.ToString()) End Try Return JsonConvert.SerializeObject(Retorno) End Function Private Sub EnviarCorreo(Correo As String, Factura As Modelos.Factura, Retorno As Modelos.Factura.MMensajeFactura, DireccionEnvio As String, UsuarioActual As Usuario) Try EnviarCorreoFactura(Correo, Factura, Retorno, DireccionEnvio, UsuarioActual) 'Dim Hilo As New System.Threading.Thread(Sub() EnviarCorreoFactura(Correo, Factura, Retorno, DireccionEnvio, UsuarioActual)) 'Hilo.Start() Catch ex As Exception OnError("Ocurrió error al mandar el correo de facturación", ex) End Try End Sub Private Sub EnviarCorreoFactura(Correo As String, Factura As Modelos.Factura, Retorno As Modelos.Factura.MMensajeFactura, DireccionEnvio As String, UsuarioActual As Usuario) Dim Body = GeneraCorreoRemision(Retorno.CveVenta, Retorno.SerieFolio, Factura.Cliente.Nombre, Factura.Cliente.NombreComercial, DireccionEnvio, Factura.Observaciones, ClsPaginas.NowADS()) Factura.Dispose() Try Dim Asunto As String = String.Format("SIG - Se ha realizado un pedido: {0}", Retorno.SerieFolio) Dim Mail As New ClsSisMail() Mail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Body) Catch ex As Exception OnError("Ocurrió error al mandar MAIL por cambio de Estatus", ex) End Try End Sub Public Function CancelarDocumento(CveVenta As Integer, CveUsuario As Integer) As String Dim Retorno = New Modelos.Factura.MMensajeFactura() Try Dim ObjUsuarios As New ClsSisUsuarios() Dim UsuarioActual As Usuario = ValidaUsuario(CveUsuario) If UsuarioActual IsNot Nothing Then 'If UsuarioActual.TienePermisoProceso(159) Then ' Dim Factura As New Modelos.Factura(UsuarioActual, CveVenta, CveEmpresa, ModExtensiones.DirectorioBaseEmpresas) ' Retorno = Factura.CancelarDocumento() 'Else ' Retorno.Mensajes.Add("Este usuario no tiene permiso para cancelar documento") 'End If Dim Factura As New Modelos.Factura(UsuarioActual, CveVenta, CveEmpresa, ModExtensiones.DirectorioBaseEmpresas) If String.IsNullOrEmpty(Factura.FolioFiscal) Then Factura.FolioFiscal = "" End If Retorno = Factura.CancelarDocumento() If Not Retorno.TieneError Then Dim DtInv As DataTable = Nothing Dim ObjInv As New ClsInventarios() ObjInv.GetMovimientos(-1, -1, -1, UsuarioActual.CveEmpresa) If ObjInv.DtResultados.Rows.Count > 0 Then DtInv = ObjInv.DtResultados.FiltraParametros($"CveVenta = {CveVenta}") ObjInv.Dispose() If DtInv IsNot Nothing Then For Each Dr As DataRow In DtInv.Rows Dim CveMovimiento As Integer = Dr("CveMovimiento").ToString().ToEntero() If CveMovimiento > 0 Then EliminarMovimiento(Retorno, UsuarioActual, CveMovimiento) End If Next Else Retorno.Mensajes.Add("No se encontraron movimientos de almacen") End If Else Retorno.Mensajes.Add("No se encontraron movimientos de almacen") End If End If End If Catch ex As Exception Retorno.Mensajes.Add(ex.ToString()) End Try Return JsonConvert.SerializeObject(Retorno) End Function Protected Sub EliminarMovimiento(ByRef Retorno As Modelos.Factura.MMensajeFactura, UsuarioActual As Usuario, CveMovimiento As Integer) Dim ObjInv As New ClsInventarios ObjInv.IniciaTransacSQL() Dim TieneError = False If Not ObjInv.MovimientoRemove(CveMovimiento, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then TieneError = True End If If Not TieneError Then ObjInv.Commit() Else Retorno.Mensajes.Add("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intetar.") End If ObjInv.Dispose() End Sub #End Region #Region "P E D I D O S" Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre Dim Timbre As New CFDITimbre Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", "")) Timbre.Comprobante.Folio = Obj.Folio.ToString Timbre.Comprobante.Serie = Obj.Serie Timbre.Comprobante.Fecha = Obj.FechaCP Timbre.Comprobante.FormadePago = Obj.ClaveFormaPagoSAT Timbre.Comprobante.CondicionesdePago = Obj.FormaPago Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT Timbre.Comprobante.Subtotal = Obj.SubTotal Timbre.Comprobante.Descuentos = Obj.Descuento Timbre.Comprobante.Moneda = Obj.MonedaSAT Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString) Timbre.Comprobante.Total = Obj.Total Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP Timbre.Comprobante.Confirmacion = "" Timbre.Receptor.RFC = Obj.Cliente.RFC Timbre.Receptor.Nombre = Obj.Cliente.Nombre Timbre.Receptor.ResidenciaFiscal = "" Timbre.Receptor.NumeroRegistroTributario = "" Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDISAT If Obj.CveTipoRelacion > 0 Then Select Case Obj.CveTipoRelacion Case 1 Timbre.CFDIRelacionados.TipoRelacion = "01" Timbre.CFDIRelacionados.TipoRelacionTexto = "01-Nota de Crédito aplicada a Ingreso" Case 2 Timbre.CFDIRelacionados.TipoRelacion = "02" Timbre.CFDIRelacionados.TipoRelacionTexto = "02-Nota de débito de los documentos relacionados" Case 3 Timbre.CFDIRelacionados.TipoRelacion = "03" Timbre.CFDIRelacionados.TipoRelacionTexto = "03-Devolución aplicada a Ingreso" Case 4 Timbre.CFDIRelacionados.TipoRelacion = "04" Timbre.CFDIRelacionados.TipoRelacionTexto = "04-Refacturación de Ingreso" Case 7 Timbre.CFDIRelacionados.TipoRelacion = "07" Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo" Case 8 Timbre.CFDIRelacionados.TipoRelacion = "08" Timbre.CFDIRelacionados.TipoRelacionTexto = "08-Factura generada por pagos en parcialidades " Case 9 Timbre.CFDIRelacionados.TipoRelacion = "09" Timbre.CFDIRelacionados.TipoRelacionTexto = "09-Factura generada por pagos diferidos" End Select End If Dim totSubTotal As Decimal = Obj.SubTotal Dim totIVA As Decimal = Obj.IVA Dim totRetIVA As Decimal = Obj.RetIVA Dim totRetISR As Decimal = Obj.RetISR Dim i As Integer = 1 'DETALLES Dim tPS As String = "" For Each drr As DataRow In Obj.DtDetalle.Rows If drr("PS").ToString.Length = 1 Then tPS = drr("Obs").ToString Else If drr("PS").ToString.Length = 0 Then tPS = "" Else tPS = String.Format("{0} {1}", drr("PS"), drr("Obs")) End If End If 'CONDICIONANTE, ESPECIAL If Obj.CveEmpresa = 15 Then drr("UM") = "" 'LES COMENTAN QUE NO DEBE IR LA ETIQUETA DE LA UNIDAD EN EL PRODUCTO Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal, .Descripcion = tPS, .ValorUnitario = drr("PU").ToString.ToDecimal, .Importe = drr("TotalImporte").ToString.ToDecimal, .Descuento = drr("Descuento").ToString.ToDecimal, .Unidad = drr("UM").ToString, .ClaveUnidad = drr("SATClaveUM").ToString, .ClaveProdServ = drr("SATClaveProdServ").ToString, .Noidentificacion = drr("Noidentificacion").ToString, .CuentaPredial = drr("CuentaPredial").ToString} 'VERIFICA SUMA SUBTOTALES If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'PROCESO DE AJUSTA DE DECIMALES concepto.Importe = totSubTotal End If totSubTotal = totSubTotal - concepto.Importe 'SIEMPRE ESTAMOS AGREGANDO EL IVA concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal}) If drr("ImporteIEPS").ToString.ToDouble > 0 Then concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal}) End If If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal}) End If If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetISR").ToString.ToDecimal, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal}) End If Timbre.Conceptos.Add(concepto) i += 1 Next Return Timbre End Function #End Region #Region "R E M I S I O N E S" Private Function CreaFactura(ByRef Retorno As Modelos.Factura.MMensajeFactura, CveCliente As Integer, CveAlmacen As Integer, CveSubProyecto As Integer, CveMoneda As Integer, UsuarioActual As Usuario, Observaciones As String, ListaPS As List(Of MVentaProductos)) As Modelos.Factura If CveSubProyecto <= 0 Then 'SE ASIGNA EL SUBPROYECTO MATRIZ, EN CASO DE NO ENCONTRARSE SE LE ASIGNA CUALQUIERA Dim Dr As DataRow = Nothing If ClsPaginas.GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltraParametros("TipoSucursal = 1").Rows.Count > 0 Then Dr = ClsPaginas.GlobalDTSubProyectos(UsuarioActual.CveEmpresa).FiltraParametros("TipoSucursal = 1").Rows(0) ElseIf ClsPaginas.GlobalDTSubProyectos(UsuarioActual.CveEmpresa).Rows.Count > 0 Then Dr = ClsPaginas.GlobalDTSubProyectos(UsuarioActual.CveEmpresa).Rows(0) End If If Dr IsNot Nothing Then CveSubProyecto = Dr("CveSubProyecto").ToString.ToEntero() End If If CveSubProyecto < 0 Then Retorno.Mensajes.Add("No se tienen asignadas sucursales") Return Nothing End If End If Dim ObjFactura As New Modelos.Factura(UsuarioActual) ObjFactura.DirectorioServidor = ModExtensiones.DirectorioBaseEmpresas Dim ObjFolios As New ClsGralFolios() If ObjFolios.GetFolios("Rem", UsuarioActual.CveEmpresa) Then Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format("CveSubProyecto = {0} And Estado = 'Activo'", CveSubProyecto)) If DT.Rows.Count > 0 Then ObjFactura.Folio = DT.Rows(0)("FActual").ToString.ToEntero ObjFactura.Serie = DT.Rows(0)("Serie").ToString End If DT.Dispose() End If ObjFolios.Dispose() If Not String.IsNullOrEmpty(ObjFactura.Folio.ToString) Then Select Case CveMoneda Case 1 ObjFactura.TipoCambio = 1 Case 2 ObjFactura.TipoCambio = ClsPaginas.GlobalTipoCambio(ClsPaginas.NowADS()).ToDecimal Case Else ObjFactura.TipoCambio = ClsPaginas.GlobalTipoCambio(ClsPaginas.NowADS()).ToDecimal End Select ObjFactura.CveVendedor = -1 'VALIDA PROMOCIONES Y EXISTENCIAS Dim ObjVentas As New ClsVentas If ObjVentas.GetPromocionesPS(-1, ClsPaginas.NowADS(), CveSubProyecto, CveCliente, ObjFactura.CveVendedor, 1, UsuarioActual.CveEmpresa) Then ObjFactura.DtPromociones = ObjVentas.DtResultados End If ObjVentas.Dispose() Try ObjFactura.TipoMensajeRespuesta = TipoMensajeRespuesta.TextoLimpio ObjFactura.Version = "3.3" ObjFactura.FolioFiscal = "" ObjFactura.CveUsuario = UsuarioActual.CveUsuario ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa ObjFactura.TipoCambio = 1 ObjFactura.ConvertirPesos = False ObjFactura.CveMoneda = CveMoneda ObjFactura.Moneda = ClsPaginas.GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda} ") ObjFactura.MonedaSAT = ClsPaginas.GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", "CveMoneda = 1") ObjFactura.TipoDocto = "Rem" ObjFactura.Fecha = ClsPaginas.NowADS() ObjFactura.FechaPago = ClsPaginas.NowADS() ObjFactura.MotivoDescuento = "" ObjFactura.Observaciones = Observaciones ObjFactura.FechaEjecucion = ClsPaginas.NowADS() ObjFactura.UsuarioCreo = UsuarioActual.Usuario ObjFactura.CveCondicionEntrega = -1 ObjFactura.CondicionEntrega = "" ObjFactura.NumeroCuenta = "" ObjFactura.CondicionesPago = 0 ObjFactura.TipoDocumento = "Remision" ObjFactura.Descuento = 0 ObjFactura.Amortizacion = 0 ObjFactura.ConvertirPesos = False ObjFactura.CveSubProyecto = CveSubProyecto ObjFactura.CveSubProyectoCobranza = CveSubProyecto ObjFactura.CveSubProyectoEjecucion = CveSubProyecto ObjFactura.SubProyecto = New SubProyectoModel(ClsPaginas.GlobalDTSubProyectos(CveEmpresa).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}")) ObjFactura.SubProyectoMatriz = New SubProyectoModel(ClsPaginas.GlobalDTSubProyectos(CveEmpresa, CveSubProyecto:=-1).FiltroPrimero("TipoSucursal=1")) 'CLIENTE ObjFactura.CveCliente = CveCliente ObjFactura.SetCliente() ObjFactura.CveAlmacen = CveAlmacen Dim ObjCliente As New ClsClientes If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, -1, TipoCliente:=-1) Then If ObjCliente.DtResultados.Rows.Count > 0 Then ObjFactura.CveFormaPago = ObjCliente.CveFormaPago ObjFactura.FormaPago = ClsPaginas.GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPago", $"CveFormaPago = {ObjCliente.CveFormaPago}") ObjFactura.ClaveFormaPagoSAT = ClsPaginas.GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", $"CveFormaPago = {ObjCliente.CveFormaPago}") ObjFactura.CveMetodoPago = ObjCliente.CveMetodoPago ObjFactura.MetodoPago = ClsPaginas.GlobalDTVtaMetodoPago.FiltroPrimeroValor("MetodoPago", $"CveMetodoPago = {ObjCliente.CveMetodoPago}") ObjFactura.ClaveMetodoPagoSAT = ClsPaginas.GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", $"CveMetodoPago = {ObjCliente.CveMetodoPago}") ObjFactura.CveUsoCFDI = ObjCliente.CveUsoCFDI ObjFactura.UsoCFDI = ClsPaginas.GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", $"CveUsoCFDI = {ObjCliente.CveUsoCFDI}") ObjFactura.ClaveUsoCFDISAT = ClsPaginas.GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {ObjCliente.CveUsoCFDI}") ObjFactura.CveMetodoPago = ObjCliente.CveMetodoPago If ClsPaginas.GlobalDTVtaMetodoPago.FiltraParametros($"CveMetodoPago = {ObjCliente.CveMetodoPago}").Rows.Count > 0 Then ObjFactura.MetodoPago = ClsPaginas.GlobalDTVtaMetodoPago.FiltraParametros($"CveMetodoPago = {ObjCliente.CveMetodoPago}").Rows(0)("MetodoPago").ToString Else ObjFactura.CveMetodoPago = 1 ObjFactura.MetodoPago = "Efectivo" End If ObjFactura.DtDetalle = CreaDTDetalle(Retorno, CveEmpresa, ObjCliente.CvePrecioLista, CveSubProyecto, (ObjCliente.RetIVA / 100D), (ObjCliente.RetISR / 100D), ListaPS) ObjFactura.DtInventario = CreaDTInv(ObjFactura.DtDetalle) End If End If If ObjCliente.GetSucursales(CveCliente) Then If ObjCliente.DtResultados.Rows.Count > 0 Then ObjFactura.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero()) Else ObjFactura.CveClienteSucursal = -1 End If End If ObjCliente.Dispose() Dim TotalImporte As Decimal = ObjFactura.DtDetalle.SUM("TotalImporte") Dim ImporteIVA As Decimal = ObjFactura.DtDetalle.SUM("ImporteIVA") Dim ImporteRetIVA As Decimal = ObjFactura.DtDetalle.SUM("ImporteRetIVA") Dim ImporteRetISR As Decimal = ObjFactura.DtDetalle.SUM("ImporteRetISR") Dim ImporteIEPS As Decimal = ObjFactura.DtDetalle.SUM("ImporteIEPS") Dim Descuento As Decimal = ObjFactura.DtDetalle.SUM("Descuento") Dim Amortizacion As Decimal = 0 Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion) 'DETALLES ObjFactura.SubTotal = TotalImporte ObjFactura.Descuento = Descuento ObjFactura.Amortizacion = Amortizacion ObjFactura.IVA = ImporteIVA ObjFactura.RetIVA = ImporteRetIVA ObjFactura.RetISR = ImporteRetISR ObjFactura.IEPS = ImporteIEPS ObjFactura.Total = Total ObjFactura.Timbre = PreParaTimbre(ObjFactura) ObjFactura.CveContratoSecciones = "" 'BORRAR ObjFactura.DtRecepcionUsados = New DataTable ObjFactura.DtRecepcionUsados.Columns.Add("CvePS", GetType(Integer)) Catch ex As Exception Retorno.Mensajes.Add(ex.ToString()) Return Nothing End Try Return ObjFactura Else Retorno.Mensajes.Add("No hay folios para esta factura.") Return Nothing End If End Function Private Function CreaDTDetalle(ByRef Retorno As Modelos.Factura.MMensajeFactura, CveEmpresa As Integer, CvePrecioLista As Integer, CveSubProyecto As Integer, ClienteRetIVA As Double, ClienteRetISR As Double, ListaPS As List(Of MVentaProductos)) As DataTable Dim TmpDT As New DataTable TmpDT.Columns.Add("CveVenta", GetType(Integer)) TmpDT.Columns.Add("Consec", GetType(Integer)) TmpDT.Columns.Add("Cantidad", GetType(Decimal)) TmpDT.Columns.Add("Codigo", GetType(String)) TmpDT.Columns.Add("CveUM", GetType(Integer)) TmpDT.Columns.Add("UM", GetType(String)) TmpDT.Columns.Add("SATClaveUM", GetType(String)) TmpDT.Columns.Add("CveClasificacion", GetType(Integer)) TmpDT.Columns.Add("Clasificacion", GetType(String)) TmpDT.Columns.Add("CvePS", GetType(Integer)) TmpDT.Columns.Add("PS", GetType(String)) TmpDT.Columns.Add("CodigoPS", GetType(String)) TmpDT.Columns.Add("SATClaveProdServ", GetType(String)) TmpDT.Columns.Add("NoIdentificacion", GetType(String)) TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) TmpDT.Columns.Add("Serie", GetType(String)) TmpDT.Columns.Add("CuentaPredial", GetType(String)) TmpDT.Columns.Add("Obs", GetType(String)) TmpDT.Columns.Add("TiempoEntrega", GetType(String)) TmpDT.Columns.Add("PU", GetType(Decimal)) TmpDT.Columns.Add("IVA", GetType(Decimal)) TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) TmpDT.Columns.Add("IEPS", GetType(Decimal)) TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) TmpDT.Columns.Add("Descuento", GetType(Decimal)) TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) TmpDT.Columns.Add("Total", GetType(Decimal)) 'Para uso del módulo contable TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) TmpDT.Columns.Add("CveProyecto", GetType(Integer)) TmpDT.Columns.Add("Proyecto", GetType(String)) TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) TmpDT.Columns.Add("SubProyecto", GetType(String)) 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) 'Contratos TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) 'Remisiones a Facturas TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) 'Pedido2 a Facturas TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) TmpDT.Columns.Add("Origen", GetType(Integer)) 'Ordenes Servicio TmpDT.Columns.Add("CveOS", GetType(Integer)) TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) TmpDT.Columns.Add("SeFacturara", GetType(Integer)) TmpDT.Columns.Add("Folio", GetType(Integer)) TmpDT.Columns.Add("Estatus", GetType(String)) 'Ordenamiento TmpDT.Columns.Add("Orden", GetType(Integer)) TmpDT.Columns.Add("TipoDocto", GetType(String)) 'OC TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) TmpDT.Columns.Add("CveTamaño", GetType(Double)) Try For Each PS As MVentaProductos In ListaPS Dim Row As DataRow = AgregarProductoServicio(Retorno, TmpDT, PS, CveEmpresa, CvePrecioLista, CveSubProyecto, ClienteRetIVA:=ClienteRetIVA, ClienteRetISR:=ClienteRetISR) If Row IsNot Nothing Then TmpDT.Rows.Add(Row) Else Retorno.Mensajes.Add($"No se pudo agregar el producto/servicio: {PS.PS}") End If Next Catch ex As Exception Retorno.Mensajes.Add(ex.ToString()) End Try Return TmpDT End Function Private Function CreaDTInv(DtDetalle As DataTable) As DataTable Dim TmpDT As New DataTable TmpDT.Columns.Add("CvePS", GetType(Integer)) TmpDT.Columns.Add("CveUM", GetType(Integer)) TmpDT.Columns.Add("Cantidad", GetType(Decimal)) TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) TmpDT.Columns.Add("Serie", GetType(String)) TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) For Each Dr As DataRow In DtDetalle.FiltraParametros("CveTipoPS = 2").Rows Dim ss As DataRow = TmpDT.NewRow() ss("CvePS") = Dr("CvePS") ss("CveUM") = Dr("CveUM") ss("Cantidad") = Dr("Cantidad") ss("CveTipoInvPS") = Dr("CveTipoInvPS") ss("Serie") = Dr("Serie") ss("CveVentaDetalle") = -1 TmpDT.Rows.Add(ss) Next Return TmpDT End Function Private Function AgregarProductoServicio(ByRef Retorno As Modelos.Factura.MMensajeFactura, TmpDT As DataTable, PS As MVentaProductos, CveEmpresa As Integer, CvePrecioLista As Integer, CveSubProyecto As Integer, Optional Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0, Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional ClienteRetIVA As Double = 0, Optional ClienteRetISR As Double = 0) As DataRow Dim Row As DataRow = Nothing Dim TotalCalculableImpuestos As Decimal = 0 Dim DrPS As DataRow = GlobalDTPS(CveEmpresa, CvePS:=PS.CvePS).FiltroPrimero("") ' Estado = -1 If DrPS Is Nothing Then Retorno.Mensajes.Add("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.") Return Nothing End If 'verifica si tiene ventaminima If PS.Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... If PS.Cantidad < DrPS("VentaMinima").ToString.ToDecimal() Then Retorno.Mensajes.Add("La cantidad es menor que la venta minima") Return Nothing End If End If If CvePrecioLista > 0 Then Dim ObjPS As New ClsProductosServicios If ObjPS.GetPSPreciosLista(CveEmpresa, CvePrecioLista, CvePS:=PS.CvePS) Then If ObjPS.DtResultados.Rows.Count > 0 Then Dim PrecioLista As Decimal = ObjPS.DtResultados.Rows(0)("PrecioLista").ToString().ToDecimal() If PrecioLista > 0 Then PS.Precio = Math.Round(PrecioLista, 6) Else PS.Precio = Math.Round(PS.Precio, 6) End If Else PS.Precio = Math.Round(PS.Precio, 6) End If Else PS.Precio = Math.Round(PS.Precio, 6) End If ObjPS.Dispose() Else PS.Precio = Math.Round(PS.Precio, 6) End If If PS.Precio <= 0 Then Retorno.Mensajes.Add($"El producto/servicio {PS.PS} debe tener el precio unitario mayor a cero") Return Nothing End If Dim DrSubProyecto As DataRow = ClsPaginas.GlobalDTSubProyectos(CveEmpresa, CveSubProyecto).Rows(0) Row = TmpDT.NewRow() Row("CveProyecto") = DrSubProyecto("CveProyecto").ToString().ToEntero() Row("Proyecto") = DrSubProyecto("Proyecto").ToString() Row("CveSubProyecto") = CveSubProyecto Row("SubProyecto") = DrSubProyecto("SubProyecto").ToString() Row("Serie") = Serie Row("TiempoEntrega") = TiempoEntrega Row("Orden") = TmpDT.Rows.Count + 1 Row("Cantidad") = PS.Cantidad Row("CveUM") = DrPS("CveUnidadMedida").ToString().ToEntero() Row("UM") = DrPS("UnidadMedida").ToString() Row("CveClasificacion") = DrPS("CveClasificacion").ToString().ToEntero() Row("Clasificacion") = DrPS("Clasificacion").ToString() Row("CvePS") = PS.CvePS Row("Obs") = PS.Obs TotalCalculableImpuestos = (PS.Cantidad * PS.Precio) - PS.Descuento Row("PU") = PS.Precio Row("Codigo") = DrPS("Codigo") Row("NoIdentificacion") = DrPS("Codigo") Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria") Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana") Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion") Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion") Row("PS") = DrPS("PS") Row("CodigoPS") = DrPS("PSCodigo").ToString Row("CveTipoPS") = DrPS("CveTipoPS") Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario") If DrPS("IVA").ToString.Contiene("-1", "") Then Row("PorcentajeIVA") = DrSubProyecto("IVA") Else Row("PorcentajeIVA") = DrPS("IVA") End If Row("IVA") = Row("PorcentajeIVA") Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2) Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, 2) Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, 2) Row("PorcentajeRetIVA") = ClienteRetIVA Row("PorcentajeRetISR") = ClienteRetISR Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje") Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, 2) Row("IEPS") = Row("ImporteIEPS") Row("Descuento") = Math.Round(PS.Descuento, 2) Row("TipoDescuento") = "2" Row("Total") = (PS.Cantidad * PS.Precio) Row("TotalImporte") = Math.Round(PS.Cantidad * PS.Precio, 2) Row("SATClaveProdServ") = DrPS("SATClavePS") Row("SATClaveUM") = DrPS("SATClaveUnidadMedida") Row("EntregaDirecta") = EntregaDirecta 'Contratos Row("CveContratoDetalle") = CveContratoDetalle Row("CveVentaDetalle") = CveVentaDetalle Row("CveMovimientoDetallePedido") = CveVentaDetalle Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle Row("CveVentaDetalleRemision") = CveVentaDetalleRemision Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion Row("CveVentaDetallePedido2") = CveVentaDetallePedido2 Row("CuentaPredial") = CuentaPredial Return Row End Function Private Function GeneraCorreoRemision(CveVenta As Integer, SerieFolio As String, RazonSocial As String, NombreComercial As String, Direcciones As String, Obs As String, FechaPedido As DateTime) As String Dim strBody As New StringBuilder Dim ObjVentas As New ClsVentas Try strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append("
Datos del Pedido ") strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", RazonSocial) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", NombreComercial) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", SerieFolio) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", FechaPedido.ToString("dd/MM/yyyy HH:mm:ss")) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", Direcciones) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", Obs) strBody.Append(" ") strBody.Append("
Razón Social:{0}
Nombre Comercial:{0}
Serie-Folio:{0}
Fecha:{0}
Dirección de envío :{0}
Observaciones :{0}
") strBody.Append("
") strBody.Append("
") 'Cargo el detalle strBody.Append("
") strBody.Append("
") strBody.Append(" Productos/Servicios ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") 'verifico los permisos según el estatus If ObjVentas.GetVentaDetalle(CveVenta) Then For Each dr As DataRow In ObjVentas.DtResultados.Rows If ObjVentas.DtResultados.Rows.Count > 0 Then strBody.AppendFormat("", dr("Cantidad").ToString.FormatoNumero, dr("Clasificacion"), dr("PS"), dr("UM")) End If Next End If strBody.Append("
Cantidad ClasificaciónProducto o ServicioUnidadMedida
{0}{1}{2}{3}
") strBody.Append("
") strBody.Append("
") strBody.Append("") Catch ex As Exception OnError("Ocurrio un error al general el correo.", ex) End Try ObjVentas.Dispose() Return strBody.ToString End Function #End Region End Class Namespace WebServiceAppModels2 Public Class WSUSER Public Property CveUsuario As Integer Public Property Usuario As String Public Property CveEmpresa As Integer Public Property CveCliente As Integer Public Property CvePrecioLista As Integer Public Property Procesos As List(Of String) Public Property Empresa As String Public Property Cliente As String Public Property Nombre As String Public Property CveRol As Integer Public Property Rol As String Public Property CveSubProyecto As Integer Public Property CveEstatusCliente As Integer End Class Public Class WsEmpresa Public Property CveEmpresa As Integer Public Property Empresa As String Public Property CveEncuestaCRM As Integer Public Property Tipo_CentroCosto As Integer End Class Public Class WSPersonal Public Property CvePersonal As Integer Public Property CodigoNombreCompleto As String Public Property CveClienteAsignado As Integer Public Property CveTurno As Integer Public Property CveDepartamento As Integer Public Property CvePuesto As Integer Public Property CveSubProyecto As Integer Public Property CveProyecto As Integer End Class Public Class WSAsistencia Public Property CveSubProyecto As Integer Public Property CvePersonal As Integer Public Property CveCliente As Integer Public Property FechaAsistencia As Date Public Property CveAsistenciasInasistencias As Integer Public Property PorcentajePago As Double Public Property HorasDobles As Double Public Property HorasTriples As Double Public Property CveMotivoHoraExtra As Integer Public Property Observacion As String Public Property CveUsuario As Integer Public Property CveEmpresa As Integer End Class Public Class WsModulos Public Property CveModulo As Integer Public Property CvePadre As Integer Public Property CvePlataforma As Integer Public Property Modulo As String Public Property Liga As String Public Property Estilo As String End Class Public Class WsRepOCGet Public Property Tipo As String Public Property CveEmpresa As Integer Public Property CveProyecto As Integer Public Property CveSubProyecto As Integer Public Property CveEstatus As Integer Public Property CveUsuario As Integer Public Property CveCliente As Integer Public Property TipoBusqueda As Integer Public Property Tick As DateTime End Class Public Class WsOCGetRep Public Property EsDelUsuario As Integer Public Property CveOrdenCompra As Integer Public Property CveEstatus As Integer Public Property Estatus As String Public Property Descripcion As String Public Property MonAbreviatura As String Public Property Justificacion As String Public Property RequiereCotizacion As Integer Public Property FechaIng As DateTime Public Property Fecha As DateTime Public Property CveEmpresa As Integer Public Property CveCliente As Integer Public Property Cliente As String Public Property CodigoAF As String Public Property Total As Decimal Public Property CveProyecto As Integer Public Property Proyecto As String Public Property CveSubProyecto As Integer Public Property SubProyecto As String Public Property CveUsuario As Integer Public Property Folio As String Public Property Lugar As String Public Property Proveedor As String Public Property Solicito As String End Class Public Class WsOCGetRep2 Public Property EsDelUsuario As Integer Public Property CveOrdenCompra As Integer Public Property CveEstatus As Integer Public Property Estatus As String Public Property Descripcion As String Public Property MonAbreviatura As String Public Property Justificacion As String Public Property RequiereCotizacion As Boolean Public Property FechaIng As DateTime Public Property Fecha As DateTime Public Property CveEmpresa As Integer Public Property CveCliente As Integer Public Property Cliente As String Public Property CodigoAF As String Public Property Total As Decimal Public Property CveProyecto As Integer Public Property Proyecto As String Public Property CveSubProyecto As Integer Public Property SubProyecto As String Public Property CveUsuario As Integer Public Property Folio As String 'Nuevos Campos Public Property Lugar As String Public Property Proveedor As String Public Property Solicito As String Public Property NombreCorto As String End Class Public Class WsOCEstatus Public Property CveEstatusUsuarios As Integer Public Property CveEstatus As Integer Public Property FechaIng As DateTime Public Property CveUsuario As Integer Public Property Nombre As String Public Property EstatusActivo As Integer Public Property CveSuperior As Integer Public Property Superior As Integer Public Property LimiteInferior As Integer Public Property LimiteSuperior As Integer Public Property Estatus As String Public Property Tipo As String Public Property CveEmpresa As Integer Public Property TipoTermino As Integer Public Property EstatusSiguiente As String Public Property CveEstatusSiguiente As Integer Public Property Nivel As Integer Public Property CveSubProyecto As Integer Public Property SubProyecto As String Public Property CveProyecto As Integer Public Property Proyecto As String End Class Public Class WsOCGet Public Property CveOC As Integer Public Property CveEmpresa As Integer Public Property CveUsuario As Integer Public Property Tick As DateTime End Class Public Class WsFiltroEvento Public Property CveUsuario As Integer Public Property CveEmpresa As Integer Public Property CveActivoFijo As Integer Public Property CveIE As Integer Public Property CveProspecto As Integer Public Property CveCliente As Integer Public Property CveOS As Integer Public Property CveOC As Integer Public Property CvePersonal As Integer Public Property CveProveedor As Integer Public Property CveCompra As Integer Public Property CveVenta As Integer Public FechaI As DateTime Public FechaF As DateTime Public Tick As DateTime End Class Public Class WsHistorial Public Property CveOrdenCompra As Integer Public Property Fecha As DateTime Public Property CveConceptoHistorialOrdenCompra As Integer Public Property ConceptoHistorialOrdenCompra As String Public Property ValorAnterior As String Public Property ValorActual As String Public Property CveUsuario As Integer Public Property Usuario As String End Class Public Class WsHistorialEstatus Public Property CveOrdenCompra As Integer Public Property Fecha As DateTime Public Property Estatus As String Public Property CveUsuario As Integer Public Property Usuario As String End Class Public Class WsProveedor Public Property CveProveedor As Integer Public Property Codigo As String Public Property Estatus As String Public Property CveEmpresa As Integer Public Property RazonSocial As String Public Property NombreComercial As String Public Property RFC As String Public Property Direccion As String Public Property ContactoMail As String Public Property CveUsuario As Integer End Class Public Class WsUnidadMedida Public Property CvePS As Integer Public Property UnidadBase As Boolean Public Property Consec As Integer Public Property Cantidad As Double Public Property UnidadMedida As String Public Property UM As String Public Property Precio As Double Public Property CveUM As Integer Public Property CveUnidadMedida As Integer End Class Public Class WsFolio Public Property CveFolio As Integer Public Property FolioActual As String End Class Public Class WsMoneda Public Property CveMoneda As Integer Public Property Moneda As String Public Property Abreviatura As String Public Property AbreviaturaSAT As String Public Property Estatus As String End Class Public Class WsSucursal Public Property CveSucursal As Integer Public Property Sucursal As String End Class Public Class WsCliente Public Property CveCliente As Integer Public Property Nombre As String Public Property NombreComercial As String Public Property NombreCorto As String Public Property Direccion As String Public Property Colonia As String Public Property Ciudad As String Public Property Localidad As String Public Property Estado As String Public Property RFC As String Public Property CP As String Public Property Mail As String Public Property NotificarA As String Public Property RetIVA As Decimal Public Property RetISR As Decimal Public Property CveEmpresa As Integer Public Property CveSucursal As Integer Public Property Sucursal As String Public Property CveMetodoPago As Integer Public Property SubProyecto As String Public Property CveSubProyecto As Integer End Class Public Class WsVenta Public Property CveVenta As Integer Public Property TipoDocto As String Public Property Folio As String Public Property Fecha As DateTime Public Property Total As Decimal Public Property Sucursal As String Public Property CveCliente As Integer Public Property Nombre As String Public Property EstatusFactura As String Public Property Usuario As String End Class Public Class WsPromocion Public Property CvePromocion As Integer Public Property Promocion As String Public Property FechaInicio As DateTime Public Property FechaFin As DateTime Public Property CveSucursal As Integer Public Property Estatus As Boolean Public Property CveVendedor As Integer Public Property CveCliente As Integer Public Property CveMoneda As Integer Public Property CveEmpresa As Integer Public Property CveUsuario As Integer End Class Public Class WsPromocionDetalle Public Property PS As String Public Property AplicaRestriccionTexto As String Public Property AplicaRestriccion As Boolean Public Property HoraInicio As DateTime Public Property HoraFin As DateTime Public Property AplicaLunes As Boolean Public Property AplicaMartes As Boolean Public Property AplicaMiercoles As Boolean Public Property AplicaJueves As Boolean Public Property AplicaViernes As Boolean Public Property AplicaSabado As Boolean Public Property AplicaDomingo As Boolean Public Property CvePS As Integer Public Property Promocion As Double Public Property PUAnterior As Double Public Property PUPromocion As Double Public Property TipoPromocion As Integer End Class Public Class WsVendedor Public Property CveVendedor As Integer Public Property Promocion As String Public Property CveEmpresa As Integer End Class Public Class WsMetodoPago Public Property CveMetodoPago As Integer Public Property ClaveSAT As String Public Property MetodoPago As String End Class Public Class WsRepBancos Public Property CveEmpresa As Integer Public Property CveCuenta As Integer Public Property CveBanco As Integer Public Property Banco As String Public Property NumCuenta As String Public Property Moneda As String Public Property CveMoneda As Integer Public Property FechaInicio As String Public Property FechaFin As String Public Property Opcion As Integer Public Property SaldoInicial As Integer Public Property Cargos As Decimal Public Property Abonos As Decimal Public Property Saldo As Decimal End Class Public Class WsRepCxC Public Property GPO As String Public Property Saldo As Decimal Public Property vencido_1_7 As Decimal Public Property vencido_8_30 As Decimal Public Property vencido_30_mas As Decimal Public Property vencido As Decimal Public Property por_vencer_0_7 As Decimal Public Property por_vencer_8_14 As Decimal Public Property por_vencer_15_30 As Decimal Public Property por_vencer_30_mas As Decimal Public Property por_vencer As Decimal Public Property Total As Decimal Public Property CveCliente As Integer Public Property vencido_1_30 As Decimal Public Property vencido_31_60 As Decimal Public Property vencido_61_90 As Decimal Public Property vencido_90_mas As Decimal Public Property por_vencer_0_30 As Decimal Public Property CveMoneda As Integer Public Property Moneda As String End Class Public Class WsRepCxP Public Property GPO As String Public Property Saldo As Decimal Public Property vencido_1_7 As Decimal Public Property vencido_8_30 As Decimal Public Property vencido_30_mas As Decimal Public Property vencido As Decimal Public Property por_vencer_0_7 As Decimal Public Property por_vencer_8_14 As Decimal Public Property por_vencer_15_30 As Decimal Public Property por_vencer_30_mas As Decimal Public Property por_vencer As Decimal Public Property Total As Decimal Public Property CveProveedor As Integer Public Property CveMoneda As Integer Public Property Moneda As String End Class Public Class WsRepPS Public Property GPO As String Public Property Total As Decimal Public Property CveProyecto As Integer Public Property CveSubProyecto As Integer Public Property CveClasificacion As Integer Public Property CveMoneda As Integer Public Property Moneda As String End Class Public Class WsIndicador Public Property TotalBancos As Double Public Property CxCTotal As Double Public Property CxPTotal As Double End Class Public Class WsTipoCambio Public Property CveTipoCambio As Integer Public Property TipoCambio As Double Public Property Fecha As Date End Class Public Class WsMovimientosMensualesCuenta Public Property total As Double Public Property mes1 As Double Public Property mes2 As Double Public Property mes3 As Double Public Property mes4 As Double Public Property mes5 As Double Public Property mes6 As Double Public Property mes7 As Double Public Property mes8 As Double Public Property mes9 As Double Public Property mes10 As Double Public Property mes11 As Double Public Property mes12 As Double End Class Public Class WsVentaDetalle Public Property CveVentaDetalle As Integer Public Property CveVenta As Integer Public Property FolioOC As String Public Property Cantidad As Decimal Public Property CveUnidadMedida As Integer Public Property Abreviatura As String Public Property CveUM As Integer Public Property UM As String Public Property CvePS As Integer Public Property PS As String Public Property PorcentajeIVA As Decimal Public Property IVA As Decimal Public Property RetIVA As Decimal Public Property RetISR As Decimal Public Property IEPS As Decimal Public Property Descripcion As String Public Property Importe As Decimal Public Property Descuento As Decimal Public Property Total As Decimal Public Property TotalDescuento As Decimal Public Property CveOrdenCompraPadre As Integer Public Property Producto As String Public Property CodigoPS As String Public Property CveTipoPS As Integer Public Property CveClasificacion As Integer Public Property Clasificacion As String Public Property CveActivoFijo As Integer Public Property Observacion As String Public Property Codigo As String Public Property CodigoAF As String Public Property TipoDato As String Public Property Obs As String Public Property CveProyecto As Integer Public Property Proyecto As String Public Property SubProyecto As String Public Property CveSubProyecto As Integer Public Property FolioOrdenCompraPadre As String Public Property CveOrdenCompraHija As Integer Public Property FolioOrdenCompraHija As String Public Property CvePresupuestoEgreso As Integer Public Property CveProgramaOperativo As Integer Public Property CveUnidadAdministrativa As Integer Public Property CveFuenteFinanciamiento As Integer Public Property CveTipoGasto As Integer Public Property CveClasificacionOG As Integer Public Property IdCuentaPorEjercer As Integer Public Property IdCuentaComprometido As Integer Public Property CantidadDisponible As Integer Public Property CveCompra As Integer Public Property FolioCompra As String Public Property ProductoOC As String Public Property CveProveedor As Integer Public Property CveMoneda As Integer End Class Public Class WsBitacora Public Property Descripcion As String Public Property CvePrioridad As Integer Public Property Imagen1 As String Public Property Extension As String End Class Public Class MVenta Public Sub New() CveVenta = -1 Total = 0 IVA = 0 SubTotal = 0 Fecha = ClsPaginas.NowADS() FechaIng = ClsPaginas.NowADS() End Sub Public Property IDTempVenta As Integer Public Property CveVenta As Integer Public Property FolioFiscal As String Public Property TipoDocto As String Public Property Serie As String Public Property Folio As Integer Public Property SerieFolio As String Public Property CveCliente As Integer Public Property CveClienteSucursal As Integer? Public Property SubTotal As Double Public Property Descuento As Double Public Property Amortizacion As Double Public Property IVA As Double Public Property RetIVA As Double Public Property RetISR As Double Public Property IEPS As Double Public Property Total As Double Public Property CveMoneda As Integer Public Property TipoCambio As Double Public Property CveMetodoPago As Integer Public Property CondicionesPago As Integer Public Property FormaPago As Integer Public Property Fecha As DateTime Public Property FechaIng As DateTime Public Property MotivoDescuento As String Public Property Observaciones As String Public Property CveEstatusFactura As Integer Public Property EstatusFactura As String Public Property EnvioMail As String Public Property SeTimbro As String Public Property TelefonoGenerico As String Public Property FechaEjecucion As DateTime Public Property CveVendedor As Integer Public Property Alfa1 As String Public Property Alfa2 As String Public Property Alfa3 As String Public Property Num1 As Integer Public Property Num2 As Integer Public Property Num3 As Integer Public Property Fech1 As DateTime Public Property Fech2 As DateTime Public Property Fech3 As DateTime Public Property CveUsuario As Integer Public Property Nombre As String Public Property SelloCancelacion As String Public Property FechaCancelacion As DateTime Public Property TipoDocto1 As String Public Property Saldo As Double Public Property Pagado As Double Public Property TipoEstatus As Integer Public Property CveUsoCFDI As Integer Public Property UsoCFDI As String Public Property CveOS As Integer Public Property CveContrato As Integer Public Property CveEmpresa As Integer Public Property Det_OrdenCompra As String Public Property Det_FechaOrdenCompra As String Public Property Otros As Double Public Property CvePrePoliza As Integer Public Property CPCliente As String Public Property Telefono As String Public Property ClienteRFC As String Public Property ClienteNombre As String Public Property MetodoPago As String Public Property CorreoVendedor As String Public Property FechaVencimiento As DateTime Public Property Moneda As String Public Property DatosCliente As String Public Property ColoniaCliente As String Public Property ClienteNoExt As String Public Property ClienteNoInt As String Public Property Municipio As String Public Property Estado As String Public Property Calle As String Public Property NoExt As String Public Property NoInt As String Public Property Colonia As String Public Property CP As String Public Property Pais As String Public Property Serie1 As String Public Property Mail As String Public Property ClienteDireccion As String Public Property ClienteCodigo As String Public Property ClienteCiudad As String Public Property ClienteLocalidad As String Public Property ClienteEstado As String Public Property ClientePais As String Public Property ClienteLugar As String Public Property SucCliente As String Public Property ClaveMetodoPagoSAT As String Public Property Entrega As String Public Property Vigencia As DateTime Public Property SucClienteLocalidad As String Public Property SucClienteCiudad As String Public Property SucClienteEstado As String Public Property SucClienteDireccion As String Public Property SucClienteNoExt As String Public Property SucClienteNoInt As String Public Property SucClienteColonia As String Public Property SucClienteCP As String Public Property SucClienteCorreo As String Public Property SucClienteTelefono As String Public Property SucClientePais As String Public Property CveVentaFacturada As Integer Public Property SucursalCliente As String Public Property VendedorCodigo As String Public Property Ref As String Public Property Abreviatura As String Public Property EsDevolucionVenta As Boolean Public Property UsuarioCreo As String Public Property EnvioDepartamento As String Public Property Inv_CveEstatusEntrega As Integer Public Property Inv_EstatusEntrega As String Public Property ImprimeNombreSucursal As Boolean Public Property Vigencia1 As DateTime Public Property CvePAC As Integer Public Property CveSubProyecto As Integer Public Property CveSubProyectoCobranza As Integer Public Property CveSubProyectoEjecucion As Integer Public Property CalleSubProyecto As String Public Property NoExtSubProyecto As String Public Property NoIntSubProyecto As String Public Property ColoniaSubProyecto As String Public Property LocalidadSubProyecto As String Public Property MunicipioSubProyecto As String Public Property EstadoSubProyecto As String Public Property MunicipioSubProyecto1 As String Public Property PaisSubProyecto As String Public Property CPSubProyecto As String Public Property SubProyecto As String Public Property CveMetodoPago33 As Integer Public Property CveFormaPago33 As Integer Public Property MetodoPago33 As String Public Property FormaPago33 As String Public Property Version As String Public Property TipoRelacion As String End Class Public Class MVentaProductos Public Property CvePS As Integer Public Property Cantidad As Decimal = 0 Public Property Obs As String Public Property PS As String Public Property Precio As Decimal Public Property Descuento As Decimal End Class Public Class MMessage Sub New() Correcto = True Mensajes = New List(Of String) End Sub Public Property Correcto As Boolean Public Property Mensajes As List(Of String) End Class End Namespace