mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-17 18:26:11 +00:00
VERSION 5.12.18
- Se agrego auditoria en los "principales" eventos, se guardan en la tabla "auditoria"
This commit is contained in:
@@ -124,6 +124,7 @@ Sub Class_Globals
|
|||||||
Private Label4 As Label
|
Private Label4 As Label
|
||||||
Private clicked As Int = 0
|
Private clicked As Int = 0
|
||||||
Dim linker As C_deviceLinker
|
Dim linker As C_deviceLinker
|
||||||
|
Dim aud As C_Auditoria
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub Initialize
|
Public Sub Initialize
|
||||||
@@ -195,6 +196,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
kh.agregaColumna(Starter.skmt, "PEDIDO", "PE_ARCH", "TEXT")
|
kh.agregaColumna(Starter.skmt, "PEDIDO", "PE_ARCH", "TEXT")
|
||||||
kh.agregaColumna(Starter.skmt, "PEDIDO_CLIENTE", "PC_ARCH", "TEXT")
|
kh.agregaColumna(Starter.skmt, "PEDIDO_CLIENTE", "PC_ARCH", "TEXT")
|
||||||
kh.agregaColumna(Starter.skmt, "PEDIDO3", "PE_ARCH", "TEXT")
|
kh.agregaColumna(Starter.skmt, "PEDIDO3", "PE_ARCH", "TEXT")
|
||||||
|
aud.Initialize(Starter.skmt)
|
||||||
Root = Root1
|
Root = Root1
|
||||||
' Root.LoadLayout("MainPage")
|
' Root.LoadLayout("MainPage")
|
||||||
Root.LoadLayout("login")
|
Root.LoadLayout("login")
|
||||||
@@ -412,6 +414,7 @@ End Sub
|
|||||||
|
|
||||||
Sub B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
Log(">>>>>> APPEAR - INICIAMOS MAIN PAGE <<<<<<<<<")
|
Log(">>>>>> APPEAR - INICIAMOS MAIN PAGE <<<<<<<<<")
|
||||||
|
aud.guarda($"Entrada a Login"$)
|
||||||
linker.Initialize(Me, "Linker", True)
|
linker.Initialize(Me, "Linker", True)
|
||||||
clicked = 0
|
clicked = 0
|
||||||
If Not(MES1.IsInitialized) Then MES1.Initialize(Me, "MES1")
|
If Not(MES1.IsInitialized) Then MES1.Initialize(Me, "MES1")
|
||||||
|
|||||||
80
B4A/C_Auditoria.bas
Normal file
80
B4A/C_Auditoria.bas
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=12.8
|
||||||
|
@EndOfDesignText@
|
||||||
|
Sub Class_Globals
|
||||||
|
Private Root As B4XView 'ignore
|
||||||
|
Private xui As XUI 'ignore
|
||||||
|
Dim audb As SQL
|
||||||
|
Dim ruta As String = File.DirInternal
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'You can add more parameters here.
|
||||||
|
Public Sub Initialize(db As SQL) As Object
|
||||||
|
If Not(audb.IsInitialized) Then audb.Initialize(ruta,"kmt.db", True)
|
||||||
|
audb = db
|
||||||
|
audb.ExecNonQuery("CREATE TABLE IF NOT EXISTS auditoria(almacen text, ruta text, usuario text, cliente text, evento text, fecha text, lat text, lon text)")
|
||||||
|
Return Me
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'This event will be called once, before the page becomes visible.
|
||||||
|
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||||
|
Root = Root1
|
||||||
|
'load the layout to Root
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
|
Sub guarda(evento As String)
|
||||||
|
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
|
||||||
|
audb.ExecNonQuery2("insert into auditoria (almacen, ruta, usuario, cliente, evento, fecha, lat, lon) values (?, ?, ?, ?, ?, ?, ?, ?)", Array As String(traeAlmacen, traeRuta, traeUsuarioDeBD, traeCliente, evento, DateTime.Date(DateTime.Now)))
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa el almacen actual de la base de datos.
|
||||||
|
Sub traeAlmacen As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private a As String
|
||||||
|
c = audb.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||||
|
c.Position = 0
|
||||||
|
a = C.GetString("ID_ALMACEN")
|
||||||
|
c.Close
|
||||||
|
Return a
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa la ruta actual de la base de datos.
|
||||||
|
Sub traeRuta As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private r As String
|
||||||
|
c = audb.ExecQuery("select CAT_CL_RUTA from kmt_info limit 1")
|
||||||
|
r = "0"
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position=0
|
||||||
|
r = c.GetString("CAT_CL_RUTA")
|
||||||
|
End If
|
||||||
|
c.Close
|
||||||
|
Return r
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa el usuario de la tabla USUARIOA
|
||||||
|
Sub traeUsuarioDeBD As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private u As String = "SinUsuario"
|
||||||
|
c = audb.ExecQuery("select USUARIO from usuarioa")
|
||||||
|
c.Position=0
|
||||||
|
If c.RowCount > 0 Then u = c.GetString("USUARIO")
|
||||||
|
c.Close
|
||||||
|
Return u
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Trae el cliente de CUENTAA
|
||||||
|
Sub traeCliente As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private cl As String
|
||||||
|
c = audb.ExecQuery("Select CUENTA from cuentaa")
|
||||||
|
c.Position = 0
|
||||||
|
cl = c.GetString("CUENTA")
|
||||||
|
c.Close
|
||||||
|
Return cl
|
||||||
|
End Sub
|
||||||
@@ -409,6 +409,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda($"Entrada a Cliente"$)
|
||||||
indicePregunta = 0
|
indicePregunta = 0
|
||||||
b_noVenta.Enabled = False
|
b_noVenta.Enabled = False
|
||||||
Log("NoVenta False")
|
Log("NoVenta False")
|
||||||
@@ -1020,6 +1021,7 @@ Sub DATOS_Click
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Guardar_Click
|
Sub Guardar_Click
|
||||||
|
B4XPages.MainPage.aud.guarda($"Guarda Venta Cliente"$)
|
||||||
DateTime.DateFormat = "MM/dd/yyyy"
|
DateTime.DateFormat = "MM/dd/yyyy"
|
||||||
sDate=DateTime.Date(DateTime.Now)
|
sDate=DateTime.Date(DateTime.Now)
|
||||||
sTime=DateTime.Time(DateTime.Now)
|
sTime=DateTime.Time(DateTime.Now)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a Historico")
|
||||||
L_CANT.Text =""
|
L_CANT.Text =""
|
||||||
L_TOTAL.Text=""
|
L_TOTAL.Text=""
|
||||||
c=Starter.skmt.ExecQuery("select count(*) as EXISTE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
|
c=Starter.skmt.ExecQuery("select count(*) as EXISTE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a Mapas")
|
||||||
GPS.Initialize("GPS")
|
GPS.Initialize("GPS")
|
||||||
Log(1)
|
Log(1)
|
||||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a No Venta")
|
||||||
e_comm.Text=""
|
e_comm.Text=""
|
||||||
lat_gps = 0
|
lat_gps = 0
|
||||||
lon_gps = 0
|
lon_gps = 0
|
||||||
@@ -86,6 +87,7 @@ Sub GUARDA_Click
|
|||||||
Else
|
Else
|
||||||
motivo = "NO ESTA EL ENCARGADO"
|
motivo = "NO ESTA EL ENCARGADO"
|
||||||
End If
|
End If
|
||||||
|
B4XPages.MainPage.aud.guarda($"Guarda No Venta: ${motivo}"$)
|
||||||
usuario = Subs.traeUsuarioDeBD
|
usuario = Subs.traeUsuarioDeBD
|
||||||
If B4XPages.MainPage.cliente.IsInitialized Then
|
If B4XPages.MainPage.cliente.IsInitialized Then
|
||||||
B4XPages.MainPage.cliente.motivoNoVenta = motivo
|
B4XPages.MainPage.cliente.motivoNoVenta = motivo
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a Nota")
|
||||||
If kh.clienteConDOE And l_tipoPedido.IsInitialized Then
|
If kh.clienteConDOE And l_tipoPedido.IsInitialized Then
|
||||||
l_tipoPedido.Visible = True
|
l_tipoPedido.Visible = True
|
||||||
Else
|
Else
|
||||||
@@ -265,6 +266,7 @@ Sub borra_Click
|
|||||||
If folio = "0" Or 1 = 1 Then 'Si el folio es 0 o el cliente actual es "abordo", los deja borrar. - Mod por CHV 220512 'Para que el abordo borre siempre agregar -> " Or Subs.clienteActual = "0""
|
If folio = "0" Or 1 = 1 Then 'Si el folio es 0 o el cliente actual es "abordo", los deja borrar. - Mod por CHV 220512 'Para que el abordo borre siempre agregar -> " Or Subs.clienteActual = "0""
|
||||||
result = Msgbox2($"¿Seguro que desea borrar el pedido${textoExtra}?"$,"Cancelar pedido", "Si", "", "No", LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
result = Msgbox2($"¿Seguro que desea borrar el pedido${textoExtra}?"$,"Cancelar pedido", "Si", "", "No", LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||||
If result = DialogResponse.POSITIVE Then
|
If result = DialogResponse.POSITIVE Then
|
||||||
|
B4XPages.MainPage.aud.guarda($"Borrar Nota Ok"$)
|
||||||
' c = Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_TIPO, PE_CEDIS FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
' c = Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_TIPO, PE_CEDIS FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||||
' If c.RowCount>0 Then
|
' If c.RowCount>0 Then
|
||||||
' For i=0 To c.RowCount -1
|
' For i=0 To c.RowCount -1
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a NuevoCliente")
|
||||||
b_guardar.Visible = False
|
b_guardar.Visible = False
|
||||||
b_guardar.Enabled = False
|
b_guardar.Enabled = False
|
||||||
permitirCtesNuevos = True
|
permitirCtesNuevos = True
|
||||||
|
|||||||
@@ -324,6 +324,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a Principal")
|
||||||
' Log(Subs.traeDiaSemana)
|
' Log(Subs.traeDiaSemana)
|
||||||
linker.Initialize(Me, "Linker", True)
|
linker.Initialize(Me, "Linker", True)
|
||||||
Starter.errorConnDBReq = False
|
Starter.errorConnDBReq = False
|
||||||
@@ -2572,6 +2573,7 @@ Sub e_ruta_EnterPressed
|
|||||||
Starter.skmt.ExecNonQuery("delete from TREND_SPENDING")
|
Starter.skmt.ExecNonQuery("delete from TREND_SPENDING")
|
||||||
Starter.skmt.ExecNonQuery("delete from HIST_TREND_SPENDING_SEMANAL")
|
Starter.skmt.ExecNonQuery("delete from HIST_TREND_SPENDING_SEMANAL")
|
||||||
Starter.skmt.ExecNonQuery("delete from VERSIONES")
|
Starter.skmt.ExecNonQuery("delete from VERSIONES")
|
||||||
|
Starter.skmt.ExecNonQuery("delete from auditoria")
|
||||||
|
|
||||||
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_ENVIOS VALUES (?,0,?)", Array As Object(sTime, "PEDIDO"))
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_ENVIOS VALUES (?,0,?)", Array As Object(sTime, "PEDIDO"))
|
||||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("NUMERO_PEDIDO"))
|
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("NUMERO_PEDIDO"))
|
||||||
@@ -2824,6 +2826,7 @@ Sub B_OK_RES_Click
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Resumen_Click
|
Sub Resumen_Click
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a resumenDia")
|
||||||
Log("###############")
|
Log("###############")
|
||||||
L_ABORDO.Text = "0"
|
L_ABORDO.Text = "0"
|
||||||
P_RESUMEN.Visible = True
|
P_RESUMEN.Visible = True
|
||||||
@@ -4071,6 +4074,7 @@ Sub IsConnectedToInternet As Boolean 'ignore
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub b_motivoNoVisita_Click
|
Private Sub b_motivoNoVisita_Click
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a motivoNoVisita")
|
||||||
r_1.Checked = True
|
r_1.Checked = True
|
||||||
r_razonNoVisita = "FALLA MECANICA"
|
r_razonNoVisita = "FALLA MECANICA"
|
||||||
If Not(kh.motivoNoVisitaActivo) Then
|
If Not(kh.motivoNoVisitaActivo) Then
|
||||||
@@ -4096,6 +4100,7 @@ Private Sub b_noVisita_Click
|
|||||||
Msgbox2Async("Si se envia la información, ya NO se va a poder continuar con la ruta, los clientes por visitar se van a bloquear.", "AVISO", "Continuar", "Cancelar", "", LoadBitmap(File.DirAssets,"alert2.png"), False)
|
Msgbox2Async("Si se envia la información, ya NO se va a poder continuar con la ruta, los clientes por visitar se van a bloquear.", "AVISO", "Continuar", "Cancelar", "", LoadBitmap(File.DirAssets,"alert2.png"), False)
|
||||||
Wait For Msgbox_Result (result As Int)
|
Wait For Msgbox_Result (result As Int)
|
||||||
If result = DialogResponse.POSITIVE Then
|
If result = DialogResponse.POSITIVE Then
|
||||||
|
B4XPages.MainPage.aud.guarda($"Se envió MotivoNoVisita: "${r_razonNoVisita}""$)
|
||||||
ToastMessageShow("CONTINUAR", False)
|
ToastMessageShow("CONTINUAR", False)
|
||||||
Starter.skmt.ExecNonQuery($"delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'NOVISITA_ACTIVA'"$)
|
Starter.skmt.ExecNonQuery($"delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'NOVISITA_ACTIVA'"$)
|
||||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("NOVISITA_ACTIVA", 1))
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("NOVISITA_ACTIVA", 1))
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a Productos")
|
||||||
If Starter.Logger Then Log("Entro: " & entro)
|
If Starter.Logger Then Log("Entro: " & entro)
|
||||||
' Log($"LIMITE ABORDO: ${limiteAbordo}"$)
|
' Log($"LIMITE ABORDO: ${limiteAbordo}"$)
|
||||||
' clv_prods_ll.Initialize(Me, "clv_prods_ll")
|
' clv_prods_ll.Initialize(Me, "clv_prods_ll")
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a Promos")
|
||||||
B4XPages.MainPage.productos.entro = 3
|
B4XPages.MainPage.productos.entro = 3
|
||||||
' LogColor(B4XPages.MainPage.productos.prodsMap, Colors.blue)
|
' LogColor(B4XPages.MainPage.productos.prodsMap, Colors.blue)
|
||||||
prodsIds.Initialize
|
prodsIds.Initialize
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ 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 B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a TicketsDia")
|
||||||
nombre_boton = "NOVENTA"
|
nombre_boton = "NOVENTA"
|
||||||
c=Starter.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART,(select CAT_CL_NOMBRE from kmt_info where cat_cl_codigo = pc_cliente ) as NOMBRE FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
|
c=Starter.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART,(select CAT_CL_NOMBRE from kmt_info where cat_cl_codigo = pc_cliente ) as NOMBRE FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
|
||||||
ListView1.Clear
|
ListView1.Clear
|
||||||
@@ -90,9 +91,10 @@ Sub Activity_KeyPress (key As Int) As Boolean
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||||
Log(value)
|
Log(Value)
|
||||||
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||||
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Value))
|
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Value))
|
||||||
|
B4XPages.MainPage.aud.guarda($"Clic largo TicketsDia: ${Value}"$)
|
||||||
Subs.iniciaActividad("Cliente")
|
Subs.iniciaActividad("Cliente")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
456
B4A/C_TrendSpending.bas
Normal file
456
B4A/C_TrendSpending.bas
Normal file
@@ -0,0 +1,456 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=12.8
|
||||||
|
@EndOfDesignText@
|
||||||
|
' 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
|
||||||
|
' 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.
|
||||||
|
|
||||||
|
' Descuento es TODO lo que tenga un precio diferente al precio de lista y NO esta en promo.
|
||||||
|
' Bonificacion es lo que tiene precio diferente al orginal y esta en promo y NO es regalo o exhibidor.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Sub Class_Globals
|
||||||
|
Private EventName As String 'ignore
|
||||||
|
Private CallBack As Object 'ignore
|
||||||
|
Dim tsMaximas As Int = 0
|
||||||
|
Private tsdb As SQL
|
||||||
|
Dim TS_RMI() As String
|
||||||
|
Dim TS_DESCUENTOS() As String
|
||||||
|
Dim TS_BONIFICACIONES() As String
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Initializes the object. You can add parameters to this method if needed.
|
||||||
|
Public Sub Initialize (vCallback As Object, vEventName As String, db As SQL) As Object
|
||||||
|
EventName = vEventName
|
||||||
|
CallBack = vCallback
|
||||||
|
tsdb = db
|
||||||
|
Private mx As Map = traeInfoTrendSpending
|
||||||
|
LogColor(mx, Colors.red)
|
||||||
|
TS_RMI = Regex.Split(",", mx.Get("RMI"))
|
||||||
|
TS_DESCUENTOS = Regex.Split(",", mx.Get("DESCUENTOS"))
|
||||||
|
TS_BONIFICACIONES = Regex.Split(",", mx.Get("BONIFICACIONES"))
|
||||||
|
LogColor(">>>>>>>>>>>>> TRENDSPENDING: " & mx, Colors.red)
|
||||||
|
LogColor("RMI: " & TS_RMI(0) & "|" & TS_RMI(1), Colors.red)
|
||||||
|
LogColor("DESCUENTOS: " & TS_DESCUENTOS(0) & "|" & TS_DESCUENTOS(1), Colors.red)
|
||||||
|
LogColor("BONIFICACIONES: " & TS_BONIFICACIONES(0) & "|" & TS_BONIFICACIONES(1), Colors.red)
|
||||||
|
Return Me
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa la tabla de productos (cat_gunaprod o cat_gunaprod2) dependiendo del tipo de venta.
|
||||||
|
Sub traeTablaProds(tipoventa As String) As String
|
||||||
|
Private tablaProds As String = "cat_gunaprod2"
|
||||||
|
If tipoventa = "ABORDO" Or tipoventa = "PREVENTA" Then tablaProds = "cat_gunaprod"
|
||||||
|
' LogColor($"Tipo= ${tipoventa}, tabla=${tablaProds}"$, Colors.RGB(200,136,0))
|
||||||
|
Return tablaProds
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Regresa el descuento de condiciones comerciales por SKU.
|
||||||
|
Sub traeDescXSku(clienteId As String, prodId As String) As String 'ignore
|
||||||
|
Private desc As String = "0"
|
||||||
|
Private c As Cursor = tsdb.ExecQuery($"Select * from CAT_DESCUENTOS_SKU where CAT_DS_CLIENTE = '${clienteId}' and CAT_DS_PRODID = '${prodId}'"$)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
desc = c.GetString("CAT_DS_PORCENTAJE")
|
||||||
|
End If
|
||||||
|
Return desc
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' Regresa un mapa con el tipo, monto permitido semanal y el acumulado hasta el día anterior:
|
||||||
|
' ej:
|
||||||
|
' - RMI=1500,0
|
||||||
|
' - DESCUENTOS=1500,0
|
||||||
|
' - BONIFICACIONES=1500,480
|
||||||
|
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": 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
|
||||||
|
c.Position = 0
|
||||||
|
semana = c.GetInt("CAT_VA_VALOR")
|
||||||
|
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"$)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
For i = 0 To c.RowCount - 1
|
||||||
|
c.Position = i
|
||||||
|
HIST_TSS_SEMANA = c.GetString($"HIST_TSS_SEMANA${semana}"$)
|
||||||
|
If Not(IsNumber(HIST_TSS_SEMANA)) Then HIST_TSS_SEMANA = 0
|
||||||
|
Private xx As String = c.GetString($"HIST_TSS_SEMANA${semana}_ACUM"$)
|
||||||
|
If xx = "null" Then xx = 0
|
||||||
|
HIST_TSS_SEMANA_ACUM = xx
|
||||||
|
If c.GetString("HIST_TSS_TIPO") = "RMI" Then
|
||||||
|
m.Put("RMI", HIST_TSS_SEMANA & "," & HIST_TSS_SEMANA_ACUM)
|
||||||
|
else if c.GetString("HIST_TSS_TIPO") = "DESCUENTOS" Then
|
||||||
|
m.Put("DESCUENTOS", HIST_TSS_SEMANA & "," & HIST_TSS_SEMANA_ACUM)
|
||||||
|
else if c.GetString("HIST_TSS_TIPO") = "BONIFICACIONES" Then
|
||||||
|
m.Put("BONIFICACIONES", HIST_TSS_SEMANA & "," & HIST_TSS_SEMANA_ACUM)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Return m
|
||||||
|
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"
|
||||||
|
If Starter.semana = 0 Then
|
||||||
|
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
|
||||||
|
c.Position = 0
|
||||||
|
Starter.semana = c.GetInt("CAT_VA_VALOR")
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
HIST_TSS_SEMANA = $"HIST_TSS_SEMANA${Starter.semana}"$
|
||||||
|
HIST_TSS_SEMANA_ACUM = $"HIST_TSS_SEMANA${Starter.semana}_ACUM"$
|
||||||
|
Private d As Cursor = tsdb.ExecQuery($"select ifnull(acumulado, 0) as ACUMULADO from TREND_SPENDING where tipo = '${tipo.ToUpperCase}'"$)
|
||||||
|
If d.RowCount > 0 Then
|
||||||
|
d.Position = 0
|
||||||
|
acumulado = d.GetString("ACUMULADO")
|
||||||
|
End If
|
||||||
|
Log("acumulado:" & acumulado & " | monto: " & monto)
|
||||||
|
Private c As Cursor = tsdb.ExecQuery($"select HIST_TSS_TIPO, ifnull(${HIST_TSS_SEMANA},0) as disponible, ifnull(${HIST_TSS_SEMANA_ACUM},0) 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" 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" 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}' "$)
|
||||||
|
tsdb.ExecNonQuery($"insert into TREND_SPENDING (tipo, acumulado) values ('${tipo.ToUpperCase}', '${nuevaBonificacion}')"$)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub traeAcumuladoHoyTS(tipo As String) As String
|
||||||
|
' Private HIST_TSS_SEMANA As String
|
||||||
|
' Private HIST_TSS_SEMANA_ACUM As String
|
||||||
|
Private acumulado As String = "0"
|
||||||
|
If Starter.semana = 0 Then
|
||||||
|
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
|
||||||
|
c.Position = 0
|
||||||
|
Starter.semana = c.GetInt("CAT_VA_VALOR")
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
' HIST_TSS_SEMANA = $"HIST_TSS_SEMANA${Starter.semana}"$
|
||||||
|
' HIST_TSS_SEMANA_ACUM = $"HIST_TSS_SEMANA${Starter.semana}_ACUM"$
|
||||||
|
Private d As Cursor = tsdb.ExecQuery($"select acumulado from TREND_SPENDING where tipo = '${tipo.ToUpperCase}'"$)
|
||||||
|
If d.RowCount > 0 Then
|
||||||
|
d.Position = 0
|
||||||
|
acumulado = d.GetString("ACUMULADO")
|
||||||
|
End If
|
||||||
|
' LogColor($"Acumulado hoy de ${tipo}: "$ & acumulado, Colors.Blue)
|
||||||
|
Return NumberFormat2(acumulado, 1, 2, 2, False)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Trae el cliente de CUENTAA
|
||||||
|
Sub traeCliente As String 'ignore
|
||||||
|
Private c As Cursor
|
||||||
|
Private cl As String
|
||||||
|
c = Starter.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||||
|
c.Position = 0
|
||||||
|
cl = c.GetString("CUENTA")
|
||||||
|
c.Close
|
||||||
|
Return cl
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub traePrecio(id As String) As String
|
||||||
|
Private precio As String = "0"
|
||||||
|
Private c As Cursor = tsdb.ExecQuery($"select cat_gp_precio from ${traeTablaProds(Starter.tipov)} where cat_gp_id = '${id}'"$)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
precio = c.GetString("CAT_GP_PRECIO")
|
||||||
|
End If
|
||||||
|
Return precio
|
||||||
|
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
|
||||||
|
Private mx As Map = traeInfoTrendSpending
|
||||||
|
TS_RMI = Regex.Split(",", mx.Get("RMI"))
|
||||||
|
TS_DESCUENTOS = Regex.Split(",", mx.Get("DESCUENTOS"))
|
||||||
|
TS_BONIFICACIONES = Regex.Split(",", mx.Get("BONIFICACIONES"))
|
||||||
|
If tipo.ToUpperCase = "RMI" Then
|
||||||
|
Private lasMaximas As Int = 0
|
||||||
|
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($"LaCant: ${laCant}"$)
|
||||||
|
Private tsRestantes As String = (TS_RMI(0) - TS_RMI(1) - traeAcumuladoHoyTS("rmi"))
|
||||||
|
Log($"tsRestantes: ${tsRestantes}"$)
|
||||||
|
If accion.ToUpperCase = "PRODMAS" Then 'Regresa lasMaximas y elMonto separadas por un "|"
|
||||||
|
If elMonto > 0 Then
|
||||||
|
lasMaximas = ((laCant * elMonto) + tsRestantes) / elMonto
|
||||||
|
If logger Then Log("lasMaximas: " & lasMaximas)
|
||||||
|
If logger Then Log("traeAcumuladoHoyTS: " & traeAcumuladoHoyTS("rmi"))
|
||||||
|
End If
|
||||||
|
' If laCant + 1 = lasMaximas Then
|
||||||
|
' ToastMessageShow("El presupuesto de RMI no permite agregar mas productos!!", False)
|
||||||
|
' End If
|
||||||
|
If logger Then Log("EL RMI: " & elMonto)
|
||||||
|
If logger Then Log($"lacant=${laCant} < lasMaximas=${lasMaximas} = ${laCant<lasMaximas}"$)
|
||||||
|
If laCant < lasMaximas Then
|
||||||
|
modTrendSpending("resta", "rmi", elMonto) ' Restamos al presupuesto de hoy (agregamos al acumulado).
|
||||||
|
Log($"modTrendSpending("resta", "rmi", ${elMonto})"$)
|
||||||
|
End If
|
||||||
|
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)
|
||||||
|
If laCant >= 0 Then
|
||||||
|
modTrendSpending("suma", "rmi", elMonto) ' Agregamos al presupuesto de hoy (restamos del acumulado).
|
||||||
|
Log($"modTrendSpending("suma", "rmi", ${elMonto})"$)
|
||||||
|
End If
|
||||||
|
Return lasMaximas & "|" & elMonto
|
||||||
|
End If
|
||||||
|
else If tipo.ToUpperCase = "DESCUENTOS" Then
|
||||||
|
Dim lasMaximas As Int = 0
|
||||||
|
Dim elMonto As String = 0
|
||||||
|
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 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 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("Acumulado hoy: " & traeAcumuladoHoyTS("descuentos"))
|
||||||
|
End If
|
||||||
|
If laCant = lasMaximas Then
|
||||||
|
ToastMessageShow("El presupuesto de DESCUENTOS no permite agregar mas productos!!", False)
|
||||||
|
End If
|
||||||
|
If logger Then Log("EL MONTO: " & elMonto)
|
||||||
|
If inv > 0 And laCant < lasMaximas Then
|
||||||
|
modTrendSpending("resta", "descuentos", elMonto) ' Restamos al presupuesto de hoy (agregamos al acumulado).
|
||||||
|
End If
|
||||||
|
If logger Then Log(">>>> MONTO RESTANTE PRESUPUESTO: " & (TS_DESCUENTOS(0) - TS_DESCUENTOS(1) - traeAcumuladoHoyTS("descuentos")))
|
||||||
|
Return lasMaximas & "|" & elMonto
|
||||||
|
else if accion.ToUpperCase = "PRODMENOS" Then 'Regresa descuentosMaximas y elMonto separadas por un "|"
|
||||||
|
If logger Then Log("LaCANT= " & laCant & ", elMonto= " & elMonto)
|
||||||
|
If laCant >= 0 Then
|
||||||
|
modTrendSpending("suma", "descuentos", elMonto) ' Agregamos al presupuesto de hoy (restamos del acumulado).
|
||||||
|
End If
|
||||||
|
Return lasMaximas & "|" & elMonto
|
||||||
|
else if accion.ToUpperCase = "TEXTCHANGED" Then
|
||||||
|
If logger Then Log("TC")
|
||||||
|
else if accion.ToUpperCase = "FOCUSCHANGED" Then 'Regresa descuentos maximas, SOLO correr esta parte si HASFOCUS es VERDADERO.
|
||||||
|
If logger Then Log("FC")
|
||||||
|
Private elMonto As String = traePrecio(id)*(traeDescXSku(clienteId, id)/100)
|
||||||
|
If elMonto > 0 Then 'And HasFocus
|
||||||
|
If logger Then Log("LA BONIFICACION: " & elMonto)
|
||||||
|
Private tsRestantes As String = (TS_DESCUENTOS(0) - TS_DESCUENTOS(1) - traeAcumuladoHoyTS("descuentos"))
|
||||||
|
If logger Then Log("Monto del PRESUPUESTO disponible: " & tsRestantes)
|
||||||
|
lasMaximas = ((laCant * elMonto) + tsRestantes) / elMonto
|
||||||
|
If logger Then Log("tsMaximas: " & lasMaximas)
|
||||||
|
End If
|
||||||
|
Return lasMaximas
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' Trae el precio del RMI desde CAT_RMI.
|
||||||
|
Sub traePrecioRMI(id As String) As String
|
||||||
|
Private precio As String = "0"
|
||||||
|
Private c As Cursor = tsdb.ExecQuery($"select cat_monto from cat_rmi where cat_id = '${id}'"$)
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
precio = c.GetString("CAT_MONTO")
|
||||||
|
End If
|
||||||
|
Return precio
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' Traemos el monto (descuento total) del producto actual.
|
||||||
|
' Utiliza el descuento de condiciones comerciales por SKU (tabla CAT_DESCUENTOS).
|
||||||
|
Sub traeMonto(clienteId As String, id As String) As String
|
||||||
|
Private tsMonto As String
|
||||||
|
tsMonto = NumberFormat2(traePrecio(id)*(traeDescXSku(clienteId, id)/100), 1, 2, 2, False)
|
||||||
|
Return tsMonto
|
||||||
|
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 = 10000000
|
||||||
|
Private tsRestantes As String = 0
|
||||||
|
Private tsMonto As String '= traeMonto(clienteId, id)
|
||||||
|
' If tsMonto > 0 Then
|
||||||
|
If tipo.ToUpperCase = "DESCUENTOS" Then
|
||||||
|
tsMonto = NumberFormat2(traePrecio(id)*(traeDescXSku(clienteId, id)/100), 1, 2, 2, False)
|
||||||
|
tsRestantes = (TS_DESCUENTOS(0) - TS_DESCUENTOS(1) - traeAcumuladoHoyTS("descuentos")) ' Traemos monto restante de Trend Spending para descuentos.
|
||||||
|
else If tipo.ToUpperCase = "RMI" Then
|
||||||
|
tsMonto = NumberFormat2(traePrecioRMI(id), 1, 2, 2, False)
|
||||||
|
tsRestantes = (TS_RMI(0) - TS_RMI(1) - traeAcumuladoHoyTS("rmi")) ' Traemos monto restante de Trend Spending para rmis.
|
||||||
|
' else 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($"${TS_BONIFICACIONES(0)} - ${TS_BONIFICACIONES(1)} - ${traeAcumuladoHoyTS("bonificaciones")}"$)
|
||||||
|
' Log($"((${laCant} * ${tsMonto}) + ${tsRestantes}) / ${tsMonto}"$)
|
||||||
|
Log($"tsMonto: ${tsMonto}"$)
|
||||||
|
Log($"tsRestantes: ${tsRestantes}"$)
|
||||||
|
tsMaximas = ((laCant * tsMonto) + tsRestantes) / tsMonto
|
||||||
|
' End If
|
||||||
|
Return tsMaximas
|
||||||
|
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 = True
|
||||||
|
Private tsMaximas As Int = 100000000
|
||||||
|
Private tsRestantes As String = 0
|
||||||
|
Private tsMonto As String
|
||||||
|
|
||||||
|
Private mx As Map = traeInfoTrendSpending
|
||||||
|
TS_RMI = Regex.Split(",", mx.Get("RMI"))
|
||||||
|
TS_DESCUENTOS = Regex.Split(",", mx.Get("DESCUENTOS"))
|
||||||
|
TS_BONIFICACIONES = Regex.Split(",", mx.Get("BONIFICACIONES"))
|
||||||
|
|
||||||
|
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($" 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})) = ${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 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
|
||||||
|
|
||||||
|
' Trae el monto de la bonificacion, que es el precio original MENOS el precio de venta con descuento.
|
||||||
|
' - 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
|
||||||
|
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}'"$)
|
||||||
|
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
|
||||||
|
tsMonto = c.GetString("CAT_GP_PRECIO") - c.GetString("CAT_DP_PRECIO") ' Precio original - precio de venta.
|
||||||
|
Else
|
||||||
|
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}"$)
|
||||||
|
End If
|
||||||
|
' Log("ROWCOUNT: " & c.RowCount)
|
||||||
|
End If
|
||||||
|
If thisLog Then LogColor($" ============ TERMINA MONTO BONIFICACION ========"$, Colors.RGB(151,0,171))
|
||||||
|
Return tsMonto
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' Recibe una lista con los ids de los productos variables, revisa cada id para traer los maximos por presupuesto para ese producto
|
||||||
|
' y pone ese maximo en una lista, luego ordena esa lista para obtener el mas chico y regresa ese como maximo.
|
||||||
|
' esta funcion se va a aplicar en la funcion maxpromos como un limite mas para que no muestre las promociones.
|
||||||
|
' NOTA: hay que ver como y cuando dejar de mostrar promociones cuando quede poco presupuesto para bonificaciones.
|
||||||
|
' NOTA: Talvez se pueda hacer que cuando se entre a PROMOS, si ya no hay presupuesto suficiente, mande un toast o msgbox diciendo que ya
|
||||||
|
' 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 = False
|
||||||
|
Private Maxs As Int = 10000000
|
||||||
|
Private prodsVariablesXPresupuestoBonificaciones As List
|
||||||
|
Private prodsVariablesRequeridos As Int = traeProdsVariablesRequeridos(promo)
|
||||||
|
prodsVariablesXPresupuestoBonificaciones.Initialize
|
||||||
|
' LogColor("===========> Prods Variables: " & idProdsVariables.Size & " <==========", Colors.red)
|
||||||
|
For i = 0 To idProdsVariables.Size - 1 'Obtenemos total de productos variables disponibes.
|
||||||
|
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), 1, promo))
|
||||||
|
Private maxProds As Int = traeBonificacionesMaximas("bonificaciones", traeCliente, idProdsVariables.Get(i), prodsVariablesRequeridos, 1, promo)
|
||||||
|
prodsVariablesXPresupuestoBonificaciones.Add(maxProds)
|
||||||
|
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
|
||||||
|
|
||||||
|
' Regresa los productos variables requeridos de la promocion dada.
|
||||||
|
Sub traeProdsVariablesRequeridos(promo As String) As Int
|
||||||
|
Private pvr As Int = 0
|
||||||
|
Private c As Cursor = Starter.skmt.ExecQuery("Select CAT_GP_STS, CAT_GP_NOMBRE from CAT_GUNAPROD2 where CAT_GP_ID = '"& promo & "'") 'Obtenemos las piezas requeridas de productos variables para la promoción.
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
pvr = c.GetString("CAT_GP_STS")
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
c.Close
|
||||||
|
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".
|
||||||
|
|
||||||
|
' Falta el codigo para el funcionamiento diferente de las bonificaciones:
|
||||||
|
' Si CAT_DP_PRECIOB es 1 --> (Precio de original (cat_precio) - precio de venta) y se suma al acumulado de BONIFICACIONES
|
||||||
|
' Si CAT_DP_PRECIOB es 0 --> precio orginal se suma al acumulado de BONIFICACIONES
|
||||||
|
'Hay que traer desde web la columna "CAT_DP_PRECIOB" y gardarla en algun lado en movil!!
|
||||||
File diff suppressed because one or more lines are too long
@@ -26,6 +26,7 @@ ModuleBookmarks30=
|
|||||||
ModuleBookmarks31=
|
ModuleBookmarks31=
|
||||||
ModuleBookmarks32=
|
ModuleBookmarks32=
|
||||||
ModuleBookmarks33=
|
ModuleBookmarks33=
|
||||||
|
ModuleBookmarks34=
|
||||||
ModuleBookmarks4=
|
ModuleBookmarks4=
|
||||||
ModuleBookmarks5=
|
ModuleBookmarks5=
|
||||||
ModuleBookmarks6=
|
ModuleBookmarks6=
|
||||||
@@ -60,6 +61,7 @@ ModuleBreakpoints30=
|
|||||||
ModuleBreakpoints31=
|
ModuleBreakpoints31=
|
||||||
ModuleBreakpoints32=
|
ModuleBreakpoints32=
|
||||||
ModuleBreakpoints33=
|
ModuleBreakpoints33=
|
||||||
|
ModuleBreakpoints34=
|
||||||
ModuleBreakpoints4=
|
ModuleBreakpoints4=
|
||||||
ModuleBreakpoints5=
|
ModuleBreakpoints5=
|
||||||
ModuleBreakpoints6=
|
ModuleBreakpoints6=
|
||||||
@@ -67,39 +69,40 @@ ModuleBreakpoints7=
|
|||||||
ModuleBreakpoints8=
|
ModuleBreakpoints8=
|
||||||
ModuleBreakpoints9=
|
ModuleBreakpoints9=
|
||||||
ModuleClosedNodes0=
|
ModuleClosedNodes0=
|
||||||
ModuleClosedNodes1=2,3,6,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,31,33,34,35,37,38,39,40,41,42,43,45,46,47
|
ModuleClosedNodes1=3,4,6,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,31,33,34,35,37,38,39,40,41,42,43,45,46,47
|
||||||
ModuleClosedNodes10=
|
ModuleClosedNodes10=
|
||||||
ModuleClosedNodes11=
|
ModuleClosedNodes11=
|
||||||
ModuleClosedNodes12=
|
ModuleClosedNodes12=
|
||||||
ModuleClosedNodes13=8,9,11,12
|
ModuleClosedNodes13=1,3
|
||||||
ModuleClosedNodes14=1,2
|
ModuleClosedNodes14=3,8,9,11,12
|
||||||
ModuleClosedNodes15=
|
ModuleClosedNodes15=1,2
|
||||||
ModuleClosedNodes16=3,8,17
|
ModuleClosedNodes16=3
|
||||||
ModuleClosedNodes17=
|
ModuleClosedNodes17=3,8,17
|
||||||
ModuleClosedNodes18=
|
ModuleClosedNodes18=
|
||||||
ModuleClosedNodes19=7,8,9,10,11,12,13,14
|
ModuleClosedNodes19=
|
||||||
ModuleClosedNodes2=
|
ModuleClosedNodes2=
|
||||||
ModuleClosedNodes20=3,4
|
ModuleClosedNodes20=7,8,9,10,11,12,13,14
|
||||||
ModuleClosedNodes21=
|
ModuleClosedNodes21=3,4
|
||||||
ModuleClosedNodes22=
|
ModuleClosedNodes22=
|
||||||
ModuleClosedNodes23=
|
ModuleClosedNodes23=
|
||||||
ModuleClosedNodes24=
|
ModuleClosedNodes24=
|
||||||
ModuleClosedNodes25=
|
ModuleClosedNodes25=
|
||||||
ModuleClosedNodes26=24,26,31,32,33,35
|
ModuleClosedNodes26=
|
||||||
ModuleClosedNodes27=
|
ModuleClosedNodes27=24,26,31,32,33,35
|
||||||
ModuleClosedNodes28=4
|
ModuleClosedNodes28=
|
||||||
ModuleClosedNodes29=
|
ModuleClosedNodes29=3,4
|
||||||
ModuleClosedNodes3=
|
ModuleClosedNodes3=
|
||||||
ModuleClosedNodes30=
|
ModuleClosedNodes30=
|
||||||
ModuleClosedNodes31=
|
ModuleClosedNodes31=
|
||||||
ModuleClosedNodes32=116
|
ModuleClosedNodes32=
|
||||||
ModuleClosedNodes33=
|
ModuleClosedNodes33=116
|
||||||
|
ModuleClosedNodes34=
|
||||||
ModuleClosedNodes4=
|
ModuleClosedNodes4=
|
||||||
ModuleClosedNodes5=
|
ModuleClosedNodes5=
|
||||||
ModuleClosedNodes6=
|
ModuleClosedNodes6=
|
||||||
ModuleClosedNodes7=
|
ModuleClosedNodes7=
|
||||||
ModuleClosedNodes8=
|
ModuleClosedNodes8=
|
||||||
ModuleClosedNodes9=
|
ModuleClosedNodes9=3
|
||||||
NavigationStack=C_Principal,cargar_Click,1031,0,Subs,modTrendSpending,2210,3,C_TrendSpending,modTrendSpending,112,2,C_Productos,B4XPage_Appear,236,0,C_TrendSpending,traeDescXSku,59,0,C_TrendSpending,traeInfoTrendSpending,73,2,C_Principal,JobDone,2240,0,Main,Activity_Create,43,0,B4XMainPage,Class_Globals,119,0,B4XMainPage,Initialize,129,0
|
NavigationStack=C_Auditoria,traeCliente,67,6,C_Auditoria,traeRuta,46,0,C_Auditoria,traeUsuarioDeBD,60,4,C_Auditoria,traeAlmacen,36,6,C_Auditoria,Class_Globals,0,0,C_Auditoria,B4XPage_Created,15,0,C_Auditoria,Initialize,12,0,B4XMainPage,B4XPage_Appear,409,0,B4XMainPage,Class_Globals,120,0,Starter,Process_Globals,55,0
|
||||||
SelectedBuild=0
|
SelectedBuild=0
|
||||||
VisibleModules=31,1,12,3,32,13,14,20,19,33
|
VisibleModules=32,1,13,4,33,15,34,2,20,14,16,8,7,9,10,11,12,29,5
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ Sub Activity_Create(FirstTime As Boolean)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Activity_Resume
|
Sub Activity_Resume
|
||||||
|
B4XPages.MainPage.aud.guarda("Entrada a MapaRutas")
|
||||||
If GPS.GPSEnabled = False Then
|
If GPS.GPSEnabled = False Then
|
||||||
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
||||||
StartActivity(GPS.LocationSettingsIntent)
|
StartActivity(GPS.LocationSettingsIntent)
|
||||||
@@ -232,6 +233,7 @@ Sub OnInfoWindowClickListener1_click(Marker1 As Marker)
|
|||||||
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||||
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?) ", Array As Object(Marker1.Title))
|
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?) ", Array As Object(Marker1.Title))
|
||||||
Activity.Finish
|
Activity.Finish
|
||||||
|
B4XPages.MainPage.aud.guarda($"Clic Tooltip Mapas Ruta: ${Marker1.Title}"$)
|
||||||
Subs.iniciaActividad("Cliente")
|
Subs.iniciaActividad("Cliente")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user