mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-19 19:19:14 +00:00
14/12/23 - Corrección en el calclulo del limite de abordo y etiqueta de info en pedido.
- Se corrigió la subrutina que calcula el limite de abordo disponible. - Se agregó que se muestre el total del pedido actual cuando se agregan productos al pedido.
This commit is contained in:
@@ -275,7 +275,7 @@ Sub Class_Globals
|
||||
Private BP_DOE_R1 As Button
|
||||
Private ime As IME
|
||||
Dim laDist As Float
|
||||
Private Panel11 As Panel
|
||||
Private p_rechazoDOE As Panel
|
||||
Dim RMI_VALOR As String
|
||||
Dim errorImpresora As Int = 0
|
||||
Private b_inicioFinVenta As Button
|
||||
@@ -400,20 +400,15 @@ End Sub
|
||||
Sub B4XPage_Appear
|
||||
clienteId = kh.traeCliente
|
||||
P_DOE.Visible = False
|
||||
If clienteId.StartsWith("N") Then b_noVenta.Visible = False
|
||||
dentroDeGeocerca = False
|
||||
|
||||
' Log($"TOTAL VENTA: ${kh.traeTotalCliente}"$)
|
||||
B_VENTA.Visible = False
|
||||
b_noVenta.Visible = False
|
||||
If clienteId.StartsWith("N") Then b_noVenta.Visible = False
|
||||
l_doe.Text = "HAY PEDIDO DOE"
|
||||
' Log(Starter.rp.Check("android.permission.BLUETOOTH_CONNECT"))
|
||||
b_inicioFinVenta.Text = "INICIAR VENTA"
|
||||
b_inicioFinVenta.BringToFront
|
||||
If Not(Starter.enVenta) And la_cuenta.Text <> "0" Then
|
||||
b_inicioFinVenta.Visible = True
|
||||
' Log("EnVenta Visible")
|
||||
Else
|
||||
' Log("EnVenta NO Visible")
|
||||
b_inicioFinVenta.Visible = False
|
||||
End If
|
||||
|
||||
reqManager.Initialize(Me, Starter.DBReqServer)
|
||||
usarGeocerca = kh.traeUsarGeocerca
|
||||
' Log(Subs.traeUltimaActividadBD)
|
||||
@@ -477,6 +472,18 @@ Sub B4XPage_Appear
|
||||
If c.GetString("CAT_CL_ATIENDE1") <> Null And c.GetString("CAT_CL_ATIENDE1") <> "null" Then l_atiende.Text = c.GetString("CAT_CL_ATIENDE1")
|
||||
l_atiende2.Text = c.GetString("CAT_CL_ATIENTE2")
|
||||
|
||||
b_inicioFinVenta.Text = "INICIAR VENTA"
|
||||
b_inicioFinVenta.BringToFront
|
||||
' LogColor(">>>>>> EN VENTA: " & Starter.enVenta, Colors.red)
|
||||
If Not(Starter.enVenta) And la_cuenta.Text <> "0" Then
|
||||
b_inicioFinVenta.Visible = True
|
||||
' Log("EnVenta Visible")
|
||||
Else
|
||||
' Log("EnVenta NO Visible")
|
||||
b_inicioFinVenta.Visible = False
|
||||
End If
|
||||
' LogColor(">>>>>> EN VENTA: " & Starter.enVenta, Colors.red)
|
||||
|
||||
' LONGITUD = 0
|
||||
' If c.GetString("CAT_CL_LONG") <> Null And c.GetString("CAT_CL_LONG") <> "null" And IsNumber(c.GetString("CAT_CL_LONG")) Then LONGITUD = c.GetString("CAT_CL_LONG")
|
||||
' LATITUD = 0
|
||||
@@ -508,22 +515,22 @@ Sub B4XPage_Appear
|
||||
' LogColor($"${c.GetString("CAT_CL_LAT")}, ${c.GetString("CAT_CL_LONG")}"$, Colors.red)
|
||||
If logger Then Log($"Lat: ${LATITUD}, Lon: ${LONGITUD}"$)
|
||||
NOMBRE = c.GetString("CAT_CL_NOMBRE")
|
||||
' Log(l_total.text)
|
||||
If l_total.Text = Null Or l_total.Text = "null" Then
|
||||
If Not(clienteId.StartsWith("N")) Then b_noVenta.Visible = True
|
||||
Log($"TOTAL DE LA VENTA: ${kh.traeTotalCliente}"$)
|
||||
If kh.traeTotalCliente < 0.01 And kh.traeTotalClienteDOE < 0.01 Then
|
||||
If Not(clienteId.StartsWith("N")) And la_cuenta.Text <> "0" Then b_noVenta.Visible = True 'Ni cliente nuevo, ni abordo.
|
||||
Else
|
||||
b_noVenta.Visible = False
|
||||
If la_cuenta.Text = "0" Then
|
||||
If la_cuenta.text = 0 Then
|
||||
CREDITO_DISPONIBLE = 10000000
|
||||
CREDITO = 0
|
||||
b_inicioFinVenta.Visible = False
|
||||
End If
|
||||
End If
|
||||
If S1.GetString("CUANTOS") = 0 Then
|
||||
' b_noVenta.Visible = True
|
||||
Else 'Si ya hay venta, ocultamos el boton de "NO VENTA"
|
||||
b_noVenta.Visible = False
|
||||
End If
|
||||
' If S1.GetString("CUANTOS") = 0 Then
|
||||
'' b_noVenta.Visible = True
|
||||
' Else 'Si ya hay venta, ocultamos el boton de "NO VENTA"
|
||||
' b_noVenta.Visible = False
|
||||
' End If
|
||||
If CREDITO = "1" Then
|
||||
Msgbox("ALTO","A este cliente no se le puede vender ya que tienen adeudo en su crédito") 'ignore
|
||||
B_VENTA.Visible = False
|
||||
@@ -599,7 +606,7 @@ Sub B4XPage_Appear
|
||||
Else
|
||||
Guardar.Visible = True
|
||||
End If
|
||||
If Not(l_total.Text > 0) Then Guardar.Visible = True
|
||||
If Not(l_total.Text > 0) And Not(kh.traeTotalClienteDOE > 0) Then Guardar.Visible = True
|
||||
' If la_cuenta.text = "0" Then Guardar.Visible = True 'Abordo
|
||||
If l_total.Text = Null Or l_total.Text = "null" Or l_total.text = "0" Then Guardar.Visible = True 'Si no hay venta entonces "Guardar" es visible.
|
||||
|
||||
@@ -702,6 +709,12 @@ Sub B4XPage_Appear
|
||||
Else
|
||||
B_IMP2.Enabled = False
|
||||
End If
|
||||
If kh.traeTotalClienteDOE > 0 Then
|
||||
Private cs As CSBuilder
|
||||
cs.Initialize
|
||||
l_doe.Text = cs.append($"Pedido DOE: $${kh.traeTotalClienteDOE}"$).color(Colors.red).append(CRLF).Append($"TOTAL PEDIDO: $${(kh.traeTotalCliente+kh.traeTotalClienteDOE)}"$).Popall
|
||||
' l_doe.Text = $"Pedido DOE: $${kh.traeTotalClienteDOE}${CRLF}TOTAL PEDIDO: $${(kh.traeTotalCliente+kh.traeTotalClienteDOE)}"$
|
||||
End If
|
||||
If Subs.revisaImpresa Then Guardar.Visible = True
|
||||
End Sub
|
||||
|
||||
@@ -733,7 +746,7 @@ End Sub
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
'Este codigo se corre desde Tracker/flp_LocationChanged
|
||||
b_ubicacion.TextColor = Colors.Gray
|
||||
Sleep(200)
|
||||
' Sleep(200)
|
||||
b_ubicacion.TextColor = Colors.White
|
||||
If logger Then Log($"${Location1.Latitude}, ${Location1.Longitude}, ${Location1.Accuracy}"$)
|
||||
|
||||
@@ -760,6 +773,7 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
Else
|
||||
l_ubicacion2.TextColor = Colors.Black
|
||||
dentroDeGeocerca = True
|
||||
Log("dentro de geocerca")
|
||||
End If
|
||||
|
||||
'''' GEO CERCA
|
||||
@@ -795,9 +809,9 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
|
||||
' Log($"${gps_boton_doe}|${clienteConPromo}"$)
|
||||
|
||||
If gps_boton_doe = "1" And clienteConPromo = "0" Then b_whats.Visible = True
|
||||
If gps_boton_doe = "1" And clienteConPromo = "0" And revisaExistenciasDOE Then b_whats.Visible = True
|
||||
If Not(clienteDeudor) Then B_VENTA.Visible = True 'Si el cliente no tiene adeudo, habilitamos el boton de venta
|
||||
pedido_doe_muestra
|
||||
If Not(p_rechazoDOE.Visible) Then pedido_doe_muestra
|
||||
Else
|
||||
b_noVenta.Visible = False
|
||||
B_VENTA.Visible = False
|
||||
@@ -838,6 +852,10 @@ Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
else if p_promowhats.Visible Then
|
||||
P_INF_GENERAL.Visible = True
|
||||
p_promowhats.Visible = False
|
||||
else if p_rechazoDOE.Visible Then
|
||||
p_rechazoDOE.Visible = False
|
||||
BP_DOE_A.Visible = True
|
||||
BP_DOE_R.Visible = True
|
||||
Else
|
||||
Msgbox("Presione Imprimir y Guardar para continuar","Aviso") 'ignore
|
||||
End If
|
||||
@@ -906,7 +924,6 @@ Sub Guardar_Click
|
||||
If logger Then Log("Cerramos Cliente, iniciamos Principal")
|
||||
' B4XPages.ShowPage("Principal")
|
||||
|
||||
|
||||
B4XPages.MainPage.productos.reiniciarlistaProds = True
|
||||
B4XPages.MainPage.productos.prodsMap.Initialize
|
||||
B4XPages.MainPage.promos.promosMap.Initialize
|
||||
@@ -921,6 +938,7 @@ Sub Guardar_Click
|
||||
Else
|
||||
b_inicioFinVenta.Visible = False
|
||||
Starter.enVenta = False
|
||||
' LogColor(">>>>>> EN VENTA: " & Starter.enVenta, Colors.red)
|
||||
Subs.iniciaActividad("principal")
|
||||
B4XPages.ShowPageAndRemovePreviousPages("Principal")
|
||||
End If
|
||||
@@ -3773,7 +3791,7 @@ Private Sub b_aceptarrpomo_Click
|
||||
' l_promowhats.Text = c.GetString("CAT_CL_NOMBRE")
|
||||
' End If
|
||||
' c.Close
|
||||
Private almadoe As Cursor = Starter.skmt.ExecQuery("SELECT ID_ALMACEN FROM CAT_ALMaCEN")
|
||||
Private almadoe As Cursor = Starter.skmt.ExecQuery("SELECT ID_ALMACEN FROM CAT_ALMACEN")
|
||||
almadoe.Position = 0
|
||||
LogColor(almadoe.GetString("ID_ALMACEN"),Colors.Blue)
|
||||
If almadoe.GetString("ID_ALMACEN") = "3" Then
|
||||
@@ -3809,7 +3827,7 @@ Private Sub b_aceptarrpomo_Click
|
||||
Starter.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT,PC_ALMACEN,PC_RUTA,PC_COSTO_SIN) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), Starter.lon_gps, Starter.lat_gps,Id_Almacen,Starter.rutaV,c.GetString("TOTAL_CLIE_SIN")))
|
||||
Starter.skmt.ExecNonQuery("delete from pedido3")
|
||||
Starter.skmt.ExecNonQuery("UPDATE PEDIDO SET PE_FOLIO = 0 where PE_FOLIO IS NULL")
|
||||
Starter.skmt.ExecNonQuery("INSERT INTO PEDIDO3 (PE_PRECIO2, PE_TIPO, PE_FECHA, PE_DESC, PE_COSTO_SIN, PE_RUTA, PE_CEDIS, PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_PRONOMBRE, PE_PROID, PE_CLIENTE, PE_USUARIO ) SELECT PE_PRECIO2, PE_TIPO, PE_FECHA, PE_DESC, PE_COSTO_SIN, PE_RUTA, PE_CEDIS, SUM(PE_COSTO_TOT) AS PE_COSTO_TOT, PE_COSTOU, SUM(PE_CANT) As PE_CANT, PE_PRONOMBRE, PE_PROID, PE_CLIENTE, PE_USUARIO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) GROUP BY PE_PRECIO2, PE_TIPO, PE_DESC, PE_COSTO_SIN, PE_RUTA, PE_CEDIS, PE_COSTOU, PE_PRONOMBRE, PE_PROID, PE_CLIENTE ") 'Mod por CHV - 220302 - Agregué PE_FECHA al select/insert
|
||||
Starter.skmt.ExecNonQuery("INSERT INTO PEDIDO3 (PE_PRECIO2, PE_TIPO, PE_FECHA, PE_DESC, PE_COSTO_SIN, PE_RUTA, PE_CEDIS, PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_PRONOMBRE, PE_PROID, PE_CLIENTE, PE_USUARIO ) SELECT PE_PRECIO2, PE_TIPO, PE_FECHA, PE_DESC, PE_COSTO_SIN, PE_RUTA, PE_CEDIS, SUM(PE_COSTO_TOT) AS PE_COSTO_TOT, PE_COSTOU, SUM(PE_CANT) As PE_CANT, PE_PRONOMBRE, PE_PROID, PE_CLIENTE, PE_USUARIO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) GROUP BY PE_PRECIO2, PE_TIPO, PE_DESC, PE_COSTO_SIN, PE_RUTA, PE_CEDIS, PE_COSTOU, PE_PRONOMBRE, PE_PROID, PE_CLIENTE ")
|
||||
' starter.skmt.ExecNonQuery2("INSERT INTO")
|
||||
p_promowhats.Visible = False
|
||||
P_INF_GENERAL.Visible = True
|
||||
@@ -3888,7 +3906,7 @@ Private Sub b_geopass_Click
|
||||
Log($"${Starter.DBReqServer}, ${et_geopass.Text}, ${Subs.traeAlmacen}, ${Subs.traeRuta}"$)
|
||||
et_geopass.Text = ""
|
||||
End If
|
||||
If Not(clienteId.StartsWith("N")) Then b_noVenta.Visible = True
|
||||
If Not(clienteId.StartsWith("N")) And la_cuenta.Text <> "0" Then b_noVenta.Visible = True 'Ni cliente nuevo, ni abordo.
|
||||
p_pideGeoPass.Visible = False
|
||||
ime.HideKeyboard
|
||||
' Log("Guardamos coords")
|
||||
@@ -3972,17 +3990,21 @@ Private Sub BP_DOE_A_Click
|
||||
Starter.skmt.TransactionSuccessful
|
||||
Starter.skmt.EndTransaction
|
||||
P_DOE.Visible = False
|
||||
B4XPage_Appear
|
||||
End Sub
|
||||
|
||||
Private Sub BP_DOE_R_Click
|
||||
Dim result As Int
|
||||
result = Msgbox2("El cliente perderá el descuento si cancela el pedio, se cancela el pedido ?", "Pedido Cancela", "SI", "", "NO", LoadBitmap(File.DirAssets, "alert2.png"))
|
||||
If result = DialogResponse.Positive Then
|
||||
Panel11.Visible = True
|
||||
P_DOE.Visible = False
|
||||
p_rechazoDOE.BringToFront
|
||||
p_rechazoDOE.Visible = True
|
||||
BP_DOE_A.Visible = False
|
||||
BP_DOE_R.Visible = False
|
||||
Else
|
||||
P_DOE.Visible = False
|
||||
P_DOE.Visible = True
|
||||
' Log("yyy")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -4000,8 +4022,9 @@ private Sub pedido_doe_muestra
|
||||
If YA_TIENE_PEDIDO_DOE = 0 Then
|
||||
C5=Starter.skmt.ExecQuery("select COUNT(*) AS CLIENTE_DOE from PEDIDO_DOE WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) ")
|
||||
C5.Position = 0
|
||||
If C5.GetString("CLIENTE_DOE") >0 Then
|
||||
P_DOE.VISIBLE = True
|
||||
If C5.GetString("CLIENTE_DOE") > 0 Then
|
||||
' Log("xxx")
|
||||
P_DOE.Visible = True
|
||||
P_DOE.Elevation = 100
|
||||
P_DOE.BringToFront
|
||||
C6=Starter.skmt.ExecQuery("select PE_PROID, PE_PRONOMBRE, PE_CANT, PE_COSTO_TOT from PEDIDO_DOE where PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
@@ -4046,7 +4069,7 @@ Private Sub BP_DOE_R1_Click
|
||||
motivo = motivo & " " & e_comm.Text
|
||||
BP_DOE_A.Visible = True
|
||||
BP_DOE_R.Visible = True
|
||||
Panel11.Visible = False
|
||||
p_rechazoDOE.Visible = False
|
||||
P_DOE.Visible = False
|
||||
c=Starter.skmt.ExecQuery("select PE_PROID,PE_CANT, PE_TIPO FROM PEDIDO_DOE where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||
If c.RowCount>0 Then
|
||||
@@ -4059,6 +4082,7 @@ Private Sub BP_DOE_R1_Click
|
||||
Starter.skmt.ExecNonQuery("delete from PEDIDOS_DOE_ENTREGA where PC_CLIENTE in (Select CUENTA from cuentaa)")
|
||||
Starter.skmt.ExecNonQuery2("insert into PEDIDOS_DOE_ENTREGA (PC_CLIENTE, PC_ENTREGA) VALUES (?,?) ", Array As Object(clie_id,motivo))
|
||||
Starter.skmt.ExecNonQuery("delete from pedido_DOE where pe_cliente in (Select CUENTA from cuentaa)")
|
||||
Subs.bitacora(Subs.fechanormal(DateTime.Now),usuario, Id_Almacen, ruta_tienda, "Rechazo DOE", la_cuenta.text, Subs.fechanormal(DateTime.Now), "", Starter.lat_gps, Starter.lon_gps, "2", "", "")
|
||||
P_DOE.Visible = False
|
||||
End Sub
|
||||
|
||||
@@ -4067,15 +4091,39 @@ Private Sub b_inicioFinVenta_Click
|
||||
If Starter.enVenta Then
|
||||
Subs.bitacora(Subs.fechanormal(DateTime.Now), usuario, Id_Almacen, ruta_tienda, "Termina Venta", la_cuenta.text, "", Subs.fechanormal(DateTime.Now), Starter.lat_gps, Starter.lon_gps, precision, motivoNoVenta, "")
|
||||
Starter.enVenta = False
|
||||
LogColor(">>>>>> EN VENTA: " & Starter.enVenta, Colors.red)
|
||||
Subs.iniciaActividad("principal")
|
||||
B4XPages.ShowPageAndRemovePreviousPages("Principal")
|
||||
Else
|
||||
Subs.bitacora(Subs.fechanormal(DateTime.Now),usuario, Id_Almacen, ruta_tienda, "Inicia Venta", la_cuenta.text, Subs.fechanormal(DateTime.Now), "", Starter.lat_gps, Starter.lon_gps, precision, motivoNoVenta, "")
|
||||
Starter.enVenta = True
|
||||
LogColor(">>>>>> EN VENTA: " & Starter.enVenta, Colors.red)
|
||||
End If
|
||||
b_inicioFinVenta.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub P_DOE_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub p_rechazoDOE_Click
|
||||
|
||||
End Sub
|
||||
|
||||
'Revisa si hay suficiente existencia para dar la promo DOE.
|
||||
Sub revisaExistenciasDOE As Boolean 'ignore
|
||||
Private suficiente As Boolean = True
|
||||
Private p As Cursor = Starter.skmt.ExecQuery($"select * from cat_gunaprod2 where cat_gp_id in ('1008027226', '1008027228', '1008013799')"$)
|
||||
If p.RowCount > 1 Then
|
||||
For i = 0 To p.RowCount - 1
|
||||
p.Position = i
|
||||
If p.GetString("CAT_GP_ID") = "1008027226" And p.GetString("CAT_GP_ALMACEN") < 2 Then suficiente = False
|
||||
If p.GetString("CAT_GP_ID") = "1008027228" And p.GetString("CAT_GP_ALMACEN") < 1 Then suficiente = False
|
||||
If p.GetString("CAT_GP_ID") = "1008013799" And p.GetString("CAT_GP_ALMACEN") < 1 Then suficiente = False
|
||||
Next
|
||||
End If
|
||||
' 2, "LECHE ALL BRAN CHOCO 236ML", "1008027226"
|
||||
' 1, "LECHE ALL BRAN NUEZ 236ML", "1008027228"
|
||||
' 1, "LECHE CHOCO MELVIN 236ML", "1008013799"
|
||||
Return suficiente
|
||||
End Sub
|
||||
Reference in New Issue
Block a user