mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-19 02:59:14 +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:
@@ -7,8 +7,8 @@ Version=12.8
|
||||
' Clase para las funciones de Trend Spending.
|
||||
' Trend spending son 3 presupuestos que tiene Kelloggs, que son bonificaciones, descuentos y RMIs, estos se calculan semanalmente
|
||||
' y se descargan de la tabla HIST_TRADE_SPENDING_SEMANAL, de ahi obtenemos el presupuesto de la semana y el acumulado hasta ayer
|
||||
' en la noche, a cada presupuesto le vamos sumando cada que agregamos a pedido un descuento (Precios diferentes al original que
|
||||
' NO están en PROMOS), una bonificacion (precios con descuento que estan en promociones) o un RMI (de estos sumamos al presupuesto
|
||||
' en la noche, a cada presupuesto le vamos sumando cada que agregamos a pedido un DESCUENTO (Precios diferentes al original que
|
||||
' NO están en PROMOS), una BONIFICACION (precios con descuento que estan en promociones) o un RMI (de estos sumamos al presupuesto
|
||||
' el precio del RMI seleccionado), de acuerdo al presupuesto disponible de cada tipo, se limitan los productos, es decir que si
|
||||
' el presupuesto de bonificaciones ya se agoto, ya no aparecen promociones, o si el de descuentos se agoto, ya no se pueden agregar
|
||||
' mas productos con descuento.
|
||||
@@ -68,7 +68,7 @@ Sub traeInfoTrendSpending As Map
|
||||
Private semana As Int = 0
|
||||
Private HIST_TSS_SEMANA As String = 0
|
||||
Private HIST_TSS_SEMANA_ACUM As String = 0
|
||||
Private m As Map = CreateMap("RMI": 100000 & "," & 0, "DESCUENTOS": 100000 & "," & 0, "BONIFICACIONES": 100000 & "," & 0) ' El 100,000 es el default del presupuesto, por si NO HAY datos de trend spending.
|
||||
Private m As Map = CreateMap("RMI": 10000000 & "," & 0, "DESCUENTOS": 10000000 & "," & 0, "BONIFICACIONES": 10000000 & "," & 0) ' El 100,000 es el default del presupuesto, por si NO HAY datos de trend spending.
|
||||
' m.Initialize
|
||||
Private c As Cursor = tsdb.ExecQuery($"select cat_va_valor from cat_variables where cat_va_descripcion = 'SEM_CAL_LABORAL'"$)
|
||||
If c.RowCount > 0 Then
|
||||
@@ -97,6 +97,7 @@ End Sub
|
||||
|
||||
' Modifica el acumulado del Trend Speding, le "suma" o "resta" al presupuesto especificado (RMI, BONIFICACIONES o DESCUENTOS)
|
||||
Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
||||
LogColor($"Accion: ${accion}, Tipo: ${tipo}, Monto: ${monto}"$, Colors.Blue)
|
||||
Private HIST_TSS_SEMANA As String
|
||||
Private HIST_TSS_SEMANA_ACUM As String
|
||||
Private acumulado As String = "0"
|
||||
@@ -116,21 +117,24 @@ Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
||||
End If
|
||||
Log("acumulado:" & acumulado & " | monto: " & monto)
|
||||
Private c As Cursor = tsdb.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}'"$)
|
||||
' Log(($"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}'"$))
|
||||
Log("---- " & c.RowCount)
|
||||
If accion.ToUpperCase = "RESTA" Then
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
If tipo.ToUpperCase = "DESCUENTOS" Or tipo.ToUpperCase = "RMI" Then
|
||||
If tipo.ToUpperCase = "DESCUENTOS" Or tipo.ToUpperCase = "RMI" Or tipo.ToUpperCase = "BONIFICACIONES" Then
|
||||
Private nuevaBonificacion As String = NumberFormat2((acumulado + monto), 1, 2, 2, False)
|
||||
LogColor($"Nuevo acumulado ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||
tsdb.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
||||
tsdb.ExecNonQuery($"insert into TREND_SPENDING (tipo, acumulado) values ('${tipo.ToUpperCase}', '${nuevaBonificacion}')"$)
|
||||
Log($"Insertamos en TRADE_SPENDING: ${nuevaBonificacion}"$)
|
||||
' else if tipo.ToUpperCase = "RMI" Then
|
||||
End If
|
||||
End If
|
||||
else if accion.ToUpperCase = "SUMA" Then
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
If tipo.ToUpperCase = "DESCUENTOS" Or tipo.ToUpperCase = "RMI" Then
|
||||
If tipo.ToUpperCase = "DESCUENTOS" Or tipo.ToUpperCase = "RMI" Or tipo.ToUpperCase = "BONIFICACIONES" Then
|
||||
Private nuevaBonificacion As String = NumberFormat2((acumulado - monto), 1, 2, 2, False)
|
||||
LogColor($"Nueva bonificacion = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||
tsdb.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
||||
@@ -185,6 +189,8 @@ End Sub
|
||||
|
||||
Sub trendSpending(accion As String, tipo As String, clienteId As String, id As String, laCant As String, inv As Int) As String
|
||||
Private logger As Boolean = True
|
||||
LogColor("-------- > TRADE SPENDING < ---------", Colors.red)
|
||||
' Log("DescxSku: " & traeDescXSku(clienteId, id))
|
||||
Dim TS_RMI() As String
|
||||
Dim TS_DESCUENTOS() As String
|
||||
Dim TS_BONIFICACIONES() As String
|
||||
@@ -197,8 +203,8 @@ Sub trendSpending(accion As String, tipo As String, clienteId As String, id As S
|
||||
Log($"Acumulado de RMIs: ${traeAcumuladoHoyTS("rmi")}"$)
|
||||
Private elMonto As String = NumberFormat2(traePrecioRMI(id), 1, 2, 2, False)
|
||||
If logger Then Log($"elMonto: ${elMonto}"$)
|
||||
If logger Then Log($"TS_RMI(0): ${TS_RMI(0)}"$)
|
||||
If logger Then Log($"TS_RMI(1): ${TS_RMI(1)}"$)
|
||||
' If logger Then Log($"TS_RMI(0): ${TS_RMI(0)}"$)
|
||||
' If logger Then Log($"TS_RMI(1): ${TS_RMI(1)}"$)
|
||||
If logger Then Log($"LaCant: ${laCant}"$)
|
||||
Private tsRestantes As String = (TS_RMI(0) - TS_RMI(1) - traeAcumuladoHoyTS("rmi"))
|
||||
Log($"tsRestantes: ${tsRestantes}"$)
|
||||
@@ -216,7 +222,7 @@ Sub trendSpending(accion As String, tipo As String, clienteId As String, id As S
|
||||
If laCant < lasMaximas Then
|
||||
modTrendSpending("resta", "rmi", elMonto) ' Restamos al presupuesto de hoy (agregamos al acumulado).
|
||||
End If
|
||||
If logger Then Log("RMI RESTANTES: " & (TS_RMI(0) - TS_RMI(1) - traeAcumuladoHoyTS("rmi")))
|
||||
If logger Then LogColor("RMI RESTANTES: " & (TS_RMI(0) - TS_RMI(1) - traeAcumuladoHoyTS("rmi")), Colors.red)
|
||||
Return lasMaximas & "|" & elMonto
|
||||
else if accion.ToUpperCase = "PRODMENOS" Then
|
||||
If logger Then Log("LaCANT= " & laCant & ", elMonto= " & elMonto)
|
||||
@@ -231,14 +237,14 @@ Sub trendSpending(accion As String, tipo As String, clienteId As String, id As S
|
||||
Private elMonto As String = NumberFormat2(traePrecio(id)*(traeDescXSku(clienteId, id)/100), 1, 2, 2, False)
|
||||
Private tsRestantes As String = (TS_DESCUENTOS(0) - TS_DESCUENTOS(1) - traeAcumuladoHoyTS("descuentos"))
|
||||
If logger Then Log("EL MONTO: " & elMonto)
|
||||
If logger Then Log("Monto del presupuesto disponible: " & tsRestantes)
|
||||
If logger Then LogColor("Monto del presupuesto disponible: " & tsRestantes, Colors.blue)
|
||||
If accion.ToUpperCase = "PRODMAS" Then 'Regresa lasMaximas y elMonto separadas por un "|"
|
||||
If logger Then Log("PMAS")
|
||||
' If logger Then Log("PMAS")
|
||||
If elMonto > 0 Then
|
||||
lasMaximas = ((laCant * elMonto) + tsRestantes) / elMonto
|
||||
If logger Then Log("lasMaximas: " & lasMaximas)
|
||||
If logger Then Log("lasMaximas2: " & traeMaximas("descuentos", clienteId, id, laCant, ""))
|
||||
If logger Then Log(traeAcumuladoHoyTS("descuentos"))
|
||||
' If logger Then Log("lasMaximas2: " & traeMaximas("descuentos", clienteId, id, laCant, ""))
|
||||
If logger Then Log("Acumulado hoy: " & traeAcumuladoHoyTS("descuentos"))
|
||||
End If
|
||||
If laCant = lasMaximas Then
|
||||
ToastMessageShow("El presupuesto de DESCUENTOS no permite agregar mas productos!!", False)
|
||||
@@ -293,7 +299,7 @@ End Sub
|
||||
|
||||
' Trae la cantidad máxima de rmis, bonificaciones o descuentos por presupuesto.
|
||||
Sub traeMaximas(tipo As String, clienteId As String, id As String, laCant As String, promoId As String) As Int
|
||||
Private tsMaximas As Int = 100000
|
||||
Private tsMaximas As Int = 10000000
|
||||
Private tsRestantes As String = 0
|
||||
Private tsMonto As String '= traeMonto(clienteId, id)
|
||||
' If tsMonto > 0 Then
|
||||
@@ -316,23 +322,25 @@ Sub traeMaximas(tipo As String, clienteId As String, id As String, laCant As Str
|
||||
Return tsMaximas
|
||||
End Sub
|
||||
|
||||
' Trae la cantidad máxima de bonificaciones por presupuesto.
|
||||
' Trae la cantidad máxima de productos con bonificacion por presupuesto.
|
||||
' Si el presupuesto es 10 y la bonificacion del producto es 2, el máximo es 5 productos.
|
||||
Sub traeBonificacionesMaximas(tipo As String, clienteId As String, id As String, laCant As String, promoId As String) As Int
|
||||
Private tsMaximas As Int = 100000
|
||||
Private tsMaximas As Int = 10000000
|
||||
Private tsRestantes As String = 0
|
||||
Private tsMonto As String
|
||||
LogColor($"${TS_BONIFICACIONES(0)} - ${TS_BONIFICACIONES(1)} - ${traeAcumuladoHoyTS("bonificaciones")}"$, Colors.Red)
|
||||
LogColor($"Presupuesto: ${TS_BONIFICACIONES(0)} - Acumulado ayer: ${TS_BONIFICACIONES(1)} - Hoy: ${traeAcumuladoHoyTS("bonificaciones")}"$, Colors.Red)
|
||||
If tipo.ToUpperCase = "BONIFICACIONES" Then
|
||||
tsMonto = NumberFormat2(traeMontoBonificacion(id, promoId), 1, 2, 2, False)
|
||||
tsRestantes = (TS_BONIFICACIONES(0) - TS_BONIFICACIONES(1) - traeAcumuladoHoyTS("bonificaciones")) ' Traemos monto restante de Trend Spending para bonificaciones.
|
||||
End If
|
||||
Log($"tsMonto: ${tsMonto}"$)
|
||||
Log($"tsRestantes: ${tsRestantes}"$)
|
||||
Log($"laCant: ${laCant}"$)
|
||||
Log($"Monto de bonificacion: ${tsMonto}"$)
|
||||
Log($"Presupuesto disponible: ${tsRestantes}"$)
|
||||
Log($"Cantidad: ${laCant}"$)
|
||||
Log($"Floor(tsRestantes / (tsMonto * laCant))= ${Floor(tsRestantes / (tsMonto * laCant))}"$)
|
||||
If tsMonto > 0 Then
|
||||
tsMaximas = Floor(tsRestantes / (tsMonto * laCant))
|
||||
Log(">>> tsMaximas: " & tsMaximas)
|
||||
End If
|
||||
Log(">>> tsMaximas: " & tsMaximas)
|
||||
Return tsMaximas
|
||||
End Sub
|
||||
|
||||
@@ -350,7 +358,8 @@ Sub traeMontoBonificacion(id As String, promoId As String) As String
|
||||
Else
|
||||
tsMonto = c.GetString("CAT_GP_PRECIO") ' Precio original.
|
||||
End If
|
||||
' Log($"${c.GetString("CAT_GP_PRECIO")} - ${c.GetString("CAT_DP_PRECIO")}"$)
|
||||
' Log("PRECIOB: " & c.GetInt("CAT_DP_PRECIOB"))
|
||||
' Log($"Precio normal: ${c.GetString("CAT_GP_PRECIO")}, Precio desc: ${c.GetString("CAT_DP_PRECIO")}, Monto bonificacion: ${tsMonto}"$)
|
||||
End If
|
||||
' Log("ROWCOUNT: " & c.RowCount)
|
||||
Return tsMonto
|
||||
@@ -365,23 +374,23 @@ End Sub
|
||||
' Aunque si hay suficiente para mostrar algunas promos ... pues que si las muestre.
|
||||
Sub maxPromosPorProdsVariables(idProdsVariables As List, promo As String)As Int
|
||||
Private logger As Boolean = True
|
||||
Private Maxs As Int = 100000
|
||||
Private Maxs As Int = 10000000
|
||||
Private prodsVariablesXPresupuestoBonificaciones As List
|
||||
Private prodsVariablesRequeridos As Int = traeProdsVariablesRequeridos(promo)
|
||||
prodsVariablesXPresupuestoBonificaciones.Initialize
|
||||
' Log("PRODS SIZE: " & idProdsVariables.Size)
|
||||
' LogColor("===========> Prods Variables: " & idProdsVariables.Size & " <==========", Colors.red)
|
||||
For i = 0 To idProdsVariables.Size - 1 'Obtenemos total de productos variables disponibes.
|
||||
If logger Then Log($"Este prodVariable: ${idProdsVariables.Get(i)}"$)
|
||||
If logger Then LogColor($"=>> prodVariable ${i} : ${idProdsVariables.Get(i)}, ${Subs.traeProdNombre(idProdsVariables.Get(i))} <<=="$, Colors.blue)
|
||||
' Log($"Este invDisponible: ${invDispParaPromo.Get(idProdsVariables.Get(i))}"$)
|
||||
If logger Then Log(">> Monto Bonificacion: " & traeMontoBonificacion(idProdsVariables.Get(i), promo))
|
||||
Private maxProds As Int = traeBonificacionesMaximas("bonificaciones", traeCliente, idProdsVariables.Get(i), prodsVariablesRequeridos, promo)
|
||||
prodsVariablesXPresupuestoBonificaciones.Add(maxProds)
|
||||
If logger Then LogColor(">> Max prods x Bonificaciones: " & maxProds, Colors.blue)
|
||||
Next
|
||||
prodsVariablesXPresupuestoBonificaciones.Sort(True)
|
||||
If prodsVariablesXPresupuestoBonificaciones.Size > 0 Then
|
||||
Maxs = prodsVariablesXPresupuestoBonificaciones.Get(0)
|
||||
End If
|
||||
If logger Then LogColor("=====>> Max prods variables x monto de bonificaciones: " & Maxs, Colors.blue)
|
||||
Return Maxs
|
||||
End Sub
|
||||
|
||||
@@ -400,6 +409,11 @@ Sub traeProdsVariablesRequeridos(promo As String) As Int
|
||||
Return pvr
|
||||
End Sub
|
||||
|
||||
|
||||
'########################################################################################
|
||||
' Los productos fijos NO estan restando del presupuesto de BONIFICACIONES
|
||||
'########################################################################################
|
||||
|
||||
'Poner en una funcion (maxPromosPorProdsFijos) el codigo para traer las promos maximas por productos fijos, igual que la de productos
|
||||
' variables, y ponerla igual en "traeMaxPromos" en lugar de en "revisaMaxPromosProdsFijosPorInventario".
|
||||
|
||||
|
||||
Reference in New Issue
Block a user