- VERSOIN 5.11.26

- Se agregó le descripcion del "flujo" de las promociones en C_Promos
This commit is contained in:
2025-11-30 02:32:36 -06:00
parent 749cf6e7fe
commit 7a88acaf4c
13 changed files with 442 additions and 88 deletions

View File

@@ -82,7 +82,7 @@ Sub traeInfoTrendSpending As Map
End If
If semana > 0 Then
c = tsdb.ExecQuery($"select HIST_TSS_TIPO, HIST_TSS_SEMANA${semana}, ifnull(HIST_TSS_SEMANA${semana}_ACUM,0) as HIST_TSS_SEMANA${semana}_ACUM from HIST_TREND_SPENDING_SEMANAL"$)
Log($"select HIST_TSS_TIPO, HIST_TSS_SEMANA${semana}, ifnull(HIST_TSS_SEMANA${semana}_ACUM,0) as HIST_TSS_SEMANA${semana}_ACUM from HIST_TREND_SPENDING_SEMANAL"$)
' Log($"select HIST_TSS_TIPO, HIST_TSS_SEMANA${semana}, ifnull(HIST_TSS_SEMANA${semana}_ACUM,0) as HIST_TSS_SEMANA${semana}_ACUM from HIST_TREND_SPENDING_SEMANAL"$)
If c.RowCount > 0 Then
For i = 0 To c.RowCount - 1
c.Position = i
@@ -335,7 +335,7 @@ End Sub
' 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, elPrecioVenta As String, promoId As String) As Int
Private thisLog As Boolean = False
Private thisLog As Boolean = True
Private tsMaximas As Int = 100000000
Private tsRestantes As String = 0
Private tsMonto As String
@@ -345,22 +345,26 @@ Sub traeBonificacionesMaximas(tipo As String, clienteId As String, id As String,
TS_DESCUENTOS = Regex.Split(",", mx.Get("DESCUENTOS"))
TS_BONIFICACIONES = Regex.Split(",", mx.Get("BONIFICACIONES"))
If thisLog Then LogColor($"Presupuesto: ${TS_BONIFICACIONES(0)} - Acumulado ayer: ${TS_BONIFICACIONES(1)} - Hoy: ${traeAcumuladoHoyTS("bonificaciones")}"$, Colors.Red)
If thisLog Then LogColor($" ============ INICIA BONIFICACIONES MAXIMAS (${id}) ========"$, Colors.RGB(0,197,110))
If thisLog Then LogColor($" Presupuesto: ${TS_BONIFICACIONES(0)} - Acumulado ayer: ${TS_BONIFICACIONES(1)} - Hoy: ${traeAcumuladoHoyTS("bonificaciones")}"$, Colors.Magenta)
If tipo.ToUpperCase = "BONIFICACIONES" Then
tsMonto = NumberFormat2(traeMontoBonificacion(id, elPrecioVenta, promoId), 1, 2, 2, False)
tsRestantes = (TS_BONIFICACIONES(0) - TS_BONIFICACIONES(1) - traeAcumuladoHoyTS("bonificaciones")) ' Traemos monto restante de Trend Spending para bonificaciones.
Log("TS_BONIFICACIONES(0) - TS_BONIFICACIONES(1) - traeAcumuladoHoyTS('bonificaciones')")
Log($"${TS_BONIFICACIONES(0)} - ${TS_BONIFICACIONES(1)} - ${traeAcumuladoHoyTS("bonificaciones")}"$)
Log($" PresupuestoBonifs: ${TS_BONIFICACIONES(0)}, AcumuladoBonifs: ${TS_BONIFICACIONES(1)}, traeAcumuladoHoyTS('bonificaciones'): ${traeAcumuladoHoyTS("bonificaciones")}"$)
' Log($" ${TS_BONIFICACIONES(0)} - ${TS_BONIFICACIONES(1)} - ${traeAcumuladoHoyTS("bonificaciones")}"$)
End If
If thisLog Then Log($"Monto de bonificacion: ${tsMonto}"$)
If thisLog Then Log($"Presupuesto disponible: ${tsRestantes}"$)
If thisLog Then Log($"Cantidad: ${laCant}"$)
If thisLog Then Log($"Floor(tsRestantes / (tsMonto * laCant))= ${Floor(tsRestantes / (tsMonto * laCant))}"$)
If thisLog Then Log($"Floor(${tsRestantes} / (${tsMonto} * ${laCant}))= ${Floor(tsRestantes / (tsMonto * laCant))}"$)
If thisLog Then Log($" Monto de bonificacion: ${tsMonto}"$)
If thisLog Then Log($" Presupuesto disponible: ${tsRestantes}"$)
' If thisLog Then Log($"Cantidad: ${laCant}"$)
If thisLog Then Log($" Floor(tsRestantes / (tsMonto * laCant)) <==> Floor(${tsRestantes} / (${tsMonto} * ${laCant})) = ${Floor(tsRestantes / (tsMonto * laCant))}"$)
' If thisLog Then Log($"Floor(${tsRestantes} / (${tsMonto} * ${laCant}))= ${Floor(tsRestantes / (tsMonto * laCant))}"$)
If tsMonto > 0 Then
tsMaximas = Floor(tsRestantes / (tsMonto * laCant))
End If
If thisLog Then Log(">>> tsMaximas: " & tsMaximas)
If thisLog Then LogColor(" ************************************************", Colors.red)
If thisLog Then LogColor(" ***** BONIFICACIONES MAXIMAS: " & tsMaximas & " *****", Colors.red)
If thisLog Then LogColor(" ************************************************", Colors.red)
If thisLog Then LogColor(" ============ TERMINA BONIFICACIONNES MAXIMAS ========", Colors.RGB(0,197,110))
Return tsMaximas
End Sub
@@ -368,14 +372,15 @@ End Sub
' - Si CAT_DP_PRECIOB es 1, la bonificacion es: Precio original - precio de venta.
' - Si CAT_DP_PRECIOB es 0, la bonificacion es: Precio original.
Sub traeMontoBonificacion(id As String, precio As String, promoId As String) As String
Private thisLog As Boolean = True
LogColor($">>>>>>> ${promoId}, ${precio}, ${id}"$, Colors.Magenta)
Private thisLog As Boolean = False
If thisLog Then LogColor($" ============ INICIA MONTO BONIFICACION (${id}) ========"$, Colors.RGB(151,0,171))
If thisLog Then LogColor($" ###### ${promoId}, ${precio}, ${id}"$, Colors.Magenta)
Private tsMonto As String = 0
Private re As Cursor = Starter.skmt.ExecQuery($"select cat_gp_id from cat_gunaprod2 where (cat_gp_tipo like 'REGALO%' or cat_gp_tipo like 'EXHIBIDOR%') and cat_gp_id = '${id}'"$) ' Revisamos si el producto es regalo o exhibidor.
If re.RowCount = 0 Then' No es regalo ni exhibidor.
Private c As Cursor = tsdb.ExecQuery($"SELECT CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_PRECIO, CAT_DP_TIPO, CAT_GP_PRECIO, CAT_DP_PRECIOB FROM CAT_DETALLES_PAQ join ${traeTablaProds(Starter.tipov)} on CAT_GP_ID = CAT_DP_IDPROD where CAT_GP_ID = '${id}' and CAT_DP_PRECIO = '${precio}' and CAT_DP_ID = '${promoId}'"$)
Log($"SELECT CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_PRECIO, CAT_DP_TIPO, CAT_GP_PRECIO, CAT_DP_PRECIOB FROM CAT_DETALLES_PAQ join ${traeTablaProds(Starter.tipov)} on CAT_GP_ID = CAT_DP_IDPROD where CAT_GP_ID = '${id}' and CAT_DP_PRECIO = '${precio}' and CAT_DP_ID = '${promoId}'"$)
Log($"rowcount: ${c.RowCount}"$)
' Log($"SELECT CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_PRECIO, CAT_DP_TIPO, CAT_GP_PRECIO, CAT_DP_PRECIOB FROM CAT_DETALLES_PAQ join ${traeTablaProds(Starter.tipov)} on CAT_GP_ID = CAT_DP_IDPROD where CAT_GP_ID = '${id}' and CAT_DP_PRECIO = '${precio}' and CAT_DP_ID = '${promoId}'"$)
If thisLog Then Log($" Rowcount DP y CGP2: ${c.RowCount}"$)
If c.RowCount > 0 Then
c.Position = 0
If c.GetInt("CAT_DP_PRECIOB") = 1 Or (c.GetInt("CAT_DP_PRECIOB") = 0 And c.GetString("CAT_GP_PRECIO") = c.GetString("CAT_DP_PRECIO")) Then
@@ -384,10 +389,11 @@ Sub traeMontoBonificacion(id As String, precio As String, promoId As String) As
tsMonto = c.GetString("CAT_GP_PRECIO") ' Precio original.
End If
' Log("PRECIOB: " & c.GetInt("CAT_DP_PRECIOB"))
If thisLog Then Log($"Precio normal: ${c.GetString("CAT_GP_PRECIO")}, Precio desc: ${c.GetString("CAT_DP_PRECIO")}, Monto bonificacion: ${tsMonto}"$)
If thisLog Then Log($" Precio normal: ${c.GetString("CAT_GP_PRECIO")}, Precio desc: ${c.GetString("CAT_DP_PRECIO")}, Monto bonificacion: ${tsMonto}"$)
End If
' Log("ROWCOUNT: " & c.RowCount)
End If
If thisLog Then LogColor($" ============ TERMINA MONTO BONIFICACION ========"$, Colors.RGB(151,0,171))
Return tsMonto
End Sub
@@ -399,7 +405,7 @@ End Sub
' se agoto el presupuesto.
' 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 logger As Boolean = False
Private Maxs As Int = 10000000
Private prodsVariablesXPresupuestoBonificaciones As List
Private prodsVariablesRequeridos As Int = traeProdsVariablesRequeridos(promo)