mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-20 11:39:13 +00:00
- VERSOIN 5.11.26
- Se agregó le descripcion del "flujo" de las promociones en C_Promos
This commit is contained in:
134
B4A/Subs.bas
134
B4A/Subs.bas
@@ -863,6 +863,7 @@ Sub traeNombreCliente(id As String) As String
|
||||
Do While c.NextRow
|
||||
n = c.GetString("CAT_CL_NOMBRE")
|
||||
Loop
|
||||
c.Close
|
||||
Return n
|
||||
End Sub
|
||||
|
||||
@@ -1008,7 +1009,7 @@ End Sub
|
||||
' resultado="OK" 'Ok si existe la promocion.
|
||||
' prodsVariablesRequeridos=5} 'Cantidad de productos variables requeridos para la promoción.
|
||||
Sub traePromo(promo As String, cliente As String) As Map
|
||||
Private thisLog As Boolean = True
|
||||
Private thisLog As Boolean = false
|
||||
If thisLog Then Log("traePromo:"&promo)
|
||||
Private inicioContador As String = DateTime.Now
|
||||
Private c As Cursor = Starter.skmt.ExecQuery("Select * from promos_comp where cat_pa_id = '"& promo&"'") 'Obtenemos el maximo de promociones a otorgar.
|
||||
@@ -1029,7 +1030,7 @@ Sub traePromo(promo As String, cliente As String) As Map
|
||||
'######### PROMOCIONES SEGMENTADAS ##########
|
||||
' Si la promo esta en la lista, SOLO los clientes que la tengan la pueden ver.
|
||||
Private ps As Cursor = Starter.skmt.ExecQuery($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}'"$) ' and HCCP_CLIENTE = '${cliente}'
|
||||
Log($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}'"$)
|
||||
' Log($"select * from HIST_CLIENTE_CANT_PROMOS where HCCP_PROMO = '${promo}'"$)
|
||||
If thisLog Then Log($"PROMOS SEGMENTADAS ENCONTRADAS: ${ps.RowCount}"$)
|
||||
If thisLog Then Log(promoMap)
|
||||
If ps.RowCount > 0 Then
|
||||
@@ -1045,13 +1046,16 @@ Sub traePromo(promo As String, cliente As String) As Map
|
||||
If thisLog Then Log($"registros:${ps2.RowCount}, cliente: ${ps2.GetString("HCCP_CLIENTE")} cant:${ps2.GetString("HCCP_CANT")}"$)
|
||||
promoMap = CreateMap("id":promo, "maxXcliente":(ps2.GetString("HCCP_CANT")-ps2.GetString("HCCP_CANT_VENDIDA")), "maxRecurrente":ps2.GetString("HCCP_CANT"), "maxPromos":ps2.GetString("HCCP_CANT")) 'Si es segmentada SOLO le aparece a ciertos clientes.
|
||||
End If
|
||||
ps2.Close
|
||||
End If
|
||||
ps.Close
|
||||
If thisLog Then Log(promoMap)
|
||||
' ########## TERMINA PROMOS SEGMENTADAS ##########
|
||||
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
|
||||
If c.GetString("hist") > 0 Then siHistorico = 1
|
||||
promoMap.Put("historico", siHistorico)
|
||||
c.Close
|
||||
c = Starter.skmt.ExecQuery("Select * from CAT_DETALLES_PAQ where CAT_DP_ID = '"& promo & "'") 'Obtenemos los detalles de la promoción.
|
||||
c.Position = 0
|
||||
If c.RowCount > 0 Then
|
||||
@@ -1090,6 +1094,7 @@ Sub traePromo(promo As String, cliente As String) As Map
|
||||
Else
|
||||
promoMap.Put("resultado", "No hay datos de la promoción.")
|
||||
End If
|
||||
c.Close
|
||||
c = Starter.skmt.ExecQuery("Select CAT_GP_STS, CAT_GP_NOMBRE from CAT_GUNAPROD2 where CAT_GP_ID = '"& promo & "'") 'Obtenemos las piezas requeridas de productos variables para la promoción.
|
||||
c.Position = 0
|
||||
Private pvr As String = 0
|
||||
@@ -1109,7 +1114,7 @@ End Sub
|
||||
|
||||
'Regresa un mapa con el inventario disponible por producto para la promoción (desde la base de datos).
|
||||
Sub traemosInventarioDisponibleParaPromo(promo As String) As Map 'ignore
|
||||
Private thisLog As Boolean = True
|
||||
Private thisLog As Boolean = False
|
||||
Private c As Cursor
|
||||
c = Starter.skmt.ExecQuery2("SELECT CAT_GP_ID, CAT_GP_ALMACEN FROM CAT_GUNAPROD2 WHERE CAT_GP_ID IN (select CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID = ?)", Array As String(promo))
|
||||
' Private prodInv As Map
|
||||
@@ -1129,6 +1134,7 @@ Sub traemosInventarioDisponibleParaPromo(promo As String) As Map 'ignore
|
||||
Next
|
||||
' prodInv.Put("inventarios", prods)
|
||||
End If
|
||||
c.Close
|
||||
Return prods
|
||||
End Sub
|
||||
|
||||
@@ -1147,7 +1153,7 @@ Sub restaFijosPromo(promoMap As Map) As Map 'ignore
|
||||
Private prodsFijos As List = promoMap.get("prodsFijos") 'Obtenemos un a lista con los productos fijos de la promoción.
|
||||
If thisLog Then LogColor("ProdsFijos -> " & prodsFijos, Colors.red)
|
||||
inventariosDisponiblesParaEstaPromo.Put("resultado", "No hay suficiente producto para la promocion.") 'Valor por default
|
||||
Log($"Prods fijos requeridos ${prodsFijos.Size}"$)
|
||||
If thisLog Then Log($"Prods fijos requeridos ${prodsFijos.Size}"$)
|
||||
If prodsFijos.Size = 0 Then inventariosDisponiblesParaEstaPromo.Put("resultado", "ok") 'Si no lleva prods fijos la promo, entonces ponemos FIJOS OK.
|
||||
For p = 0 To prodsFijos.Size - 1
|
||||
Private t As String = prodsFijos.Get(p) 'Obtenemos el Id de este producto desde la lista de productos fijos.
|
||||
@@ -1198,7 +1204,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 = true '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
|
||||
@@ -1224,14 +1230,15 @@ Sub traeMaxPromos(pm As Map) As Int
|
||||
maxPromos.Add(hccp.GetInt("HCCP_CANT"))
|
||||
End If
|
||||
maxPromos.Sort(True)
|
||||
If thisLog Then Log($">>>>> Max promos : ${maxPromos}"$)
|
||||
If thisLog Then Log($" >>>>> MAX PROMOS X CONF : ${maxPromos} <==> ${maxPromos.Get(0)}"$)
|
||||
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}"$)
|
||||
If thisLog Then Log($" >>>>> MAX PROMOS - PROMOS VENDIDAS <==> ${mp0} - ${(traePromosVendidas(pm.Get("id"), traeCliente)).As(Int)} = ${mp}"$)
|
||||
End If
|
||||
hccp.Close
|
||||
Return mp 'Regresamos el numero mas pequeño de las opciones.
|
||||
End Sub
|
||||
|
||||
@@ -1244,6 +1251,7 @@ Sub traePromosVendidas(promo As String, cliente As String) As Int
|
||||
c.Position = 0
|
||||
If c.GetString("cuantas") <> Null Then pv = c.GetString("cuantas")
|
||||
End If
|
||||
c.Close
|
||||
Return pv
|
||||
End Sub
|
||||
|
||||
@@ -1263,7 +1271,9 @@ Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
|
||||
' Log("|"&revisaMaxPromosProdsFijosPorInventario(pm)&"|")
|
||||
Private maxPromosXprodsFijos As Int = revisaMaxPromosProdsFijosPorInventario(pm)
|
||||
If maxPromosXprodsFijos < 1 Then pm.Put("resultado", 0)
|
||||
LogColor($">>> Promos disponibles por productos fijos = ${maxPromosXprodsFijos}"$, Colors.Magenta)
|
||||
If thisLog Then LogColor($"***********************************************************************"$, Colors.Blue)
|
||||
LogColor($"*** PROMOS DISPONIBLES X PRODS FIJOS (${idPromo}) = ${maxPromosXprodsFijos} ***"$, Colors.Blue)
|
||||
If thisLog Then LogColor($"***********************************************************************"$, Colors.Blue)
|
||||
If pm.Get("resultado") = "ok" Then 'Si encontramos la promoción, entonces ...
|
||||
'Buscamos el máximo de promociones permitidas.
|
||||
mp = traeMaxPromos(pm)
|
||||
@@ -1279,7 +1289,9 @@ Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
|
||||
If inventarioSinFijos.Get("resultado") = "ok" Then
|
||||
'Revisamos que los productos variables requeridos sean menos que el inventario total (mapa).
|
||||
Private pv As Boolean = alcanzanLosVariablesParaPromo(pm, inventarioSinFijos)
|
||||
If thisLog Then Log("Alcanzan los variables? --> " & pv)
|
||||
If thisLog Then LogColor($"****************************************************"$, Colors.Blue)
|
||||
If thisLog Then LogColor($"***** ¿ALCANZAN LOS VARIABLES? ==> ${IIf(pv, "SI", "NO")} *****"$, Colors.Blue)
|
||||
If thisLog Then LogColor($"****************************************************"$, Colors.Blue)
|
||||
If pv Then Return CreateMap("status":"ok", "mp":pm) Else Return CreateMap("status":"ko", "mp":pm)
|
||||
Else
|
||||
If thisLog Then LogColor("NO HAY INVENTARIO SUFICIENTE " & idPromo, Colors.red)
|
||||
@@ -1296,6 +1308,8 @@ Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
|
||||
Log($"Promo ${idPromo} mal configurada"$)
|
||||
ToastMessageShow($"Promo ${idPromo} mal configurada"$, True)
|
||||
Log(LastException)
|
||||
' Agregamos esta línea para evitar el NullPointerException
|
||||
Return CreateMap("status":"ko", "mp":Null)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -1344,45 +1358,47 @@ End Sub
|
||||
|
||||
'Regresa cuantas promos alcanzan con los productos FIJOS que hay en inventario.
|
||||
Sub revisaMaxPromosProdsFijosPorInventario(pm As Map) As Int
|
||||
Private thisLog As Boolean = True
|
||||
Private thisLog As Boolean = False
|
||||
Private invFijoXpromo As Map
|
||||
Private t As List
|
||||
t.Initialize
|
||||
t.Add(traeMaxPromos(pm)) ' Agregamos a la lista las promos maximas permitidas (recurrente, cliente y promo).
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green)
|
||||
If thisLog Then LogColor($"============ INICIA MAX PROMOS X PRODS FIJOS X INV ========"$, Colors.RGB(176,0,0))
|
||||
If thisLog Then LogColor($" ### MAX PROMOS (recurrente, cliente y promo): ${t}"$, Colors.Green)
|
||||
invFijoXpromo.Initialize
|
||||
If thisLog Then LogColor($"pm=${pm}"$, Colors.Blue)
|
||||
If thisLog Then LogColor($" pm=${pm}"$, Colors.Blue)
|
||||
Private invDispParaPromo As Map = traemosInventarioDisponibleParaPromo(pm.Get("id"))
|
||||
If thisLog Then Log($"invDispParaPromo=${invDispParaPromo}"$)
|
||||
If thisLog Then Log($" invDispParaPromo=${invDispParaPromo}"$)
|
||||
Private prodsFijosPiezas As List = pm.Get("prodsFijosPiezas")
|
||||
Private idProdsFijos As List = pm.Get("prodsFijos")
|
||||
Private idProdsFijosPrecios As List = pm.Get("prodsFijosPrecios")
|
||||
For p = 0 To idProdsFijos.Size -1 'Generamos una lista con las promos disponibles por producto (dividimos el inventario total entre las piezas requeridas).
|
||||
Private thisInvDisp As Int = 0
|
||||
If invDispParaPromo.Get(idProdsFijos.Get(p)) <> Null Then thisInvDisp = invDispParaPromo.Get(idProdsFijos.Get(p))
|
||||
If thisLog Then Log($"id=${idProdsFijos.Get(p)}, inv=${thisInvDisp}, pzasReq=${prodsFijosPiezas.Get(p)}"$)
|
||||
|
||||
LogColor($"====== ${idProdsFijos.Get(p)} - Inv1:${thisInvDisp}, inv2: ${traeExistenciasPorId(idProdsFijos.Get(p))}"$, Colors.Magenta)
|
||||
If thisInvDisp <> traeExistenciasPorId(idProdsFijos.Get(p)) Then
|
||||
LogColor("#### ERROR DE INVENTARIO ####" , Colors.red)
|
||||
End If
|
||||
|
||||
If thisLog Then Log($" id=${idProdsFijos.Get(p)}, inv=${thisInvDisp}, pzasReq=${prodsFijosPiezas.Get(p)}"$)
|
||||
' LogColor($" ====== ${idProdsFijos.Get(p)} - Inv1:${thisInvDisp}, inv2: ${traeExistenciasPorId(idProdsFijos.Get(p))}"$, Colors.Magenta)
|
||||
' If thisInvDisp <> traeExistenciasPorId(idProdsFijos.Get(p)) Then
|
||||
' LogColor(" #### ERROR DE INVENTARIO ####" , Colors.red)
|
||||
' End If
|
||||
' If thisLog Then Log($"${(thisInvDisp / prodsFijosPiezas.Get(p))}"$)
|
||||
Private x() As String = Regex.Split("\.", $"${(thisInvDisp / prodsFijosPiezas.Get(p))}"$) 'Separamos el resultado de la division por el punto decimal.
|
||||
t.Add(x(0).As(Int)) 'Solo guardamos la parte del entero de la division. (promos por inventario)
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green) 'promos por inventario
|
||||
If thisLog Then Log(">> Promos x Prods Fijos: " & x(0))
|
||||
Log(">>>>> Monto Bonificacion: " & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsFijos.Get(p), idProdsFijosPrecios.Get(p), pm.Get("id")))
|
||||
If thisLog Then LogColor(">> Max prods fijos x Bonificaciones: " & B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), idProdsFijosPrecios.Get(p), pm.Get("id")), Colors.blue)
|
||||
' If thisLog Then LogColor($" ### T: ${t}"$, Colors.Green) 'promos por inventario
|
||||
If thisLog Then LogColor($" >>>>> PROMOS X PRODS FIJOS (${idProdsFijos.Get(p)}): ${x(0)} <<<<<"$, Colors.red)
|
||||
Log($" >>>>> Monto Bonificacion FIJOS (${idProdsFijos.Get(p)}): "$ & B4XPages.MainPage.promos.ts.traeMontoBonificacion(idProdsFijos.Get(p), idProdsFijosPrecios.Get(p), pm.Get("id")))
|
||||
If thisLog Then LogColor(" >> MAX PRODS FIJOS X BONIFICACIONES: " & B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), idProdsFijosPrecios.Get(p), pm.Get("id")), Colors.blue)
|
||||
t.Add(B4XPages.MainPage.promos.ts.traeBonificacionesMaximas("bonificaciones", clienteActual, idProdsFijos.Get(p), prodsFijosPiezas.Get(p), idProdsFijosPrecios.Get(p), pm.Get("id"))) 'Agregamos las promos disponibles por Trade Spending
|
||||
If thisLog Then LogColor($"### T: ${t}"$, Colors.Green)
|
||||
If thisLog Then LogColor($" ### PROMOS X INV: ${t}"$, Colors.Green) 'promos por inventario
|
||||
Next
|
||||
t.Sort(True) 'Ordenamos la lista para que en el lugar 0 este el resultao mas pequeño.
|
||||
If thisLog Then LogColor($"prodsFijos=${idProdsFijos}"$, Colors.Blue)
|
||||
If thisLog Then LogColor($"prodsFijosPiezasReq=${prodsFijosPiezas}"$, Colors.Blue)
|
||||
' If thisLog Then LogColor($"invFijoXpromo=${invFijoXpromo}"$, Colors.Blue)
|
||||
If thisLog Then LogColor(">>>>>> T: " & t, Colors.red)
|
||||
If thisLog Then LogColor("Max promos x inv de prodsFijos = " & t.Get(0), Colors.red)
|
||||
If thisLog Then LogColor($" prodsFijos=${idProdsFijos}"$, Colors.Blue)
|
||||
If thisLog Then LogColor($" prodsFijosPiezasReq=${prodsFijosPiezas}"$, Colors.Blue)
|
||||
' If thisLog Then LogColor($" invFijoXpromo=${invFijoXpromo}"$, Colors.Blue)
|
||||
If thisLog Then LogColor(" >>>>>> T: " & t, Colors.Magenta)
|
||||
LogColor(" ***********************************************************************", Colors.red)
|
||||
LogColor($" ****** MAX PROMOS X INV DE PRODS FIJOS (${pm.get("id")}): "$ & t.Get(0) & " ******", Colors.red)
|
||||
LogColor(" ***********************************************************************", Colors.red)
|
||||
If thisLog Then LogColor($"============ TERMINA MAX PROMOS X PRODS FIJOS X INV ========"$, Colors.RGB(176,0,0))
|
||||
Return t.Get(0) 'Regresamos el resultado mas pequeño.
|
||||
End Sub
|
||||
|
||||
@@ -1436,7 +1452,7 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||
|
||||
' Log(pm.Get("prodsFijos").As(List).Size)
|
||||
' Log(maxPromosXFijos)
|
||||
|
||||
|
||||
For x = 1 To maxPromosXFijos
|
||||
If thisLog Then Log("==================== maxPromosXFijos "& x &" ========================")
|
||||
If thisLog Then Log("=====================================================")
|
||||
@@ -1459,7 +1475,7 @@ Sub revisaMaxPromosProdsVariablesPorInventario(pm As Map) As Int 'ignore
|
||||
totalProdsVariablesDisponibles = totalProdsVariablesDisponibles + invDispParaPromo.Get(idProdsVariables.Get(i))
|
||||
End If
|
||||
Next
|
||||
If thisLog Then Log($"prodsVariablesXPresupuestoBonificaciones: ${prodsVariablesXPresupuestoBonificaciones}"$)
|
||||
If thisLog Then Log($"1924: ${prodsVariablesXPresupuestoBonificaciones}"$)
|
||||
'Revisamos variables.
|
||||
If thisLog Then Log($"Var disponibles - var requeridos : ${totalProdsVariablesDisponibles} - ${prodsVariablesRequeridos*x}"$)
|
||||
totalProdsVariablesDisponibles = totalProdsVariablesDisponibles - (prodsVariablesRequeridos*x)
|
||||
@@ -1501,6 +1517,7 @@ Sub cuantosVariablesDisponiblesDB(promo As String)
|
||||
If c.GetString("CAT_GP_ALMACEN") <> Null Then x = c.GetString("CAT_GP_ALMACEN")
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
End If
|
||||
Return x
|
||||
End Sub
|
||||
@@ -2415,7 +2432,7 @@ Sub traeExistenciasPorId(id As String) As Int
|
||||
existencias = inv.GetString("CAT_GP_ALMACEN").As(Int)
|
||||
End If
|
||||
' Log("ex:" & existencias)
|
||||
Private inv As Cursor = Starter.skmt.ExecQuery($"Select ifnull(SUM(pe_cant),0) As total_vendido FROM pedido WHERE pe_tipo = 'VENTA' and pe_proid = '${id}'"$)
|
||||
inv = Starter.skmt.ExecQuery($"Select ifnull(SUM(pe_cant),0) As total_vendido FROM pedido WHERE pe_tipo = 'VENTA' and pe_proid = '${id}'"$)
|
||||
inv.Position = 0
|
||||
vendido = inv.GetInt("total_vendido")
|
||||
' Log("ven:" & vendido)
|
||||
@@ -2461,4 +2478,55 @@ Sub deshabilitaValidaciones
|
||||
' B4XPages.MainPage.principal.Resumen.Enabled = True
|
||||
' B4XPages.MainPage.principal.BUSCA.Enabled = True
|
||||
ToastMessageShow("REALIZADO", False)
|
||||
End Sub
|
||||
|
||||
' Recalcula en inventario actual, utiliza la tabla CAT_GUNAPROD5 que tiene el inventario INICIAL y le resta
|
||||
' lo que hay en PEDIDO, y actualiza CAT_GUNAPROD2 con el valor calculado.
|
||||
Public Sub RecalcularInventario
|
||||
Private inicial As Long = DateTime.Now
|
||||
' 1. Índices: ESTO ES CRUCIAL. Si no tienes estos índices, ningún query será rápido.
|
||||
' Ejecuta esto una sola vez al crear la BD o al iniciar la app, no en cada cálculo.
|
||||
' skmt.ExecNonQuery("CREATE INDEX IF NOT EXISTS idx_pedido_proid ON PEDIDO(PE_PROID)")
|
||||
' skmt.ExecNonQuery("CREATE INDEX IF NOT EXISTS idx_pedido_cliente ON PEDIDO(PE_CLIENTE)")
|
||||
' skmt.ExecNonQuery("CREATE INDEX IF NOT EXISTS idx_cat5_id ON CAT_GUNAPROD5(CAT_GP_ID)")
|
||||
|
||||
Starter.skmt.BeginTransaction
|
||||
Try
|
||||
' Lógica del Query:
|
||||
' 1. Toma el inventario inicial del día desde CAT_GUNAPROD5 (T5).
|
||||
' 2. Le resta SOLO las ventas reales de la tabla PEDIDO.
|
||||
' 3. FILTRA (Ignora) los RMIs usando PE_CEDIS <> 'DUR' y el nombre '%CAMBIO%'.
|
||||
' 4. Actualiza CAT_GUNAPROD2 masivamente.
|
||||
|
||||
Dim sql As String = _
|
||||
"UPDATE CAT_GUNAPROD2 " & _
|
||||
"SET CAT_GP_ALMACEN = ( " & _
|
||||
" SELECT (IFNULL(T5.CAT_GP_ALMACEN, 0) - IFNULL(Ventas.CantidadVendida, 0)) " & _
|
||||
" FROM CAT_GUNAPROD5 T5 " & _
|
||||
" LEFT JOIN ( " & _
|
||||
" SELECT PE_PROID, SUM(PE_CANT) AS CantidadVendida " & _
|
||||
" FROM PEDIDO " & _
|
||||
" WHERE PE_CLIENTE <> '0' " & _
|
||||
" AND PE_CEDIS <> 'DUR' " & _
|
||||
" AND PE_PRONOMBRE NOT LIKE '%CAMBIO%' " & _
|
||||
" GROUP BY PE_PROID " & _
|
||||
" ) Ventas ON T5.CAT_GP_ID = Ventas.PE_PROID " & _
|
||||
" WHERE T5.CAT_GP_ID = CAT_GUNAPROD2.CAT_GP_ID " & _
|
||||
") " & _
|
||||
"WHERE EXISTS ( " & _ '<-- ESTA ES LA CLAVE QUE EVITA LOS NULLS
|
||||
" SELECT 1 FROM CAT_GUNAPROD5 T5 " & _
|
||||
" WHERE T5.CAT_GP_ID = CAT_GUNAPROD2.CAT_GP_ID " & _
|
||||
")"
|
||||
|
||||
' Ejecutamos el cálculo masivo
|
||||
Starter.skmt.ExecNonQuery(sql)
|
||||
|
||||
Starter.skmt.TransactionSuccessful
|
||||
If Starter.Logger Then Log("Inventario Sincronizado (Excluyendo RMIs)")
|
||||
|
||||
Catch
|
||||
Log("Error al recalcular inventario: " & LastException)
|
||||
End Try
|
||||
Starter.skmt.EndTransaction
|
||||
LogColor(">>>>> Tiempo de RecalcularInventario: " & ((DateTime.Now - inicial)/1000), Colors.red)
|
||||
End Sub
|
||||
Reference in New Issue
Block a user