mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-20 19:49:12 +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:
@@ -468,6 +468,11 @@ Sub B4XPage_Appear
|
|||||||
LogColor("Permisos de almacenamiento: " & MES1.HasPermission, Colors.Magenta)
|
LogColor("Permisos de almacenamiento: " & MES1.HasPermission, Colors.Magenta)
|
||||||
' If MES1.HasPermission Then kh.revisaSiExisteRespaldo '' Se comenta causa el error de que en el primer cliente,al guardar la venta se trabe la aplicacion!!
|
' If MES1.HasPermission Then kh.revisaSiExisteRespaldo '' Se comenta causa el error de que en el primer cliente,al guardar la venta se trabe la aplicacion!!
|
||||||
End If
|
End If
|
||||||
|
Private cu As Cursor = Starter.skmt.ExecQuery("select USUARIO from USUARIOA")
|
||||||
|
If cu.RowCount > 0 Then
|
||||||
|
cu.Position = 0
|
||||||
|
If cu.GetString("USUARIO") <> "" Then user.Text = cu.GetString("USUARIO")
|
||||||
|
End If
|
||||||
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
|
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
|
||||||
Starter.skmt.ExecNonQuery($"insert into versiones (version, fecha) values ('${Application.VersionName}', '${DateTime.Date(DateTime.Now)}')"$)
|
Starter.skmt.ExecNonQuery($"insert into versiones (version, fecha) values ('${Application.VersionName}', '${DateTime.Date(DateTime.Now)}')"$)
|
||||||
End Sub
|
End Sub
|
||||||
@@ -1027,4 +1032,5 @@ End Sub
|
|||||||
Private Sub ImageView1_LongClick
|
Private Sub ImageView1_LongClick
|
||||||
Log("###### TRAEMOS FECHA #######")
|
Log("###### TRAEMOS FECHA #######")
|
||||||
GetFecha
|
GetFecha
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
@@ -41,11 +41,13 @@ Sub Class_Globals
|
|||||||
Private L_TOTAL_D As Label
|
Private L_TOTAL_D As Label
|
||||||
Private l_tipoPedido As Label
|
Private l_tipoPedido As Label
|
||||||
Dim pedidoMostrado As String = "NORMAL"
|
Dim pedidoMostrado As String = "NORMAL"
|
||||||
|
Dim ts As C_TrendSpending
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'You can add more parameters here.
|
'You can add more parameters here.
|
||||||
Public Sub Initialize As Object
|
Public Sub Initialize As Object
|
||||||
kh.Initialize(Me, "kh", Starter.skmt)
|
kh.Initialize(Me, "kh", Starter.skmt)
|
||||||
|
ts.Initialize(Me, "ts", Starter.skmt)
|
||||||
Return Me
|
Return Me
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -142,7 +144,7 @@ Sub B4XPage_Appear
|
|||||||
C_DOE=Starter.skmt.ExecQuery2("select sum(pe_cant) AS CANTIDAD, sum(pe_costo_tot) AS MONTO from pedido where PE_CEDIS <> PE_PROID and pe_cliente in (Select CUENTA from cuentaa) AND PE_CEDIS = ?", Array As String("DOE"))
|
C_DOE=Starter.skmt.ExecQuery2("select sum(pe_cant) AS CANTIDAD, sum(pe_costo_tot) AS MONTO from pedido where PE_CEDIS <> PE_PROID and pe_cliente in (Select CUENTA from cuentaa) AND PE_CEDIS = ?", Array As String("DOE"))
|
||||||
C_DOE.Position=0
|
C_DOE.Position=0
|
||||||
L_CANT_D.Text = C_DOE.GetString("CANTIDAD")
|
L_CANT_D.Text = C_DOE.GetString("CANTIDAD")
|
||||||
L_TOTAL_D.Text = numberformat2(kh.traeTotalCliente, 1, 2, 2, True)
|
L_TOTAL_D.Text = NumberFormat2(kh.traeTotalCliente, 1, 2, 2, True)
|
||||||
c.Close
|
c.Close
|
||||||
Else
|
Else
|
||||||
B_PEDIDO_DOE.VISIBLE = False
|
B_PEDIDO_DOE.VISIBLE = False
|
||||||
@@ -274,7 +276,11 @@ Sub borra_Click
|
|||||||
' Starter.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
' Starter.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||||
' Starter.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
|
' Starter.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
|
||||||
' Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
' Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||||
If pedidoMostrado = "DOE" Then Subs.borraPedidoDOEClienteActual Else Subs.borraPedidoClienteActual
|
If pedidoMostrado = "DOE" Then
|
||||||
|
Subs.borraPedidoDOEClienteActual
|
||||||
|
Else
|
||||||
|
Subs.borraPedidoClienteActual
|
||||||
|
End If
|
||||||
' B4XPages.MainPage.productos.prodsMap.Initialize 'inicializamos mapa de productos para que no aparezcan como vendidos en la lista
|
' B4XPages.MainPage.productos.prodsMap.Initialize 'inicializamos mapa de productos para que no aparezcan como vendidos en la lista
|
||||||
B4XPages.MainPage.promos.promosMap.Initialize
|
B4XPages.MainPage.promos.promosMap.Initialize
|
||||||
' Log("Llamamos LlenaProdsLL")
|
' Log("Llamamos LlenaProdsLL")
|
||||||
@@ -469,12 +475,18 @@ Private Sub clv_pedidos_ItemLongClick (position As Int, Value As Object)
|
|||||||
Starter.skmt.ExecNonQuery($"update ${Subs.traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ${pPromos.GetString("PE_CANT")} where cat_gp_id = '${pPromos.Getstring("PE_PROID")}'"$)
|
Starter.skmt.ExecNonQuery($"update ${Subs.traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ${pPromos.GetString("PE_CANT")} where cat_gp_id = '${pPromos.Getstring("PE_PROID")}'"$)
|
||||||
Next
|
Next
|
||||||
Starter.skmt.ExecNonQuery2("delete from pedido where pe_cedis in (select pe_cedis from pedido where PE_CEDIS = ? and pe_pronombre = ?) and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(m.Get("cedis"), Value))
|
Starter.skmt.ExecNonQuery2("delete from pedido where pe_cedis in (select pe_cedis from pedido where PE_CEDIS = ? and pe_pronombre = ?) and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(m.Get("cedis"), Value))
|
||||||
|
Private precio0 As String = Subs.traePrecio(prod.GetString("PE_PROID"))
|
||||||
|
Private precioConDesc As String = (B4XPages.MainPage.cliente.kh.traeDescXSku(Subs.traeCliente, prod.GetString("PE_PROID"))/100)*precio0
|
||||||
|
ts.modTrendSpending("suma", "descuentos", (precioConDesc * prod.GetString("PE_CANT")))
|
||||||
Else
|
Else
|
||||||
If thisLog Then Log($"SUMAMOS ${m.get("cant")} a ${m.get("prodId")} "$)
|
If thisLog Then Log($"SUMAMOS ${m.get("cant")} a ${m.get("prodId")} "$)
|
||||||
'Si no es RMI, actualizamos el inventario.
|
'Si no es RMI, actualizamos el inventario.
|
||||||
If prod.GetString("PE_CEDIS") <> "DUR" Then Starter.skmt.ExecNonQuery2($"update ${Subs.traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?"$, Array As Object(m.get("cant"), m.get("prodId")))
|
If prod.GetString("PE_CEDIS") <> "DUR" Then Starter.skmt.ExecNonQuery2($"update ${Subs.traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?"$, Array As Object(m.get("cant"), m.get("prodId")))
|
||||||
If thisLog Then Log($"BORRAMOS ${Value}, ${m.Get("cedis")}"$)
|
If thisLog Then Log($"BORRAMOS ${Value}, ${m.Get("cedis")}"$)
|
||||||
Starter.skmt.ExecNonQuery2("delete from pedido where pe_pronombre = ? and pe_cedis = ? and pe_cant = ? and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value, m.Get("cedis"), m.Get("cant")))
|
Starter.skmt.ExecNonQuery2("delete from pedido where pe_pronombre = ? and pe_cedis = ? and pe_cant = ? and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value, m.Get("cedis"), m.Get("cant")))
|
||||||
|
Private precio0 As String = Subs.traePrecio(prod.GetString("PE_PROID"))
|
||||||
|
Private precioConDesc As String = (B4XPages.MainPage.cliente.kh.traeDescXSku(Subs.traeCliente, prod.GetString("PE_PROID"))/100)*precio0
|
||||||
|
ts.modTrendSpending("suma", "descuentos", (precioConDesc * prod.GetString("PE_CANT")))
|
||||||
End If
|
End If
|
||||||
prod.Close
|
prod.Close
|
||||||
DateTime.DateFormat = "MM/dd/yyyy"
|
DateTime.DateFormat = "MM/dd/yyyy"
|
||||||
|
|||||||
@@ -943,9 +943,9 @@ Sub cargar_Click
|
|||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "traeInfoTrendSpending"
|
cmd.Name = "traeInfoTrendSpending"
|
||||||
' cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
' cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
||||||
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
cmd.Parameters = Array As Object(238, 2)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "trendSpending")
|
reqManager.ExecuteQuery(cmd , 0, "trendSpending")
|
||||||
LogColor($"Trend Spending: Ruta: ${e_ruta.text}, almacen: ${ALMACEN}"$, Colors.red)
|
LogColor($"Trade Spending: Ruta: ${e_ruta.text}, almacen: ${ALMACEN}"$, Colors.red)
|
||||||
|
|
||||||
If E_RUTA2.Text <> "" Then
|
If E_RUTA2.Text <> "" Then
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
@@ -2101,7 +2101,7 @@ Sub JobDone(Job As HttpJob)
|
|||||||
' If Starter.Logger Then Log($"tiempo Total "${Job.Tag}": ${((DateTime.Now - inicioContador)/1000)}"$)
|
' If Starter.Logger Then Log($"tiempo Total "${Job.Tag}": ${((DateTime.Now - inicioContador)/1000)}"$)
|
||||||
|
|
||||||
If CARGA = "CARGAR" And S_CP.Text = "LISTO" And S_CC.Text = "LISTO" And S_CH.Text = "LISTO" Then
|
If CARGA = "CARGAR" And S_CP.Text = "LISTO" And S_CC.Text = "LISTO" And S_CH.Text = "LISTO" Then
|
||||||
LogColor("TERMINAMOS", Colors.red)
|
' LogColor("TERMINAMOS", Colors.red)
|
||||||
B_OK_PAS.Text = "OK"
|
B_OK_PAS.Text = "OK"
|
||||||
copiaCatGPPromocion
|
copiaCatGPPromocion
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ Sub B4XPage_Appear
|
|||||||
TS_RMI = Regex.Split(",", mx.Get("RMI"))
|
TS_RMI = Regex.Split(",", mx.Get("RMI"))
|
||||||
TS_DESCUENTOS = Regex.Split(",", mx.Get("DESCUENTOS"))
|
TS_DESCUENTOS = Regex.Split(",", mx.Get("DESCUENTOS"))
|
||||||
TS_BONIFICACIONES = Regex.Split(",", mx.Get("BONIFICACIONES"))
|
TS_BONIFICACIONES = Regex.Split(",", mx.Get("BONIFICACIONES"))
|
||||||
Log(">>>>>>>>>>>>> TRENDSPENDING: " & mx)
|
Log(">>>>>>>>>>>>> TRADESPENDING: " & mx)
|
||||||
Log("RMI: " & TS_RMI(0) & "|" & TS_RMI(1))
|
Log("RMI: " & TS_RMI(0) & "|" & TS_RMI(1))
|
||||||
Log("DESCUENTOS: " & TS_DESCUENTOS(0) & "|" & TS_DESCUENTOS(1))
|
Log("DESCUENTOS: " & TS_DESCUENTOS(0) & "|" & TS_DESCUENTOS(1))
|
||||||
Log("BONIFICACIONES: " & TS_BONIFICACIONES(0) & "|" & TS_BONIFICACIONES(1))
|
Log("BONIFICACIONES: " & TS_BONIFICACIONES(0) & "|" & TS_BONIFICACIONES(1))
|
||||||
@@ -314,6 +314,7 @@ Sub lv_catalogos_ItemClick (Position As Int, Value As Object)
|
|||||||
If hayPedido Then p_botonesVenta.Visible = True 'Si ya hay pedido, entonces mostramos los botones.
|
If hayPedido Then p_botonesVenta.Visible = True 'Si ya hay pedido, entonces mostramos los botones.
|
||||||
l_mDisponible.Visible = False
|
l_mDisponible.Visible = False
|
||||||
Else
|
Else
|
||||||
|
Log("ENTRAMOS A PROMOS")
|
||||||
clv_prods_ll.AsView.Visible = False
|
clv_prods_ll.AsView.Visible = False
|
||||||
lv_promos.Visible = True
|
lv_promos.Visible = True
|
||||||
lfila.text = "PROMOCIONES"
|
lfila.text = "PROMOCIONES"
|
||||||
@@ -686,7 +687,7 @@ Sub b_prodMas_Click
|
|||||||
' Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
' Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
||||||
' Log($"Existencias: ${inv}, inv: ${Subs.traeinventario(pnl.GetView(1).Tag)}"$)
|
' Log($"Existencias: ${inv}, inv: ${Subs.traeinventario(pnl.GetView(1).Tag)}"$)
|
||||||
Private inv As Int = Subs.traeinventario(pnl.GetView(1).Tag)
|
Private inv As Int = Subs.traeinventario(pnl.GetView(1).Tag)
|
||||||
Log($"inv: ${Subs.traeinventario(pnl.GetView(1).Tag)}"$)
|
' Log($"inv: ${Subs.traeinventario(pnl.GetView(1).Tag)}"$)
|
||||||
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
|
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
|
||||||
Private almacenX As String = Subs.traeAlmacen
|
Private almacenX As String = Subs.traeAlmacen
|
||||||
Private nombreX As String = Subs.traeProdNombre(id)
|
Private nombreX As String = Subs.traeProdNombre(id)
|
||||||
@@ -721,10 +722,10 @@ Sub b_prodMas_Click
|
|||||||
Private tsRestantes As String = (TS_DESCUENTOS(0) - TS_DESCUENTOS(1) - ts.traeAcumuladoHoyTS("descuentos")) ' Traemos monto restante de Trend Spending para bonificaciones.
|
Private tsRestantes As String = (TS_DESCUENTOS(0) - TS_DESCUENTOS(1) - ts.traeAcumuladoHoyTS("descuentos")) ' Traemos monto restante de Trend Spending para bonificaciones.
|
||||||
tsMonto = NumberFormat2(ts.traePrecio(id)*(ts.traeDescXSku(clienteId, id)/100), 1, 2, 2, False) ' Traemos el monto (descuento total) del producto actual.
|
tsMonto = NumberFormat2(ts.traePrecio(id)*(ts.traeDescXSku(clienteId, id)/100), 1, 2, 2, False) ' Traemos el monto (descuento total) del producto actual.
|
||||||
tsMaximas = ((laCant.text * tsMonto) + tsRestantes) / tsMonto ' Traemos la cantidad maxima de descuentos por presupuesto de Trend Spending.
|
tsMaximas = ((laCant.text * tsMonto) + tsRestantes) / tsMonto ' Traemos la cantidad maxima de descuentos por presupuesto de Trend Spending.
|
||||||
Log("tsRestantes: " & tsRestantes)
|
' Log("tsRestantes: " & tsRestantes)
|
||||||
' Log("tsMonto: " & tsMonto)
|
' Log("tsMonto: " & tsMonto)
|
||||||
Log("tsMaximas: " & tsMaximas)
|
Log("tsMaximas: " & tsMaximas)
|
||||||
Log("tsMaximas2: " & ts.traeMaximas("descuentos", clienteId, id, laCant.Text, ""))
|
' Log("tsMaximas2: " & ts.traeMaximas("descuentos", clienteId, id, laCant.Text, ""))
|
||||||
' Log("tsMonto2: " & ts.traeMonto(clienteId, id))
|
' Log("tsMonto2: " & ts.traeMonto(clienteId, id))
|
||||||
Else if lfila.Text = "RMI" Then
|
Else if lfila.Text = "RMI" Then
|
||||||
Log(">>>>>>>>>> RMI <<<<<<<<<<<<<<")
|
Log(">>>>>>>>>> RMI <<<<<<<<<<<<<<")
|
||||||
@@ -748,13 +749,16 @@ Sub b_prodMas_Click
|
|||||||
' Log(inv > 0)
|
' Log(inv > 0)
|
||||||
' Log(tsMonto.As(Int) = 0)
|
' Log(tsMonto.As(Int) = 0)
|
||||||
|
|
||||||
|
If laCant.Text + 1 > tsMaximas Then 'lfila.Text = "PRODUCTOS" and
|
||||||
|
ToastMessageShow("¡Presupuesto de descuentos alcanzado!", False)
|
||||||
|
End If
|
||||||
If 1 = 2 And buttonTag = "vendido" And lfila.Text = "PRODUCTOS" Then
|
If 1 = 2 And buttonTag = "vendido" And lfila.Text = "PRODUCTOS" Then
|
||||||
' Log(11)
|
' Log(11)
|
||||||
' Log("VENDIDO")
|
' Log("VENDIDO")
|
||||||
Log($"${(laCant.Text + 1 <= inv)} And ${(kh.totalPedido - precio > 1)}"$)
|
Log($"${(laCant.Text + 1 <= inv)} And ${(kh.totalPedido - precio > 1)}"$)
|
||||||
' If inv > 0 And (laCant.Text + 1 <= (laCant.Text + existencias)) And (kh.totalPedido - precio > 1) Then
|
' If inv > 0 And (laCant.Text + 1 <= (laCant.Text + existencias)) And (kh.totalPedido - precio > 1) Then
|
||||||
If inv > 0 And (kh.totalPedido - precio > 1) Then
|
If inv > 0 And (kh.totalPedido - precio > 1) Then
|
||||||
Log(2)
|
' Log(2)
|
||||||
' Log(clv_prods_ll.GetValue(index).As(Map))
|
' Log(clv_prods_ll.GetValue(index).As(Map))
|
||||||
clv_prods_ll.GetValue(index).As(Map).Put("almacen", (inv - 1))
|
clv_prods_ll.GetValue(index).As(Map).Put("almacen", (inv - 1))
|
||||||
inv = inv - 1
|
inv = inv - 1
|
||||||
@@ -788,7 +792,8 @@ Sub b_prodMas_Click
|
|||||||
' Log(77)
|
' Log(77)
|
||||||
laCant.Text = "0"
|
laCant.Text = "0"
|
||||||
End If
|
End If
|
||||||
' Log(99)
|
|
||||||
|
Log(99)
|
||||||
If lfila.Text = "RMI" Then
|
If lfila.Text = "RMI" Then
|
||||||
almacenX = "DUR"
|
almacenX = "DUR"
|
||||||
nombreX = "CAMBIO"&Subs.traeRMINombre(id)
|
nombreX = "CAMBIO"&Subs.traeRMINombre(id)
|
||||||
@@ -1145,7 +1150,7 @@ End Sub
|
|||||||
Private Sub lv_promos_ItemLongClick (Position As Int, Value As Object)
|
Private Sub lv_promos_ItemLongClick (Position As Int, Value As Object)
|
||||||
Log("Promo longclic = "&Value)
|
Log("Promo longclic = "&Value)
|
||||||
Private id As String = ""
|
Private id As String = ""
|
||||||
Dim c As Cursor = Starter.skmt.ExecQuery($"select CAT_GP_ID from cat_gunaprod where CAT_GP_TIPO = 'PROMOS' and CAT_GP_NOMBRE = '${Value}'"$)
|
Dim c As Cursor = Starter.skmt.ExecQuery($"select CAT_GP_ID from ${Subs.traeTablaProds(starter.tipov)} where CAT_GP_TIPO = 'PROMOS' and CAT_GP_NOMBRE = '${Value}'"$)
|
||||||
If c.RowCount > 0 Then
|
If c.RowCount > 0 Then
|
||||||
c.Position = 0
|
c.Position = 0
|
||||||
id = c.GetString("CAT_GP_ID")
|
id = c.GetString("CAT_GP_ID")
|
||||||
@@ -1517,7 +1522,7 @@ Sub LlenaProdsLL(p As ResultSet, extra As String)
|
|||||||
Else
|
Else
|
||||||
' Log("NO HAY RESULTSET")
|
' Log("NO HAY RESULTSET")
|
||||||
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPO, CAT_GP_TIPOPROD from ${Subs.traeTablaProds(Starter.tipov)} where CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' and CAT_GP_PROMOCION <> '1' ORDER BY CAT_GP_TIPOPROD2 DESC, CAT_GP_NOMBRE"$)
|
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPO, CAT_GP_TIPOPROD from ${Subs.traeTablaProds(Starter.tipov)} where CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' and CAT_GP_PROMOCION <> '1' ORDER BY CAT_GP_TIPOPROD2 DESC, CAT_GP_NOMBRE"$)
|
||||||
If Starter.Logger Then Log($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPO, CAT_GP_TIPOPROD from ${Subs.traeTablaProds(Starter.tipov)} where CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' and CAT_GP_PROMOCION <> '1' ORDER BY CAT_GP_TIPOPROD2 DESC, CAT_GP_NOMBRE"$)
|
' If Starter.Logger Then Log($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPO, CAT_GP_TIPOPROD from ${Subs.traeTablaProds(Starter.tipov)} where CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' and CAT_GP_PROMOCION <> '1' ORDER BY CAT_GP_TIPOPROD2 DESC, CAT_GP_NOMBRE"$)
|
||||||
' Log(p.RowCount & " - " & Subs.traeTablaProds(Starter.tipov))
|
' Log(p.RowCount & " - " & Subs.traeTablaProds(Starter.tipov))
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@@ -1556,7 +1561,7 @@ Sub LlenaProdsLL(p As ResultSet, extra As String)
|
|||||||
listaProdsConCant.Initialize
|
listaProdsConCant.Initialize
|
||||||
listaProdsConCantIndex.Initialize
|
listaProdsConCantIndex.Initialize
|
||||||
listaHints.Initialize
|
listaHints.Initialize
|
||||||
Log(listaProds)
|
' Log(listaProds)
|
||||||
For q = 0 To listaProds.Size - 1' Sacamos los productos con cantidad previa.
|
For q = 0 To listaProds.Size - 1' Sacamos los productos con cantidad previa.
|
||||||
If listaProds.Get(q).As(Map).Get("cant").As(Int) <> 0 Then
|
If listaProds.Get(q).As(Map).Get("cant").As(Int) <> 0 Then
|
||||||
' Log(listaProds.Get(q).As(Map).Get("cant"))
|
' Log(listaProds.Get(q).As(Map).Get("cant"))
|
||||||
|
|||||||
@@ -85,7 +85,9 @@ End Sub
|
|||||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
Sub muestraPromo(promo As String, cliente As String)
|
Sub muestraPromo(promo As String, cliente As String)
|
||||||
Log("muestraPromo:"&promo)
|
LogColor($"****************************************************************"$, Colors.red)
|
||||||
|
LogColor($"************ muestraPromo: ${promo} *************"$, Colors.red)
|
||||||
|
' Log("muestraPromo: "&promo)
|
||||||
Private thisLog As Boolean = False
|
Private thisLog As Boolean = False
|
||||||
' If thisLog Then Log(promo)
|
' If thisLog Then Log(promo)
|
||||||
estaPromo = promo
|
estaPromo = promo
|
||||||
@@ -166,7 +168,7 @@ Sub muestraPromo(promo As String, cliente As String)
|
|||||||
Private thisProd As Map = prodsPromo.Get(p)
|
Private thisProd As Map = prodsPromo.Get(p)
|
||||||
If thisLog Then Log(thisProd)
|
If thisLog Then Log(thisProd)
|
||||||
If existenciaProdVariable > 0 Then
|
If existenciaProdVariable > 0 Then
|
||||||
Log($">>>>> AGREGAMOS PROD VARIABLE ${p}"$)
|
If thisLog 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)
|
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
|
||||||
End If
|
End If
|
||||||
@@ -338,6 +340,7 @@ Sub cuentaProds
|
|||||||
End If
|
End If
|
||||||
l_total.Text = $"Total: $$1.2{totalCompra}"$
|
l_total.Text = $"Total: $$1.2{totalCompra}"$
|
||||||
l_totProds.text = $"Productos: ${totalProds}"$
|
l_totProds.text = $"Productos: ${totalProds}"$
|
||||||
|
' Log(esteTag.Get(2) & "|" & estaPromo)
|
||||||
Next
|
Next
|
||||||
If thisLog Then Log($"Total Prods: ${totalProds}, Total: $$1.2{totalCompra}"$)
|
If thisLog Then Log($"Total Prods: ${totalProds}, Total: $$1.2{totalCompra}"$)
|
||||||
l_total.Text = $"Total: $$1.2{totalCompra}"$
|
l_total.Text = $"Total: $$1.2{totalCompra}"$
|
||||||
@@ -365,6 +368,7 @@ Sub cuentaProds
|
|||||||
' cant1.Text = 0
|
' cant1.Text = 0
|
||||||
' Next
|
' Next
|
||||||
' End If
|
' End If
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
|
Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
|
||||||
@@ -470,6 +474,7 @@ End Sub
|
|||||||
|
|
||||||
Private Sub b_terminar1_Click
|
Private Sub b_terminar1_Click
|
||||||
cuentaProds
|
cuentaProds
|
||||||
|
Private elMontoTSDeLaVenta As String = 0
|
||||||
' Log("====================================================================")
|
' Log("====================================================================")
|
||||||
' Log($"${prodsIds}${CRLF}${prodsCants}${CRLF}${prodsPrecios}"$)
|
' Log($"${prodsIds}${CRLF}${prodsCants}${CRLF}${prodsPrecios}"$)
|
||||||
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
||||||
@@ -479,7 +484,12 @@ Private Sub b_terminar1_Click
|
|||||||
For t = 0 To prodsIds2.Size - 1 'Guardamos los productos variables de la promocion en pedido.
|
For t = 0 To prodsIds2.Size - 1 'Guardamos los productos variables de la promocion en pedido.
|
||||||
Private pn As String = Subs.traeProdNombre(prodsIds2.Get(t))
|
Private pn As String = Subs.traeProdNombre(prodsIds2.Get(t))
|
||||||
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios2.Get(t), prodsCants2.Get(t), pn, prodsIds2.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios2.Get(t), prodsCants2.Get(t), pn, prodsIds2.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
||||||
|
' Traemos el monto de las bonificacionos a guardar. -- Trade Spending
|
||||||
|
Log("Monto Bonificacion -->> " & ts.traeMontoBonificacion(prodsIds2.Get(t), estaPromo))
|
||||||
|
elMontoTSDeLaVenta = elMontoTSDeLaVenta + (ts.traeMontoBonificacion(prodsIds2.Get(t), estaPromo) * prodsCants2.Get(t))
|
||||||
|
Log("Acumulado: " & elMontoTSDeLaVenta)
|
||||||
Next
|
Next
|
||||||
|
ts.modTrendSpending("RESTA", "BONIFICACIONES", elMontoTSDeLaVenta)
|
||||||
lv_prodsFijos.Clear
|
lv_prodsFijos.Clear
|
||||||
B4XPages.MainPage.bTerminarClicked = True
|
B4XPages.MainPage.bTerminarClicked = True
|
||||||
B4XPages.ShowPage("productos")
|
B4XPages.ShowPage("productos")
|
||||||
@@ -488,6 +498,7 @@ End Sub
|
|||||||
|
|
||||||
Private Sub b_continuar_Click
|
Private Sub b_continuar_Click
|
||||||
cuentaProds
|
cuentaProds
|
||||||
|
Private elMontoTSDeLaVenta As String = 0
|
||||||
' Log("====================================================================")
|
' Log("====================================================================")
|
||||||
Log($"${prodsIds}${CRLF}${prodsCants}${CRLF}${prodsPrecios}"$)
|
Log($"${prodsIds}${CRLF}${prodsCants}${CRLF}${prodsPrecios}"$)
|
||||||
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
||||||
@@ -497,7 +508,12 @@ Private Sub b_continuar_Click
|
|||||||
For t = 0 To prodsIds2.Size - 1 'Guardamos los productos variables de la promocion en pedido.
|
For t = 0 To prodsIds2.Size - 1 'Guardamos los productos variables de la promocion en pedido.
|
||||||
Private pn As String = Subs.traeProdNombre(prodsIds2.Get(t))
|
Private pn As String = Subs.traeProdNombre(prodsIds2.Get(t))
|
||||||
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios2.Get(t), prodsCants2.Get(t), pn, prodsIds2.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios2.Get(t), prodsCants2.Get(t), pn, prodsIds2.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
||||||
|
' Traemos el monto de las bonificacionos a guardar. -- Trade Spending
|
||||||
|
Log("Monto Bonificacion -->> " & ts.traeMontoBonificacion(prodsIds2.Get(t), estaPromo))
|
||||||
|
elMontoTSDeLaVenta = elMontoTSDeLaVenta + (ts.traeMontoBonificacion(prodsIds2.Get(t), estaPromo) * prodsCants2.Get(t))
|
||||||
|
Log("Acumulado: " & elMontoTSDeLaVenta)
|
||||||
Next
|
Next
|
||||||
|
ts.modTrendSpending("RESTA", "BONIFICACIONES", elMontoTSDeLaVenta)
|
||||||
lv_prodsFijos.Clear
|
lv_prodsFijos.Clear
|
||||||
' Activity_KeyPress(KeyCodes.KEYCODE_BACK)
|
' Activity_KeyPress(KeyCodes.KEYCODE_BACK)
|
||||||
' CallSubDelayed2(productos, "Activity_KeyPress", KeyCodes.KEYCODE_BACK)
|
' CallSubDelayed2(productos, "Activity_KeyPress", KeyCodes.KEYCODE_BACK)
|
||||||
|
|||||||
@@ -911,7 +911,7 @@ Version=12.8
|
|||||||
#Region Project Attributes
|
#Region Project Attributes
|
||||||
#ApplicationLabel: Kelloggs Venta
|
#ApplicationLabel: Kelloggs Venta
|
||||||
#VersionCode: 3000
|
#VersionCode: 3000
|
||||||
#VersionName: 5.06.25
|
#VersionName: 5.07.30
|
||||||
#SupportedOrientations: portrait
|
#SupportedOrientations: portrait
|
||||||
#CanInstallToExternalStorage: False
|
#CanInstallToExternalStorage: False
|
||||||
#BridgeLogger:true
|
#BridgeLogger:true
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ ModuleBreakpoints7=
|
|||||||
ModuleBreakpoints8=
|
ModuleBreakpoints8=
|
||||||
ModuleBreakpoints9=
|
ModuleBreakpoints9=
|
||||||
ModuleClosedNodes0=
|
ModuleClosedNodes0=
|
||||||
ModuleClosedNodes1=6,7,8,9,10,11,12,14,15,16
|
ModuleClosedNodes1=2,6,7,8,9,10,11,12,14,16
|
||||||
ModuleClosedNodes10=
|
ModuleClosedNodes10=
|
||||||
ModuleClosedNodes11=3,5,6
|
ModuleClosedNodes11=3,5,6
|
||||||
ModuleClosedNodes12=3,7,8,9,10,11,12
|
ModuleClosedNodes12=3,7,8,9,10,11,12
|
||||||
ModuleClosedNodes13=6,7,8,9,10,11,12,13,14,16,17
|
ModuleClosedNodes13=6,7,8,9,12,13
|
||||||
ModuleClosedNodes14=
|
ModuleClosedNodes14=
|
||||||
ModuleClosedNodes15=
|
ModuleClosedNodes15=2,3,7,8,15,17
|
||||||
ModuleClosedNodes16=
|
ModuleClosedNodes16=
|
||||||
ModuleClosedNodes17=
|
ModuleClosedNodes17=
|
||||||
ModuleClosedNodes18=
|
ModuleClosedNodes18=
|
||||||
@@ -87,9 +87,9 @@ ModuleClosedNodes26=
|
|||||||
ModuleClosedNodes27=4
|
ModuleClosedNodes27=4
|
||||||
ModuleClosedNodes28=
|
ModuleClosedNodes28=
|
||||||
ModuleClosedNodes29=
|
ModuleClosedNodes29=
|
||||||
ModuleClosedNodes3=5,6
|
ModuleClosedNodes3=1,3,5,6
|
||||||
ModuleClosedNodes30=
|
ModuleClosedNodes30=
|
||||||
ModuleClosedNodes31=115
|
ModuleClosedNodes31=114,116
|
||||||
ModuleClosedNodes32=
|
ModuleClosedNodes32=
|
||||||
ModuleClosedNodes4=
|
ModuleClosedNodes4=
|
||||||
ModuleClosedNodes5=
|
ModuleClosedNodes5=
|
||||||
@@ -97,6 +97,6 @@ ModuleClosedNodes6=
|
|||||||
ModuleClosedNodes7=
|
ModuleClosedNodes7=
|
||||||
ModuleClosedNodes8=
|
ModuleClosedNodes8=
|
||||||
ModuleClosedNodes9=
|
ModuleClosedNodes9=
|
||||||
NavigationStack=C_Promos,Initialize,45,0,C_Promos,Class_Globals,41,0,C_Productos,Class_Globals,5,0,C_Principal,cargar_Click,941,0,C_TrendSpending,Class_Globals,18,0,C_Principal,B4XPage_Appear,318,2,C_Principal,JobDone,2081,0,C_Principal,Class_Globals,213,0,C_Principal,Initialize,217,0,C_TrendSpending,Initialize,32,6
|
NavigationStack=Subs,traeMaxPromos,1180,0,Subs,alcanzanLosVariablesParaPromo,1159,0,Subs,revisaMaxPromosProdsFijosPorInventario,1346,1,C_TrendSpending,traeInfoTrendSpending,64,0,C_TrendSpending,traeMaximas,295,0,C_TrendSpending,traeBonificacionesMaximas,321,2,C_TrendSpending,maxPromosPorProdsVariables,370,0,C_Principal,cargar_Click,885,0,C_Cliente,B4XPage_Appear,545,0,kms_helperSubs,traeLimiteCredito,1279,0,kms_helperSubs,ping,1277,0
|
||||||
SelectedBuild=0
|
SelectedBuild=0
|
||||||
VisibleModules=1,30,11,19,15,3,31,12,28,16,18,13
|
VisibleModules=1,30,11,15,3,31,12,13,7,28,25
|
||||||
|
|||||||
159
B4A/Subs.bas
159
B4A/Subs.bas
@@ -1004,7 +1004,7 @@ End Sub
|
|||||||
' resultado="OK" 'Ok si existe la promocion.
|
' resultado="OK" 'Ok si existe la promocion.
|
||||||
' prodsVariablesRequeridos=5} 'Cantidad de productos variables requeridos para la promoción.
|
' prodsVariablesRequeridos=5} 'Cantidad de productos variables requeridos para la promoción.
|
||||||
Sub traePromo(promo As String, cliente As String) As Map
|
Sub traePromo(promo As String, cliente As String) As Map
|
||||||
Private thisLog As Boolean = True
|
Private thisLog As Boolean = False
|
||||||
If thisLog Then Log("traePromo:"&promo)
|
If thisLog Then Log("traePromo:"&promo)
|
||||||
Private inicioContador As String = DateTime.Now
|
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 las el maximo de promocioones a otorgar.
|
||||||
@@ -1076,7 +1076,10 @@ Sub traePromo(promo As String, cliente As String) As Map
|
|||||||
promoMap.Put("prodsVariablesCant", prodsVariables.Size)
|
promoMap.Put("prodsVariablesCant", prodsVariables.Size)
|
||||||
promoMap.Put("prodsVariablesPrecios", prodsVariablesPrecios)
|
promoMap.Put("prodsVariablesPrecios", prodsVariablesPrecios)
|
||||||
promoMap.Put("resultado", "ok")
|
promoMap.Put("resultado", "ok")
|
||||||
|
' LogColor($"****************************************************************"$, Colors.red)
|
||||||
|
LogColor("*********** Prods Fijos: " & prodsFijos.Size & " Prods Variables: " & prodsVariables.Size & " ************", Colors.red)
|
||||||
|
' LogColor("***************** Prods Variables: " & prodsVariables.Size & " *************", Colors.red)
|
||||||
|
LogColor($"****************************************************************"$, Colors.red)
|
||||||
Else
|
Else
|
||||||
promoMap.Put("resultado", "No hay datos de la promoción.")
|
promoMap.Put("resultado", "No hay datos de la promoción.")
|
||||||
End If
|
End If
|
||||||
@@ -1161,7 +1164,7 @@ End Sub
|
|||||||
'Revisa si tenemos los productos variables requeridos para la promoción (mapa).
|
'Revisa si tenemos los productos variables requeridos para la promoción (mapa).
|
||||||
'Hay que darle como parametro un mapa (traePromo(promo)) con toda la informacion de la promocion.
|
'Hay que darle como parametro un mapa (traePromo(promo)) con toda la informacion de la promocion.
|
||||||
Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As Boolean 'ignore
|
Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As Boolean 'ignore
|
||||||
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.
|
||||||
If thisLog Then LogColor("Inventario inicial: "&inventarioSinFijos, Colors.Gray) 'Inventario inicial.
|
If thisLog Then LogColor("Inventario inicial: "&inventarioSinFijos, Colors.Gray) 'Inventario inicial.
|
||||||
Private totalProdsVariables As Int = 0
|
Private totalProdsVariables As Int = 0
|
||||||
' Private prodsmap As Map = promoMap.Get("productos") 'Obtenemos un mapa con todos los productos de la promoción.
|
' Private prodsmap As Map = promoMap.Get("productos") 'Obtenemos un mapa con todos los productos de la promoción.
|
||||||
@@ -1180,8 +1183,6 @@ Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As
|
|||||||
Return res
|
Return res
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'prodsFijos=[1000000126, 1008013885]
|
|
||||||
|
|
||||||
'Regresa el numero máximo de promociones permitidas, tomando en cuenta recurrentes, clientes y maxPromos.
|
'Regresa el numero máximo de promociones permitidas, tomando en cuenta recurrentes, clientes y maxPromos.
|
||||||
Sub traeMaxPromos(pm As Map) As Int
|
Sub traeMaxPromos(pm As Map) As Int
|
||||||
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
|
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
|
||||||
@@ -1196,11 +1197,11 @@ Sub traeMaxPromos(pm As Map) As Int
|
|||||||
' Else
|
' Else
|
||||||
' LogColor("SIN HCCP CANT", Colors.Magenta)
|
' LogColor("SIN HCCP CANT", Colors.Magenta)
|
||||||
' End If
|
' End If
|
||||||
If thisLog Then LogColor("==== HISTORICO:"&pm.Get("historico"), Colors.Red)
|
' If thisLog Then LogColor("==== Historico: "&pm.Get("historico"), Colors.Red)
|
||||||
' Log("### PRODS VARIABLES: " & pm.Get("prodsVariables"))
|
' Log("### PRODS VARIABLES: " & pm.Get("prodsVariables"))
|
||||||
Private maxPromosXDescPV As String = B4XPages.MainPage.promos.ts.maxPromosPorProdsVariables(pm.Get("prodsVariables"), pm.Get("id"))
|
Private maxPromosXDescPV As String = B4XPages.MainPage.promos.ts.maxPromosPorProdsVariables(pm.Get("prodsVariables"), pm.Get("id"))
|
||||||
Log("########### " & maxPromosXDescPV)
|
' Log("########### " & maxPromosXDescPV)
|
||||||
If thisLog Then Log(pm)
|
' If thisLog Then Log(pm)
|
||||||
maxPromos.Add(maxPromosXDescPV.As(Int))
|
maxPromos.Add(maxPromosXDescPV.As(Int))
|
||||||
If pm.Get("historico") = "1" Then maxPromos.Add(pm.Get("maxRecurrente")) 'Si hay historico, agregamos maxRecurrente
|
If pm.Get("historico") = "1" Then maxPromos.Add(pm.Get("maxRecurrente")) 'Si hay historico, agregamos maxRecurrente
|
||||||
If pm.Get("maxPromos") <> "null" Then maxPromos.Add(pm.Get("maxPromos").As(Int)) 'Agregamos maxPromos
|
If pm.Get("maxPromos") <> "null" Then maxPromos.Add(pm.Get("maxPromos").As(Int)) 'Agregamos maxPromos
|
||||||
@@ -1233,49 +1234,56 @@ Sub traePromosVendidas(promo As String, cliente As String) As Int
|
|||||||
Return pv
|
Return pv
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'3799, 7226, 7228, 7230
|
|
||||||
|
|
||||||
Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
|
Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
|
||||||
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
|
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
|
||||||
Private inicioContador As String = DateTime.Now
|
Private inicioContador As String = DateTime.Now
|
||||||
Private mp As Int = 0
|
Private mp As Int = 0
|
||||||
|
If thisLog Then LogColor($"****************************************************************"$, Colors.red)
|
||||||
If thisLog Then LogColor($"********* Iniciamos revision de Promo ${idPromo} *********"$, Colors.red)
|
If thisLog Then LogColor($"********* Iniciamos revision de Promo ${idPromo} *********"$, Colors.red)
|
||||||
'Obtenemos el mapa con toda la info de la promoción.
|
If thisLog Then LogColor($"****************************************************************"$, Colors.red)
|
||||||
Private pm As Map = traePromo(idPromo, cliente)
|
Try
|
||||||
' B4XPages.MainPage.productos.promosC.traePromo(idPromo, cliente)
|
'Obtenemos el mapa con toda la info de la promoción.
|
||||||
If thisLog Then LogColor(pm, Colors.Blue)
|
Private pm As Map = traePromo(idPromo, cliente)
|
||||||
' If thisLog Then LogColor("|" & pm.Get("maxPromos") & "|", Colors.Blue)
|
' B4XPages.MainPage.productos.promosC.traePromo(idPromo, cliente)
|
||||||
' Log("|"&revisaMaxPromosProdsFijosPorInventario(pm)&"|")
|
If thisLog Then LogColor(pm, Colors.Blue)
|
||||||
If revisaMaxPromosProdsFijosPorInventario(pm) < 1 Then pm.Put("resultado", 0)
|
' If thisLog Then LogColor("|" & pm.Get("maxPromos") & "|", Colors.Blue)
|
||||||
' Log($"resultado = ${pm.Get("resultado")}"$)
|
' Log("|"&revisaMaxPromosProdsFijosPorInventario(pm)&"|")
|
||||||
If pm.Get("resultado") = "ok" Then 'Si encontramos la promoción, entonces ...
|
Private maxPromosXprodsFijos As Int = revisaMaxPromosProdsFijosPorInventario(pm)
|
||||||
'Buscamos el máximo de promociones permitidas.
|
If maxPromosXprodsFijos < 1 Then pm.Put("resultado", 0)
|
||||||
mp = traeMaxPromos(pm)
|
LogColor($">>> Promos disponibles por productos fijos = ${maxPromosXprodsFijos}"$, Colors.Magenta)
|
||||||
' If thisLog Then LogColor($"Promociones permitidas=${mp}"$, Colors.Blue)
|
If pm.Get("resultado") = "ok" Then 'Si encontramos la promoción, entonces ...
|
||||||
' If thisLog Then Log("Promos vendidas: " & traePromosVendidas(idPromo, cliente))
|
'Buscamos el máximo de promociones permitidas.
|
||||||
If mp < 1 Then
|
mp = traeMaxPromos(pm)
|
||||||
If thisLog Then LogColor("Ya se vendieron las promos PERMITIDAS para el cliente", Colors.red)
|
' If thisLog Then LogColor($"Promociones permitidas=${mp}"$, Colors.Blue)
|
||||||
Return CreateMap("status":"ko", "mp":pm)
|
' If thisLog Then Log("Promos vendidas: " & traePromosVendidas(idPromo, cliente))
|
||||||
End If
|
If mp < 1 Then
|
||||||
'Restamos del inventario (mapa) las piezas necesarias para los productos fijos.
|
If thisLog Then LogColor("Ya se vendieron las promos PERMITIDAS para el cliente", Colors.red)
|
||||||
Private inventarioSinFijos As Map = restaFijosPromo(pm)
|
Return CreateMap("status":"ko", "mp":pm)
|
||||||
If thisLog Then LogColor("inventariosfijos="&inventarioSinFijos, Colors.Magenta)
|
End If
|
||||||
If inventarioSinFijos.Get("resultado") = "ok" Then
|
'Restamos del inventario (mapa) las piezas necesarias para los productos fijos.
|
||||||
'Revisamos que los productos variables requeridos sean menos que el inventario total (mapa).
|
Private inventarioSinFijos As Map = restaFijosPromo(pm)
|
||||||
Private pv As Boolean = alcanzanLosVariablesParaPromo(pm, inventarioSinFijos)
|
If thisLog Then LogColor("inventariosfijos="&inventarioSinFijos, Colors.Magenta)
|
||||||
If thisLog Then Log("Alcanzan los variables? --> " & pv)
|
If inventarioSinFijos.Get("resultado") = "ok" Then
|
||||||
If pv Then Return CreateMap("status":"ok", "mp":pm) Else Return CreateMap("status":"ko", "mp":pm)
|
'Revisamos que los productos variables requeridos sean menos que el inventario total (mapa).
|
||||||
|
Private pv As Boolean = alcanzanLosVariablesParaPromo(pm, inventarioSinFijos)
|
||||||
|
If thisLog Then Log("Alcanzan los variables? --> " & pv)
|
||||||
|
If pv Then Return CreateMap("status":"ok", "mp":pm) Else Return CreateMap("status":"ko", "mp":pm)
|
||||||
|
Else
|
||||||
|
If thisLog Then LogColor("NO HAY INVENTARIO SUFICIENTE " & idPromo, Colors.red)
|
||||||
|
Return CreateMap("status":"ko", "mp":pm)
|
||||||
|
End If
|
||||||
Else
|
Else
|
||||||
If thisLog Then LogColor("NO HAY INVENTARIO SUFICIENTE " & idPromo, Colors.red)
|
|
||||||
Return CreateMap("status":"ko", "mp":pm)
|
Return CreateMap("status":"ko", "mp":pm)
|
||||||
End If
|
End If
|
||||||
Else
|
' Si tenemos suficiente inventario para los variables mostramos la promocion, si no ...
|
||||||
Return CreateMap("status":"ko", "mp":pm)
|
' break 'NO HAY INVENTARIO SUFICIENTE PARA LA PROMOCION.
|
||||||
End If
|
|
||||||
' Si tenemos suficiente inventario para los variables mostramos la promocion, si no ...
|
|
||||||
' break 'NO HAY INVENTARIO SUFICIENTE PARA LA PROMOCION.
|
|
||||||
|
|
||||||
LogColor("TIEMPO DE PROCESO ESTA PROMO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
LogColor("TIEMPO DE PROCESO ESTA PROMO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||||
|
Catch
|
||||||
|
Log($"Promo ${idPromo} mal configurada"$)
|
||||||
|
ToastMessageShow($"Promo ${idPromo} mal configurada"$, True)
|
||||||
|
Log(LastException)
|
||||||
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'Regresa cuantas promos alcanzan con los productos FIJOS que hay en inventario.
|
'Regresa cuantas promos alcanzan con los productos FIJOS que hay en inventario.
|
||||||
@@ -1337,21 +1345,21 @@ Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
|
|||||||
For p = 0 To idProdsFijos.Size -1 'Generamos una lista con las promos disponibles por producto (dividimos el inventario total entre las piezas requeridas).
|
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
|
Private thisInvDisp As Int = 0
|
||||||
If invDispParaPromo.Get(idProdsFijos.Get(p)) <> Null Then thisInvDisp = invDispParaPromo.Get(idProdsFijos.Get(p))
|
If invDispParaPromo.Get(idProdsFijos.Get(p)) <> Null Then thisInvDisp = invDispParaPromo.Get(idProdsFijos.Get(p))
|
||||||
If thisLog Then Log($"id=${idProdsFijos.Get(p)}, inv=${thisInvDisp}, pzas=${prodsFijosPiezas.Get(p)}"$)
|
If thisLog Then Log($"id=${idProdsFijos.Get(p)}, inv=${thisInvDisp}, pzasReq=${prodsFijosPiezas.Get(p)}"$)
|
||||||
Log(">>>>> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsFijos.Get(p), pm.Get("id")))
|
' 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.
|
||||||
|
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)
|
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")))
|
t.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), pm.Get("id")))
|
||||||
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.
|
|
||||||
If thisLog Then Log(x(0))
|
|
||||||
t.Add(x(0).As(Int)) 'Solo guardamos la parte del entero de la division.
|
|
||||||
Next
|
Next
|
||||||
t.Sort(True) 'Ordenamos la lista para que en el lugar 0 este el resultao mas pequeño.
|
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($"prodsFijos=${idProdsFijos}"$, Colors.Blue)
|
||||||
If thisLog Then LogColor($"prodsFijosPiezasReq=${prodsFijosPiezas}"$, Colors.Blue)
|
If thisLog Then LogColor($"prodsFijosPiezasReq=${prodsFijosPiezas}"$, Colors.Blue)
|
||||||
' If thisLog Then LogColor($"invFijoXpromo=${invFijoXpromo}"$, Colors.Blue)
|
' If thisLog Then LogColor($"invFijoXpromo=${invFijoXpromo}"$, Colors.Blue)
|
||||||
LogColor(">>>>>> T: " & t, Colors.red)
|
' LogColor(">>>>>> T: " & t, Colors.red)
|
||||||
If thisLog Then LogColor("Max promos de prodsFijos POR inventario = " & t.Get(0), 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.
|
Return t.Get(0) 'Regresamos el resultado mas pequeño.
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -1361,7 +1369,7 @@ End Sub
|
|||||||
'regresa el maximo por productos fijos. Ej. si las promos por variables es 10, pero el maximo por
|
'regresa el maximo por productos fijos. Ej. si las promos por variables es 10, pero el maximo por
|
||||||
'fijos es 5, entonces regresamos 5.
|
'fijos es 5, entonces regresamos 5.
|
||||||
Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||||
Private thisLog As Boolean = True
|
Private thisLog As Boolean = False
|
||||||
If thisLog Then LogColor("==================revisaMaxPromosProdsVariablesPorInventario====================", Colors.red)
|
If thisLog Then LogColor("==================revisaMaxPromosProdsVariablesPorInventario====================", Colors.red)
|
||||||
If thisLog Then Log("======================================================")
|
If thisLog Then Log("======================================================")
|
||||||
Private invFijoXpromo As Map
|
Private invFijoXpromo As Map
|
||||||
@@ -1402,8 +1410,8 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
|||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Log(pm.Get("prodsFijos").As(List).Size)
|
' Log(pm.Get("prodsFijos").As(List).Size)
|
||||||
Log(maxPromosXFijos)
|
' Log(maxPromosXFijos)
|
||||||
|
|
||||||
For x = 1 To maxPromosXFijos
|
For x = 1 To maxPromosXFijos
|
||||||
If thisLog Then Log("==================== maxPromosXFijos "& x &" ========================")
|
If thisLog Then Log("==================== maxPromosXFijos "& x &" ========================")
|
||||||
@@ -1535,16 +1543,25 @@ Sub borraPedidoClienteActual As String
|
|||||||
Log($"Registros = ${thisC.RowCount}"$)
|
Log($"Registros = ${thisC.RowCount}"$)
|
||||||
If thisC.RowCount > 0 Then
|
If thisC.RowCount > 0 Then
|
||||||
For i = 0 To thisC.RowCount - 1
|
For i = 0 To thisC.RowCount - 1
|
||||||
thisC.Position=i
|
thisC.Position = i
|
||||||
|
Log($"Posicion: ${i}, PE_CEDIS=${thisC.GetString("PE_CEDIS")}"$)
|
||||||
If thisC.GetString("PE_CEDIS") <> "DUR" Then
|
If thisC.GetString("PE_CEDIS") <> "DUR" Then
|
||||||
Starter.skmt.ExecNonQuery2($"update ${traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?"$, Array As Object(thisC.GetString("PE_CANT"), thisC.GetString("PE_PROID")))
|
Log("No DUR")
|
||||||
'Codigo para regresar dinero al presupuesto de BONIFICACIONES (Trend Spending)
|
'Codigo para regresar dinero al presupuesto de BONIFICACIONES (Trend Spending)
|
||||||
Private precio0 As String = traePrecio(thisC.GetString("PE_PROID"))
|
Private precio0 As String = traePrecio(thisC.GetString("PE_PROID"))
|
||||||
Private precioConDesc As String = (B4XPages.MainPage.cliente.kh.traeDescXSku(traeCliente, thisC.GetString("PE_PROID"))/100)*precio0
|
Private precioConDesc As String = (B4XPages.MainPage.cliente.kh.traeDescXSku(traeCliente, thisC.GetString("PE_PROID"))/100)*precio0
|
||||||
Log(precioConDesc)
|
Log("precioConDesc: " & precioConDesc)
|
||||||
Log(">>>>>>>>>>>>> " & (precioConDesc * thisC.GetString("PE_CANT")))
|
Log(">>>>>>>>>>>>> " & (precioConDesc * thisC.GetString("PE_CANT")))
|
||||||
modTrendSpending("suma", "bonificaciones", (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"))
|
||||||
|
Log("Regresamos bonificaciones " & thisC.GetString("PE_PROID") & "=" & desc)
|
||||||
|
modTrendSpending("suma", "bonificaciones", desc)
|
||||||
|
Else ' Si no es promo, entonces es descuento.
|
||||||
|
Log("Regresamos descuentos " & thisC.GetString("PE_PROID") & "=" & (precioConDesc * thisC.GetString("PE_CANT")))
|
||||||
|
modTrendSpending("suma", "descuentos", (precioConDesc * thisC.GetString("PE_CANT")))
|
||||||
|
End If
|
||||||
'Termina Trend Spending
|
'Termina Trend Spending
|
||||||
|
Starter.skmt.ExecNonQuery2($"update ${traeTablaProds(Starter.tipov)} set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?"$, Array As Object(thisC.GetString("PE_CANT"), thisC.GetString("PE_PROID")))
|
||||||
End If
|
End If
|
||||||
' Starter.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (traeAlmacen, thisC.GetString("PE_PROID"),thisC.GetString("PE_CANT")* -1))
|
' Starter.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (traeAlmacen, thisC.GetString("PE_PROID"),thisC.GetString("PE_CANT")* -1))
|
||||||
Next
|
Next
|
||||||
@@ -1555,9 +1572,6 @@ Sub borraPedidoClienteActual As String
|
|||||||
If thisC.RowCount < 1 Then Starter.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
If thisC.RowCount < 1 Then Starter.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||||
Log("###### delete from pedido_cliente - " & traeCliente)
|
Log("###### delete from pedido_cliente - " & traeCliente)
|
||||||
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return 1
|
Return 1
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -2144,12 +2158,12 @@ Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
|||||||
d.Position = 0
|
d.Position = 0
|
||||||
acumulado = d.GetString("ACUMULADO")
|
acumulado = d.GetString("ACUMULADO")
|
||||||
End If
|
End If
|
||||||
Log("acumulado:" & acumulado & " | monto: " & monto)
|
Log("acumulado: " & acumulado & " | monto: " & monto)
|
||||||
Private c As Cursor = Starter.skmt.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}'"$)
|
Private c As Cursor = Starter.skmt.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}'"$)
|
||||||
If accion.ToUpperCase = "RESTA" Then
|
If accion.ToUpperCase = "RESTA" Then
|
||||||
If c.RowCount > 0 Then
|
If c.RowCount > 0 Then
|
||||||
c.Position = 0
|
c.Position = 0
|
||||||
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Then
|
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Or tipo.ToUpperCase = "DESCUENTOS" Then
|
||||||
Private nuevaBonificacion As String = NumberFormat2((acumulado + monto), 1, 2, 2, False)
|
Private nuevaBonificacion As String = NumberFormat2((acumulado + monto), 1, 2, 2, False)
|
||||||
LogColor($"Nuevo acumulado ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
LogColor($"Nuevo acumulado ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||||
Starter.skmt.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
Starter.skmt.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
||||||
@@ -2160,9 +2174,9 @@ Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
|||||||
else if accion.ToUpperCase = "SUMA" Then
|
else if accion.ToUpperCase = "SUMA" Then
|
||||||
If c.RowCount > 0 Then
|
If c.RowCount > 0 Then
|
||||||
c.Position = 0
|
c.Position = 0
|
||||||
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Then
|
If tipo.ToUpperCase = "BONIFICACIONES" Or tipo.ToUpperCase = "RMI" Or tipo.ToUpperCase = "DESCUENTOS" Then
|
||||||
Private nuevaBonificacion As String = NumberFormat2((acumulado - monto), 1, 2, 2, False)
|
Private nuevaBonificacion As String = NumberFormat2((acumulado - monto), 1, 2, 2, False)
|
||||||
LogColor($"Nueva bonificacion = ${nuevaBonificacion}"$, Colors.Magenta)
|
LogColor($"Nueva ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||||
Starter.skmt.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
Starter.skmt.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
||||||
Starter.skmt.ExecNonQuery($"insert into TREND_SPENDING (tipo, acumulado) values ('${tipo.ToUpperCase}', '${nuevaBonificacion}')"$)
|
Starter.skmt.ExecNonQuery($"insert into TREND_SPENDING (tipo, acumulado) values ('${tipo.ToUpperCase}', '${nuevaBonificacion}')"$)
|
||||||
End If
|
End If
|
||||||
@@ -2328,4 +2342,19 @@ End Sub
|
|||||||
' precio = c.GetString("CAT_MONTO")
|
' precio = c.GetString("CAT_MONTO")
|
||||||
' End If
|
' End If
|
||||||
' Return precio
|
' Return precio
|
||||||
'End Sub
|
'End Sub
|
||||||
|
|
||||||
|
' Revisa que la contraseña sea la correcta: pass1 + dia (sin ceros) + hora (24 hrs sin ceros)
|
||||||
|
Sub revisaContrasenaHoy
|
||||||
|
Private pass1 As String = "KMT"
|
||||||
|
Private contrasenaHoy As String = pass1 & DateTime.GetDayOfMonth(DateTime.Now) & DateTime.GetHour(DateTime.now)
|
||||||
|
Log($"${contrasenaHoy}"$)
|
||||||
|
' Log(New)
|
||||||
|
' If New = contrasenaHoy Then
|
||||||
|
' p_login.Visible = False
|
||||||
|
' Sleep(80)
|
||||||
|
' et_usuario.Text = ""
|
||||||
|
' If Not(versionOk) Then ExitApplication 'Si la version no es correcta, salimos de la aplicacion.
|
||||||
|
' kb.HideKeyboard
|
||||||
|
' End If
|
||||||
|
End Sub
|
||||||
@@ -7,8 +7,8 @@ Version=12.8
|
|||||||
' Clase para las funciones de Trend Spending.
|
' 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
|
' 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
|
' 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
|
' 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
|
' 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 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
|
' 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.
|
' mas productos con descuento.
|
||||||
@@ -68,7 +68,7 @@ Sub traeInfoTrendSpending As Map
|
|||||||
Private semana As Int = 0
|
Private semana As Int = 0
|
||||||
Private HIST_TSS_SEMANA As String = 0
|
Private HIST_TSS_SEMANA As String = 0
|
||||||
Private HIST_TSS_SEMANA_ACUM 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
|
' m.Initialize
|
||||||
Private c As Cursor = tsdb.ExecQuery($"select cat_va_valor from cat_variables where cat_va_descripcion = 'SEM_CAL_LABORAL'"$)
|
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
|
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)
|
' 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)
|
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 As String
|
||||||
Private HIST_TSS_SEMANA_ACUM As String
|
Private HIST_TSS_SEMANA_ACUM As String
|
||||||
Private acumulado As String = "0"
|
Private acumulado As String = "0"
|
||||||
@@ -116,21 +117,24 @@ Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
|||||||
End If
|
End If
|
||||||
Log("acumulado:" & acumulado & " | monto: " & monto)
|
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}'"$)
|
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 accion.ToUpperCase = "RESTA" Then
|
||||||
If c.RowCount > 0 Then
|
If c.RowCount > 0 Then
|
||||||
c.Position = 0
|
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)
|
Private nuevaBonificacion As String = NumberFormat2((acumulado + monto), 1, 2, 2, False)
|
||||||
LogColor($"Nuevo acumulado ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
LogColor($"Nuevo acumulado ${tipo} = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||||
tsdb.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
tsdb.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
||||||
tsdb.ExecNonQuery($"insert into TREND_SPENDING (tipo, acumulado) values ('${tipo.ToUpperCase}', '${nuevaBonificacion}')"$)
|
tsdb.ExecNonQuery($"insert into TREND_SPENDING (tipo, acumulado) values ('${tipo.ToUpperCase}', '${nuevaBonificacion}')"$)
|
||||||
|
Log($"Insertamos en TRADE_SPENDING: ${nuevaBonificacion}"$)
|
||||||
' else if tipo.ToUpperCase = "RMI" Then
|
' else if tipo.ToUpperCase = "RMI" Then
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
else if accion.ToUpperCase = "SUMA" Then
|
else if accion.ToUpperCase = "SUMA" Then
|
||||||
If c.RowCount > 0 Then
|
If c.RowCount > 0 Then
|
||||||
c.Position = 0
|
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)
|
Private nuevaBonificacion As String = NumberFormat2((acumulado - monto), 1, 2, 2, False)
|
||||||
LogColor($"Nueva bonificacion = ${nuevaBonificacion}"$, Colors.Magenta)
|
LogColor($"Nueva bonificacion = ${nuevaBonificacion}"$, Colors.Magenta)
|
||||||
tsdb.ExecNonQuery($"delete from TREND_SPENDING where tipo = '${tipo.ToUpperCase}' "$)
|
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
|
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
|
Private logger As Boolean = True
|
||||||
|
LogColor("-------- > TRADE SPENDING < ---------", Colors.red)
|
||||||
|
' Log("DescxSku: " & traeDescXSku(clienteId, id))
|
||||||
Dim TS_RMI() As String
|
Dim TS_RMI() As String
|
||||||
Dim TS_DESCUENTOS() As String
|
Dim TS_DESCUENTOS() As String
|
||||||
Dim TS_BONIFICACIONES() 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")}"$)
|
Log($"Acumulado de RMIs: ${traeAcumuladoHoyTS("rmi")}"$)
|
||||||
Private elMonto As String = NumberFormat2(traePrecioRMI(id), 1, 2, 2, False)
|
Private elMonto As String = NumberFormat2(traePrecioRMI(id), 1, 2, 2, False)
|
||||||
If logger Then Log($"elMonto: ${elMonto}"$)
|
If logger Then Log($"elMonto: ${elMonto}"$)
|
||||||
If logger Then Log($"TS_RMI(0): ${TS_RMI(0)}"$)
|
' 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(1): ${TS_RMI(1)}"$)
|
||||||
If logger Then Log($"LaCant: ${laCant}"$)
|
If logger Then Log($"LaCant: ${laCant}"$)
|
||||||
Private tsRestantes As String = (TS_RMI(0) - TS_RMI(1) - traeAcumuladoHoyTS("rmi"))
|
Private tsRestantes As String = (TS_RMI(0) - TS_RMI(1) - traeAcumuladoHoyTS("rmi"))
|
||||||
Log($"tsRestantes: ${tsRestantes}"$)
|
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
|
If laCant < lasMaximas Then
|
||||||
modTrendSpending("resta", "rmi", elMonto) ' Restamos al presupuesto de hoy (agregamos al acumulado).
|
modTrendSpending("resta", "rmi", elMonto) ' Restamos al presupuesto de hoy (agregamos al acumulado).
|
||||||
End If
|
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
|
Return lasMaximas & "|" & elMonto
|
||||||
else if accion.ToUpperCase = "PRODMENOS" Then
|
else if accion.ToUpperCase = "PRODMENOS" Then
|
||||||
If logger Then Log("LaCANT= " & laCant & ", elMonto= " & elMonto)
|
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 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"))
|
Private tsRestantes As String = (TS_DESCUENTOS(0) - TS_DESCUENTOS(1) - traeAcumuladoHoyTS("descuentos"))
|
||||||
If logger Then Log("EL MONTO: " & elMonto)
|
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 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
|
If elMonto > 0 Then
|
||||||
lasMaximas = ((laCant * elMonto) + tsRestantes) / elMonto
|
lasMaximas = ((laCant * elMonto) + tsRestantes) / elMonto
|
||||||
If logger Then Log("lasMaximas: " & lasMaximas)
|
If logger Then Log("lasMaximas: " & lasMaximas)
|
||||||
If logger Then Log("lasMaximas2: " & traeMaximas("descuentos", clienteId, id, laCant, ""))
|
' If logger Then Log("lasMaximas2: " & traeMaximas("descuentos", clienteId, id, laCant, ""))
|
||||||
If logger Then Log(traeAcumuladoHoyTS("descuentos"))
|
If logger Then Log("Acumulado hoy: " & traeAcumuladoHoyTS("descuentos"))
|
||||||
End If
|
End If
|
||||||
If laCant = lasMaximas Then
|
If laCant = lasMaximas Then
|
||||||
ToastMessageShow("El presupuesto de DESCUENTOS no permite agregar mas productos!!", False)
|
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.
|
' 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
|
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 tsRestantes As String = 0
|
||||||
Private tsMonto As String '= traeMonto(clienteId, id)
|
Private tsMonto As String '= traeMonto(clienteId, id)
|
||||||
' If tsMonto > 0 Then
|
' If tsMonto > 0 Then
|
||||||
@@ -316,23 +322,25 @@ Sub traeMaximas(tipo As String, clienteId As String, id As String, laCant As Str
|
|||||||
Return tsMaximas
|
Return tsMaximas
|
||||||
End Sub
|
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
|
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 tsRestantes As String = 0
|
||||||
Private tsMonto As String
|
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
|
If tipo.ToUpperCase = "BONIFICACIONES" Then
|
||||||
tsMonto = NumberFormat2(traeMontoBonificacion(id, promoId), 1, 2, 2, False)
|
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.
|
tsRestantes = (TS_BONIFICACIONES(0) - TS_BONIFICACIONES(1) - traeAcumuladoHoyTS("bonificaciones")) ' Traemos monto restante de Trend Spending para bonificaciones.
|
||||||
End If
|
End If
|
||||||
Log($"tsMonto: ${tsMonto}"$)
|
Log($"Monto de bonificacion: ${tsMonto}"$)
|
||||||
Log($"tsRestantes: ${tsRestantes}"$)
|
Log($"Presupuesto disponible: ${tsRestantes}"$)
|
||||||
Log($"laCant: ${laCant}"$)
|
Log($"Cantidad: ${laCant}"$)
|
||||||
|
Log($"Floor(tsRestantes / (tsMonto * laCant))= ${Floor(tsRestantes / (tsMonto * laCant))}"$)
|
||||||
If tsMonto > 0 Then
|
If tsMonto > 0 Then
|
||||||
tsMaximas = Floor(tsRestantes / (tsMonto * laCant))
|
tsMaximas = Floor(tsRestantes / (tsMonto * laCant))
|
||||||
Log(">>> tsMaximas: " & tsMaximas)
|
|
||||||
End If
|
End If
|
||||||
|
Log(">>> tsMaximas: " & tsMaximas)
|
||||||
Return tsMaximas
|
Return tsMaximas
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -350,7 +358,8 @@ Sub traeMontoBonificacion(id As String, promoId As String) As String
|
|||||||
Else
|
Else
|
||||||
tsMonto = c.GetString("CAT_GP_PRECIO") ' Precio original.
|
tsMonto = c.GetString("CAT_GP_PRECIO") ' Precio original.
|
||||||
End If
|
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
|
End If
|
||||||
' Log("ROWCOUNT: " & c.RowCount)
|
' Log("ROWCOUNT: " & c.RowCount)
|
||||||
Return tsMonto
|
Return tsMonto
|
||||||
@@ -365,23 +374,23 @@ End Sub
|
|||||||
' Aunque si hay suficiente para mostrar algunas promos ... pues que si las muestre.
|
' Aunque si hay suficiente para mostrar algunas promos ... pues que si las muestre.
|
||||||
Sub maxPromosPorProdsVariables(idProdsVariables As List, promo As String)As Int
|
Sub maxPromosPorProdsVariables(idProdsVariables As List, promo As String)As Int
|
||||||
Private logger As Boolean = True
|
Private logger As Boolean = True
|
||||||
Private Maxs As Int = 100000
|
Private Maxs As Int = 10000000
|
||||||
Private prodsVariablesXPresupuestoBonificaciones As List
|
Private prodsVariablesXPresupuestoBonificaciones As List
|
||||||
Private prodsVariablesRequeridos As Int = traeProdsVariablesRequeridos(promo)
|
Private prodsVariablesRequeridos As Int = traeProdsVariablesRequeridos(promo)
|
||||||
prodsVariablesXPresupuestoBonificaciones.Initialize
|
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.
|
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))}"$)
|
' Log($"Este invDisponible: ${invDispParaPromo.Get(idProdsVariables.Get(i))}"$)
|
||||||
If logger Then Log(">> Monto Bonificacion: " & traeMontoBonificacion(idProdsVariables.Get(i), promo))
|
If logger Then Log(">> Monto Bonificacion: " & traeMontoBonificacion(idProdsVariables.Get(i), promo))
|
||||||
Private maxProds As Int = traeBonificacionesMaximas("bonificaciones", traeCliente, idProdsVariables.Get(i), prodsVariablesRequeridos, promo)
|
Private maxProds As Int = traeBonificacionesMaximas("bonificaciones", traeCliente, idProdsVariables.Get(i), prodsVariablesRequeridos, promo)
|
||||||
prodsVariablesXPresupuestoBonificaciones.Add(maxProds)
|
prodsVariablesXPresupuestoBonificaciones.Add(maxProds)
|
||||||
If logger Then LogColor(">> Max prods x Bonificaciones: " & maxProds, Colors.blue)
|
|
||||||
Next
|
Next
|
||||||
prodsVariablesXPresupuestoBonificaciones.Sort(True)
|
prodsVariablesXPresupuestoBonificaciones.Sort(True)
|
||||||
If prodsVariablesXPresupuestoBonificaciones.Size > 0 Then
|
If prodsVariablesXPresupuestoBonificaciones.Size > 0 Then
|
||||||
Maxs = prodsVariablesXPresupuestoBonificaciones.Get(0)
|
Maxs = prodsVariablesXPresupuestoBonificaciones.Get(0)
|
||||||
End If
|
End If
|
||||||
|
If logger Then LogColor("=====>> Max prods variables x monto de bonificaciones: " & Maxs, Colors.blue)
|
||||||
Return Maxs
|
Return Maxs
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -400,6 +409,11 @@ Sub traeProdsVariablesRequeridos(promo As String) As Int
|
|||||||
Return pvr
|
Return pvr
|
||||||
End Sub
|
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
|
'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".
|
' variables, y ponerla igual en "traeMaxPromos" en lugar de en "revisaMaxPromosProdsFijosPorInventario".
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user