11/11/23 - Correcciones en MaxPromos y MaxCientesNuevos

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

View File

@@ -111,6 +111,8 @@ Sub Class_Globals
Private b_aceptarExtras As Button
Private cb_cartaPorte As CheckBox
Private l_cartaPorte As Label
Private et_maxClientesNuevos As EditText
Private l_maxClientesNuevos As Label
End Sub
Public Sub Initialize
@@ -361,6 +363,7 @@ Sub B4XPage_Appear
kh.SetButtonTintList(cb_cartaPorte, Colors.LightGray, Colors.RGB(43, 154, 211))
cb_geocerca.Checked = kh.traeUsarGeocerca
cb_cartaPorte.Checked = kh.traeUsarCartaPorte
et_maxClientesNuevos.Text = kh.traeMaxClientesNuevos
' server = "http://keymon.com.mx:1782"
' server = "http://201.99.139.28:1782"
' server = "http://177.244.63.54:1782"
@@ -729,6 +732,7 @@ Private Sub b_cargaLocalOk_Click
kh.RD_restaura_cat_gunaprod2
kh.RD_restaura_cat_detalle_paq
kh.RD_restaura_kmt_info
kh.RD_restaura_promos_comp
ime.HideKeyboard
ToastMessageShow("¡¡CARGA EXITOSA!!", True)
Else
@@ -766,6 +770,13 @@ 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)
End Sub
@@ -778,19 +789,27 @@ Private Sub et_geocerca_TextChanged (Old As String, New As String)
If New = x.GetString("CAT_VA_VALOR") Or New = "KMTS1" Then
cb_geocerca.Enabled = True
cb_cartaPorte.Enabled = True
et_maxClientesNuevos.Enabled = True
l_geocerca.TextColor = Colors.RGB(43, 154, 211)
l_cartaPorte.TextColor = Colors.RGB(43, 154, 211)
l_maxClientesNuevos.TextColor = Colors.RGB(43, 154, 211)
et_maxClientesNuevos.TextColor = Colors.RGB(43, 154, 211)
Else
cb_geocerca.Enabled = False
cb_cartaPorte.Enabled = False
et_maxClientesNuevos.Enabled = False
l_geocerca.TextColor = Colors.LightGray
l_cartaPorte.TextColor = Colors.LightGray
l_maxClientesNuevos.TextColor = Colors.LightGray
et_maxClientesNuevos.TextColor = Colors.LightGray
End If
Else if New = "KMTS1" Then
cb_geocerca.Enabled = True
cb_cartaPorte.Enabled = True
et_maxClientesNuevos.Enabled = True
l_geocerca.TextColor = Colors.RGB(43, 154, 211)
l_cartaPorte.TextColor = Colors.RGB(43, 154, 211)
l_maxClientesNuevos.TextColor = Colors.RGB(43, 154, 211)
End If
End Sub

View File

@@ -9,7 +9,7 @@ Sub Class_Globals
Private xui As XUI 'ignore
'// Process Globals
Dim g As GPS
dim kh as kms_helperSubs
Dim kh As kms_helperSubs
Dim reqManager As DBRequestManager
Dim ruta As String
Dim clie_id As String

View File

@@ -212,7 +212,7 @@ Sub borra_Click
' Starter.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
' Starter.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
Subs.borraPedidoClienteActual
B4XPages.MainPage.productos.prodsMap.Initialize 'inicializamos mapa de productos para que noaparezcan como vendidos en la lista
' B4XPages.MainPage.productos.prodsMap.Initialize 'inicializamos mapa de productos para que no aparezcan como vendidos en la lista
B4XPages.MainPage.promos.promosMap.Initialize
' Log("Llamamos LlenaProdsLL")
If B4XPages.MainPage.productos.PCLV.IsInitialized Then B4XPages.MainPage.productos.LlenaProdsLL(Null, Null)

View File

@@ -292,6 +292,7 @@ Sub B4XPage_Appear
kh.RD_respalda_cat_gunaprod2
kh.RD_respalda_kmt_info
kh.RD_respalda_pedido
kh.RD_respalda_promos_comp
Else
Log("****** RD NO INICIALIZADO ********")
End If

View File

@@ -138,7 +138,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
LlenaProdsLL(Null, Null)
list_prodsPedido.Initialize
Log("list_prodsPedido.Initialize")
prodsMap.Initialize
' prodsMap.Initialize
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
@@ -543,8 +543,8 @@ 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(tmpMap)
prodsMap.Put(id, tmpMap)
If laCant.Text = 0 Then prodsMap.Remove(id)
' prodsMap.Put(id, tmpMap)
' If laCant.Text = 0 Then prodsMap.Remove(id)
' LogColor("prodsMap="&prodsMap, Colors.blue)
' (Subs.traeAlmacen, p1.Get("precio"), p1.Get("cant"), pn, p, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
Private almacenX As String = Subs.traeAlmacen
@@ -565,28 +565,34 @@ Sub b_prodMas_Click
etCantHasFocus = False
Private buttonTag As String = Sender.As(Button).tag
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
' LogColor("b_prodMas_Click", Colors.Magenta)
LogColor("b_prodMas_Click", Colors.Magenta)
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
Dim pnl As B4XView = pnl0.GetView(0)
' Log("========= " & pnl0.Tag)
' Log("========= " & pnl.Tag)
' Log("========= " & pnl.GetView(1).Tag)
Private existencias As String = pnl.GetView(1).Tag
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
If laCant.Text = "" Then laCant.Text = 0
Private tmpMap As Map = clv_prods_ll.GetValue(index).As(Map)
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen")
Log(tmpMap)
If buttonTag = "vendido" Then
If inv > 0 And (laCant.Text + 1 <= inv) And (Subs.totalPedido - precio > 1) Then
' Log(clv_prods_ll.GetValue(index).As(Map))
Log($"${(laCant.Text + 1 <= inv)} And ${(Subs.totalPedido - precio > 1)}"$)
If inv > 0 And (laCant.Text + 1 <= existencias) And (Subs.totalPedido - precio > 1) Then
Log(clv_prods_ll.GetValue(index).As(Map))
clv_prods_ll.GetValue(index).As(Map).Put("almacen", (inv - 1))
inv = inv - 1
laCant.Text = $"$1.0{laCant.Text+1}"$
' Log(clv_prods_ll.GetValue(index).As(Map))
Log(clv_prods_ll.GetValue(index).As(Map))
End If
else If laCant.Text + 1 <= inv And lfila.Text = "PRODUCTOS" Then
' LogColor(inv, Colors.blue)
LogColor(inv, Colors.blue)
laCant.Text = $"$1.0{laCant.Text + 1}"$
Log(Subs.totalPedido)
else If lfila.Text = "RMI" And laCant.Text + 1 <= inv And (Subs.totalPedido - precio > 1) Then
' LogColor(inv, Colors.blue)
LogColor(inv, Colors.blue)
laCant.Text = $"$1.0{laCant.Text + 1}"$
Log(Subs.totalPedido)
else if Subs.totalPedido < 1 Then
@@ -855,7 +861,7 @@ Private Sub b_rechazar_Click
result = Msgbox2($"Seguro que desea borrar el pedido completo?${CRLF}Haciendo clic largo sobre un producto se pueden borrar articulos por separado."$,"Rechazar Pedido", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
If result = DialogResponse.POSITIVE Then
Subs.borraPedidoClienteActual
prodsMap.Initialize
' prodsMap.Initialize
B4XPages.MainPage.promos.promosMap.Initialize
' Log("Llamamos LlenaProdsLL")
LlenaProdsLL(Null, Null)

Binary file not shown.

Binary file not shown.

View File

@@ -872,7 +872,7 @@ Version=12.5
#Region Project Attributes
#ApplicationLabel: Kelloggs Venta
#VersionCode: 3000
#VersionName: 3.10.29 PRUEBA V4
#VersionName: 3.11.08 PRUEBA V4
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#BridgeLogger:true

View File

@@ -65,8 +65,8 @@ ModuleBreakpoints9=
ModuleClosedNodes0=
ModuleClosedNodes1=
ModuleClosedNodes10=
ModuleClosedNodes11=50,51,52
ModuleClosedNodes12=1,3
ModuleClosedNodes11=1,3,50,51,52
ModuleClosedNodes12=1,15,16
ModuleClosedNodes13=
ModuleClosedNodes14=39,40,41,42,43,44
ModuleClosedNodes15=
@@ -94,6 +94,6 @@ ModuleClosedNodes6=
ModuleClosedNodes7=
ModuleClosedNodes8=
ModuleClosedNodes9=
NavigationStack=Subs,panelAnchoAlto,724,0,C_Subs,panelVisible,266,0,C_Subs,panelOculto,274,0,Subs,traeCoordsDeBD,709,0,Subs,centraEditText,586,0,Subs,centraPanel,585,0,C_Subs,panelAnchoAlto,280,0,C_Subs,centraEditText,311,0,C_Subs,centraPanelV,303,0,C_Subs,centraProgressBar,308,0,C_Productos,B4XPage_Appear,143,0
NavigationStack=B4XMainPage,et_maxClientesNuevos_TextChanged,768,5,Visual Designer,principal.bal,-100,1,B4XMainPage,b_aceptarExtras_Click,812,0,B4XMainPage,Initialize,116,0,B4XMainPage,et_geocerca_TextChanged,804,6,kms_helperSubs,traeUsarGeocerca,642,0,kms_helperSubs,traeMaxClientesNuevos,655,2,kms_helperSubs,traeUsarCartaPorte,644,0,Visual Designer,login.bal,-100,6,B4XMainPage,B4XPage_Appear,359,5
SelectedBuild=0
VisibleModules=1,29,11,24,3,30,14,12
VisibleModules=1,29,11,24,3,30,14,12,7,13,9

View File

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

View File

@@ -69,6 +69,7 @@ Sub RD_Init
If chkIfTableExists(skmt, "CAT_GUNAPROD") Then rkmt.ExecNonQuery($"create table if not exists CAT_GUNAPROD (${getTableColumnList(skmt, "CAT_GUNAPROD")}, FECHA TEXT)"$)
If chkIfTableExists(skmt, "CAT_GUNAPROD2") Then rkmt.ExecNonQuery($"create table if not exists CAT_GUNAPROD2 (${getTableColumnList(skmt, "CAT_GUNAPROD2")}, FECHA TEXT)"$)
If chkIfTableExists(skmt, "kmt_info") Then rkmt.ExecNonQuery($"create table if not exists kmt_info (${getTableColumnList(skmt, "kmt_info")}, FECHA TEXT)"$)
If chkIfTableExists(skmt, "PROMOS_COMP") Then rkmt.ExecNonQuery($"create table if not exists PROMOS_COMP (${getTableColumnList(skmt, "PROMOS_COMP")}, FECHA TEXT)"$)
DateTime.DateFormat = "yyyyMMdd"
fechaHoy = DateTime.Date(DateTime.Now)
If Starter.Logger Then Log("RKMTS: " & rkmt.IsInitialized)
@@ -293,6 +294,45 @@ Sub RD_restaura_kmt_info
Log("R-KMT: " & ((DateTime.Now - inicio)/1000) & " segs")
End Sub
'RD - Copia la tabla promos_comp a rkmt.db en la tarjeta del celular.
Sub RD_respalda_promos_comp
Private inicio As String = DateTime.Now
' Log("Copiando kmt_info ...")
Private x As Cursor = skmt.ExecQuery("select * from PROMOS_COMP")
If x.RowCount > 0 Then
Private lasCols As String = getTableColumnListName(skmt, "PROMOS_COMP")
rkmt.BeginTransaction
rkmt.ExecNonQuery($"delete from PROMOS_COMP where fecha = '${fechaHoy}'"$)
rkmt.ExecNonQuery($"insert into PROMOS_COMP (${lasCols}, FECHA) select ${lasCols}, '${fechaHoy}' as FECHA from skmt1.PROMOS_COMP"$)
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
rkmt.EndTransaction
End If
x.Close
LogColor("KMT: " & ((DateTime.Now - inicio)/1000) & " segs", Colors.RGB(166,37,0))
End Sub
'RD - Copia la tabla promos_comp de rkmt.db al celular.
Sub RD_restaura_promos_comp
Private inicio As String = DateTime.Now
' Log("Restaurando KMT_INFO ...")
fechaRestauracion = RD_fechaRestauracionSQL(RD_fechaRestauracion)
Private lasCols As String = getTableColumnListName(rkmt, "PROMOS_COMP")
lasCols = lasCols.Replace(", FECHA", "") 'Quitamos la fecha del respaldo.
Private c As Cursor = rkmt.ExecQuery($"select distinct fecha from PROMOS_COMP ${fechaRestauracion} order by fecha desc"$) 'where fecha <> '${fechaHoy}' 'Traemos la ultima fecha antes de hoy.
' Log(c.RowCount)
If c.RowCount > 0 Then
c.Position = 0
' Log(c.GetString("FECHA"))
skmt.ExecNonQuery("delete from PROMOS_COMP")
skmt.ExecNonQuery($"insert into PROMOS_COMP (${lasCols}) select ${lasCols} from rkmt1.PROMOS_COMP where fecha = '${c.GetString("FECHA")}'"$)
Log($"insert into PROMOS_COMP (${lasCols}) select ${lasCols} from rkmt1.PROMOS_COMP where fecha = '${c.GetString("FECHA")}'"$)
Else
ToastMessageShow($"No hay respaldo para la fecha ${fechaRestauracion.SubString(fechaRestauracion.Length - 10)}"$, True)
End If
Log("R-KMT: " & ((DateTime.Now - inicio)/1000) & " segs")
End Sub
'RD - Realiza un "vacuum" de la base de datos "rkmt".
Sub RD_vacuum 'ignore
Log("Vacuum")
@@ -618,6 +658,17 @@ Sub traeUsarCartaPorte As Boolean 'ignore
Return CP
End Sub
'Regresa los clientes nuevos maximos.
Sub traeMaxClientesNuevos As Int 'ignore
Private CN As Int = 0
Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'MAXCTESNUEVOS'"$)
If x.RowCount > 0 Then
x.Position = 0
CN = x.GetString("CAT_VA_VALOR")
End If
Return CN
End Sub
'################ Manage External Storage (MES) #########################
'
''Inicializa "Manage External Storage" (MES), que nos da acceso a la tarjeta de memoria en Android 11+