mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-17 18:26:11 +00:00
- VERSION 5.10.15
- Se hicieron correcciones al codigo de Trade Spending. - Se cambio la tabla de donde lee los datos para dar de alta clientes nuevos, antes en CLIENTES_NUEVOS_X_RUTA, ahora CAT_RUTAS.
This commit is contained in:
@@ -867,6 +867,13 @@ Private Sub b_cargaLocalOk_Click
|
||||
p_cargaLocal.Visible = False
|
||||
' Log(et_cargaLocal.Text.Length > pass1.Length)
|
||||
|
||||
Log("Deshabilitamos VERIFY_DEVICE")
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("VERIFY_DEVICE"))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("VERIFY_DEVICE", 0))
|
||||
Log("Deshabilitamos VALIDA_VERSION")
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("VALIDA_VERSION"))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("VALIDA_VERSION", 0))
|
||||
|
||||
Log(et_cargaLocal.text)
|
||||
If et_cargaLocal.Text.Length = pass1.Length Then ' Si no se especifica nada, la fecha es hoy MENOS un día.
|
||||
et_cargaLocal.text = et_cargaLocal.text & "-1"
|
||||
@@ -949,12 +956,7 @@ Private Sub cb_cartaPorte_CheckedChange(Checked As Boolean)
|
||||
Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('CARTAPORTE', '${Checked}')"$)
|
||||
End Sub
|
||||
|
||||
Private Sub et_maxClientesNuevos_TextChanged (Old As String, New As String)
|
||||
If IsNumber(New) Then
|
||||
Starter.skmt.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'MAXCTESNUEVOS'")
|
||||
Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('MAXCTESNUEVOS', '${New}')"$)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
private Sub l_geocerca_Click
|
||||
If cb_geocerca.Enabled = False Then ToastMessageShow("Ingrese la contraseña para modificar", True)
|
||||
@@ -965,6 +967,8 @@ Private Sub et_geocerca_TextChanged (Old As String, New As String)
|
||||
Log(New & "|" & Starter.passSupervisor)
|
||||
If x.RowCount > 0 Then
|
||||
x.Position = 0
|
||||
Log("Pass FinDia: |" & x.GetString("CAT_VA_VALOR")&"|"&New&"|")
|
||||
Log(New.Trim = x.GetString("CAT_VA_VALOR").Trim)
|
||||
If New = x.GetString("CAT_VA_VALOR") Or New = Starter.passSupervisor Then
|
||||
cb_geocerca.Enabled = True
|
||||
cb_cartaPorte.Enabled = True
|
||||
@@ -1055,19 +1059,19 @@ Private Sub ImageView1_LongClick
|
||||
' cmdX.Name = "update_usuario_guna_nobajas"
|
||||
' cmdX.Parameters = Array As Object("CDAZA")
|
||||
' reqManagerX.Executequery(cmdX, 0, "traeConexion")
|
||||
|
||||
' Log("traeConexion")
|
||||
' Private reqManagerX As DBRequestManager
|
||||
' reqManagerX.Initialize(Me, "http://keymon.net:9010/DB2")
|
||||
' Private cmdX As DBCommand
|
||||
' cmdX.Initialize
|
||||
' cmdX.Name = "traeVersion999"
|
||||
' cmdX.Parameters = Array As Object("CDAZA")
|
||||
' reqManagerX.ExecuteCommand(cmdX, "prueba")
|
||||
|
||||
If Subs.traeAlmacen <> "" Then
|
||||
linker.VerifyDevice(Subs.traeAlmacen, Subs.traeRuta)
|
||||
End If
|
||||
|
||||
Log("traeConexion")
|
||||
Private reqManagerX As DBRequestManager
|
||||
reqManagerX.Initialize(Me, "http://keymon.net:9010/SALMA")
|
||||
Private cmdX As DBCommand
|
||||
cmdX.Initialize
|
||||
cmdX.Name = "traeConexion4"
|
||||
cmdX.Parameters = Array As Object("CDAZA", 2, 3, 4)
|
||||
reqManagerX.ExecuteQuery(cmdX, 0, "prueba")
|
||||
|
||||
' If Subs.traeAlmacen <> "" Then
|
||||
' linker.VerifyDevice(Subs.traeAlmacen, Subs.traeRuta)
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub ponUsuario
|
||||
|
||||
@@ -772,6 +772,7 @@ Sub B4XPage_Appear
|
||||
|
||||
'PROMOS POR MONTO
|
||||
Private mPromoXMonto As Map = Subs.revisaPromoPorMonto
|
||||
Private elMontoTSDeLaVenta As String = 0
|
||||
' LogColor("PROMOXMONTO:" & mPromoXMonto, Colors.Blue)
|
||||
If mPromoXMonto.Size > 0 And clienteId <> 0 Then ' El "clienteId <> 0" es para que no la promo cuando se pida ABORDO
|
||||
If l_total.Text > mPromoXMonto.Get("rangoMin") And l_total.Text < mPromoXMonto.Get("precio1") Then
|
||||
@@ -786,8 +787,13 @@ Sub B4XPage_Appear
|
||||
dp.Position = i
|
||||
If dp.GetString("CAT_DP_TIPO") = "0" Then
|
||||
Subs.guardaProductoSinGestion(mPromoXMonto.Get("id"), dp.GetString("CAT_DP_PRECIO"), dp.GetString("CAT_DP_PZAS"), Subs.traeProdNombre(dp.GetString("CAT_DP_IDPROD")), dp.GetString("CAT_DP_IDPROD"), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
||||
' Traemos el monto de las bonificacionos a guardar. -- Trade Spending
|
||||
Log("Monto Bonificacion -->> " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(dp.GetString("CAT_DP_IDPROD"), dp.GetString("CAT_DP_PRECIO"), mPromoXMonto.Get("id")))
|
||||
elMontoTSDeLaVenta = elMontoTSDeLaVenta + (B4XPages.MainPage.promos.ts.traeMontoBonificacion(dp.GetString("CAT_DP_IDPROD"), dp.GetString("CAT_DP_PRECIO"), mPromoXMonto.Get("id")) * dp.GetString("CAT_DP_PZAS"))
|
||||
End If
|
||||
Next
|
||||
B4XPages.MainPage.promos.ts.modTrendSpending("RESTA", "BONIFICACIONES", elMontoTSDeLaVenta)
|
||||
Log($"### modTrendSpending("RESTA", "BONIFICACIONES", ${elMontoTSDeLaVenta})"$)
|
||||
MsgboxAsync($"Promo por monto "${Subs.traeProdNombre(mPromoXMonto.Get("id"))}" agregada."$,"AVISO")
|
||||
B4XPage_Appear
|
||||
End If
|
||||
|
||||
@@ -552,7 +552,7 @@ Sub B4XPage_Appear
|
||||
trabajar.Enabled = False
|
||||
NUEVO.Enabled = False
|
||||
B_PROXIMA.Enabled = False
|
||||
LogColor("deshabilitamos", Colors.magenta)
|
||||
' LogColor("deshabilitamos", Colors.magenta)
|
||||
Else
|
||||
Private cd1 As ColorDrawable
|
||||
cd1.Initialize(Colors.RGB(213, 0, 0), 5dip)
|
||||
@@ -573,7 +573,7 @@ Sub B4XPage_Appear
|
||||
Btn_CheckList.Enabled = False
|
||||
NUEVO.Enabled = False
|
||||
B_PROXIMA.Enabled = False
|
||||
LogColor("deshabilitamos", Colors.magenta)
|
||||
' LogColor("deshabilitamos", Colors.magenta)
|
||||
Else
|
||||
trabajar.Enabled = True
|
||||
Resumen.Enabled = True
|
||||
@@ -581,7 +581,7 @@ Sub B4XPage_Appear
|
||||
Btn_CheckList.Enabled = True
|
||||
NUEVO.Enabled = True
|
||||
B_PROXIMA.Enabled = True
|
||||
LogColor("deshabilitamos", Colors.magenta)
|
||||
' LogColor("deshabilitamos", Colors.magenta)
|
||||
End If
|
||||
|
||||
'################################################################################
|
||||
@@ -1830,6 +1830,7 @@ Sub JobDone(Job As HttpJob)
|
||||
If RESULT.Tag = "version" Then 'query tag
|
||||
connecta.TextColor = Colors.White
|
||||
' Subs.logJobDoneResultados(RESULT)
|
||||
Subs.logJobDoneResultados(RESULT)
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Starter.skmt.ExecNonQuery("delete from VERSION")
|
||||
Dim CAT_RU_VERSION_REQUERIDA As String = records(RESULT.Columns.Get("CAT_RU_VERSION_REQUERIDA"))
|
||||
@@ -1850,7 +1851,7 @@ Sub JobDone(Job As HttpJob)
|
||||
BUSCA.Enabled = False
|
||||
Btn_CheckList.Enabled = False
|
||||
' ExitApplication
|
||||
LogColor("deshabilitamos", Colors.magenta)
|
||||
' LogColor("deshabilitamos", Colors.magenta)
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -2331,12 +2332,23 @@ Sub connecta_Click
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
'Revisamos que la version actual sea la correcta.
|
||||
Sub connecta2
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_version_KELL"
|
||||
cmd.Parameters = Array As Object(ALMACEN, e_ruta.text)
|
||||
reqManager.ExecuteQuery(cmd , 0, "version")
|
||||
Private revisaVersion As Boolean = True ' La verificacion se realiza por default
|
||||
Private vv As Cursor = Starter.skmt.ExecQuery("select * from cat_variables where CAT_VA_DESCRIPCION = 'VALIDA_VERSION'")
|
||||
If vv.RowCount > 0 Then
|
||||
vv.Position = 0
|
||||
If vv.GetString("CAT_VA_VALOR") = 0 Then revisaVersion = False
|
||||
End If
|
||||
If revisaVersion Then ' Si VALIDA_VERSION no está en CERO ... revisamos.
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_version_KELL"
|
||||
cmd.Parameters = Array As Object(ALMACEN, e_ruta.text)
|
||||
reqManager.ExecuteQuery(cmd , 0, "version")
|
||||
Else ' Si está en CERO (Validacion deshabilitada), continuamos a connecta3.
|
||||
connecta3
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub connecta3
|
||||
@@ -2416,7 +2428,7 @@ Sub e_ruta_EnterPressed
|
||||
Starter.skmt.ExecNonQuery("delete from TREND_SPENDING")
|
||||
Starter.skmt.ExecNonQuery("delete from HIST_TREND_SPENDING_SEMANAL")
|
||||
Starter.skmt.ExecNonQuery("delete from VERSIONES")
|
||||
|
||||
|
||||
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("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("NUMERO_PEDIDO",0))
|
||||
@@ -2424,6 +2436,8 @@ Sub e_ruta_EnterPressed
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object("FINDIA_FECHA", Starter.FECHA_HOY))
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("NOVISITA_ACTIVA"))
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("NOVISITA_RAZON"))
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("VERIFY_DEVICE"))
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("VALIDA_VERSION"))
|
||||
If File.Exists(File.DirInternal,"FOTO1.jpg") Then File.Delete(File.DirInternal,"FOTO1.jpg")
|
||||
If File.Exists(File.DirInternal,"FOTO2.jpg") Then File.Delete(File.DirInternal,"FOTO2.jpg")
|
||||
If File.Exists(File.DirInternal,"FOTO3.jpg") Then File.Delete(File.DirInternal,"FOTO3.jpg")
|
||||
@@ -3880,7 +3894,7 @@ Private Sub b_noVisita_Click
|
||||
b_motivoNoVisita.Background = cd1
|
||||
B_MAPA_RUTA.Enabled = False
|
||||
trabajar.Enabled = False
|
||||
LogColor("deshabilitamos", Colors.magenta)
|
||||
' LogColor("deshabilitamos", Colors.magenta)
|
||||
NUEVO.Enabled = False
|
||||
B_PROXIMA.Enabled = False
|
||||
Else If result = DialogResponse.CANCEL Then
|
||||
|
||||
@@ -113,6 +113,9 @@ End Sub
|
||||
Public Sub Initialize As Object
|
||||
kh.Initialize(Me, "kh", Starter.skmt)
|
||||
ts.Initialize(Me, "ts", Starter.skmt)
|
||||
Log(TS_RMI)
|
||||
Log(TS_DESCUENTOS)
|
||||
Log(TS_BONIFICACIONES)
|
||||
' promosC.Initialize(Me, "promosC", Starter.skmt)
|
||||
Return Me
|
||||
End Sub
|
||||
@@ -604,7 +607,7 @@ Sub b_prodMenos_Click
|
||||
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
|
||||
' Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":Subs.traeAlmacen)
|
||||
Log(clv_prods_ll.GetValue(index).As(Map))
|
||||
|
||||
|
||||
' ######## Trend Spending - Poner estas lineas antes de que si es negativo se ponga en CERO.
|
||||
' Private laBonificacion As String = kh.traePrecio(id)*(kh.traeDescXSku(clienteId, id)/100)
|
||||
' If laBonificacion > 0 Then
|
||||
@@ -620,7 +623,7 @@ Sub b_prodMenos_Click
|
||||
' Subs.modTrendSpending("suma", "bonificaciones", laBonificacion)
|
||||
' End If
|
||||
' #######################
|
||||
|
||||
|
||||
' ######## Trend Spending - Poner estas lineas antes de que si es negativo se ponga en CERO.
|
||||
If lfila.Text = "PRODUCTOS" Then
|
||||
Log(">>>>>>>>>> PRODUCTOS <<<<<<<<<<<<<<")
|
||||
@@ -629,7 +632,7 @@ Sub b_prodMenos_Click
|
||||
ts.trendSpending("prodMenos", "rmi", clienteId, id, laCant.Text, 0)
|
||||
End If
|
||||
' #######################
|
||||
|
||||
|
||||
If laCant.Text < 0 Then laCant.Text = 0
|
||||
' Log(tmpMap)
|
||||
' prodsMap.Put(id, tmpMap)
|
||||
@@ -792,7 +795,7 @@ Sub b_prodMas_Click
|
||||
' Log(77)
|
||||
laCant.Text = "0"
|
||||
End If
|
||||
|
||||
|
||||
Log(99)
|
||||
If lfila.Text = "RMI" Then
|
||||
almacenX = "DUR"
|
||||
@@ -1150,7 +1153,7 @@ End Sub
|
||||
Private Sub lv_promos_ItemLongClick (Position As Int, Value As Object)
|
||||
Log("Promo longclic = "&Value)
|
||||
Private id As String = ""
|
||||
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}'"$)
|
||||
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
|
||||
c.Position = 0
|
||||
id = c.GetString("CAT_GP_ID")
|
||||
@@ -1442,7 +1445,7 @@ Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As In
|
||||
LogColor("#### ERROR DE INVENTARIO ####" , Colors.red)
|
||||
End If
|
||||
'#######################################################
|
||||
|
||||
|
||||
l_prodX.Tag = clv_prods_ll.GetValue(i).As(Map).Get("id")
|
||||
l_pCant.Tag = clv_prods_ll.GetValue(i).As(Map).Get("id")
|
||||
End If
|
||||
|
||||
@@ -44,12 +44,18 @@ Sub Class_Globals
|
||||
Dim montoPedidoActual As String
|
||||
Dim promosMap As Map
|
||||
Dim ts As C_TrendSpending
|
||||
Dim TS_RMI() As String
|
||||
Dim TS_DESCUENTOS() As String
|
||||
Dim TS_BONIFICACIONES() As String
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
' promosC.Initialize(Me, "promosC", Starter.skmt)
|
||||
ts.Initialize("ts", "ts", Starter.skmt)
|
||||
Log(TS_RMI)
|
||||
Log(TS_DESCUENTOS)
|
||||
Log(TS_BONIFICACIONES)
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
@@ -479,29 +485,35 @@ Private Sub b_terminar1_Click
|
||||
Log($"${prodsIds}${CRLF}${prodsCants}${CRLF}${prodsPrecios}"$)
|
||||
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
||||
Private pn As String = Subs.traeProdNombre(prodsIds.Get(t))
|
||||
|
||||
|
||||
Private idProdFijo As String = prodsIds.Get(t)
|
||||
Private cantProdFijo As Int = prodsCants.Get(t)
|
||||
|
||||
Private prodsPrecio As String = prodsPrecios.Get(t)
|
||||
|
||||
Log($"#### idProdFijo: ${idProdFijo}, ${cantProdFijo}, ${prodsPrecio}"$)
|
||||
|
||||
' ' Asumimos que el índice 0 es el encabezado de la promoción (estaPromo) y no tiene bonificación de producto.
|
||||
If t > 0 Then
|
||||
Private bonificacion_monto As String = ts.traeMontoBonificacion(idProdFijo, estaPromo)
|
||||
Private bonificacion_monto As String = ts.traeMontoBonificacion(idProdFijo, prodsPrecio, estaPromo)
|
||||
Log(bonificacion_monto)
|
||||
Log("elMontoTSDeLaVenta=" & elMontoTSDeLaVenta)
|
||||
Log($"${elMontoTSDeLaVenta} + (${bonificacion_monto} * ${cantProdFijo})"$)
|
||||
elMontoTSDeLaVenta = elMontoTSDeLaVenta + (bonificacion_monto * cantProdFijo)
|
||||
Log($"TS Fijo Acumulado: ${elMontoTSDeLaVenta}, Prod: ${idProdFijo}"$)
|
||||
End If
|
||||
|
||||
|
||||
If prodsCants.Get(t) > 0 Then Subs.guardaProductoSinGestion(estaPromo, prodsPrecios.Get(t), prodsCants.Get(t), pn, prodsIds.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
||||
Next
|
||||
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))
|
||||
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("Monto Bonificacion -->> " & ts.traeMontoBonificacion(prodsIds2.Get(t), prodsPrecios2.Get(t), estaPromo))
|
||||
elMontoTSDeLaVenta = elMontoTSDeLaVenta + (ts.traeMontoBonificacion(prodsIds2.Get(t), prodsPrecios2.Get(t), estaPromo) * prodsCants2.Get(t))
|
||||
Log("Acumulado: " & elMontoTSDeLaVenta)
|
||||
Next
|
||||
ts.modTrendSpending("RESTA", "BONIFICACIONES", elMontoTSDeLaVenta)
|
||||
Log($"### modTrendSpending("RESTA", "BONIFICACIONES", ${elMontoTSDeLaVenta})"$)
|
||||
lv_prodsFijos.Clear
|
||||
B4XPages.MainPage.bTerminarClicked = True
|
||||
B4XPages.ShowPage("productos")
|
||||
@@ -515,29 +527,35 @@ Private Sub b_continuar_Click
|
||||
Log($"${prodsIds}${CRLF}${prodsCants}${CRLF}${prodsPrecios}"$)
|
||||
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
||||
Private pn As String = Subs.traeProdNombre(prodsIds.Get(t))
|
||||
|
||||
|
||||
Private idProdFijo As String = prodsIds.Get(t)
|
||||
Private cantProdFijo As Int = prodsCants.Get(t)
|
||||
|
||||
Private prodsPrecio As String = prodsPrecios.Get(t)
|
||||
|
||||
Log($"#### idProdFijo: ${idProdFijo}, ${cantProdFijo}, ${prodsPrecio}"$)
|
||||
|
||||
' ' Asumimos que el índice 0 es el encabezado de la promoción (estaPromo) y no tiene bonificación de producto.
|
||||
If t > 0 Then
|
||||
Private bonificacion_monto As String = ts.traeMontoBonificacion(idProdFijo, estaPromo)
|
||||
Private bonificacion_monto As String = ts.traeMontoBonificacion(idProdFijo, prodsPrecio, estaPromo)
|
||||
Log(bonificacion_monto)
|
||||
Log("elMontoTSDeLaVenta=" & elMontoTSDeLaVenta)
|
||||
Log($"${elMontoTSDeLaVenta} + (${bonificacion_monto} * ${cantProdFijo})"$)
|
||||
elMontoTSDeLaVenta = elMontoTSDeLaVenta + (bonificacion_monto * cantProdFijo)
|
||||
Log($"TS Fijo Acumulado: ${elMontoTSDeLaVenta}, Prod: ${idProdFijo}"$)
|
||||
End If
|
||||
|
||||
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios.Get(t), prodsCants.Get(t), pn, prodsIds.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
||||
|
||||
If prodsCants.Get(t) > 0 Then Subs.guardaProductoSinGestion(estaPromo, prodsPrecios.Get(t), prodsCants.Get(t), pn, prodsIds.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, Starter.tipov)
|
||||
Next
|
||||
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))
|
||||
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("Monto Bonificacion -->> " & ts.traeMontoBonificacion(prodsIds2.Get(t), prodsPrecios2.Get(t), estaPromo))
|
||||
elMontoTSDeLaVenta = elMontoTSDeLaVenta + (ts.traeMontoBonificacion(prodsIds2.Get(t), prodsPrecios2.Get(t), estaPromo) * prodsCants2.Get(t))
|
||||
Log("Acumulado: " & elMontoTSDeLaVenta)
|
||||
Next
|
||||
ts.modTrendSpending("RESTA", "BONIFICACIONES", elMontoTSDeLaVenta)
|
||||
Log($"### modTrendSpending("RESTA", "BONIFICACIONES", ${elMontoTSDeLaVenta})"$)
|
||||
lv_prodsFijos.Clear
|
||||
' Activity_KeyPress(KeyCodes.KEYCODE_BACK)
|
||||
' CallSubDelayed2(productos, "Activity_KeyPress", KeyCodes.KEYCODE_BACK)
|
||||
|
||||
@@ -93,31 +93,41 @@ End Sub
|
||||
' Almacen: El identificador del almacén.
|
||||
' Ruta: El identificador de la ruta.
|
||||
Public Sub verifyDevice(Almacen_ As String, Ruta_ As String)
|
||||
Dim DeviceId_ As String = GetDeviceGUID ' Obtenemos o generamos el GUID del dispositivo.
|
||||
LogColor(DeviceId_, Colors.red)
|
||||
almacen = Almacen_
|
||||
ruta = Ruta_
|
||||
deviceId = DeviceId_
|
||||
If DeviceId_ = "" Then
|
||||
If logger Then LogColor("Error: GUID del dispositivo no pudo ser obtenido o generado.", Colors.Red)
|
||||
' Enviar una respuesta de error al callback si no se pudo obtener el GUID.
|
||||
If SubExists(CallBack, EventName & "_Response") Then ' [New Query]
|
||||
CallSub2(CallBack, EventName & "_Response", "GUID_ERROR") ' Dispara el evento Linker_Response("GUID_ERROR")
|
||||
End If
|
||||
Return
|
||||
Private verificar As Boolean = True ' La verificacion se realiza por default
|
||||
Private tv As Cursor = Starter.skmt.ExecQuery("select * from cat_variables where CAT_VA_DESCRIPCION = 'VERIFY_DEVICE'")
|
||||
If tv.RowCount > 0 Then
|
||||
tv.Position = 0
|
||||
If tv.GetString("CAT_VA_VALOR") = 0 Then verificar = False
|
||||
End If
|
||||
If verificar Then ' Si VERIFY_DEVICE no está en CERO ... verificamos.
|
||||
Dim DeviceId_ As String = GetDeviceGUID ' Obtenemos o generamos el GUID del dispositivo.
|
||||
LogColor(DeviceId_, Colors.red)
|
||||
almacen = Almacen_
|
||||
ruta = Ruta_
|
||||
deviceId = DeviceId_
|
||||
If DeviceId_ = "" Then
|
||||
If logger Then LogColor("Error: GUID del dispositivo no pudo ser obtenido o generado.", Colors.Red)
|
||||
' Enviar una respuesta de error al callback si no se pudo obtener el GUID.
|
||||
If SubExists(CallBack, EventName & "_Response") Then ' [New Query]
|
||||
CallSub2(CallBack, EventName & "_Response", "GUID_ERROR") ' Dispara el evento Linker_Response("GUID_ERROR")
|
||||
End If
|
||||
Return
|
||||
End If
|
||||
|
||||
If logger Then Log($"Enviando solicitud de verificación para DeviceId: ${DeviceId_}, Almacen: ${Almacen_}, Ruta: ${Ruta_}"$)
|
||||
If logger Then Log($"Enviando solicitud de verificación para DeviceId: ${DeviceId_}, Almacen: ${Almacen_}, Ruta: ${Ruta_}"$)
|
||||
|
||||
Dim cmd As DBCommand ' Creamos un comando para enviar al servidor.
|
||||
cmd.Initialize
|
||||
cmd.Name = "verify_device"
|
||||
' Pasamos el almacén, la ruta y el GUID del dispositivo como parámetros.
|
||||
cmd.Parameters = Array As Object(Almacen_, Ruta_) ', DeviceId_
|
||||
Log($"Enviamos almacen: ${Almacen_} y ruta: ${Ruta_}"$)
|
||||
Dim cmd As DBCommand ' Creamos un comando para enviar al servidor.
|
||||
cmd.Initialize
|
||||
cmd.Name = "verify_device"
|
||||
' Pasamos el almacén, la ruta y el GUID del dispositivo como parámetros.
|
||||
cmd.Parameters = Array As Object(Almacen_, Ruta_) ', DeviceId_
|
||||
Log($"Enviamos almacen: ${Almacen_} y ruta: ${Ruta_}"$)
|
||||
|
||||
' Ejecutamos el comando en el servidor. 'Me' indica que DBRequestManager_JobDone en esta clase manejará la respuesta.
|
||||
reqManager.ExecuteQuery(cmd, 0, "verify_device")
|
||||
' Ejecutamos el comando en el servidor. 'Me' indica que DBRequestManager_JobDone en esta clase manejará la respuesta.
|
||||
reqManager.ExecuteQuery(cmd, 0, "verify_device")
|
||||
Else ' Si está en CERO (Verificacion deshabilitada), regresamos "OK".
|
||||
CallSub2(CallBack, EventName & "_Response", "OK")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub linkDevice(Almacen_ As String, Ruta_ As String)
|
||||
|
||||
Binary file not shown.
@@ -917,7 +917,7 @@ Version=12.8
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: Kelloggs Venta
|
||||
#VersionCode: 3000
|
||||
#VersionName: 5.10.01
|
||||
#VersionName: 5.10.02
|
||||
#SupportedOrientations: portrait
|
||||
#CanInstallToExternalStorage: False
|
||||
#BridgeLogger:true
|
||||
|
||||
@@ -67,11 +67,11 @@ ModuleBreakpoints7=
|
||||
ModuleBreakpoints8=
|
||||
ModuleBreakpoints9=
|
||||
ModuleClosedNodes0=
|
||||
ModuleClosedNodes1=6
|
||||
ModuleClosedNodes1=6,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,32,33,34,35,37,38,39,40,41,42,43,45,46,47
|
||||
ModuleClosedNodes10=
|
||||
ModuleClosedNodes11=
|
||||
ModuleClosedNodes12=1,26,40
|
||||
ModuleClosedNodes13=7,8,9,10,11,12
|
||||
ModuleClosedNodes12=1
|
||||
ModuleClosedNodes13=1,7,8,9,10,11,12
|
||||
ModuleClosedNodes14=6,7,8,9,12,13
|
||||
ModuleClosedNodes15=
|
||||
ModuleClosedNodes16=3,8,17
|
||||
@@ -95,11 +95,11 @@ ModuleClosedNodes31=
|
||||
ModuleClosedNodes32=101,116
|
||||
ModuleClosedNodes33=
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=5
|
||||
ModuleClosedNodes5=
|
||||
ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=
|
||||
ModuleClosedNodes8=
|
||||
ModuleClosedNodes9=
|
||||
NavigationStack=C_Principal,enviaPedido,3368,0,kms_helperSubs,revisaImpresa,1066,0,kms_helperSubs,clienteConDOE,1062,0,B4XMainPage,B4XPage_Created,153,0,Diseñador Visual,productos.bal,-100,1,Diseñador Visual,principal.bal,-100,1,B4XMainPage,Class_Globals,32,0,C_Principal,connecta_Click,2326,0,C_Principal,connecta2,2334,0,C_Principal,connecta3,2338,0
|
||||
NavigationStack=C_Cliente,B4XPage_Appear,774,0,B4XMainPage,B4XPage_Appear,407,0,kms_helperSubs,traeMaxClientesNuevos,1034,0,C_Principal,cargar_Click,881,0,C_Productos,Class_Globals,0,0,C_Promos,revisaInvProdsVariables,472,0,C_Promos,b_terminar1_Click,511,0,C_Promos,b_continuar_Click,551,0,C_TrendSpending,traeMontoBonificacion,360,0,C_Productos,b_terminar1_Click,1080,0,C_Productos,LlenaProdsLL,1507,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=31,1,12,5,16,26,3,32,13,14,19,4,15
|
||||
VisibleModules=31,1,12,5,16,3,32,13,14,9,8,26
|
||||
|
||||
@@ -56,7 +56,7 @@ Sub Process_Globals
|
||||
Dim pingShell As Boolean = False
|
||||
Dim errorConnDBReq As Boolean = False
|
||||
Dim GUID As String = ""
|
||||
Dim passSupervisor As String = "13X#X$X46" ' Valor predeterminado DIFERENTE a ""
|
||||
Dim passSupervisor As String = "135###" ' Valor predeterminado DIFERENTE a ""
|
||||
Dim semana As Int = 0
|
||||
End Sub
|
||||
|
||||
@@ -189,17 +189,20 @@ Sub ENVIA_ULTIMA_GPS
|
||||
If i = "SALTY SNACKS" Then salty = x
|
||||
Next
|
||||
h.Close
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "UPDATE_KELL_ACTUAL3_GPS"
|
||||
cmd.Parameters = Array As Object(montoActual, clientesVisitaHoy, clientesVenta, clientesVisitados, lat_gps, lon_gps, batt, 0, 0, 0, Application.VersionName, rtec, ping, salty, Subs.dameClientesFueraDeFrecuencia, almacen, rutaPreventa)
|
||||
' If Logger Then LogColor(montoActual&","&clientesVisitaHoy&","&clientesVenta&","&clientesVisitados&","&lat_gps&","&lon_gps&","&batt&","&0&","&0&","&0&","&Application.VersionName&","&rtec&","&ping&","&salty&","& Subs.dameClientesFueraDeFrecuencia&","&almacen&","&rutaPreventa, Colors.Magenta)
|
||||
reqManager.ExecuteCommand(cmd,"updateKell_UTR")
|
||||
|
||||
cmd.Name = "select_hora"
|
||||
reqManager.ExecuteQuery(cmd , 0, "hora")
|
||||
|
||||
If Subs.EstaEnHorarioPermitido Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "UPDATE_KELL_ACTUAL3_GPS"
|
||||
cmd.Parameters = Array As Object(montoActual, clientesVisitaHoy, clientesVenta, clientesVisitados, lat_gps, lon_gps, batt, 0, 0, 0, Application.VersionName, rtec, ping, salty, Subs.dameClientesFueraDeFrecuencia, almacen, rutaPreventa)
|
||||
' If Logger Then LogColor(montoActual&","&clientesVisitaHoy&","&clientesVenta&","&clientesVisitados&","&lat_gps&","&lon_gps&","&batt&","&0&","&0&","&0&","&Application.VersionName&","&rtec&","&ping&","&salty&","& Subs.dameClientesFueraDeFrecuencia&","&almacen&","&rutaPreventa, Colors.Magenta)
|
||||
reqManager.ExecuteCommand(cmd,"updateKell_UTR")
|
||||
|
||||
cmd.Name = "select_hora"
|
||||
reqManager.ExecuteQuery(cmd , 0, "hora")
|
||||
' log(subs.revisaHora)
|
||||
|
||||
End If
|
||||
|
||||
' If Logger Then Log(reqManager)
|
||||
' If Logger Then Log("++ ++ ++ Envia_Ultima GPS - Inst_visitas - server: "& server)
|
||||
skmt.ExecNonQuery2("Update cat_variables set CAT_VA_VALOR = ? WHERE CAT_VA_DESCRIPCION = ?" , Array As String(DateTime.Time(DateTime.Now),"HoraIngreso"))
|
||||
|
||||
62
B4A/Subs.bas
62
B4A/Subs.bas
@@ -1005,10 +1005,10 @@ End Sub
|
||||
' resultado="OK" 'Ok si existe la promocion.
|
||||
' prodsVariablesRequeridos=5} 'Cantidad de productos variables requeridos para la promoción.
|
||||
Sub traePromo(promo As String, cliente As String) As Map
|
||||
Private thisLog As Boolean = False
|
||||
Private thisLog As Boolean = True
|
||||
If thisLog Then Log("traePromo:"&promo)
|
||||
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 el maximo de promociones a otorgar.
|
||||
Private siHistorico As String = 0
|
||||
Private promoMap As Map
|
||||
Private prodsFijos, prodsFijosPrecios, prodsFijosPiezas, prodsVariables, prodsVariablesPrecios As List
|
||||
@@ -1020,12 +1020,15 @@ Sub traePromo(promo As String, cliente As String) As Map
|
||||
prodsVariablesPrecios.Initialize
|
||||
c.Position = 0
|
||||
promoMap = CreateMap("id":promo, "maxXcliente":0, "maxRecurrente":0, "maxPromos":0) 'Ponemos el DEFAULT en CERO.
|
||||
If c.RowCount > 0 Then promoMap = CreateMap("id":promo, "maxXcliente":c.GetString("CAT_PA_MAXPROMCLIE"), "maxRecurrente":c.GetString("CAT_PA_MAXPROMREC"), "maxPromos":c.GetString("CAT_PA_MAXPROM"))
|
||||
If c.RowCount > 0 Then
|
||||
promoMap = CreateMap("id":promo, "maxXcliente":c.GetString("CAT_PA_MAXPROMCLIE"), "maxRecurrente":c.GetString("CAT_PA_MAXPROMREC"), "maxPromos":c.GetString("CAT_PA_MAXPROM"))
|
||||
End If
|
||||
'######### PROMOCIONES SEGMENTADAS ##########
|
||||
' Si la promo esta en la lista, SOLO los clientes que la tengan la pueden ver.
|
||||
Private ps As Cursor = Starter.skmt.ExecQuery($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}' and HCCP_CLIENTE = '${cliente}'"$)
|
||||
Private ps As Cursor = Starter.skmt.ExecQuery($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}'"$) ' and HCCP_CLIENTE = '${cliente}'
|
||||
' Log($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}'"$)
|
||||
If thisLog Then Log($"PROMOS SEGMENTADAS DISPONIBLES: ${ps.RowCount}"$)
|
||||
If thisLog Then Log(promoMap)
|
||||
If ps.RowCount > 0 Then
|
||||
ps.Position = 0
|
||||
promoMap = CreateMap("id":promo, "maxXcliente":0, "maxRecurrente":0, "maxPromos":0) 'Si es segmentada la ponemos en cero, porque SOLO le debe de aparecer a ciertos clientes.
|
||||
@@ -1343,12 +1346,14 @@ Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
|
||||
Private t As List
|
||||
t.Initialize
|
||||
t.Add(traeMaxPromos(pm)) ' Agregamos a la lista las promos maximas permitidas (recurrente, cliente y promo).
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green)
|
||||
invFijoXpromo.Initialize
|
||||
If thisLog Then LogColor($"pm=${pm}"$, Colors.Blue)
|
||||
Private invDispParaPromo As Map = traemosInventarioDisponibleParaPromo(pm.Get("id"))
|
||||
If thisLog Then Log($"invDispParaPromo=${invDispParaPromo}"$)
|
||||
Private prodsFijosPiezas As List = pm.Get("prodsFijosPiezas")
|
||||
Private idProdsFijos As List = pm.Get("prodsFijos")
|
||||
Private idProdsFijosPrecios As List = pm.Get("prodsFijosPrecios")
|
||||
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
|
||||
If invDispParaPromo.Get(idProdsFijos.Get(p)) <> Null Then thisInvDisp = invDispParaPromo.Get(idProdsFijos.Get(p))
|
||||
@@ -1361,17 +1366,19 @@ Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
|
||||
|
||||
' 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.
|
||||
t.Add(x(0).As(Int)) 'Solo guardamos la parte del entero de la division. (promos por inventario)
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green) 'promos por inventario
|
||||
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)
|
||||
t.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), pm.Get("id")))
|
||||
Log(">>>>> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsFijos.Get(p), idProdsFijosPrecios.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), idProdsFijosPrecios.Get(p), pm.Get("id")), Colors.blue)
|
||||
t.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), idProdsFijosPrecios.Get(p), pm.Get("id"))) 'Agregamos las promos disponibles por Trade Spending
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green)
|
||||
Next
|
||||
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($"prodsFijosPiezasReq=${prodsFijosPiezas}"$, Colors.Blue)
|
||||
' If thisLog Then LogColor($"invFijoXpromo=${invFijoXpromo}"$, Colors.Blue)
|
||||
' LogColor(">>>>>> T: " & t, Colors.red)
|
||||
If thisLog Then LogColor(">>>>>> T: " & t, 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.
|
||||
End Sub
|
||||
@@ -1394,6 +1401,7 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||
Private maxPromos As String = traeMaxPromos(pm)
|
||||
Private maxPromosXFijos As Int = revisaMaxPromosProdsFijosPorInventario(pm)
|
||||
Private idProdsVariables As List = pm.Get("prodsVariables")
|
||||
Private prodsVariablesPrecios As List = pm.Get("prodsVariablesPrecios")
|
||||
Private prodsVariablesRequeridos As Int = pm.Get("prodsVariablesRequeridos")
|
||||
Private prodsFijosPiezas As List = pm.Get("prodsFijosPiezas")
|
||||
Private idProdsFijos As List = pm.Get("prodsFijos")
|
||||
@@ -1443,7 +1451,7 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||
Log($"Este prodVariable: ${idProdsVariables.Get(i)}"$)
|
||||
Log($"Este invDisponible: ${invDispParaPromo.Get(idProdsVariables.Get(i))}"$)
|
||||
' Log(">> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsVariables.Get(i), pm.Get("id")))
|
||||
prodsVariablesXPresupuestoBonificaciones.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsVariables.Get(i), prodsVariablesRequeridos, pm.Get("id")))
|
||||
prodsVariablesXPresupuestoBonificaciones.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsVariables.Get(i), prodsVariablesRequeridos, prodsVariablesPrecios.Get(i), pm.Get("id")))
|
||||
' If thisLog Then LogColor(">> Max prods fijos x Bonificaciones: " & B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsVariables.Get(i), prodsVariablesRequeridos, pm.Get("id")), Colors.blue)
|
||||
totalProdsVariablesDisponibles = totalProdsVariablesDisponibles + invDispParaPromo.Get(idProdsVariables.Get(i))
|
||||
End If
|
||||
@@ -1552,7 +1560,7 @@ Sub borraPedidoClienteActual As String
|
||||
Log($"Borramos pedido del cliente ${traeCliente}"$)
|
||||
Private thisC As Cursor
|
||||
' Private tablaProds As String = "cat_gunaprod2"
|
||||
thisC = Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_CEDIS FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) and PE_CEDIS <> 'DOE'")
|
||||
thisC = Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_CEDIS, PE_COSTOU FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) and PE_CEDIS <> 'DOE'")
|
||||
Log($"Registros = ${thisC.RowCount}"$)
|
||||
If thisC.RowCount > 0 Then
|
||||
For i = 0 To thisC.RowCount - 1
|
||||
@@ -1566,7 +1574,8 @@ Sub borraPedidoClienteActual As String
|
||||
Log("precioConDesc: " & precioConDesc)
|
||||
Log(">>>>>>>>>>>>> " & (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"))
|
||||
Private desc As String = B4XPages.MainPage.promos.ts.traeMontoBonificacion(thisC.GetString("PE_PROID"), thisC.GetString("PE_COSTOU"), thisC.GetString("PE_CEDIS"))
|
||||
desc = desc * thisC.GetString("PE_CANT")
|
||||
Log("Regresamos bonificaciones " & thisC.GetString("PE_PROID") & "=" & desc)
|
||||
modTrendSpending("suma", "bonificaciones", desc)
|
||||
Else ' Si no es promo, entonces es descuento.
|
||||
@@ -2095,11 +2104,17 @@ End Sub
|
||||
' 1 si versionActual es MAYOR que versionMinima
|
||||
Sub comparaVersiones(versionMinima As String, versionActual As String) As Int
|
||||
Dim Pattern As String = "[^0-9.]"
|
||||
Log(versionMinima)
|
||||
If versionMinima = "NA" Then Return 0 ' Si version minima es igal a "NA" regresamos "Version valida"
|
||||
versionMinima = Regex.Replace(Pattern, versionMinima, "") ' Quitamos todo lo que no sea numero o punto.
|
||||
versionActual = Regex.Replace(Pattern, versionActual, "") ' Quitamos todo lo que no sea numero o punto.
|
||||
Log($"${versionMinima}|${versionActual}"$)
|
||||
Dim partesMin() As String = Regex.Split("\.", versionMinima)
|
||||
Dim partesAct() As String = Regex.Split("\.", versionActual)
|
||||
If partesMin.Length < 2 Then
|
||||
ToastMessageShow("Version incorrecta", False)
|
||||
Return -1 ' ← Actual no cumple el formato mínimo
|
||||
End If
|
||||
' Si la actual tiene MENOS partes que la mínima, es inválida (opcional)
|
||||
If partesAct.Length < partesMin.Length Then
|
||||
ToastMessageShow("Version incorrecta", False)
|
||||
@@ -2110,7 +2125,7 @@ Sub comparaVersiones(versionMinima As String, versionActual As String) As Int
|
||||
Dim numMin As Int = partesMin(i)
|
||||
Dim numAct As Int = partesAct(i)
|
||||
If numAct < numMin Then
|
||||
ToastMessageShow("Versión vieja, por favor actualizar!", False)
|
||||
ToastMessageShow("Versión descontinuada, por favor actualizar!", False)
|
||||
Return -1 ' Actual es menor
|
||||
Else If numAct > numMin Then
|
||||
Return 1 ' Actual es mayor
|
||||
@@ -2402,4 +2417,25 @@ Sub traeExistenciasPorId(id As String) As Int
|
||||
existencias = (existencias - vendido)
|
||||
inv.Close
|
||||
Return existencias
|
||||
End Sub
|
||||
|
||||
' Devuelve True si la hora actual está entre las 5:00 AM y las 22:30 PM
|
||||
Sub EstaEnHorarioPermitido As Boolean
|
||||
' Obtener la hora y el minuto actual
|
||||
Dim HoraActual As Int = DateTime.GetHour(DateTime.Now)
|
||||
Dim MinutoActual As Int = DateTime.GetMinute(DateTime.Now)
|
||||
|
||||
' Convertir la hora actual a minutos totales desde la medianoche para una comparación simple
|
||||
Dim TiempoActualEnMinutos As Int = (HoraActual * 60) + MinutoActual
|
||||
|
||||
' Definir los límites del horario permitido en minutos
|
||||
Dim InicioEnMinutos As Int = (5 * 60) + 0 ' 5:00 AM = 300 minutos
|
||||
Dim FinEnMinutos As Int = (22 * 60) + 30 ' 22:30 PM = 1350 minutos
|
||||
|
||||
' Comprobar si la hora actual está dentro del rango
|
||||
If TiempoActualEnMinutos >= InicioEnMinutos And TiempoActualEnMinutos <= FinEnMinutos Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Sub
|
||||
@@ -119,9 +119,7 @@ Sub revisaSiExisteRespaldo
|
||||
If File.size(File.DirInternal&"/kmts", $"${name(0)}.rkmt.km"$) < 43000 And File.Exists(File.DirRootExternal & extDir, $"${name(0)}.rkmt.km"$) Then
|
||||
LogColor("Copiamos el respaldo desde la tarjeta!!", Colors.red)
|
||||
File.Copy(File.DirRootExternal & extDir, $"${name(0)}.rkmt.km"$, File.DirInternal&"/kmts", $"${name(0)}.rkmt.km"$)
|
||||
|
||||
RD_Init
|
||||
|
||||
Else
|
||||
LogColor("No hay respaldo en tarjeta externa!", Colors.red)
|
||||
End If
|
||||
|
||||
@@ -29,7 +29,7 @@ Public Sub Initialize (vCallback As Object, vEventName As String, db As SQL) As
|
||||
CallBack = vCallback
|
||||
tsdb = db
|
||||
Private mx As Map = traeInfoTrendSpending
|
||||
' LogColor(mx, Colors.red)
|
||||
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"))
|
||||
@@ -76,12 +76,15 @@ Sub traeInfoTrendSpending As Map
|
||||
semana = c.GetInt("CAT_VA_VALOR")
|
||||
End If
|
||||
If semana > 0 Then
|
||||
c = tsdb.ExecQuery($"select HIST_TSS_TIPO, HIST_TSS_SEMANA${semana}, HIST_TSS_SEMANA${semana}_ACUM from HIST_TREND_SPENDING_SEMANAL"$)
|
||||
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}"$)
|
||||
HIST_TSS_SEMANA_ACUM = c.GetString($"HIST_TSS_SEMANA${semana}_ACUM"$)
|
||||
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
|
||||
@@ -97,7 +100,7 @@ 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)
|
||||
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"
|
||||
@@ -110,7 +113,7 @@ Sub modTrendSpending(accion As String, tipo As String, monto As String)
|
||||
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}'"$)
|
||||
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")
|
||||
@@ -221,6 +224,7 @@ Sub trendSpending(accion As String, tipo As String, clienteId As String, id As S
|
||||
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
|
||||
@@ -228,6 +232,7 @@ Sub trendSpending(accion As String, tipo As String, clienteId As String, id As S
|
||||
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
|
||||
@@ -324,15 +329,23 @@ 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, promoId As String) As Int
|
||||
Private thisLog As Boolean = False
|
||||
Private tsMaximas As Int = 10000000
|
||||
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($"Presupuesto: ${TS_BONIFICACIONES(0)} - Acumulado ayer: ${TS_BONIFICACIONES(1)} - Hoy: ${traeAcumuladoHoyTS("bonificaciones")}"$, Colors.Red)
|
||||
If tipo.ToUpperCase = "BONIFICACIONES" Then
|
||||
tsMonto = NumberFormat2(traeMontoBonificacion(id, promoId), 1, 2, 2, False)
|
||||
tsMonto = NumberFormat2(traeMontoBonificacion(id, elPrecioVenta, promoId), 1, 2, 2, False)
|
||||
tsRestantes = (TS_BONIFICACIONES(0) - TS_BONIFICACIONES(1) - traeAcumuladoHoyTS("bonificaciones")) ' Traemos monto restante de Trend Spending para bonificaciones.
|
||||
Log("TS_BONIFICACIONES(0) - TS_BONIFICACIONES(1) - traeAcumuladoHoyTS('bonificaciones')")
|
||||
Log($"${TS_BONIFICACIONES(0)} - ${TS_BONIFICACIONES(1)} - ${traeAcumuladoHoyTS("bonificaciones")}"$)
|
||||
End If
|
||||
If thisLog Then Log($"Monto de bonificacion: ${tsMonto}"$)
|
||||
If thisLog Then Log($"Presupuesto disponible: ${tsRestantes}"$)
|
||||
@@ -349,14 +362,16 @@ 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, promoId As String) As String
|
||||
private thisLog as boolean = False
|
||||
' Log(promoId)
|
||||
Sub traeMontoBonificacion(id As String, precio As String, promoId As String) As String
|
||||
Private thisLog As Boolean = True
|
||||
LogColor($">>>>>>> ${promoId}, ${precio}, ${id}"$, Colors.Magenta)
|
||||
Private tsMonto As String = 0
|
||||
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_ID = '${promoId}'"$)
|
||||
Private c As Cursor = tsdb.ExecQuery($"SELECT CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_PRECIO, CAT_DP_TIPO, CAT_GP_PRECIO, CAT_DP_PRECIOB FROM CAT_DETALLES_PAQ join ${traeTablaProds(Starter.tipov)} on CAT_GP_ID = CAT_DP_IDPROD where CAT_GP_ID = '${id}' and CAT_DP_PRECIO = '${precio}' and CAT_DP_ID = '${promoId}'"$)
|
||||
Log($"SELECT CAT_DP_ID, CAT_DP_IDPROD, CAT_DP_PRECIO, CAT_DP_TIPO, CAT_GP_PRECIO, CAT_DP_PRECIOB FROM CAT_DETALLES_PAQ join ${traeTablaProds(Starter.tipov)} on CAT_GP_ID = CAT_DP_IDPROD where CAT_GP_ID = '${id}' and CAT_DP_PRECIO = '${precio}' and CAT_DP_ID = '${promoId}'"$)
|
||||
Log($"rowcount: ${c.RowCount}"$)
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
If c.GetInt("CAT_DP_PRECIOB") = 1 Then
|
||||
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.
|
||||
@@ -376,7 +391,7 @@ End Sub
|
||||
' se agoto el presupuesto.
|
||||
' Aunque si hay suficiente para mostrar algunas promos ... pues que si las muestre.
|
||||
Sub maxPromosPorProdsVariables(idProdsVariables As List, promo As String)As Int
|
||||
Private logger As Boolean = False
|
||||
Private logger As Boolean = True
|
||||
Private Maxs As Int = 10000000
|
||||
Private prodsVariablesXPresupuestoBonificaciones As List
|
||||
Private prodsVariablesRequeridos As Int = traeProdsVariablesRequeridos(promo)
|
||||
@@ -385,8 +400,8 @@ Sub maxPromosPorProdsVariables(idProdsVariables As List, promo As String)As Int
|
||||
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), promo))
|
||||
Private maxProds As Int = traeBonificacionesMaximas("bonificaciones", traeCliente, idProdsVariables.Get(i), prodsVariablesRequeridos, promo)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user