cambios de extensiones .SUM de double a decimal

This commit is contained in:
2023-11-12 21:21:50 -07:00
parent 7ab88313cb
commit 053512112c
57 changed files with 747 additions and 811 deletions

View File

@@ -142,9 +142,12 @@ Public Class E119 : Implements IHttpHandler
Catch ex As Exception
context.Response.ContentType = "text/html"
retorno = ex.ToString()
ex.GuardaLog(ex.ToString())
Dim respuesta As New AuthMessage
respuesta.ErrorMessage = New ResponseMsgError() With {.message = "La solicitud no se pudo procesar."}
respuesta.IsSucces = False
respuesta.StatusCode = 200
retorno = JsonConvert.SerializeObject(respuesta.ErrorMessage)
context.Response.Write(retorno)
End Try
End Sub
@@ -343,154 +346,141 @@ Public Class E119 : Implements IHttpHandler
If JsonRequest Is Nothing Then
TieneError = True
End If
Else
TieneError = True
End If
End Using
End If
If TieneError Then
RespuestaError.message = "No se pudo procesar la solicitud - Formato mal formado"
context.Response.StatusCode = 200
Return JsonConvert.SerializeObject("xx")
Return JsonConvert.SerializeObject(RespuestaError)
End If
If Not TieneError Then
Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa)
Dim ObjFactura As Modelos.Factura
Dim ObjFactura As Modelos.Factura = Nothing
Dim Resp As New Modelos.Factura.MMensajeFactura
If Usuario IsNot Nothing Then
End If
Dim ObjClientes As New ClsClientes()
Dim ObjInventario As New ClsInventarios(ObjClientes.IniciaTransacSQL())
Dim CveSubProyecto, CveCliente, CveMoneda, CvePS As Integer
Dim Cantidad, PU, Descuento As Decimal
Dim Obs As String = ""
CveSubProyecto = 12659 ' fijo Ecommerce
CveCliente = 0
CveMoneda = 1
Descuento = 0
Dim RFC As String = If(JsonRequest("billing") Is Nothing, "", JsonRequest("billing")("first_name").ToString())
Dim NombreCliente As String = If(JsonRequest("billing") Is Nothing, "", JsonRequest("billing")("first_name").ToString() & " " & JsonRequest("billing")("last_name").ToString())
'BUSCAR SI ESTÁ REGISTRADO EL CLIENTE
If ObjClientes.GetClientes(-1, "-1", "-1", "-1", RFC, "-1", "-1", -1, CveEmpresa, 1, TipoCliente:=-1, TopSelect:=1) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
'Resp.TieneError = False
CveCliente = ObjClientes.CveCliente
'Resp.Mensajes.Add("El RFC ya existe en el sistema")
Dim ObjClientes As New ClsClientes()
Dim ObjInventario As New ClsInventarios(ObjClientes.IniciaTransacSQL())
Dim CveSubProyecto, CveCliente, CveMoneda, CvePS As Integer
Dim Cantidad, PU, Descuento As Decimal
Dim Obs As String = ""
CveSubProyecto = 12659 ' fijo Ecommerce
CveCliente = 0
CveMoneda = 1
Descuento = 0
Dim RFC As String = If(JsonRequest("billing") Is Nothing, "", JsonRequest("billing")("first_name").ToString())
Dim NombreCliente As String = If(JsonRequest("billing") Is Nothing, "", JsonRequest("billing")("first_name").ToString() & " " & JsonRequest("billing")("last_name").ToString())
'BUSCAR SI ESTÁ REGISTRADO EL CLIENTE
If ObjClientes.GetClientes(-1, "-1", "-1", "-1", RFC, "-1", "-1", -1, CveEmpresa, 1, TipoCliente:=-1, TopSelect:=1) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
'Resp.TieneError = False
CveCliente = ObjClientes.CveCliente
'Resp.Mensajes.Add("El RFC ya existe en el sistema")
End If
End If
End If
If CveCliente = 0 Then
' 'DATOS DE BILLING
If JsonRequest("billing") IsNot Nothing Then
Dim CveEstado As Integer = -1
Dim Direccion As String = If(JsonRequest("billing")("address_1") Is Nothing, "", JsonRequest("billing")("address_1").ToString())
Dim NumExt As String = ""
Dim NumInt As String = ""
Dim Colonia As String = ""
Dim Ciudad As String = If(JsonRequest("billing")("city") Is Nothing, "", JsonRequest("billing")("city").ToString())
Dim Localidad As String = If(JsonRequest("billing")("city") Is Nothing, "", JsonRequest("billing")("city").ToString())
Dim CP As String = If(JsonRequest("billing")("postcode") Is Nothing, "", JsonRequest("billing")("postcode").ToString())
Dim Telefono As String = If(JsonRequest("billing")("phone") Is Nothing, "", JsonRequest("billing")("phone").ToString())
Dim Correo As String = If(JsonRequest("billing")("email") Is Nothing, "", JsonRequest("billing")("email").ToString())
Dim Estado As String = If(JsonRequest("billing")("state") Is Nothing, "", JsonRequest("billing")("state").ToString())
If Not String.IsNullOrEmpty(Estado) Then
CveEstado = ClsPaginas.GlobalDTGralEstados("MEX").FiltroPrimeroValor("CveEstado", $"NombreEstado = '{Estado.Trim}'").ToEntero()
If CveEstado <= 0 Then 'SI NO ENCUENTRA EL ESTADO INGRESA EL DE SONORA
If CveCliente = 0 Then
' 'DATOS DE BILLING
If JsonRequest("billing") IsNot Nothing Then
Dim CveEstado As Integer = -1
Dim Direccion As String = If(JsonRequest("billing")("address_1") Is Nothing, "", JsonRequest("billing")("address_1").ToString())
Dim NumExt As String = ""
Dim NumInt As String = ""
Dim Colonia As String = ""
Dim Ciudad As String = If(JsonRequest("billing")("city") Is Nothing, "", JsonRequest("billing")("city").ToString())
Dim Localidad As String = If(JsonRequest("billing")("city") Is Nothing, "", JsonRequest("billing")("city").ToString())
Dim CP As String = If(JsonRequest("billing")("postcode") Is Nothing, "", JsonRequest("billing")("postcode").ToString())
Dim Telefono As String = If(JsonRequest("billing")("phone") Is Nothing, "", JsonRequest("billing")("phone").ToString())
Dim Correo As String = If(JsonRequest("billing")("email") Is Nothing, "", JsonRequest("billing")("email").ToString())
Dim Estado As String = If(JsonRequest("billing")("state") Is Nothing, "", JsonRequest("billing")("state").ToString())
If Not String.IsNullOrEmpty(Estado) Then
CveEstado = ClsPaginas.GlobalDTGralEstados("MEX").FiltroPrimeroValor("CveEstado", $"NombreEstado = '{Estado.Trim}'").ToEntero()
If CveEstado <= 0 Then 'SI NO ENCUENTRA EL ESTADO INGRESA EL DE SONORA
CveEstado = 26
End If
Else
CveEstado = 26
End If
Else
CveEstado = 26
End If
If ObjClientes.AgregarClienteNoFrecuente(NombreCliente, Direccion, NumExt, NumInt, Colonia, Localidad, Ciudad, CveEstado, RFC, CP, Telefono, Correo, CveSubProyecto, CveUsuario, CveEmpresa, "", -1, -1) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
CveCliente = ObjClientes.DtResultados(0)("CveCliente").ToString().ToEntero()
If ObjClientes.AgregarClienteNoFrecuente(NombreCliente, Direccion, NumExt, NumInt, Colonia, Localidad, Ciudad, CveEstado, RFC, CP, Telefono, Correo, CveSubProyecto, CveUsuario, CveEmpresa, "", -1, -1) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
CveCliente = ObjClientes.DtResultados(0)("CveCliente").ToString().ToEntero()
End If
End If
End If
End If
End If
Try
Try
ObjFactura = Modelos.Factura.CrearVentaNueva(Usuario, CveSubProyecto, CveCliente, CveMoneda, "Rem")
Dim ListaPS As JArray = JArray.Parse(JsonRequest("line_items").ToString())
Dim Consec As Integer = 1
For Each JsonPS As JObject In ListaPS
Cantidad = JsonPS("quantity").ToString.ToDecimal()
PU = JsonPS("price").ToString.ToDecimal()
CvePS = ClsPaginas.GlobalDTPSSimplificado(CveEmpresa, Codigo:=JsonPS("sku").ToString()).FiltroPrimeroValor("CvePS").ToEntero()
ObjFactura = Modelos.Factura.CrearVentaNueva(Usuario, CveSubProyecto, CveCliente, CveMoneda, "Rem")
Dim ListaPS As JArray = JArray.Parse(JsonRequest("line_items").ToString())
Dim Consec As Integer = 1
For Each JsonPS As JObject In ListaPS
Cantidad = JsonPS("quantity").ToString.ToDecimal()
PU = JsonPS("price").ToString.ToDecimal()
CvePS = ClsPaginas.GlobalDTPSSimplificado(CveEmpresa, Codigo:=JsonPS("sku").ToString()).FiltroPrimeroValor("CvePS").ToEntero()
ObjFactura.AgregarPS(CvePS, Cantidad, PU, Descuento, Obs, CveSubProyecto:=CveSubProyecto)
ObjFactura.AgregarPS(CvePS, Cantidad, PU, Descuento, Obs, CveSubProyecto:=CveSubProyecto)
''VALIDAR QUE SEA EL MISMO PRODUCTO
If CvePS <= 0 Then
TieneError = True
'Retorno.Mensajes.Add(String.Format("No se encontró el producto: {0}", JsonPS("name").ToString()))
Exit For
End If
''VALIDA EXISTENCIA ANTES DE GENERAR LA FACTURA
'If ObjFactura.TipoDocto = "Ing" AndAlso DrPS("CveTipoPS").ToString() = "2" Then
' Dim Existencia As Decimal = ObjInventarios.GetExistenciasPS(DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero, UsuarioActual.CveEmpresa, ObjFactura.CveAlmacen, CveSubProyecto:=ObjFactura.CveSubProyecto, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), ExcluyeAdelantado:=1, PendientePorSurtir:=1, RestringirAlmacenes:=1, ExcluyeApartados:=-1)
' If Cantidad > Existencia Then
' Retorno.TieneError = True
' Retorno.Mensajes.Add(String.Format("No hay existencia suficiente para este producto: {0}, cuenta con : {1}", DrPS("PSCodigo").ToString(), Existencia))
' Exit For
' End If
'End If
Consec += 1
Next
''VALIDAR QUE SEA EL MISMO PRODUCTO
If CvePS <= 0 Then
TieneError = True
'Retorno.Mensajes.Add(String.Format("No se encontró el producto: {0}", JsonPS("name").ToString()))
Exit For
End If
Consec += 1
Next
ObjFactura.CalculaTotales()
ObjFactura.CalculaTotales()
If ObjFactura IsNot Nothing Then
Resp = ObjFactura.EmitirFactura(False, Transac:=ObjClientes.IniciaTransacSQL())
If ObjFactura IsNot Nothing Then
Resp = ObjFactura.EmitirFactura(False, Transac:=ObjClientes.IniciaTransacSQL())
If Resp.CveVenta > 0 Then
Respuesta.status = "success"
Respuesta.data = Resp.SerieFolio
If Resp.CveVenta > 0 Then
Respuesta.status = "success"
Respuesta.data = Resp.SerieFolio
Else
TieneError = True
End If
If TieneError Then
Dim sb As New StringBuilder()
For Each msg As String In Resp.Mensajes
sb.AppendFormat("{0}. ", msg)
Next
RespuestaError.message = sb.ToString()
End If
Else
TieneError = True
End If
If TieneError Then
Dim sb As New StringBuilder()
For Each msg As String In Resp.Mensajes
sb.AppendFormat("{0}. ", msg)
Next
RespuestaError.message = sb.ToString()
End If
Else
Catch ex As Exception
TieneError = True
Dim sb As New StringBuilder()
For Each msg As String In Resp.Mensajes
sb.AppendFormat("{0}. ", msg)
Next
RespuestaError.message = sb.ToString()
End Try
If TieneError Then
ObjClientes.RollBack()
ObjClientes.Dispose()
ObjInventario.Dispose()
Else
ObjClientes.Commit()
ObjClientes.Dispose()
ObjInventario.Dispose()
End If
Catch ex As Exception
TieneError = True
End Try
If TieneError Then
ObjClientes.RollBack()
ObjClientes.Dispose()
ObjInventario.Dispose()
Else
ObjClientes.Commit()
ObjClientes.Dispose()
ObjInventario.Dispose()
If ObjFactura IsNot Nothing Then ObjFactura.Dispose()
End If
If ObjFactura IsNot Nothing Then ObjFactura.Dispose()
'End If
End If
If TieneError Then