- VERSION 5.04.01

- Se agregó la validacion de fechas de fin de promoción para Preventa y Venta.
- Se agregó que cuando se hace abordo (siguiente carga), los limites configurados para las promos (maxpromos, maxrec y maxxcliente) no se tomen en cuenta.
This commit is contained in:
2025-04-02 13:23:01 -06:00
parent 814bfb136c
commit 44c02757dc
6 changed files with 71 additions and 40 deletions

View File

@@ -858,6 +858,8 @@ Sub traePromo(promo As String, cliente As String) As Map
promoMap.Put("prodsFijosPiezas", prodsFijosPiezas)
promoMap.Put("prodsVariablesCant", prodsVariables.Size)
promoMap.Put("prodsVariablesPrecios", prodsVariablesPrecios)
promoMap.Put("vigencia", c.GetString("CAT_PA_VIGENCIA_FIN").SubString2(0, c.GetString("CAT_PA_VIGENCIA_FIN").IndexOf(" ")))
promoMap.Put("vigencia_abordo", c.GetString("CAT_PA_VIGENCIAABORDO").SubString2(0, c.GetString("CAT_PA_VIGENCIAABORDO").IndexOf(" ")))
promoMap.Put("resultado", "ok")
Else
promoMap.Put("resultado", "No hay datos de la promoción.")
@@ -980,11 +982,11 @@ Sub traeMaxPromos(pm As Map) As Int
' End If
If thisLog Then LogColor("==== HISTORICO:"&pm.Get("historico"), Colors.Red)
If thisLog Then Log(pm)
Log(maxPromos)
' Log(maxPromos)
If pm.Get("historico") = "1" Then maxPromos.Add(pm.Get("maxRecurrente")) 'Si hay historico, agregamos maxRecurrente
maxPromos.Add(pm.Get("maxPromos")) 'Agregamos maxPromos
maxPromos.Add(pm.Get("maxXcliente")) 'Agregamos maxXcliente
Log(maxPromos)
' Log(maxPromos)
If hccp.RowCount > 0 Then 'Agregamos promos HCCP
hccp.Position = 0
maxPromos.Add(hccp.GetString("HCCP_CANT"))
@@ -994,6 +996,7 @@ Sub traeMaxPromos(pm As Map) As Int
mp0 = maxPromos.Get(0)
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 Starter.tipov = "ABORDO" Then mp = 5000 ' Si es ABORDO (siguiente carga), se quitan los limites configurados
Return mp 'Regresamos el numero mas pequeño de las opciones.
End Sub
@@ -1019,11 +1022,13 @@ Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
If thisLog Then LogColor(pm, Colors.Blue)
' If thisLog Then LogColor("|" & pm.Get("maxPromos") & "|", Colors.Blue)
' Log("|"&revisaMaxPromosProdsFijosPorInventario(pm)&"|")
Private vigente As Boolean = revisaFechaVigenciaPromo(pm) ' Revisamos que la promo este vigente segun las fechas de preventa y venta
If revisaMaxPromosProdsFijosPorInventario(pm) < 1 Then pm.Put("resultado", 0)
Log($"resultado = ${pm.Get("resultado")}"$)
If pm.Get("resultado") = "ok" Then 'Si encontramos la promoción, entonces ...
Log($"Max promos de prodsFijos POR inventario = ${pm.Get("resultado")}"$)
If vigente And pm.Get("resultado") = "ok" Then 'Si encontramos la promoción, entonces ...
'Buscamos el máximo de promociones permitidas.
mp = traeMaxPromos(pm)
Log("########### " & Starter.tipov & "|" & mp & "|")
' If thisLog Then LogColor($"Promociones permitidas=${mp}"$, Colors.Blue)
' If thisLog Then Log("Promos vendidas: " & traePromosVendidas(idPromo, cliente))
If mp < 1 Then
@@ -1485,4 +1490,24 @@ Sub agregaColumna(tabla As String, columna As String, tipo As String) 'ignore
End Try
Log(2)
End Try
End Sub
'Regresa verdadero o falso dependiendo de la fecha de vigencia del tipo de venta.
Sub revisaFechaVigenciaPromo(pm As Map) As Boolean
Private vigente As Boolean = False
LogColor("Entramos a revisaFechaVigenciaPromo", Colors.red)
' Log("Fecha vigencia: " & pm.Get("vigencia"))
' Log("Fecha vigencia abordo: " & pm.Get("vigencia_abordo"))
' Log("Tipo venta: " & Starter.tipov)
DateTime.DateFormat = "yyyyMMdd"
If Starter.tipov = "PREVENTA" Or Starter.tipov = "ABORDO" Then
Private vigencia As String = pm.Get("vigencia").As(String).Replace("-", "")
If vigencia >= DateTime.Date(DateTime.Now) Then vigente = True
Else if Starter.tipov = "VENTA" Then
Private vigencia As String = pm.Get("vigencia_abordo").As(String).Replace("-", "")
If vigencia >= DateTime.Date(DateTime.Now) Then vigente = True
End If
' Log(Starter.tipov & "|" & vigencia & "|" & DateTime.Date(DateTime.Now))
LogColor("Promo vigente: " & vigente, Colors.red)
Return vigente
End Sub