mirror of
https://github.com/KeymonSoft/Guna_Preventa.git
synced 2026-04-18 05:09:23 +00:00
- VERSION 4.10.21
- Se amplió el campo de cantidad en productos. - Se corrigió el error cuando la cantidad era mayor a 999. - Se corrigió que no guardara los productos cuando te regresabas o le dabas continuar o las varias opciones que no los guardaba. - Se corrigió que si te aparecía la leyenda de producto VENDIDO y luego lo borrabas desde Nota, y te seguía apareciendo como vendido. - Se modificó el código de subs.traeRuta para que traiga la ruta del cliente ACTUAL, esto es por las suplencias.
This commit is contained in:
106
B4A/Subs.bas
106
B4A/Subs.bas
@@ -637,8 +637,10 @@ Sub traeAlmacen As String 'ignore
|
||||
Private c As Cursor
|
||||
Private a As String = "NA"
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||
c.Position = 0
|
||||
a = C.GetString("ID_ALMACEN")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
a = C.GetString("ID_ALMACEN")
|
||||
End If
|
||||
c.Close
|
||||
Return a
|
||||
End Sub
|
||||
@@ -660,16 +662,29 @@ Sub traeProdNombre(id As String) As String
|
||||
End Sub
|
||||
|
||||
'Regresa la ruta actual de la base de datos.
|
||||
'Si hay cliente definido (en la pantalla de cliente), trae la ruta de ese cliente, si no, trae la primera ruta de kmt_info2. (esto es por las suplencias)
|
||||
Sub traeRuta As String 'ignore
|
||||
Private c As Cursor
|
||||
Private r As String
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select distinct CAT_CL_RUTA from kmt_info2 where CAT_CL_RUTA not in (select * from ruta_suplencia)")
|
||||
r = "0"
|
||||
If c.RowCount > 0 Then
|
||||
c.Position=0
|
||||
r = c.GetString("CAT_CL_RUTA")
|
||||
End If
|
||||
c.Close
|
||||
Private r As String = "0"
|
||||
Private idCliente As String = ""
|
||||
Try
|
||||
If B4XPages.MainPage.cliente.IsInitialized And B4XPages.MainPage.cliente.la_cuenta.IsInitialized Then ' Si
|
||||
idCliente = B4XPages.MainPage.cliente.la_cuenta.text
|
||||
End If
|
||||
If idCliente <> "" Then
|
||||
c = B4XPages.MainPage.skmt.ExecQuery($"select distinct CAT_CL_RUTA from kmt_info2 where CAT_CL_RUTA not in (select * from ruta_suplencia) and CAT_CL_CODIGO = '${idCliente}'"$)
|
||||
Else
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select distinct CAT_CL_RUTA from kmt_info2 where CAT_CL_RUTA not in (select * from ruta_suplencia)")
|
||||
End If
|
||||
' Log(c.RowCount)
|
||||
If c.RowCount > 0 Then
|
||||
c.Position=0
|
||||
r = c.GetString("CAT_CL_RUTA")
|
||||
End If
|
||||
c.Close
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
Return r
|
||||
End Sub
|
||||
|
||||
@@ -1259,7 +1274,6 @@ Sub vendidoPromoEsp As Boolean
|
||||
Return w
|
||||
End Sub
|
||||
|
||||
|
||||
'En geocerca si mete la contraseña poner 0 en precision gps y si esta dentro de los 50 mts poner 1 y 2 para eventos que no lo ocupen
|
||||
'Mandar fecha de sync(sysdate)
|
||||
Sub bitacora(fechab As String, usuariob As String, almacenb As String, rutab As String, eventob As String, clienteb As String, iniciob As String, finb As String, latitudb As String, longitudb As String, precision As String, motivonoventa As String, motivonovisita As String )
|
||||
@@ -1268,8 +1282,7 @@ Sub bitacora(fechab As String, usuariob As String, almacenb As String, rutab As
|
||||
Private cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "mandaBitacora3_GUNA"
|
||||
|
||||
Log("BITACORA3")
|
||||
' Log("BITACORA3")
|
||||
Private nombreCliente As String = traeNombreCliente(clienteb)
|
||||
If eventob = "Llega a almacen" Then
|
||||
nombreCliente = "BOLETA"
|
||||
@@ -1605,4 +1618,71 @@ Sub traeUsarIntentBDWA As Boolean 'ignore
|
||||
End If
|
||||
Log($"cb_importarBDWA = ${BDWA}"$)
|
||||
Return BDWA
|
||||
End Sub
|
||||
|
||||
Sub actualizaProducto(cedis As String, costoU As String, cant As String, nombre As String, prodId As String, clienteId As String, fecha As String, usuario As String, rutaV As String, precioSin As String, tipoVenta As String)
|
||||
If nombre.Length < 6 Then ToastMessageShow("(actualizaProducto) El nombre del producto no es valido " & nombre, True)
|
||||
precioSin = NumberFormat2(precioSin, 1, 2, 2, False)
|
||||
costoU = NumberFormat2(costoU, 1, 2, 2, False)
|
||||
LogColor($"actualizaProducto, c=${clienteId}, p=${prodId}, nombre=${nombre}, cant=${cant}, cedis=${cedis}, tipo=${tipoVenta}"$, Colors.Magenta)
|
||||
' Private tablaProds As String = "cat_gunaprod2"
|
||||
' If tipoVenta = "ABORDO" Then tablaProds = "cat_gunaprod"
|
||||
Private c As Cursor=Starter.skmt.ExecQuery($"select * from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}'"$)
|
||||
If c.RowCount > 0 Then
|
||||
' LogColor("ACTUALIZAMOS PROD - " & traeTablaProds(tipoVenta), Colors.Blue)
|
||||
c.Position = 0
|
||||
Private antCant As Int = 0
|
||||
If IsNumber(c.GetInt("PE_CANT")) Then antCant=c.GetInt("PE_CANT")
|
||||
Private difCant As Int = cant - antCant
|
||||
Starter.skmt.ExecNonQuery($"update pedido set pe_cant = ${cant}, pe_costo_tot = ${NumberFormat2((cant*c.GetString("PE_COSTOU")), 1, 2, 2, False)}, pe_folio = '${tipoVenta}' where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
If cedis <> "DUR" Then Starter.skmt.ExecNonQuery($"update ${traeTablaProds(tipoVenta)} set cat_gp_almacen = cat_gp_almacen - (${difCant}) where cat_gp_id = '${prodId}' "$)
|
||||
If cant = 0 Then
|
||||
LogColor($"BORRAMOS PRODUCTO - ${prodId}"$, Colors.Red)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
Log($"Borramos pe_cedis='${cedis}' and pe_proid='${prodId}' and pe_cliente='${clienteId}'"$)
|
||||
Private pe As Cursor = Starter.skmt.ExecQuery("select count(pe_cliente) as cuantosPedidos from pedido where pe_cliente In (select cuenta from cuentaa)")
|
||||
pe.Position=0
|
||||
If pe.GetString("cuantosPedidos") = 0 Then
|
||||
Log("###### delete from pedido_cliente - " & traeCliente & "|" & clienteId)
|
||||
Log($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
'INSERTAMOS
|
||||
' LogColor("INSERTAMOS PROD", Colors.red)
|
||||
If cant > 0 Then guardaProductoSinGestion(cedis, costoU, cant, nombre, prodId, clienteId, fecha, usuario, rutaV, precioSin, tipoVenta)
|
||||
End If
|
||||
c.Close
|
||||
End Sub
|
||||
|
||||
|
||||
'Inserta un producto en la tabla "pedido" y "pedido_cliente" y actualiza "cat_gunaprod".
|
||||
'NO ACTUALIZA LA BANDERA DE GESTION EN LA TABLA "kmt_info".
|
||||
'Si "gestion=2" entonces el sistema considera que el pedido ya se guardó y ya no se debe modificar.
|
||||
Sub guardaProductoSinGestion(cedis As String, costoU As String, cant As String, nombre As String, prodId As String, clienteId As String, fecha As String, usuario As String, rutaV As String, precioSin As String, tipoVenta As String)
|
||||
If nombre.Length < 6 Then ToastMessageShow("(guardaProductoSinGestion) El nombre del producto no es valido " & nombre, True)
|
||||
precioSin = NumberFormat2(precioSin, 1, 2, 2, False)
|
||||
costoU = NumberFormat2(costoU, 1, 2, 2, False)
|
||||
' LogColor("guardaProductoSinGestion: "&prodId&", cant="&cant&", tipo="&tipoVenta, Colors.Magenta)
|
||||
Private c As Cursor
|
||||
' Private tablaProds As String = "cat_gunaprod2"
|
||||
' If tipoVenta = "ABORDO" Then tablaProds = "cat_gunaprod"
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS, PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_PRONOMBRE, PE_PROID, PE_CLIENTE, PE_FECHA, PE_USUARIO, PE_RUTA, PE_COSTO_SIN, PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (cedis, (cant * costoU), costoU, cant, nombre, prodId, clienteId, fecha, usuario, rutaV, precioSin, tipoVenta))
|
||||
'Actualizamos el inventario en cat_gunaprod solo si no es RMI
|
||||
If cedis <> "DUR" Then Starter.skmt.ExecNonQuery2($"update ${traeTablaProds(tipoVenta)} set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? "$, Array As Object(cant, prodId))
|
||||
c=Starter.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, SUM(PE_COSTO_SIN) AS TOTAL_CLIE_SIN FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
' Log("###### delete from pedido_cliente - " & traeCliente & "|" & clienteId)
|
||||
' Log($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
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(clienteId, fecha, usuario, c.GetString("CANT_CLIE"), c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps, cedis, rutaV, c.GetString("TOTAL_CLIE_SIN")))
|
||||
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
|
||||
Reference in New Issue
Block a user