- VERSION 5.03.02

- Se agregó código para las promos por monto.
- Se agregó codigo para validar la hora del telefono con la hora del servidor.
This commit is contained in:
2025-03-04 13:25:42 -06:00
parent d87a3c3c63
commit 267a0e7bf9
13 changed files with 318 additions and 61 deletions

View File

@@ -845,6 +845,7 @@ Sub traeRuta As String 'ignore
Return r
End Sub
'Trae el cliente de CUENTAA
Sub traeCliente As String 'ignore
Private c As Cursor
Private cl As String
@@ -955,39 +956,43 @@ Sub guardaProductoSin(cedis As String, costoTot As String, costoU As String, can
End Sub
Sub actualizaProducto(cedis As String, costoU As String, cant As String, nombre As String, prodId As String, clienteId As String, fecha As String, usuario As String, rutaV As String, precioSin As String, tipoVenta As String)
If nombre.Length < 6 Then ToastMessageShow("(actualizaProducto) El nombre del producto no es valido " & nombre, True)
precioSin = NumberFormat2(precioSin, 1, 2, 2, False)
costoU = NumberFormat2(costoU, 1, 2, 2, False)
LogColor($"actualizaProducto, c=${clienteId}, p=${prodId}, nombre=${nombre}, cant=${cant}, cedis=${cedis}, tipo=${tipoVenta}"$, Colors.Magenta)
If revisaHora Then
If nombre.Length < 6 Then ToastMessageShow("(actualizaProducto) El nombre del producto no es valido " & nombre, True)
precioSin = NumberFormat2(precioSin, 1, 2, 2, False)
costoU = NumberFormat2(costoU, 1, 2, 2, False)
LogColor($"actualizaProducto, c=${clienteId}, p=${prodId}, nombre=${nombre}, cant=${cant}, cedis=${cedis}, tipo=${tipoVenta}"$, Colors.Magenta)
' Private tablaProds As String = "cat_gunaprod2"
' If tipoVenta = "ABORDO" Then tablaProds = "cat_gunaprod"
Private c As Cursor=Starter.skmt.ExecQuery($"select * from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}'"$)
If c.RowCount > 0 Then
LogColor("ACTUALIZAMOS PROD - " & traeTablaProds(tipoVenta), Colors.Blue)
c.Position = 0
Private antCant As Int = 0
If IsNumber(c.GetInt("PE_CANT")) Then antCant=c.GetInt("PE_CANT")
Private difCant As Int = cant - antCant
Starter.skmt.ExecNonQuery($"update pedido set pe_cant = ${cant}, pe_costo_tot = ${NumberFormat2((cant*c.GetString("PE_COSTOU")), 1, 2, 2, False)}, pe_tipo = '${tipoVenta}' where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
If cedis <> "DUR" Then Starter.skmt.ExecNonQuery($"update ${traeTablaProds(tipoVenta)} set cat_gp_almacen = cat_gp_almacen - (${difCant}) where cat_gp_id = '${prodId}' "$)
If cant = 0 Then
LogColor($"BORRAMOS PRODUCTO - ${prodId}"$, Colors.Red)
Starter.skmt.ExecNonQuery($"delete from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
Log($"Borramos pe_cedis='${cedis}' and pe_proid='${prodId}' and pe_cliente='${clienteId}'"$)
Private pe As Cursor = Starter.skmt.ExecQuery("select count(pe_cliente) as cuantosPedidos from pedido where pe_cliente In (select cuenta from cuentaa)")
pe.Position=0
If pe.GetString("cuantosPedidos") = 0 Then
Log("###### delete from pedido_cliente - " & traeCliente & "|" & clienteId)
Log($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
Starter.skmt.ExecNonQuery($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
Private c As Cursor=Starter.skmt.ExecQuery($"select * from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}'"$)
If c.RowCount > 0 Then
LogColor("ACTUALIZAMOS PROD - " & traeTablaProds(tipoVenta), Colors.Blue)
c.Position = 0
Private antCant As Int = 0
If IsNumber(c.GetInt("PE_CANT")) Then antCant=c.GetInt("PE_CANT")
Private difCant As Int = cant - antCant
Starter.skmt.ExecNonQuery($"update pedido set pe_cant = ${cant}, pe_costo_tot = ${NumberFormat2((cant*c.GetString("PE_COSTOU")), 1, 2, 2, False)}, pe_tipo = '${tipoVenta}' where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
If cedis <> "DUR" Then Starter.skmt.ExecNonQuery($"update ${traeTablaProds(tipoVenta)} set cat_gp_almacen = cat_gp_almacen - (${difCant}) where cat_gp_id = '${prodId}' "$)
If cant = 0 Then
LogColor($"BORRAMOS PRODUCTO - ${prodId}"$, Colors.Red)
Starter.skmt.ExecNonQuery($"delete from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
Log($"Borramos pe_cedis='${cedis}' and pe_proid='${prodId}' and pe_cliente='${clienteId}'"$)
Private pe As Cursor = Starter.skmt.ExecQuery("select count(pe_cliente) as cuantosPedidos from pedido where pe_cliente In (select cuenta from cuentaa)")
pe.Position=0
If pe.GetString("cuantosPedidos") = 0 Then
Log("###### delete from pedido_cliente - " & traeCliente & "|" & clienteId)
Log($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
Starter.skmt.ExecNonQuery($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
End If
End If
End If
Else
'INSERTAMOS
Else
'INSERTAMOS
' LogColor("INSERTAMOS PROD", Colors.red)
If cant > 0 Then guardaProductoSinGestion(cedis, costoU, cant, nombre, prodId, clienteId, fecha, usuario, rutaV, precioSin, tipoVenta)
If cant > 0 Then guardaProductoSinGestion(cedis, costoU, cant, nombre, prodId, clienteId, fecha, usuario, rutaV, precioSin, tipoVenta)
End If
c.Close
Else
Msgbox("La hora del equipo NO coincide con la hora del servidor, el producto NO se agregó al pedido", "AVISO IMPORTANTE")
End If
c.Close
End Sub
'Regresa un mapa con la información de la promo.
@@ -1175,6 +1180,8 @@ Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As
Return res
End Sub
'prodsFijos=[1000000126, 1008013885]
'Regresa el numero máximo de promociones permitidas, tomando en cuenta recurrentes, clientes y maxPromos.
Sub traeMaxPromos(pm As Map) As Int
Private thisLog As Boolean = False 'Si es verdadero, muestra los logs de este sub.
@@ -1314,7 +1321,7 @@ End Sub
'Regresa cuantas promos alcanzan con los productos FIJOS que hay en inventario.
Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
Private thisLog As Boolean = False
Private thisLog As Boolean = True
Private invFijoXpromo As Map
Private t As List
t.Initialize
@@ -1329,9 +1336,9 @@ Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
Private thisInvDisp As Int = 0
If invDispParaPromo.Get(idProdsFijos.Get(p)) <> Null Then thisInvDisp = invDispParaPromo.Get(idProdsFijos.Get(p))
If thisLog Then Log($"id=${idProdsFijos.Get(p)}, inv=${thisInvDisp}, pzas=${prodsFijosPiezas.Get(p)}"$)
If thisLog Then Log($"${(thisInvDisp / prodsFijosPiezas.Get(p))}"$)
' If thisLog Then Log($"${(thisInvDisp / prodsFijosPiezas.Get(p))}"$)
Private x() As String = Regex.Split("\.", $"${(thisInvDisp / prodsFijosPiezas.Get(p))}"$) 'Separamos el resultado de la division por el punto decimal.
If thisLog Then Log(x(0))
' If thisLog Then Log(x(0))
t.Add(x(0).As(Int)) 'Solo guardamos la parte del entero de la division.
Next
t.Sort(True) 'Ordenamos la lista para que en el lugar 0 este el resultao mas pequeño.
@@ -1349,7 +1356,7 @@ End Sub
'regresa el maximo por productos fijos. Ej. si las promos por variables es 10, pero el maximo por
'fijos es 5, entonces regresamos 5.
Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
Private thisLog As Boolean = False
Private thisLog As Boolean = True
If thisLog Then Log("======================================================")
If thisLog Then Log("======================================================")
Private invFijoXpromo As Map
@@ -1920,4 +1927,46 @@ Sub parseHTTPError(error As String) As String
' LogColor(error.SubString2(inicio + 17, final), Colors.Blue)
End If
Return nuevoError
End Sub
'Regresa un mapa con la promocion por monto, siempre y cuando esta tenga existencias y no exista en el pedido del cliente.
Sub revisaPromoPorMonto As Map
Private m As Map
Private rangoMin As String = "0"
Private promoId As String = ""
m.Initialize
Private pm As Cursor = Starter.skmt.ExecQuery("select CAT_PA_ID, ifNull(CAT_PA_PORCENTAJE_PAQUETE, 0) as CAT_PA_PORCENTAJE_PAQUETE, ifNull(CAT_PA_PRECIO1, 0) as CAT_PA_PRECIO1, ifNull(CAT_PA_PRECIO2, 0) as CAT_PA_PRECIO2 from promos_comp where CAT_PA_TIPO_PROMONTO = '1' and CAT_PA_ID not in (select PE_CEDIS from PEDIDO where PE_CEDIS = PE_PROID)") 'Traemos las "promos por monto" que no existen en el "PEDIDO" del cliente.
If pm.RowCount > 0 Then
Private clienteId As String = traeCliente
For i = 0 To pm.RowCount - 1
pm.Position = i
Private tm As Map = procesaPromocion(pm.GetString("CAT_PA_ID"), clienteId)
Log(pm.GetString("CAT_PA_ID"))
Log("STATUS PROMO: " & tm.Get("status"))
If tm.Get("status") = "ok" And pm.GetString("CAT_PA_PORCENTAJE_PAQUETE") <> "0" And pm.GetString("CAT_PA_PRECIO2") <> "0" Then
rangoMin = pm.GetString("CAT_PA_PRECIO1") - ((pm.GetString("CAT_PA_PORCENTAJE_PAQUETE") / 100) * pm.GetString("CAT_PA_PRECIO1"))
promoId = pm.GetString("CAT_PA_ID")
m.Put("id", promoId)
m.Put("rangoMin", rangoMin)
m.Put("precio1", pm.GetString("CAT_PA_PRECIO1"))
m.Put("precio2", pm.GetString("CAT_PA_PRECIO2"))
End If
Next
End If
Return m
End Sub
Sub revisaHora As Boolean
Private horaCorrecta As Boolean = False
Private h As Cursor = Starter.skmt.ExecQuery("select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'HORA'")
If h.RowCount > 0 Then
h.Position = 0
DateTime.DateFormat = "HH"
Private ahora As String = DateTime.Date(DateTime.Now)
Log($"${h.GetInt("CAT_VA_VALOR")} >= ${(ahora - 2)} and ${h.GetInt("CAT_VA_VALOR")} <= ${(ahora + 2)}"$)
If h.GetInt("CAT_VA_VALOR") >= ahora - 2 And h.GetInt("CAT_VA_VALOR") <= ahora + 2 Then
horaCorrecta = True
End If
End If
Return horaCorrecta
End Sub