mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-20 03:29:14 +00:00
Se corrige un error que permitía meter promocijes de mas y dejaba inventario en negativo.
- Cuando el producto fijo de una promocion tambien es parte de los productos variables de la misma, al aumentar la cantidad de promociones a comprar, el invenatrio del producto variable no se actualizaba. ej. Si la promo usa 3 productos fijos y quedan 10 para los variables, cuando pedimos 2 promociones, en lugar de usar 3 para los fijos, ahora vamos a necesitar 6, y en lugar de quedar 10 para los variables, ahora solo quedan 7.
This commit is contained in:
@@ -161,7 +161,10 @@ Sub muestraPromo(promo As String, cliente As String)
|
||||
Private estePrecio = listaPreciosPV.Get(indicePV)
|
||||
Private thisProd As Map = prodsPromo.Get(p)
|
||||
If thisLog Then Log(thisProd)
|
||||
If existenciaProdVariable > 0 Then clv_prodsVariabes.Add(CreateListItem(Subs.traeProdNombre(p)&CRLF&"Hay " & invDispPromo.Get(p) & " $" & estePrecio, estePrecio, invDispPromo.Get(p), clv_prodsVariabes.AsView.Width, 50dip, Null, p), p)
|
||||
If existenciaProdVariable > 0 Then
|
||||
Log($">>>>> AGREGAMOS PROD VARIABLE ${p}"$)
|
||||
clv_prodsVariabes.Add(CreateListItem(Subs.traeProdNombre(p)&CRLF&"Hay " & invDispPromo.Get(p) & " $" & estePrecio, estePrecio, invDispPromo.Get(p), clv_prodsVariabes.AsView.Width, 50dip, Null, p), p)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
b_terminar1.Visible = False
|
||||
@@ -224,6 +227,7 @@ Sub CreateListItem(Text As String, precioU As String, inv As Int, Width As Int,
|
||||
et_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
et_pCant.BringToFront
|
||||
' i_prod.Bitmap = img
|
||||
p.Tag = prodId
|
||||
Return p
|
||||
End Sub
|
||||
|
||||
@@ -272,8 +276,8 @@ Sub b_prodMas_Click
|
||||
' Private inv As String = Regex.Split("\|", laCant.tag)(1)
|
||||
Private prodId As String = Regex.Split("\|", laCant.tag)(2)
|
||||
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":estaPromo)
|
||||
' Log(tmpMap)
|
||||
promosMap.Put(prodId, tmpMap)
|
||||
Log("PRODMAS PROMOSMAP - " & promosMap)
|
||||
' LogColor(promosMap, Colors.Magenta)
|
||||
End If
|
||||
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
@@ -349,14 +353,14 @@ Sub cuentaProds
|
||||
' Log($"Termina cuentaProds - ${Starter.cp_running}"$)
|
||||
|
||||
'Si la cantidad es mayor que los productos requeridos, entonces ponemos todos en CERO.
|
||||
If totalProds > prodsVarReq + tpf Then
|
||||
For i = 0 To clv_prodsVariabes.GetSize - 1
|
||||
Private p0 As B4XView = clv_prodsVariabes.GetPanel(i)
|
||||
Private p As B4XView = p0.GetView(0)
|
||||
Private cant1 As B4XView = p.GetView(2).GetView(4)
|
||||
cant1.Text = 0
|
||||
Next
|
||||
End If
|
||||
' If totalProds > prodsVarReq + tpf Then
|
||||
' For i = 0 To clv_prodsVariabes.GetSize - 1
|
||||
' Private p0 As B4XView = clv_prodsVariabes.GetPanel(i)
|
||||
' Private p As B4XView = p0.GetView(0)
|
||||
' Private cant1 As B4XView = p.GetView(2).GetView(4)
|
||||
' cant1.Text = 0
|
||||
' Next
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
|
||||
@@ -374,6 +378,24 @@ Private Sub b_promoMenos_Click
|
||||
tpf = tpf2 * et_promoCant.Text.As(Int)
|
||||
prodsVarReq = prodsVarReq2 * et_promoCant.Text.As(Int)
|
||||
Log($"Max promos=${et_promoCant.Text.As(Int)}, Prods fijos=${tpf}, "$)
|
||||
|
||||
Private invVariableMod As Map = revisaInvProdsVariables 'Si se modifica el inventario de los prods variables, recargamos el CLV de prods variables.
|
||||
If invVariableMod.Size > 0 Then
|
||||
Private listProds As List
|
||||
listProds.Initialize
|
||||
For i = 0 To clv_prodsVariabes.Size - 1 'Generamos una lista con los productos del CLV.
|
||||
Private pa1 As B4XView = clv_prodsVariabes.GetPanel(i).GetView(0).GetView(2).GetView(4)
|
||||
Private elTag() As String = Regex.Split("\|", pa1.Tag)
|
||||
Private elInv As Int = elTag(1)
|
||||
If invVariableMod.ContainsKey(elTag(2)) Then elInv = invVariableMod.Get(elTag(2))
|
||||
listProds.Add(CreateListItem(Subs.traeProdNombre(elTag(2))&CRLF&"Hay " & elInv & " $" & elTag(0), elTag(0), elInv, clv_prodsVariabes.AsView.Width, 50dip, Null, elTag(2)))
|
||||
Next
|
||||
clv_prodsVariabes.Clear
|
||||
For i = 0 To listProds.Size - 1 'Usamos la lista para poblar el CLV con los datos modificados.
|
||||
clv_prodsVariabes.Add(listProds.Get(i), listProds.Get(i).As(Panel).tag)
|
||||
Next
|
||||
End If
|
||||
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
@@ -387,9 +409,61 @@ Private Sub b_promoMas_Click
|
||||
Log($"Max promos=${et_promoCant.Text.As(Int)}, Prods fijos=${tpf}, "$)
|
||||
End If
|
||||
If et_promoCant.text > maxCantPromos Then et_promoCant.Text = maxCantPromos
|
||||
|
||||
Private invVariableMod As Map = revisaInvProdsVariables 'Si se modifica el inventario de los prods variables, necesitamos recargar el CLV de prods variables.
|
||||
If invVariableMod.Size > 0 Then
|
||||
Private listProds As List
|
||||
listProds.Initialize
|
||||
For i = 0 To clv_prodsVariabes.Size - 1 'Generamos una lista con los productos del CLV.
|
||||
Private pa1 As B4XView = clv_prodsVariabes.GetPanel(i).GetView(0).GetView(2).GetView(4)
|
||||
Private elTag() As String = Regex.Split("\|", pa1.Tag)
|
||||
Private elInv As Int = elTag(1)
|
||||
If invVariableMod.ContainsKey(elTag(2)) Then elInv = invVariableMod.Get(elTag(2))
|
||||
listProds.Add(CreateListItem(Subs.traeProdNombre(elTag(2))&CRLF&"Hay " & elInv & " $" & elTag(0), elTag(0), elInv, clv_prodsVariabes.AsView.Width, 50dip, Null, elTag(2)))
|
||||
Next
|
||||
clv_prodsVariabes.Clear
|
||||
For i = 0 To listProds.Size - 1 'Usamos la lista para poblar el CLV con los datos modificados.
|
||||
clv_prodsVariabes.Add(listProds.Get(i), listProds.Get(i).As(Panel).tag)
|
||||
Next
|
||||
End If
|
||||
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
' Revisa si el inventario de un producto variable cambia cuando se modifica la cantidad de promociones que se van a ordenar.
|
||||
' Esto pasa cuando el producto fijo de una promocion tambien es parte de los productos variables de la misma, asi que
|
||||
' si la promo usa 3 productos fijos y quedan 10 para los variables, cuando pedimos 2 promociones, en lugar de usar
|
||||
' 3 para los fijos, ahora vamos a necesitar 6, y en lugar de quedar 10 para los variables, ahora solo quedan 7.
|
||||
' Regresa un mapa con el nuevo inventario de los productos variables afectados.
|
||||
Sub revisaInvProdsVariables As Map
|
||||
Private invVariablesModificados As Map = CreateMap()
|
||||
' Private prodsFijosOriginales As Int = (tpf / et_promoCant.Text)
|
||||
' LogColor($"Prods fijos originales = ${prodsFijosOriginales}"$, Colors.Red)
|
||||
Private nuevoInvDisponible As Int
|
||||
For f = 0 To prodsIds.Size - 1
|
||||
' Log(prodsIds.Get(f))
|
||||
' LogColor($"${prodsIds.Get(f)} -> ${prodsCants.Get(f)}"$, Colors.Red)
|
||||
For i = 0 To clv_prodsVariabes.GetSize - 1
|
||||
Private pa0 As B4XView = clv_prodsVariabes.GetPanel(i).GetView(0).GetView(1)
|
||||
Private pa1 As B4XView = clv_prodsVariabes.GetPanel(i).GetView(0).GetView(2).GetView(4)
|
||||
Private pp As String = pa1.Tag
|
||||
' Log($"EL TAG -> ${pp}"$)
|
||||
Private elTag() As String = Regex.Split("\|", pp)
|
||||
If elTag.Length > 1 Then
|
||||
If elTag(2) = prodsIds.Get(f) Then
|
||||
Private invDeBD As Int = Subs.traeInvDeBD(elTag(2))
|
||||
' Log($"XXX -> ${pa0.text} -> ${invDeBD}"$)
|
||||
nuevoInvDisponible = invDeBD - tpf
|
||||
LogColor($"Nuevo inv desponible = ${invDeBD} - ${tpf} = ${nuevoInvDisponible}"$, Colors.Red)
|
||||
invVariablesModificados.Put(prodsIds.Get(f), nuevoInvDisponible)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
Log($"INV MODIFICADOS: ${invVariablesModificados}"$)
|
||||
Return invVariablesModificados
|
||||
End Sub
|
||||
|
||||
Private Sub b_terminar1_Click
|
||||
cuentaProds
|
||||
' Log("====================================================================")
|
||||
|
||||
Reference in New Issue
Block a user