11/11/23 - Correcciones en MaxPromos y MaxCientesNuevos

- Se corrigio que las maxPromos no las regresaba bien.
- Se puso la opcion de especificar el maximo de clinetes nuevos en el engrane (Extras), todavia NO esta terminado.
This commit is contained in:
2023-11-11 05:35:12 -06:00
parent ea1bb8d292
commit e4fa8439ec
11 changed files with 107 additions and 24 deletions

View File

@@ -973,6 +973,7 @@ Sub traePromo(promo As String, cliente As String) As Map
prodsVariables.Initialize
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"))
c = Starter.skmt.ExecQuery("Select count(*) as hist from HIST_PROMOS where HP_CLIENTE = '"& cliente & "' and HP_CODIGO_PROMOCION = '" & promo & "'") 'Revisamos si hay historico de la promoción.
c.Position = 0
@@ -1108,7 +1109,7 @@ End Sub
'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.
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
Private maxPromos As List
Private mp0, mp As String = "0"
maxPromos.Initialize
@@ -1123,17 +1124,22 @@ Sub traeMaxPromos(pm As Map) As Int
If thisLog Then LogColor("==== HISTORICO:"&pm.Get("historico"), Colors.Red)
If thisLog Then Log(pm)
If pm.Get("historico") = "1" Then maxPromos.Add(pm.Get("maxRecurrente")) 'Si hay historico, agregamos maxRecurrente
maxPromos.Add(pm.Get("maxPromos")) 'Agregamos maxPromos
maxPromos.Add(pm.Get("maxXcliente")) 'Agregamos maxXcliente
If pm.Get("maxPromos") <> "null" Then maxPromos.Add(pm.Get("maxPromos").As(Int)) 'Agregamos maxPromos
If pm.Get("maxXcliente") <> "null" Then maxPromos.Add(pm.Get("maxXcliente").As(Int)) 'Agregamos maxXcliente
If hccp.RowCount > 0 Then 'Agregamos promos HCCP
hccp.Position = 0
maxPromos.Add(hccp.GetString("HCCP_CANT"))
maxPromos.Add(hccp.GetInt("HCCP_CANT"))
End If
maxPromos.Sort(True)
Log($">>>>> max promos : ${maxPromos}"$)
If thisLog Then Log(maxPromos)
mp0 = maxPromos.Get(0)
mp = mp0 - traePromosVendidas(pm.Get("id"), traeCliente)
If thisLog Then Log($"Max Promos (${mp0}) - promos vendidas (${(traePromosVendidas(pm.Get("id"), traeCliente)).As(Int)}) = ${mp}"$)
mp = 0
If maxPromos.Size > 0 Then
mp0 = maxPromos.Get(0)
Log(mp0)
mp = mp0 - traePromosVendidas(pm.Get("id"), traeCliente)
If thisLog Then Log($"Max Promos (${mp0}) - promos vendidas (${(traePromosVendidas(pm.Get("id"), traeCliente)).As(Int)}) = ${mp}"$)
End If
Return mp 'Regresamos el numero mas pequeño de las opciones.
End Sub