14/01/24 - Correcciones para listas de precios y totales en Nota

This commit is contained in:
2024-01-14 04:37:57 -06:00
parent 9e08c4c77b
commit 5538d4726d
6 changed files with 152 additions and 77 deletions

View File

@@ -99,9 +99,9 @@ Sub B4XPage_Appear
c=Starter.skmt.ExecQuery("select PE_PRONOMBRE, PE_CEDIS, PE_COSTO_TOT, PE_CANT, PE_FOLIO, PE_TIPO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_TIPO desc, PE_CEDIS, PE_COSTO_TOT, PE_PRONOMBRE") c=Starter.skmt.ExecQuery("select PE_PRONOMBRE, PE_CEDIS, PE_COSTO_TOT, PE_CANT, PE_FOLIO, PE_TIPO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_TIPO desc, PE_CEDIS, PE_COSTO_TOT, PE_PRONOMBRE")
ListView1.Clear ListView1.Clear
Private cs As CSBuilder Private cs As CSBuilder
If c.RowCount>0 Then If c.RowCount > 0 Then
For i=0 To c.RowCount -1 For i = 0 To c.RowCount - 1
c.Position=i c.Position = i
Dim label1 As Label Dim label1 As Label
label1 = ListView1.TwoLinesLayout.Label label1 = ListView1.TwoLinesLayout.Label
label1.TextSize = 15 label1.TextSize = 15
@@ -120,10 +120,14 @@ Sub B4XPage_Appear
Next Next
End If End If
If Existe <> 0 Then If Existe <> 0 Then
c=Starter.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)") ' c=Starter.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
C.Position=0 ' C.Position=0
L_CANT.Text = c.GetString("PC_NOART")
L_TOTAL.Text = c.GetString("PC_MONTO") c=Starter.skmt.ExecQuery("select sum(pe_cant) AS CANTIDAD, sum(pe_costo_tot) AS MONTO from pedido where PE_CEDIS <> PE_PROID and pe_cliente in (Select CUENTA from cuentaa)")
c.Position=0
L_CANT.Text = c.GetString("CANTIDAD")
L_TOTAL.Text = c.GetString("MONTO")
c.Close c.Close
c=Starter.skmt.ExecQuery("select SUM(IFNULL(PE_DESC,0)) AS DESCUENTO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)") c=Starter.skmt.ExecQuery("select SUM(IFNULL(PE_DESC,0)) AS DESCUENTO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
c.Position=0 c.Position=0

View File

@@ -99,7 +99,7 @@ Sub Class_Globals
Private lv_precio2 As ListView Private lv_precio2 As ListView
Private cb_precio2 As B4XComboBox Private cb_precio2 As B4XComboBox
Private PERFIL As String Private PERFIL As String
Private prodAct As label Private prodAct As Label
End Sub End Sub
'You can add more parameters here. 'You can add more parameters here.
@@ -545,28 +545,31 @@ Sub b_prodMenos_Click
LogColor("b_prodMenos_Click", Colors.Magenta) LogColor("b_prodMenos_Click", Colors.Magenta)
Dim index As Int = clv_prods_ll.GetItemFromView(Sender) Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen") Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen")
Log($">>> ALMACEN: ${inv}"$)
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index) Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
Dim pnl As B4XView = pnl0.GetView(0) Dim pnl As B4XView = pnl0.GetView(0)
Dim lProdX As B4XView = pnl.GetView(1)
Dim laCant As B4XView = pnl.GetView(2).GetView(2) Dim laCant As B4XView = pnl.GetView(2).GetView(2)
Private precio2 As String=clv_prods_ll.GetValue(index).As(Map).Get("precio") Private precio2 As String = lProdX.tag.As(Map).Get("precio")
' Log($"precio|stock:${laCant.tag}"$) ' Log($"precio|stock:${laCant.tag}"$)
' Log("lacant.text="&laCant.text & "|" & buttonTag) ' Log("lacant.text="&laCant.text & "|" & buttonTag)
If buttonTag = "vendido" And laCant.Text > 0 Then If buttonTag = "vendido" And laCant.Text > 0 Then
Log(clv_prods_ll.GetValue(index).As(Map)) Log(clv_prods_ll.GetValue(index).As(Map))
clv_prods_ll.GetValue(index).As(Map).Put("almacen",inv + 1) lProdX.tag.As(Map).Put("almacen",inv + 1)
Log(clv_prods_ll.GetValue(index).As(Map)) Log(lProdX.tag.As(Map))
' clv_prods_ll.GetValue(index).As(Map).Get("almacen") = clv_prods_ll.GetValue(index).As(Map).Get("almacen") + 1 ' clv_prods_ll.GetValue(index).As(Map).Get("almacen") = clv_prods_ll.GetValue(index).As(Map).Get("almacen") + 1
End If End If
If laCant.Text = "" Then laCant.Text = 0 If laCant.Text = "" Then laCant.Text = 0
laCant.Text = $"${NumberFormat2((laCant.Text - 1), 1, 0, 0, False)}"$ laCant.Text = $"$1.0{laCant.Text - 1}"$
If laCant.Text < 0 Then laCant.Text = 0 If laCant.Text < 0 Then laCant.Text = 0
Private tmpMap As Map = clv_prods_ll.GetValue(index).As(Map) Private tmpMap As Map = lProdX.tag.As(Map)
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio") Private precio As String = tmpMap.Get("precio")
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id") Private id As String = tmpMap.Get("id")
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":Subs.traeAlmacen) Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":Subs.traeAlmacen)
Log(tmpMap)
' Log(tmpMap) ' Log(tmpMap)
prodsMap.Put(id, tmpMap) ' prodsMap.Put(id, tmpMap)
If laCant.Text = 0 Then prodsMap.Remove(id) ' If laCant.Text = 0 Then prodsMap.Remove(id)
' LogColor("prodsMap="&prodsMap, Colors.blue) ' 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) ' (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 Private almacenX As String = Subs.traeAlmacen
@@ -580,6 +583,18 @@ Sub b_prodMenos_Click
Log(">>>>>>> Insertamos prod desde prodMenos") Log(">>>>>>> Insertamos prod desde prodMenos")
Subs.actualizaProducto(almacenX, precioX, precio2, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov) Subs.actualizaProducto(almacenX, precioX, precio2, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
cuentaProds cuentaProds
If lfila.Text <> "RMI" Then
Private cs As CSBuilder
cs.Initialize
'Traemos el inventario actual
Private i As Cursor = Starter.skmt.ExecQuery($"select CAT_GP_ALMACEN from cat_gunaprod2 where CAT_GP_ID = '${id}'"$)
Private invActualizado As String = "0"
If i.RowCount > 0 Then
i.Position = 0
invActualizado = i.GetString("CAT_GP_ALMACEN")
End If
If Starter.tipov <> "ABORDO" Then lProdX.Text = cs.Color(Colors.red).append(nombreX).pop.append(CRLF).Append("Existencias: " & invActualizado).Color(0xFF017F01).Append($" $${precio}"$).Popall
End If
If Subs.totalPedido < 1 Then laCant.Text = "0" If Subs.totalPedido < 1 Then laCant.Text = "0"
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$) ' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
End Sub End Sub
@@ -591,57 +606,80 @@ Sub b_prodMas_Click
LogColor("b_prodMas_Click", Colors.Magenta) LogColor("b_prodMas_Click", Colors.Magenta)
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index) Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
Dim pnl As B4XView = pnl0.GetView(0) Dim pnl As B4XView = pnl0.GetView(0)
Dim lProdX As B4XView = pnl.GetView(1)
Private existencias As String = lProdX.tag.As(Map).Get("almacen")
' LogColor(clv_prods_ll.GetValue(index).As(Map), Colors.blue)
' LogColor(lProdX.tag.As(Map), Colors.red)
Log($">>> ALMACEN: ${existencias}"$)
Dim laCant As B4XView = pnl.GetView(2).GetView(2) Dim laCant As B4XView = pnl.GetView(2).GetView(2)
If laCant.Text = "" Then laCant.Text = 0 If laCant.Text = "" Then laCant.Text = 0
' Private tmpMap As Map = clv_prods_ll.GetValue(index).As(Map) Private tmpMap As Map = lProdX.tag.As(Map)
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio") Private precio As String = tmpMap.Get("precio")
Private precio2 As String = precio Private precio2 As String = precio
Private inv As Int = clv_prods_ll.GetValue(index).As(Map).Get("almacen") Private inv As Int = tmpMap.Get("almacen")
Log(clv_prods_ll.GetValue(index)) ' Log(tmpMap)
If buttonTag = "vendido" Then If buttonTag = "vendido" Then
If inv > 0 And (laCant.Text + 1 <= inv) And (Subs.totalPedido - precio > 1) Then ' Log("VENDIDO")
' Log($"${(laCant.Text + 1 <= inv)} And ${(Subs.totalPedido - precio > 1)}"$)
If inv > 0 And (laCant.Text + 1 <= (laCant.Text + existencias)) And (Subs.totalPedido - precio > 1) Then
' Log(clv_prods_ll.GetValue(index).As(Map)) ' Log(clv_prods_ll.GetValue(index).As(Map))
clv_prods_ll.GetValue(index).As(Map).Put("almacen", (inv - 1)) tmpMap.Put("almacen", (inv - 1))
inv = inv - 1 inv = inv - 1
laCant.Text = $"${NumberFormat2((laCant.Text + 1), 1, 0, 0, False)}"$ ' laCant.Text = $"$1.0{laCant.Text+1}"$
laCant.Text = NumberFormat2((laCant.Text + 1), 1, 0, 0, False)
' Log(clv_prods_ll.GetValue(index).As(Map)) ' Log(clv_prods_ll.GetValue(index).As(Map))
End If End If
else If laCant.Text + 1 <= inv And lfila.Text = "PRODUCTOS" Then else If laCant.Text + 1 <= inv And lfila.Text = "PRODUCTOS" Then
' LogColor(inv, Colors.blue) ' LogColor(inv, Colors.blue)
laCant.Text = $"${NumberFormat2((laCant.Text + 1), 1, 0, 0, False)}"$ ' laCant.Text = $"$1.0{laCant.Text + 1}"$
Log(Subs.totalPedido) laCant.Text = NumberFormat2((laCant.Text + 1), 1, 0, 0, False)
' Log(Subs.totalPedido)
else If lfila.Text = "RMI" And laCant.Text + 1 <= inv And (Subs.totalPedido - precio > 1) Then 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 = $"${NumberFormat2((laCant.Text + 1), 1, 0, 0, False)}"$ ' laCant.Text = $"$1.0{laCant.Text + 1}"$
laCant.Text = NumberFormat2((laCant.Text + 1), 1, 0, 0, False)
Log(Subs.totalPedido) Log(Subs.totalPedido)
else if Subs.totalPedido < 1 Then else if Subs.totalPedido < 1 Then
laCant.Text = "0" laCant.Text = "0"
End If End If
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id") Private id As String = tmpMap.Get("id")
Private almacenX As String = Subs.traeAlmacen Private almacenX As String = Subs.traeAlmacen
Private nombreX As String = Subs.traeProdNombre(id) Private nombreX As String = Subs.traeProdNombre(id)
Private precioX As String = precio Private precioX As String = precio
'Aqui va el cambio de precio de acuerdo al perfil.
' if perfil = xx then precioX = xxx
If lfila.Text = "RMI" Then If lfila.Text = "RMI" Then
almacenX = "DUR" almacenX = "DUR"
nombreX = "CAMBIO"&Subs.traeRMINombre(id) nombreX = "CAMBIO"&Subs.traeRMINombre(id)
precioX = precioX * -1 precioX = precioX * -1
End If End If
Log(">>>>>>> Insertamos prod desde prodMas")
Subs.actualizaProducto(almacenX, precioX, precio2, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov) Subs.actualizaProducto(almacenX, precioX, precio2, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
cuentaProds
If Subs.totalPedido < 1 Then If Subs.totalPedido < 1 Then
etCantHasFocus = True etCantHasFocus = True
Log("A CERO") Log("A CERO")
laCant.Text = "0" laCant.Text = "0"
et_pCant_TextChanged(100, 0) et_pCant_TextChanged(100, 0)
End If End If
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$) If Subs.traeCliente = 0 Then
' Log("######### "& NumberFormat2((kh.traeLimiteAbordoWeb - (kh.traeLimiteAbordoXInventario - kh.traeVenta) - kh.traeVentaAbordo), 0, 2, 2, False))
laCant.Text = NumberFormat2((laCant.Text - 1), 1, 0, 0, False)
Subs.actualizaProducto(almacenX, precioX, precio2, laCant.text, nombreX, id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, Starter.tipov)
' Log("######### "& NumberFormat2((kh.traeLimiteAbordoWeb - (kh.traeLimiteAbordoXInventario - kh.traeVenta) - kh.traeVentaAbordo), 0, 2, 2, False))
End If
cuentaProds
If lfila.Text <> "RMI" Then
Private cs As CSBuilder
cs.Initialize
'Traemos el inventario actual
Private i As Cursor = Starter.skmt.ExecQuery($"select CAT_GP_ALMACEN from cat_gunaprod2 where CAT_GP_ID = '${id}'"$)
Private invActualizado As String = "0"
If i.RowCount > 0 Then
i.Position = 0
invActualizado = i.GetString("CAT_GP_ALMACEN")
End If
If Starter.tipov <> "ABORDO" Then lProdX.Text = cs.Color(Colors.red).append(nombreX).pop.append(CRLF).Append("Existencias: " & invActualizado).Color(0xFF017F01).Append($" $${precio}"$).Popall
End If
Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
End Sub End Sub
Private Sub et_pCant_FocusChanged (HasFocus As Boolean) Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
@@ -662,7 +700,7 @@ Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
End Sub End Sub
Private Sub et_pCant_TextChanged (Old As String, New As String) Private Sub et_pCant_TextChanged (Old As String, New As String)
' LogColor($"txt changed: ${Old}|${New}, hasfocus=${etCantHasFocus}"$,Colors.Magenta) LogColor($"txt changed: ${Old}|${New}, hasfocus=${etCantHasFocus}"$,Colors.Magenta)
' If Not(Old = "0" And New = "") And etCantHasFocus Then cuentaProds ' If Not(Old = "0" And New = "") And etCantHasFocus Then cuentaProds
If etCantHasFocus = True Then If etCantHasFocus = True Then
@@ -675,7 +713,7 @@ Private Sub et_pCant_TextChanged (Old As String, New As String)
' Log(clv_prods_ll.GetValue(index).As(Map)) ' Log(clv_prods_ll.GetValue(index).As(Map))
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id") Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio") Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
private precio2 as string = precio Private precio2 As String = precio
' Log("++++++++++ " & precio) ' Log("++++++++++ " & precio)
Dim tempTot As String = Subs.totalPedido Dim tempTot As String = Subs.totalPedido
Dim disp As String = 0 Dim disp As String = 0
@@ -737,7 +775,7 @@ Sub cuentaProds
p_botonesVenta.BringToFront p_botonesVenta.BringToFront
c.Position = 0 c.Position = 0
' If Subs.totalPedido > 1 And lfila.Text <> "RMI" And Starter.tipov <> "ABORDO" Then b_rmi.Visible = True Else b_rmi.Visible = False ' If Subs.totalPedido > 1 And lfila.Text <> "RMI" And Starter.tipov <> "ABORDO" Then b_rmi.Visible = True Else b_rmi.Visible = False
Log(Subs.totalPedido) ' Log(Subs.totalPedido)
If lfila.Text = "RMI" Then l_mDisponible.Visible = True Else l_mDisponible.Visible = False If lfila.Text = "RMI" Then l_mDisponible.Visible = True Else l_mDisponible.Visible = False
l_mDisponible.Text = $"Disponible: $${Subs.totalPedido}"$ l_mDisponible.Text = $"Disponible: $${Subs.totalPedido}"$
' Log($"Total Prods: ${c.GetString("cant")}, Total Compra: $$1.2{c.GetString("total")}"$) ' Log($"Total Prods: ${c.GetString("cant")}, Total Compra: $$1.2{c.GetString("total")}"$)
@@ -1026,34 +1064,29 @@ Sub l_prodX_Click
prodAct = Sender prodAct = Sender
Log(prodAct.Text) Log(prodAct.Text)
l_info.Text = Sender.as(Label).text l_info.Text = Sender.as(Label).text
Log(Sender.as(Label).tag) Private elTag As Map = Sender.as(Label).tag
Private id As String = Sender.as(Label).tag.As(Map).Get("id") ' Log(elTag)
Private c As Cursor = Starter.skmt.ExecQuery($"select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA IN ('1','10') AND CAT_GP_ID = '${id}' ORDER BY NLISTA ASC"$) Private id As String = elTag.Get("id")
' Private c As Cursor = Starter.skmt.ExecQuery($"select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA IN ('1','10') AND CAT_GP_ID = '${id}' ORDER BY NLISTA ASC"$)
' Log(c.RowCount)
' cb_precio2.Tag = Sender.as(Label).tag
' If c.RowCount > 0 Then
' Private losPreciosList As List
' losPreciosList.Initialize
' cb_precio2.mBase.Visible = True
' losPreciosList.Add("-= Seleccione Precio =-")
' For i = 0 To c.RowCount - 1
' c.Position = i
' losPreciosList.Add(c.GetString("NLISTA") & " - " & NumberFormat2(c.GetDouble("PRECIO"), 1, 2, 2, False))
' Next
' cb_precio2.SetItems(losPreciosList)
' End If
Log(c.RowCount) Private listaPrecios As List = traeListaPrecios(Subs.traeAlmacen, ruta, id, PERFIL)
' lv_precio2.Clear If listaPrecios.Size > 0 Then
cb_precio2.SetItems(listaPrecios)
Dim Label1, Label2 As Label cb_precio2.Tag = elTag
Label1 = lv_precio2.SingleLineLayout.Label
Label1.TextSize = 14
Label1.TextColor = Colors.black
' Label2 = lv_precio2.TwoLinesLayout.SecondLabel
' Label2.TextSize = 14
' Label2.TextColor = Colors.DarkGray
cb_precio2.Tag = Sender.as(Label).tag
If c.RowCount > 0 Then
Private losPreciosList As List
losPreciosList.Initialize
' l_info.Height = 250dip
' lv_precio2.Visible = True
cb_precio2.mBase.Visible = True cb_precio2.mBase.Visible = True
losPreciosList.Add("-= Seleccione Precio =-")
For i = 0 To c.RowCount - 1
c.Position = i
losPreciosList.Add(c.GetString("NLISTA") & " - " & NumberFormat2(c.GetDouble("PRECIO"), 1, 2, 2, False))
' lv_precio2.AddSingleLine2(c.GetString("NLISTA") & " - " & c.GetString("PRECIO"), c.GetString("PRECIO"))
Next
cb_precio2.SetItems(losPreciosList)
End If End If
l_info.BringToFront l_info.BringToFront
l_info.Visible = True l_info.Visible = True
@@ -1152,6 +1185,7 @@ Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As In
l_prodX.Text = cs.Color(Colors.red).append(clv_prods_ll.GetValue(i).As(Map).Get("prod")).pop.append(CRLF).Append("Existencias: " & clv_prods_ll.GetValue(i).As(Map).Get("almacen")).Color(0xFF017F01).Append($" $${precio}"$).Popall l_prodX.Text = cs.Color(Colors.red).append(clv_prods_ll.GetValue(i).As(Map).Get("prod")).pop.append(CRLF).Append("Existencias: " & clv_prods_ll.GetValue(i).As(Map).Get("almacen")).Color(0xFF017F01).Append($" $${precio}"$).Popall
l_prodX.Tag = clv_prods_ll.GetValue(i).As(Map) l_prodX.Tag = clv_prods_ll.GetValue(i).As(Map)
l_pCant.Tag = clv_prods_ll.GetValue(i).As(Map).Get("id") l_pCant.Tag = clv_prods_ll.GetValue(i).As(Map).Get("id")
et_pCant.Tag = clv_prods_ll.GetValue(i).As(Map)
End If End If
' Log($"${i}, ${FirstIndex}, ${LastIndex}, ${Pnl.NumberOfViews}. ${clv_prods_ll.Size}"$) ' Log($"${i}, ${FirstIndex}, ${LastIndex}, ${Pnl.NumberOfViews}. ${clv_prods_ll.Size}"$)
Else 'Not visible Else 'Not visible
@@ -1212,7 +1246,7 @@ Sub LlenaProdsLL(p As ResultSet, extra As String)
Log("LlenaProdsLL") Log("LlenaProdsLL")
listaProds.Initialize listaProds.Initialize
hayPedido = Subs.hayPedido hayPedido = Subs.hayPedido
Log($"HAYPEDIDO: ${hayPedido}"$) ' Log($"HAYPEDIDO: ${hayPedido}"$)
If hayPedido Then 'Si hay pedido obtenemos las cantidades de los productos para agregarlos al CLV. If hayPedido Then 'Si hay pedido obtenemos las cantidades de los productos para agregarlos al CLV.
Dim cantsMap, tiposMap, preciosMap As Map Dim cantsMap, tiposMap, preciosMap As Map
cantsMap.Initialize cantsMap.Initialize
@@ -1222,7 +1256,7 @@ Sub LlenaProdsLL(p As ResultSet, extra As String)
'Si EXTRA es igual a rmi, entonces regresamos los RMIs existentes. 'Si EXTRA es igual a rmi, entonces regresamos los RMIs existentes.
If extra = "rmi" Then pe = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT, PE_COSTOU from PEDIDO where PE_CLIENTE = '${clienteId}' and PE_CEDIS = 'DUR'"$) If extra = "rmi" Then pe = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT, PE_COSTOU from PEDIDO where PE_CLIENTE = '${clienteId}' and PE_CEDIS = 'DUR'"$)
LogColor("Ponemos productos de pedido anterior: "&pe.RowCount, Colors.red) ' LogColor("Ponemos productos de pedido anterior: "&pe.RowCount, Colors.red)
Do While pe.NextRow Do While pe.NextRow
Private cant As Int = 0 Private cant As Int = 0
Private tipo As String = "" Private tipo As String = ""
@@ -1255,8 +1289,9 @@ Sub LlenaProdsLL(p As ResultSet, extra As String)
If hayPedido And preciosMap.ContainsKey(p.GetString("CAT_GP_ID")) Then precioX = preciosMap.Get(p.GetString("CAT_GP_ID")) If hayPedido And preciosMap.ContainsKey(p.GetString("CAT_GP_ID")) Then precioX = preciosMap.Get(p.GetString("CAT_GP_ID"))
' Log(precioX) ' Log(precioX)
' Log(">>>>>> preciosMap: " & preciosMap) ' Log(">>>>>> preciosMap: " & preciosMap)
Dim tempMap As Map = CreateMap("prod":p.GetString("CAT_GP_NOMBRE"), "precio":precioX, "almacen":p.GetString("CAT_GP_ALMACEN"), "id":p.GetString("CAT_GP_ID"), "cant":cant, "tipo":tipoV) Dim tempMap As Map = CreateMap("prod":p.GetString("CAT_GP_NOMBRE"), "precio":precioX, "almacen":p.GetString("CAT_GP_ALMACEN"), "id":p.GetString("CAT_GP_ID"), "cant":cant, "tipo":Starter.tipoV)
' Log($"tipo: |${tempMap.Get("tipo")}|${Starter.tipov}| - tempMap: ${tempMap}"$) ' Log($"tipo: |${tempMap.Get("tipo")}|${Starter.tipov}| - tempMap: ${tempMap}"$)
Log($">>> ${p.GetString("CAT_GP_NOMBRE")} - ALMACEN: ${p.GetString("CAT_GP_ALMACEN")}"$)
If tempMap.Get("tipo") = "" Or tempMap.Get("tipo") = Starter.tipov Then listaProds.Add(tempMap) 'Si el tipo de venta del producto es igual al actual, mostramos el producto en la lista. If tempMap.Get("tipo") = "" Or tempMap.Get("tipo") = Starter.tipov Then listaProds.Add(tempMap) 'Si el tipo de venta del producto es igual al actual, mostramos el producto en la lista.
' Log($"${p.GetString("CAT_GP_ID")}, ${p.GetString("CAT_GP_NOMBRE")}, ${cant}"$) ' Log($"${p.GetString("CAT_GP_ID")}, ${p.GetString("CAT_GP_NOMBRE")}, ${cant}"$)
Loop Loop
@@ -1284,7 +1319,7 @@ Sub LlenaProdsLL(p As ResultSet, extra As String)
Private Pnl As B4XView = xui.CreatePanel("") Private Pnl As B4XView = xui.CreatePanel("")
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 50dip) Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 50dip)
Private tempMap As Map = listaProdsConCant.Get(pr0) Private tempMap As Map = listaProdsConCant.Get(pr0)
Private inv As String = tempMap.Get("almacen") + tempMap.Get("cant") Private inv As String = tempMap.Get("almacen")' + tempMap.Get("cant")
tempMap.Put("almacen", inv) tempMap.Put("almacen", inv)
' Log(tempMap) ' Log(tempMap)
clv_prods_ll.Add(Pnl, tempMap) clv_prods_ll.Add(Pnl, tempMap)
@@ -1389,12 +1424,48 @@ Private Sub cb_precio2_SelectedIndexChanged (Index As Int)
Private p() As String Private p() As String
p = Regex.Split("-", cb_precio2.SelectedItem) p = Regex.Split("-", cb_precio2.SelectedItem)
Private p2 As String = p(1).trim 'Obtenemos el precio Private p2 As String = p(1).trim 'Obtenemos el precio
' Log("|" & p(1).trim & "|") Log("|" & p(1).trim & "|")
Private cs As CSBuilder Private cs As CSBuilder
cs.Initialize cs.Initialize
Log($"ProdAct: ${prodAct.tag}"$)
Private pnl As B4XView = prodAct.Parent
Private laCant As EditText = pnl.GetView(2).GetView(2)
' Log(laCant.text)
prodAct.tag.As(Map).Put("precio", p2)
If laCant.Text = "0" Then 'Modificamos la cantidad para que se guarde el producto en pedido y el nuevo precio se aolique.
etCantHasFocus = True
pnl.GetView(2).GetView(2).Text = "1"
Sleep(700) 'Esperamos un poco para que se guarde el producto en la BD.
End If
prodAct.Text = cs.Color(Colors.red).append(m.Get("prod")).pop.append(CRLF).Append("Existencias: " & m.Get("almacen")).Color(0xFF017F01).Append($" $${p2}"$).Popall prodAct.Text = cs.Color(Colors.red).append(m.Get("prod")).pop.append(CRLF).Append("Existencias: " & m.Get("almacen")).Color(0xFF017F01).Append($" $${p2}"$).Popall
Starter.skmt.ExecNonQuery($"update PEDIDO set PE_COSTOU = '${p2}', PE_COSTO_TOT = '${(p2 * m.Get("cant"))}' where PE_TIPO = '${m.Get("tipo")}' and PE_COSTOU = '${m.Get("precio")}' and PE_PROID = '${m.Get("id")}' and PE_CLIENTE = '${kh.traeCliente}'"$) Starter.skmt.ExecNonQuery($"update PEDIDO set PE_COSTOU = '${p2}', PE_COSTO_TOT = '${(p2 * laCant.text)}' where PE_TIPO = '${m.Get("tipo")}' and PE_PROID = '${m.Get("id")}' and PE_CLIENTE = '${kh.traeCliente}'"$)
' Log($"update PEDIDO set PE_COSTOU = '${p2}', PE_COSTO_TOT = '${(p2 * laCant.text)}' where PE_TIPO = '${m.Get("tipo")}' and PE_PROID = '${m.Get("id")}' and PE_CLIENTE = '${kh.traeCliente}'"$)
l_info.Visible = False l_info.Visible = False
lv_precio2.Visible = False lv_precio2.Visible = False
cb_precio2.mBase.Visible = False cb_precio2.mBase.Visible = False
End Sub End Sub
'Regresa la lista de precios de acuerdo al almacen, ruta, perfil y id dados.
Sub traeListaPrecios (almacenX As String, rutaX As String, idX As String, perfilX As String) As List 'ignore
Private listaPrecios As List
listaPrecios.Initialize
listaPrecios.Add("-= Seleccione Precio =-")
If almacenX = "6" And rutaX = "16" Then
c = Starter.skmt.ExecQuery($"select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA IN ('1','10') AND CAT_GP_ID = '${idX}' ORDER BY NLISTA ASC"$)
If c.RowCount>0 Then
For i=0 To c.RowCount - 1
c.Position = i
listaPrecios.Add($"${c.GetString("NLISTA")} - ${c.GetString("PRECIO")}"$)
Next
End If
ELSE IF perfilX = "V-ESPECIAL" Then
c = Starter.skmt.ExecQuery($"select PRECIO, NLISTA FROM LISTA_PRECIOS WHERE NLISTA IN ('5','6','7','8','10') AND CAT_GP_ID = '${idX}' ORDER BY NLISTA ASC"$)
If c.RowCount>0 Then
For i=0 To c.RowCount -1
c.Position = i
listaPrecios.Add($"${c.GetString("NLISTA")} - ${NumberFormat2(c.GetDouble("PRECIO"), 1, 2, 2, False)}"$)
Next
End If
End If
Return listaPrecios
End Sub

View File

@@ -790,7 +790,7 @@ Version=12.5
#Region Project Attributes #Region Project Attributes
#ApplicationLabel: Durakelo #ApplicationLabel: Durakelo
#VersionCode: 1 #VersionCode: 1
#VersionName: 3.10.31 #VersionName: 4.01.14
'SupportedOrientations possible values: unspecified, landscape or portrait. 'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait #SupportedOrientations: portrait
#CanInstallToExternalStorage: False #CanInstallToExternalStorage: False

View File

@@ -63,7 +63,7 @@ ModuleClosedNodes5=
ModuleClosedNodes6=1 ModuleClosedNodes6=1
ModuleClosedNodes7= ModuleClosedNodes7=
ModuleClosedNodes8= ModuleClosedNodes8=
ModuleClosedNodes9= ModuleClosedNodes9=31,33,35,36,37,38,39,40,41,42
NavigationStack=C_Productos,b_continuar_Click,823,0,C_Nota,Class_Globals,0,0,Visual Designer,proditem.bal,-100,1,C_Productos,l_prodX_Click,1047,2,C_Nota,B4XPage_Created,64,0,Visual Designer,productos.bal,-100,2,Subs,borraPedidoClienteActual,1258,0,C_Nota,B4XPage_Appear,114,2,C_Productos,b_terminar1_Click,753,6,C_Productos,cb_precio2_SelectedIndexChanged,1384,6 NavigationStack=C_Productos,b_prodMenos_Click,551,2,C_Nota,Class_Globals,0,0,C_Productos,cb_precio2_SelectedIndexChanged,1432,6,C_Productos,LlenaProdsLL,1301,0,C_Productos,b_prodMas_Click,659,6,Subs,actualizaProducto,775,0,Visual Designer,proditem.bal,-100,1,Visual Designer,nota.bal,-100,1,C_Nota,B4XPage_Created,72,0,C_Nota,B4XPage_Appear,119,2,Main,Process_Globals,21,0
SelectedBuild=0 SelectedBuild=0
VisibleModules=19,1,8,16,6,3,9,20,10,21 VisibleModules=19,1,8,16,6,3,9,20,10,21

Binary file not shown.

Binary file not shown.