mirror of
https://github.com/KeymonSoft/Guna_Preventa.git
synced 2026-04-17 21:06:32 +00:00
- VERSION 5.12.10
- Se agrego codigo para las promos por rango. - FALTA PONERLO EN TICKETS y PDFS
This commit is contained in:
@@ -549,8 +549,9 @@ Sub B4XPage_Appear
|
||||
'
|
||||
' ' Al aparecer la página del cliente
|
||||
' InicializarLocalizacionMejorada
|
||||
|
||||
TraeCantProd
|
||||
|
||||
recalculoXcant
|
||||
|
||||
ImageView4.Bitmap = LoadBitmap(File.DirAssets,"images.png")
|
||||
btnPlanLealtad.Visible = False
|
||||
bitacora.inicioFin
|
||||
@@ -1194,7 +1195,13 @@ Sub B4XPage_Appear
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Log("============================================================")
|
||||
Log("============================================================")
|
||||
Log("============================================================")
|
||||
' *********************************************************
|
||||
l_total.Text = Subs.calculaTotalConPromoXRango
|
||||
' *********************************************************
|
||||
|
||||
SV_ENCUESTA.Visible = False
|
||||
P_gallina.Visible = False
|
||||
@@ -1316,21 +1323,22 @@ Sub MejorarPrecisionGPS As ResumableSub
|
||||
Return False ' No se logró buena precisión
|
||||
End Sub
|
||||
|
||||
|
||||
Sub TraeCantProd As Boolean
|
||||
|
||||
' Recalcula y pone en PEDIDO si el producto cumple lascondiciones para tener descuento
|
||||
Sub recalculoXcant
|
||||
' Private c As Cursor = B4XPages.MainPage.skmt.ExecQuery2("SELECT* FROM PEDIDO JOIN CAT_PROMOS_DESCUENTOS ON CAT_PD_PRODUCTO = PE_PROID WHERE PE_CLIENTE IN (Select CUENTA FROM CUENTAA) AND PE_CEDIS = ? AND PE_CANT >= CAT_PD_RANGO AND CAT_PD_RANGO2 <= PE_CANT", Array As String(Subs.traeAlmacen))
|
||||
Private c As Cursor = B4XPages.MainPage.skmt.ExecQuery2("SELECT * FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA FROM CUENTAA) AND PE_CEDIS = ? ", Array As String(Subs.traeAlmacen))
|
||||
|
||||
|
||||
If c.RowCount > 0 Then
|
||||
For promespdes = 0 To c.RowCount -1
|
||||
c.Position = promespdes
|
||||
|
||||
Dim rangosel As Cursor= B4XPages.MainPage.skmt.ExecQuery2("SELECT * FROM CAT_PROMOS_DESCUENTOS WHERE CAT_PD_PRODUCTO = ? AND CAT_PD_RANGO <= ? AND CAT_PD_RANGO2 >= ?",Array As String(c.GetString("PE_PROID"),c.GetInt("PE_CANT"),c.GetInt("PE_CANT")))
|
||||
If rangosel.RowCount > 0 Then
|
||||
|
||||
' delete fromo pedido where cliete = estecliente!!! y prodId = esteID
|
||||
|
||||
For hjh = 0 To rangosel.RowCount-1
|
||||
|
||||
rangosel.Position = hjh
|
||||
|
||||
If rangosel.GetString("CAT_PD_TIER").Contains(Subs.traeTipoCliente) Then
|
||||
Log(c.GetString("PE_COSTOU"))
|
||||
Log(rangosel.GetString("CAT_PD_DESCUENTO"))
|
||||
@@ -1340,18 +1348,44 @@ Sub TraeCantProd As Boolean
|
||||
Log(NumberFormat2(((c.GetString("PE_COSTOU") * rangosel.GetString("CAT_PD_DESCUENTO"))/100),0,2,2,False))
|
||||
Log(rangosel.GetString("CAT_PD_DESCUENTO"))
|
||||
Private recalculototal As Float =c.GetString("PE_CANT") * recalculo
|
||||
skmt.ExecNonQuery2("UPDATE PEDIDO set PE_RECALCULO = ?, PE_RECALCULOTOT = ?, PE_RECCEDIS = ? WHERE PE_PROID = ? AND PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA) ",Array As String(NumberFormat2(recalculo,0,2,2,False) ,NumberFormat2(recalculototal,0,2,2,False), rangosel.GetString("CAT_PD_COD_PROMO"),c.GetString("PE_PROID")))
|
||||
skmt.ExecNonQuery2("UPDATE PEDIDO set PE_RECALCULO = ?, PE_RECALCULOTOT = ?, PE_RECCEDIS = ?, PE_RECCANT = PE_CANT WHERE PE_PROID = ? AND PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA) ",Array As String(NumberFormat2(recalculo,0,2,2,False) ,NumberFormat2(recalculototal,0,2,2,False), rangosel.GetString("CAT_PD_COD_PROMO"),c.GetString("PE_PROID")))
|
||||
End If
|
||||
|
||||
Next
|
||||
Else ' No cumple el rango ...
|
||||
Dim rangosel2 As Cursor= B4XPages.MainPage.skmt.ExecQuery2("SELECT * FROM CAT_PROMOS_DESCUENTOS WHERE CAT_PD_PRODUCTO = ? and ? > cat_pd_rango2",Array As String(c.GetString("PE_PROID"),c.GetInt("PE_CANT")))
|
||||
|
||||
' definir rango sup y cantidad
|
||||
|
||||
If rangosel2.RowCount > 0 Then
|
||||
' rangosel2.Position = 0
|
||||
|
||||
Else
|
||||
skmt.ExecNonQuery2("UPDATE PEDIDO set PE_RECALCULO = NULL, PE_RECALCULOTOT = NULL, PE_RECCEDIS = NULL WHERE PE_PROID = ? AND PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA) ",Array As String(c.GetString("PE_PROID")))
|
||||
For hjh = 0 To rangosel2.RowCount-1
|
||||
rangosel2.Position = hjh
|
||||
If rangosel2.GetString("CAT_PD_TIER").Contains(Subs.traeTipoCliente) Then
|
||||
Log(c.GetString("PE_COSTOU"))
|
||||
Log(rangosel2.GetString("CAT_PD_DESCUENTO"))
|
||||
Private recalculo As Float = c.GetString("PE_COSTOU") - NumberFormat2(((c.GetString("PE_COSTOU") * rangosel2.GetString("CAT_PD_DESCUENTO"))/100),0,2,2,False)
|
||||
LogColor(recalculo,Colors.Blue)
|
||||
Log(c.GetString("PE_COSTOU"))
|
||||
Log(NumberFormat2(((c.GetString("PE_COSTOU") * rangosel2.GetString("CAT_PD_DESCUENTO"))/100),0,2,2,False))
|
||||
Log(rangosel2.GetString("CAT_PD_DESCUENTO"))
|
||||
Private recalculototal As Float = rangosel2.GetString("CAT_PD_RANGO2") * recalculo
|
||||
|
||||
' Restar total cantidad menos rango mayor para obtener la diferencia y saber cuanto hay de mas
|
||||
|
||||
' INSERT de producto (diferencia entre el rango sup y cantidad de pedido
|
||||
|
||||
skmt.ExecNonQuery2("UPDATE PEDIDO set PE_RECALCULO = ?, PE_RECALCULOTOT = ?, PE_RECCEDIS = ?, PE_RECCANT = ? WHERE PE_PROID = ? AND PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA) ",Array As String(NumberFormat2(recalculo,0,2,2,False),NumberFormat2(recalculototal,0,2,2,False),rangosel2.GetString("CAT_PD_COD_PROMO"), rangosel2.GetString("CAT_PD_RANGO2"),c.GetString("PE_PROID")))
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
Else
|
||||
skmt.ExecNonQuery2("UPDATE PEDIDO set PE_RECALCULO = NULL, PE_RECALCULOTOT = NULL, PE_RECCEDIS = NULL, PE_RECCANT = NULL WHERE PE_PROID = ? AND PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA) ",Array As String(c.GetString("PE_PROID")))
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub LA_GPS_Click
|
||||
@@ -1487,18 +1521,10 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
|
||||
distancealm = ubi1.DistanceTo(ubi2)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
' Mostrar la precisión actual
|
||||
If LA_GPS.IsInitialized Then
|
||||
LA_GPS.Text = $"UBICACIÓN - Precisión: ${NumberFormat2(Location1.Accuracy, 0, 1, 1, False)}m"$
|
||||
|
||||
End If
|
||||
|
||||
|
||||
' Solo usar ubicaciones con buena precisión
|
||||
If Location1.Accuracy < 30 Then ' Menos de 30 metros de error
|
||||
' Tu lógica actual aquí
|
||||
@@ -1555,9 +1581,6 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
bitacora.banderaGeoCerca = "0"
|
||||
' ToastMessageShow("DENTRO de rango GPS", False)
|
||||
Else If habi = "1" Then
|
||||
|
||||
|
||||
|
||||
If distancealm < 50 Then
|
||||
precision = "0"
|
||||
LA_GEO.TextColor = Colors.Blue
|
||||
@@ -1582,14 +1605,14 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
bitacora.banderaGeoCerca = "0"
|
||||
iniciofin
|
||||
Else If c.RowCount = 0 Then
|
||||
c = skmt.ExecQuery("SELECT NV_CLIENTE FROM NOVENTA CLIENTE WHERE NV_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
If c.RowCount > 0 Then
|
||||
Private c5 As Cursor = skmt.ExecQuery("SELECT NV_CLIENTE FROM NOVENTA CLIENTE WHERE NV_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
If c5.RowCount > 0 Then
|
||||
Tels.Visible = True
|
||||
gest.Visible = True
|
||||
precision = "0"
|
||||
' b_geo = "0"
|
||||
iniciofin
|
||||
Else If c.RowCount = 0 Then
|
||||
Else If c5.RowCount = 0 Then
|
||||
Tels.Visible = False
|
||||
gest.Visible = False
|
||||
' p_transparenteInicioFin.Visible = False
|
||||
@@ -1604,7 +1627,9 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
iniciofin
|
||||
End If
|
||||
End If
|
||||
c5.Close
|
||||
End If
|
||||
c.Close
|
||||
LA_GEO.TextColor = Colors.Red
|
||||
If ALMACEN = "1" Then
|
||||
Tels.Visible = False
|
||||
@@ -1650,6 +1675,7 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
iniciofin
|
||||
End If
|
||||
End If
|
||||
c.Close
|
||||
LA_GEO.TextColor = Colors.Red
|
||||
If ALMACEN = "1" Then
|
||||
Tels.Visible = False
|
||||
@@ -1659,6 +1685,7 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
iniciofin
|
||||
End If
|
||||
End If
|
||||
c.Close
|
||||
Else
|
||||
Tels.Visible = False
|
||||
gest.Visible = False
|
||||
@@ -1676,7 +1703,7 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
' RevisarGeocerca
|
||||
Else
|
||||
If LA_GPS.IsInitialized Then
|
||||
@@ -1702,12 +1729,9 @@ Sub GPS_LocationChanged (Location1 As Location)
|
||||
If LA_GEO.IsInitialized Then LA_GEO.Text= $"$1.2{distance/1000} kms"$
|
||||
|
||||
' If distance > 100 Then ToastMessageShow("Fuera de rango GPS", False)
|
||||
|
||||
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
|
||||
CallSubDelayed(Tracker, "CreateLocationRequestSmallD")
|
||||
|
||||
' CallSubDelayed(Tracker, "CreateLocationRequestSmallD")
|
||||
End Sub
|
||||
|
||||
Private Sub p_pideGeoPass_Click
|
||||
|
||||
Reference in New Issue
Block a user