mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-20 19:49:12 +00:00
- VERSION 5.10.15
- Se hicieron correcciones al codigo de Trade Spending. - Se cambio la tabla de donde lee los datos para dar de alta clientes nuevos, antes en CLIENTES_NUEVOS_X_RUTA, ahora CAT_RUTAS.
This commit is contained in:
62
B4A/Subs.bas
62
B4A/Subs.bas
@@ -1005,10 +1005,10 @@ 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 = False
|
||||
Private thisLog As Boolean = True
|
||||
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.
|
||||
Private c As Cursor = Starter.skmt.ExecQuery("Select * from promos_comp where cat_pa_id = '"& promo&"'") 'Obtenemos el maximo de promociones a otorgar.
|
||||
Private siHistorico As String = 0
|
||||
Private promoMap As Map
|
||||
Private prodsFijos, prodsFijosPrecios, prodsFijosPiezas, prodsVariables, prodsVariablesPrecios As List
|
||||
@@ -1020,12 +1020,15 @@ Sub traePromo(promo As String, cliente As String) As Map
|
||||
prodsVariablesPrecios.Initialize
|
||||
c.Position = 0
|
||||
promoMap = CreateMap("id":promo, "maxXcliente":0, "maxRecurrente":0, "maxPromos":0) 'Ponemos el DEFAULT en CERO.
|
||||
If c.RowCount > 0 Then promoMap = CreateMap("id":promo, "maxXcliente":c.GetString("CAT_PA_MAXPROMCLIE"), "maxRecurrente":c.GetString("CAT_PA_MAXPROMREC"), "maxPromos":c.GetString("CAT_PA_MAXPROM"))
|
||||
If c.RowCount > 0 Then
|
||||
promoMap = CreateMap("id":promo, "maxXcliente":c.GetString("CAT_PA_MAXPROMCLIE"), "maxRecurrente":c.GetString("CAT_PA_MAXPROMREC"), "maxPromos":c.GetString("CAT_PA_MAXPROM"))
|
||||
End If
|
||||
'######### PROMOCIONES SEGMENTADAS ##########
|
||||
' Si la promo esta en la lista, SOLO los clientes que la tengan la pueden ver.
|
||||
Private ps As Cursor = Starter.skmt.ExecQuery($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}' and HCCP_CLIENTE = '${cliente}'"$)
|
||||
Private ps As Cursor = Starter.skmt.ExecQuery($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}'"$) ' and HCCP_CLIENTE = '${cliente}'
|
||||
' Log($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}'"$)
|
||||
If thisLog Then Log($"PROMOS SEGMENTADAS DISPONIBLES: ${ps.RowCount}"$)
|
||||
If thisLog Then Log(promoMap)
|
||||
If ps.RowCount > 0 Then
|
||||
ps.Position = 0
|
||||
promoMap = CreateMap("id":promo, "maxXcliente":0, "maxRecurrente":0, "maxPromos":0) 'Si es segmentada la ponemos en cero, porque SOLO le debe de aparecer a ciertos clientes.
|
||||
@@ -1343,12 +1346,14 @@ Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
|
||||
Private t As List
|
||||
t.Initialize
|
||||
t.Add(traeMaxPromos(pm)) ' Agregamos a la lista las promos maximas permitidas (recurrente, cliente y promo).
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green)
|
||||
invFijoXpromo.Initialize
|
||||
If thisLog Then LogColor($"pm=${pm}"$, Colors.Blue)
|
||||
Private invDispParaPromo As Map = traemosInventarioDisponibleParaPromo(pm.Get("id"))
|
||||
If thisLog Then Log($"invDispParaPromo=${invDispParaPromo}"$)
|
||||
Private prodsFijosPiezas As List = pm.Get("prodsFijosPiezas")
|
||||
Private idProdsFijos As List = pm.Get("prodsFijos")
|
||||
Private idProdsFijosPrecios As List = pm.Get("prodsFijosPrecios")
|
||||
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))
|
||||
@@ -1361,17 +1366,19 @@ Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
|
||||
|
||||
' 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.
|
||||
t.Add(x(0).As(Int)) 'Solo guardamos la parte del entero de la division. (promos por inventario)
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green) 'promos por inventario
|
||||
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")))
|
||||
Log(">>>>> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsFijos.Get(p), idProdsFijosPrecios.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), idProdsFijosPrecios.Get(p), pm.Get("id")), Colors.blue)
|
||||
t.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), idProdsFijosPrecios.Get(p), pm.Get("id"))) 'Agregamos las promos disponibles por Trade Spending
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green)
|
||||
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(">>>>>> 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
|
||||
@@ -1394,6 +1401,7 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||
Private maxPromos As String = traeMaxPromos(pm)
|
||||
Private maxPromosXFijos As Int = revisaMaxPromosProdsFijosPorInventario(pm)
|
||||
Private idProdsVariables As List = pm.Get("prodsVariables")
|
||||
Private prodsVariablesPrecios As List = pm.Get("prodsVariablesPrecios")
|
||||
Private prodsVariablesRequeridos As Int = pm.Get("prodsVariablesRequeridos")
|
||||
Private prodsFijosPiezas As List = pm.Get("prodsFijosPiezas")
|
||||
Private idProdsFijos As List = pm.Get("prodsFijos")
|
||||
@@ -1443,7 +1451,7 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||
Log($"Este prodVariable: ${idProdsVariables.Get(i)}"$)
|
||||
Log($"Este invDisponible: ${invDispParaPromo.Get(idProdsVariables.Get(i))}"$)
|
||||
' Log(">> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsVariables.Get(i), pm.Get("id")))
|
||||
prodsVariablesXPresupuestoBonificaciones.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsVariables.Get(i), prodsVariablesRequeridos, pm.Get("id")))
|
||||
prodsVariablesXPresupuestoBonificaciones.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsVariables.Get(i), prodsVariablesRequeridos, prodsVariablesPrecios.Get(i), pm.Get("id")))
|
||||
' If thisLog Then LogColor(">> Max prods fijos x Bonificaciones: " & B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsVariables.Get(i), prodsVariablesRequeridos, pm.Get("id")), Colors.blue)
|
||||
totalProdsVariablesDisponibles = totalProdsVariablesDisponibles + invDispParaPromo.Get(idProdsVariables.Get(i))
|
||||
End If
|
||||
@@ -1552,7 +1560,7 @@ Sub borraPedidoClienteActual As String
|
||||
Log($"Borramos pedido del cliente ${traeCliente}"$)
|
||||
Private thisC As Cursor
|
||||
' Private tablaProds As String = "cat_gunaprod2"
|
||||
thisC = Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_CEDIS FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) and PE_CEDIS <> 'DOE'")
|
||||
thisC = Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_CEDIS, PE_COSTOU FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) and PE_CEDIS <> 'DOE'")
|
||||
Log($"Registros = ${thisC.RowCount}"$)
|
||||
If thisC.RowCount > 0 Then
|
||||
For i = 0 To thisC.RowCount - 1
|
||||
@@ -1566,7 +1574,8 @@ Sub borraPedidoClienteActual As String
|
||||
Log("precioConDesc: " & precioConDesc)
|
||||
Log(">>>>>>>>>>>>> " & (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"))
|
||||
Private desc As String = B4XPages.MainPage.promos.ts.traeMontoBonificacion(thisC.GetString("PE_PROID"), thisC.GetString("PE_COSTOU"), thisC.GetString("PE_CEDIS"))
|
||||
desc = desc * thisC.GetString("PE_CANT")
|
||||
Log("Regresamos bonificaciones " & thisC.GetString("PE_PROID") & "=" & desc)
|
||||
modTrendSpending("suma", "bonificaciones", desc)
|
||||
Else ' Si no es promo, entonces es descuento.
|
||||
@@ -2095,11 +2104,17 @@ End Sub
|
||||
' 1 si versionActual es MAYOR que versionMinima
|
||||
Sub comparaVersiones(versionMinima As String, versionActual As String) As Int
|
||||
Dim Pattern As String = "[^0-9.]"
|
||||
Log(versionMinima)
|
||||
If versionMinima = "NA" Then Return 0 ' Si version minima es igal a "NA" regresamos "Version valida"
|
||||
versionMinima = Regex.Replace(Pattern, versionMinima, "") ' Quitamos todo lo que no sea numero o punto.
|
||||
versionActual = Regex.Replace(Pattern, versionActual, "") ' Quitamos todo lo que no sea numero o punto.
|
||||
Log($"${versionMinima}|${versionActual}"$)
|
||||
Dim partesMin() As String = Regex.Split("\.", versionMinima)
|
||||
Dim partesAct() As String = Regex.Split("\.", versionActual)
|
||||
If partesMin.Length < 2 Then
|
||||
ToastMessageShow("Version incorrecta", False)
|
||||
Return -1 ' ← Actual no cumple el formato mínimo
|
||||
End If
|
||||
' Si la actual tiene MENOS partes que la mínima, es inválida (opcional)
|
||||
If partesAct.Length < partesMin.Length Then
|
||||
ToastMessageShow("Version incorrecta", False)
|
||||
@@ -2110,7 +2125,7 @@ Sub comparaVersiones(versionMinima As String, versionActual As String) As Int
|
||||
Dim numMin As Int = partesMin(i)
|
||||
Dim numAct As Int = partesAct(i)
|
||||
If numAct < numMin Then
|
||||
ToastMessageShow("Versión vieja, por favor actualizar!", False)
|
||||
ToastMessageShow("Versión descontinuada, por favor actualizar!", False)
|
||||
Return -1 ' Actual es menor
|
||||
Else If numAct > numMin Then
|
||||
Return 1 ' Actual es mayor
|
||||
@@ -2402,4 +2417,25 @@ Sub traeExistenciasPorId(id As String) As Int
|
||||
existencias = (existencias - vendido)
|
||||
inv.Close
|
||||
Return existencias
|
||||
End Sub
|
||||
|
||||
' Devuelve True si la hora actual está entre las 5:00 AM y las 22:30 PM
|
||||
Sub EstaEnHorarioPermitido As Boolean
|
||||
' Obtener la hora y el minuto actual
|
||||
Dim HoraActual As Int = DateTime.GetHour(DateTime.Now)
|
||||
Dim MinutoActual As Int = DateTime.GetMinute(DateTime.Now)
|
||||
|
||||
' Convertir la hora actual a minutos totales desde la medianoche para una comparación simple
|
||||
Dim TiempoActualEnMinutos As Int = (HoraActual * 60) + MinutoActual
|
||||
|
||||
' Definir los límites del horario permitido en minutos
|
||||
Dim InicioEnMinutos As Int = (5 * 60) + 0 ' 5:00 AM = 300 minutos
|
||||
Dim FinEnMinutos As Int = (22 * 60) + 30 ' 22:30 PM = 1350 minutos
|
||||
|
||||
' Comprobar si la hora actual está dentro del rango
|
||||
If TiempoActualEnMinutos >= InicioEnMinutos And TiempoActualEnMinutos <= FinEnMinutos Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Sub
|
||||
Reference in New Issue
Block a user