mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-20 11:39:13 +00:00
- VERSION 5.07.30
- Se aumento el credito por default para trade spending cuando NO tienen datos de 100,000 a 1,000,000 - Se cambio la ruta de prueba 238 almacen 2 por la ruta y almacen reales. - Cambios varios para trade spending.
This commit is contained in:
159
B4A/Subs.bas
159
B4A/Subs.bas
@@ -1004,7 +1004,7 @@ End Sub
|
||||
' resultado="OK" 'Ok si existe la promocion.
|
||||
' prodsVariablesRequeridos=5} 'Cantidad de productos variables requeridos para la promoción.
|
||||
Sub traePromo(promo As String, cliente As String) As Map
|
||||
Private thisLog As Boolean = True
|
||||
Private thisLog As Boolean = False
|
||||
If thisLog Then Log("traePromo:"&promo)
|
||||
Private inicioContador As String = DateTime.Now
|
||||
Private c As Cursor = Starter.skmt.ExecQuery("Select * from promos_comp where cat_pa_id = '"& promo&"'") 'Obtenemos las el maximo de promocioones a otorgar.
|
||||
@@ -1076,7 +1076,10 @@ Sub traePromo(promo As String, cliente As String) As Map
|
||||
promoMap.Put("prodsVariablesCant", prodsVariables.Size)
|
||||
promoMap.Put("prodsVariablesPrecios", prodsVariablesPrecios)
|
||||
promoMap.Put("resultado", "ok")
|
||||
|
||||
' LogColor($"****************************************************************"$, Colors.red)
|
||||
LogColor("*********** Prods Fijos: " & prodsFijos.Size & " Prods Variables: " & prodsVariables.Size & " ************", Colors.red)
|
||||
' LogColor("***************** Prods Variables: " & prodsVariables.Size & " *************", Colors.red)
|
||||
LogColor($"****************************************************************"$, Colors.red)
|
||||
Else
|
||||
promoMap.Put("resultado", "No hay datos de la promoción.")
|
||||
End If
|
||||
@@ -1161,7 +1164,7 @@ End Sub
|
||||
'Revisa si tenemos los productos variables requeridos para la promoción (mapa).
|
||||
'Hay que darle como parametro un mapa (traePromo(promo)) con toda la informacion de la promocion.
|
||||
Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As Boolean 'ignore
|
||||
Private thisLog As Boolean = False 'Si es verdadero, muestra los logs de este sub.
|
||||
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
|
||||
If thisLog Then LogColor("Inventario inicial: "&inventarioSinFijos, Colors.Gray) 'Inventario inicial.
|
||||
Private totalProdsVariables As Int = 0
|
||||
' Private prodsmap As Map = promoMap.Get("productos") 'Obtenemos un mapa con todos los productos de la promoción.
|
||||
@@ -1180,8 +1183,6 @@ 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 = True 'Si es verdadero, muestra los logs de este sub.
|
||||
@@ -1196,11 +1197,11 @@ Sub traeMaxPromos(pm As Map) As Int
|
||||
' Else
|
||||
' LogColor("SIN HCCP CANT", Colors.Magenta)
|
||||
' End If
|
||||
If thisLog Then LogColor("==== HISTORICO:"&pm.Get("historico"), Colors.Red)
|
||||
' If thisLog Then LogColor("==== Historico: "&pm.Get("historico"), Colors.Red)
|
||||
' Log("### PRODS VARIABLES: " & pm.Get("prodsVariables"))
|
||||
Private maxPromosXDescPV As String = B4XPages.MainPage.promos.ts.maxPromosPorProdsVariables(pm.Get("prodsVariables"), pm.Get("id"))
|
||||
Log("########### " & maxPromosXDescPV)
|
||||
If thisLog Then Log(pm)
|
||||
' Log("########### " & maxPromosXDescPV)
|
||||
' If thisLog Then Log(pm)
|
||||
maxPromos.Add(maxPromosXDescPV.As(Int))
|
||||
If pm.Get("historico") = "1" Then maxPromos.Add(pm.Get("maxRecurrente")) 'Si hay historico, agregamos maxRecurrente
|
||||
If pm.Get("maxPromos") <> "null" Then maxPromos.Add(pm.Get("maxPromos").As(Int)) 'Agregamos maxPromos
|
||||
@@ -1233,49 +1234,56 @@ Sub traePromosVendidas(promo As String, cliente As String) As Int
|
||||
Return pv
|
||||
End Sub
|
||||
|
||||
'3799, 7226, 7228, 7230
|
||||
|
||||
Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
|
||||
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
|
||||
Private inicioContador As String = DateTime.Now
|
||||
Private mp As Int = 0
|
||||
If thisLog Then LogColor($"****************************************************************"$, Colors.red)
|
||||
If thisLog Then LogColor($"********* Iniciamos revision de Promo ${idPromo} *********"$, Colors.red)
|
||||
'Obtenemos el mapa con toda la info de la promoción.
|
||||
Private pm As Map = traePromo(idPromo, cliente)
|
||||
' B4XPages.MainPage.productos.promosC.traePromo(idPromo, cliente)
|
||||
If thisLog Then LogColor(pm, Colors.Blue)
|
||||
' If thisLog Then LogColor("|" & pm.Get("maxPromos") & "|", Colors.Blue)
|
||||
' Log("|"&revisaMaxPromosProdsFijosPorInventario(pm)&"|")
|
||||
If revisaMaxPromosProdsFijosPorInventario(pm) < 1 Then pm.Put("resultado", 0)
|
||||
' Log($"resultado = ${pm.Get("resultado")}"$)
|
||||
If pm.Get("resultado") = "ok" Then 'Si encontramos la promoción, entonces ...
|
||||
'Buscamos el máximo de promociones permitidas.
|
||||
mp = traeMaxPromos(pm)
|
||||
' If thisLog Then LogColor($"Promociones permitidas=${mp}"$, Colors.Blue)
|
||||
' If thisLog Then Log("Promos vendidas: " & traePromosVendidas(idPromo, cliente))
|
||||
If mp < 1 Then
|
||||
If thisLog Then LogColor("Ya se vendieron las promos PERMITIDAS para el cliente", Colors.red)
|
||||
Return CreateMap("status":"ko", "mp":pm)
|
||||
End If
|
||||
'Restamos del inventario (mapa) las piezas necesarias para los productos fijos.
|
||||
Private inventarioSinFijos As Map = restaFijosPromo(pm)
|
||||
If thisLog Then LogColor("inventariosfijos="&inventarioSinFijos, Colors.Magenta)
|
||||
If inventarioSinFijos.Get("resultado") = "ok" Then
|
||||
'Revisamos que los productos variables requeridos sean menos que el inventario total (mapa).
|
||||
Private pv As Boolean = alcanzanLosVariablesParaPromo(pm, inventarioSinFijos)
|
||||
If thisLog Then Log("Alcanzan los variables? --> " & pv)
|
||||
If pv Then Return CreateMap("status":"ok", "mp":pm) Else Return CreateMap("status":"ko", "mp":pm)
|
||||
If thisLog Then LogColor($"****************************************************************"$, Colors.red)
|
||||
Try
|
||||
'Obtenemos el mapa con toda la info de la promoción.
|
||||
Private pm As Map = traePromo(idPromo, cliente)
|
||||
' B4XPages.MainPage.productos.promosC.traePromo(idPromo, cliente)
|
||||
If thisLog Then LogColor(pm, Colors.Blue)
|
||||
' If thisLog Then LogColor("|" & pm.Get("maxPromos") & "|", Colors.Blue)
|
||||
' Log("|"&revisaMaxPromosProdsFijosPorInventario(pm)&"|")
|
||||
Private maxPromosXprodsFijos As Int = revisaMaxPromosProdsFijosPorInventario(pm)
|
||||
If maxPromosXprodsFijos < 1 Then pm.Put("resultado", 0)
|
||||
LogColor($">>> Promos disponibles por productos fijos = ${maxPromosXprodsFijos}"$, Colors.Magenta)
|
||||
If pm.Get("resultado") = "ok" Then 'Si encontramos la promoción, entonces ...
|
||||
'Buscamos el máximo de promociones permitidas.
|
||||
mp = traeMaxPromos(pm)
|
||||
' If thisLog Then LogColor($"Promociones permitidas=${mp}"$, Colors.Blue)
|
||||
' If thisLog Then Log("Promos vendidas: " & traePromosVendidas(idPromo, cliente))
|
||||
If mp < 1 Then
|
||||
If thisLog Then LogColor("Ya se vendieron las promos PERMITIDAS para el cliente", Colors.red)
|
||||
Return CreateMap("status":"ko", "mp":pm)
|
||||
End If
|
||||
'Restamos del inventario (mapa) las piezas necesarias para los productos fijos.
|
||||
Private inventarioSinFijos As Map = restaFijosPromo(pm)
|
||||
If thisLog Then LogColor("inventariosfijos="&inventarioSinFijos, Colors.Magenta)
|
||||
If inventarioSinFijos.Get("resultado") = "ok" Then
|
||||
'Revisamos que los productos variables requeridos sean menos que el inventario total (mapa).
|
||||
Private pv As Boolean = alcanzanLosVariablesParaPromo(pm, inventarioSinFijos)
|
||||
If thisLog Then Log("Alcanzan los variables? --> " & pv)
|
||||
If pv Then Return CreateMap("status":"ok", "mp":pm) Else Return CreateMap("status":"ko", "mp":pm)
|
||||
Else
|
||||
If thisLog Then LogColor("NO HAY INVENTARIO SUFICIENTE " & idPromo, Colors.red)
|
||||
Return CreateMap("status":"ko", "mp":pm)
|
||||
End If
|
||||
Else
|
||||
If thisLog Then LogColor("NO HAY INVENTARIO SUFICIENTE " & idPromo, Colors.red)
|
||||
Return CreateMap("status":"ko", "mp":pm)
|
||||
End If
|
||||
Else
|
||||
Return CreateMap("status":"ko", "mp":pm)
|
||||
End If
|
||||
' Si tenemos suficiente inventario para los variables mostramos la promocion, si no ...
|
||||
' break 'NO HAY INVENTARIO SUFICIENTE PARA LA PROMOCION.
|
||||
' Si tenemos suficiente inventario para los variables mostramos la promocion, si no ...
|
||||
' break 'NO HAY INVENTARIO SUFICIENTE PARA LA PROMOCION.
|
||||
|
||||
LogColor("TIEMPO DE PROCESO ESTA PROMO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||
LogColor("TIEMPO DE PROCESO ESTA PROMO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||
Catch
|
||||
Log($"Promo ${idPromo} mal configurada"$)
|
||||
ToastMessageShow($"Promo ${idPromo} mal configurada"$, True)
|
||||
Log(LastException)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Regresa cuantas promos alcanzan con los productos FIJOS que hay en inventario.
|
||||
@@ -1337,21 +1345,21 @@ Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
|
||||
For p = 0 To idProdsFijos.Size -1 'Generamos una lista con las promos disponibles por producto (dividimos el inventario total entre las piezas requeridas).
|
||||
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)}"$)
|
||||
Log(">>>>> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsFijos.Get(p), pm.Get("id")))
|
||||
If thisLog Then Log($"id=${idProdsFijos.Get(p)}, inv=${thisInvDisp}, pzasReq=${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.
|
||||
t.Add(x(0).As(Int)) 'Solo guardamos la parte del entero de la division.
|
||||
If thisLog Then Log(">> Promos x Prods Fijos: " & x(0))
|
||||
Log(">>>>> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsFijos.Get(p), pm.Get("id")))
|
||||
If thisLog Then LogColor(">> Max prods fijos x Bonificaciones: " & B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), pm.Get("id")), Colors.blue)
|
||||
t.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), pm.Get("id")))
|
||||
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))
|
||||
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.
|
||||
If thisLog Then LogColor($"prodsFijos=${idProdsFijos}"$, Colors.Blue)
|
||||
If thisLog Then LogColor($"prodsFijosPiezasReq=${prodsFijosPiezas}"$, Colors.Blue)
|
||||
' If thisLog Then LogColor($"invFijoXpromo=${invFijoXpromo}"$, Colors.Blue)
|
||||
LogColor(">>>>>> T: " & t, Colors.red)
|
||||
If thisLog Then LogColor("Max promos de prodsFijos POR inventario = " & t.Get(0), Colors.red)
|
||||
' LogColor(">>>>>> T: " & t, Colors.red)
|
||||
If thisLog Then LogColor("Max promos x inv de prodsFijos = " & t.Get(0), Colors.red)
|
||||
Return t.Get(0) 'Regresamos el resultado mas pequeño.
|
||||
End Sub
|
||||
|
||||
@@ -1361,7 +1369,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 = True
|
||||
Private thisLog As Boolean = False
|
||||
If thisLog Then LogColor("==================revisaMaxPromosProdsVariablesPorInventario====================", Colors.red)
|
||||
If thisLog Then Log("======================================================")
|
||||
Private invFijoXpromo As Map
|
||||
@@ -1402,8 +1410,8 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||
|
||||
End If
|
||||
|
||||
Log(pm.Get("prodsFijos").As(List).Size)
|
||||
Log(maxPromosXFijos)
|
||||
' Log(pm.Get("prodsFijos").As(List).Size)
|
||||
' Log(maxPromosXFijos)
|
||||
|
||||
For x = 1 To maxPromosXFijos
|
||||
If thisLog Then Log("==================== maxPromosXFijos "& x &" ========================")
|
||||
@@ -1535,16 +1543,25 @@ Sub borraPedidoClienteActual As String
|
||||
Log($"Registros = ${thisC.RowCount}"$)
|
||||
If thisC.RowCount > 0 Then
|
||||
For i = 0 To thisC.RowCount - 1
|
||||
thisC.Position=i
|
||||
thisC.Position = i
|
||||
Log($"Posicion: ${i}, PE_CEDIS=${thisC.GetString("PE_CEDIS")}"$)
|
||||
If thisC.GetString("PE_CEDIS") <> "DUR" Then
|
||||
Starter.skmt.ExecNonQuery2($"update ${traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?"$, Array As Object(thisC.GetString("PE_CANT"), thisC.GetString("PE_PROID")))
|
||||
Log("No DUR")
|
||||
'Codigo para regresar dinero al presupuesto de BONIFICACIONES (Trend Spending)
|
||||
Private precio0 As String = traePrecio(thisC.GetString("PE_PROID"))
|
||||
Private precioConDesc As String = (B4XPages.MainPage.cliente.kh.traeDescXSku(traeCliente, thisC.GetString("PE_PROID"))/100)*precio0
|
||||
Log(precioConDesc)
|
||||
Log("precioConDesc: " & precioConDesc)
|
||||
Log(">>>>>>>>>>>>> " & (precioConDesc * thisC.GetString("PE_CANT")))
|
||||
modTrendSpending("suma", "bonificaciones", (precioConDesc * thisC.GetString("PE_CANT")))
|
||||
If Not(IsNumber(thisC.GetString("PE_CEDIS"))) Then ' Si es promo, entonces es bonificacion.
|
||||
Private desc As String = B4XPages.MainPage.promos.ts.traeMontoBonificacion(thisC.GetString("PE_PROID"), thisC.GetString("PE_CEDIS"))
|
||||
Log("Regresamos bonificaciones " & thisC.GetString("PE_PROID") & "=" & desc)
|
||||
modTrendSpending("suma", "bonificaciones", desc)
|
||||
Else ' Si no es promo, entonces es descuento.
|
||||
Log("Regresamos descuentos " & thisC.GetString("PE_PROID") & "=" & (precioConDesc * thisC.GetString("PE_CANT")))
|
||||
modTrendSpending("suma", "descuentos", (precioConDesc * thisC.GetString("PE_CANT")))
|
||||
End If
|
||||
'Termina Trend Spending
|
||||
Starter.skmt.ExecNonQuery2($"update ${traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?"$, Array As Object(thisC.GetString("PE_CANT"), thisC.GetString("PE_PROID")))
|
||||
End If
|
||||
' Starter.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (traeAlmacen, thisC.GetString("PE_PROID"),thisC.GetString("PE_CANT")* -1))
|
||||
Next
|
||||
@@ -1555,9 +1572,6 @@ Sub borraPedidoClienteActual As String
|
||||
If thisC.RowCount < 1 Then Starter.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
Log("###### delete from pedido_cliente - " & traeCliente)
|
||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
|
||||
|
||||
Return 1
|
||||
End Sub
|
||||
|
||||
@@ -2144,12 +2158,12 @@ Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
||||
d.Position = 0
|
||||
acumulado = d.GetString("ACUMULADO")
|
||||
End If
|
||||
Log("acumulado:" & acumulado & " | monto: " & monto)
|
||||
Log("acumulado: " & acumulado & " | monto: " & monto)
|
||||
Private c As Cursor = Starter.skmt.ExecQuery($"select HIST_TSS_TIPO, ${HIST_TSS_SEMANA} as disponible, ${HIST_TSS_SEMANA_ACUM} as acumulado from HIST_TREND_SPENDING_SEMANAL where HIST_TSS_TIPO = '${tipo.ToUpperCase}'"$)
|
||||
If accion.ToUpperCase = "RESTA" Then
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Then
|
||||
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Or tipo.ToUpperCase = "DESCUENTOS" Then
|
||||
Private nuevaBonificacion As String = NumberFormat2((acumulado + monto), 1, 2, 2, False)
|
||||
LogColor($"Nuevo acumulado ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||
Starter.skmt.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
||||
@@ -2160,9 +2174,9 @@ Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
||||
else if accion.ToUpperCase = "SUMA" Then
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Then
|
||||
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Or tipo.ToUpperCase = "DESCUENTOS" Then
|
||||
Private nuevaBonificacion As String = NumberFormat2((acumulado - monto), 1, 2, 2, False)
|
||||
LogColor($"Nueva bonificacion = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||
LogColor($"Nueva ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||
Starter.skmt.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
||||
Starter.skmt.ExecNonQuery($"insert into TREND_SPENDING (tipo, acumulado) values ('${tipo.ToUpperCase}', '${nuevaBonificacion}')"$)
|
||||
End If
|
||||
@@ -2328,4 +2342,19 @@ End Sub
|
||||
' precio = c.GetString("CAT_MONTO")
|
||||
' End If
|
||||
' Return precio
|
||||
'End Sub
|
||||
'End Sub
|
||||
|
||||
' Revisa que la contraseña sea la correcta: pass1 + dia (sin ceros) + hora (24 hrs sin ceros)
|
||||
Sub revisaContrasenaHoy
|
||||
Private pass1 As String = "KMT"
|
||||
Private contrasenaHoy As String = pass1 & DateTime.GetDayOfMonth(DateTime.Now) & DateTime.GetHour(DateTime.now)
|
||||
Log($"${contrasenaHoy}"$)
|
||||
' Log(New)
|
||||
' If New = contrasenaHoy Then
|
||||
' p_login.Visible = False
|
||||
' Sleep(80)
|
||||
' et_usuario.Text = ""
|
||||
' If Not(versionOk) Then ExitApplication 'Si la version no es correcta, salimos de la aplicacion.
|
||||
' kb.HideKeyboard
|
||||
' End If
|
||||
End Sub
|
||||
Reference in New Issue
Block a user