4to. Revisión Promociones
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Activities.Expressions
|
||||
Imports System.Data
|
||||
Imports DocumentFormat.OpenXml.Drawing.Diagrams
|
||||
Imports Extensiones
|
||||
@@ -59,7 +60,6 @@ Partial Class Ventas_Promociones
|
||||
|
||||
Private Property CvePromocionPadre As Integer
|
||||
Get
|
||||
|
||||
If ViewState("CvePromocionPadre") Is Nothing Then
|
||||
ViewState("CvePromocionPadre") = -1
|
||||
End If
|
||||
@@ -70,21 +70,115 @@ Partial Class Ventas_Promociones
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property PorMinMasCostoVentaFnc129 As Decimal
|
||||
Get
|
||||
|
||||
If ViewState("PorMinMasCostoVentaFnc129") Is Nothing Then
|
||||
ViewState("PorMinMasCostoVentaFnc129") = -1
|
||||
End If
|
||||
Return ViewState("PorMinMasCostoVentaFnc129").ToString.ToDecimal
|
||||
End Get
|
||||
Set(value As Decimal)
|
||||
ViewState("PorMinMasCostoVentaFnc129") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property DTPSUltimoCosto As DataTable
|
||||
Get
|
||||
If ViewState("DTPSUltimoCosto") Is Nothing Then
|
||||
ViewState("DTPSUltimoCosto") = New DataTable
|
||||
End If
|
||||
|
||||
Return CType(ViewState("DTPSUltimoCosto"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTPSUltimoCosto") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property PermisoAutorizPromocionPorcentaje As Boolean
|
||||
Get
|
||||
If ViewState("PermisoAutorizPromocionPorcentaje") Is Nothing Then
|
||||
ViewState("PermisoAutorizPromocionPorcentaje") = False
|
||||
End If
|
||||
Return Boolean.Parse(ViewState("PermisoAutorizPromocionPorcentaje").ToString)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("PermisoAutorizPromocionPorcentaje") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property BloqueadoPromocionPorcentaje As Boolean
|
||||
Get
|
||||
|
||||
If ViewState("BloqueadoPromocionPorcentaje") Is Nothing Then
|
||||
ViewState("BloqueadoPromocionPorcentaje") = False
|
||||
End If
|
||||
Return Boolean.Parse(ViewState("BloqueadoPromocionPorcentaje").ToString)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("BloqueadoPromocionPorcentaje") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property EmpresaFnc382 As Boolean
|
||||
Get
|
||||
|
||||
If ViewState("EmpresaFnc382") Is Nothing Then
|
||||
ViewState("EmpresaFnc382") = False
|
||||
End If
|
||||
Return Boolean.Parse(ViewState("EmpresaFnc382").ToString)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("EmpresaFnc382") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property EstatusOriginal As Boolean
|
||||
Get
|
||||
If ViewState("EstatusOriginal") Is Nothing Then
|
||||
ViewState("EstatusOriginal") = False
|
||||
End If
|
||||
Return Boolean.Parse(ViewState("EstatusOriginal").ToString)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("EstatusOriginal") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
|
||||
If Not Page.IsPostBack Then
|
||||
|
||||
PorMinMasCostoVentaFnc129 = UsuarioActual.Empresa.Funcionalidad(129).ToDecimal
|
||||
PermisoAutorizPromocionPorcentaje = UsuarioActual.TienePermisoProceso(386)
|
||||
|
||||
EmpresaFnc382 = If(UsuarioActual.Empresa.Funcionalidad(352) = "1", True, False) 'Grupo díaz
|
||||
'EmpresaFnc382 = True ''Para pruebas
|
||||
|
||||
CvePromocion = -1
|
||||
CargaValoresIniciales()
|
||||
CargaMonedas()
|
||||
CargaDTUltimoCosto()
|
||||
|
||||
If Request("CvePromocion") IsNot Nothing AndAlso Request("CvePromocion").ToString.ToEntero > 0 Then
|
||||
|
||||
CvePromocion = Request("CvePromocion").ToString.ToEntero
|
||||
CargaDatos()
|
||||
LnkAgrgarPlantillaPS.Visible = False
|
||||
|
||||
|
||||
|
||||
ValidaPromosiones(False)
|
||||
If EmpresaFnc382 AndAlso ChkEstatus.Checked = False AndAlso BloqueadoPromocionPorcentaje AndAlso Not PermisoAutorizPromocionPorcentaje Then
|
||||
ChkEstatus.Enabled = False
|
||||
End If
|
||||
|
||||
Else
|
||||
ChkEstatus.Enabled = True
|
||||
ChkEstatus.Checked = True
|
||||
@@ -219,6 +313,9 @@ Partial Class Ventas_Promociones
|
||||
|
||||
TempDT.Columns.Add("IncluyeImpuestos", GetType(Boolean))
|
||||
|
||||
TempDT.Columns.Add("UltimoCosto", GetType(Decimal))
|
||||
TempDT.Columns.Add("CostoPromedio", GetType(Decimal))
|
||||
|
||||
|
||||
TempDTOrigial = TempDT.Copy
|
||||
|
||||
@@ -244,6 +341,26 @@ Partial Class Ventas_Promociones
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDTUltimoCosto()
|
||||
|
||||
If Not EmpresaFnc382 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
DTPSUltimoCosto = New DataTable
|
||||
|
||||
Dim ObjInv As New ClsInventarios
|
||||
|
||||
If ObjInv.GetUltimoCosto(UsuarioActual.CveEmpresa) Then
|
||||
DTPSUltimoCosto = ObjInv.DtResultados
|
||||
End If
|
||||
|
||||
ObjInv.Dispose()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
#Region " PS "
|
||||
@@ -305,6 +422,7 @@ Partial Class Ventas_Promociones
|
||||
End If
|
||||
|
||||
ChkEstatus.Checked = If(Dr("Estatus").ToString = "True", True, False)
|
||||
EstatusOriginal = ChkEstatus.Checked
|
||||
DdlMoneda.SelectedValueExist(Dr("CveMoneda").ToString)
|
||||
DdlMarca.SelectedValueExist(Dr("CveMarca").ToString)
|
||||
DdlTipoAplicacion.SelectedValueExist(Dr("TipoAplicacion").ToString)
|
||||
@@ -356,6 +474,10 @@ Partial Class Ventas_Promociones
|
||||
ChangeDdlProducto()
|
||||
|
||||
LbPUActual.Text = ""
|
||||
LblCostoPromedio.Text = ""
|
||||
LblUltimoCosto.Text = ""
|
||||
|
||||
|
||||
DdlTipoPromocion.SelectedValue = "-1"
|
||||
TxtPromocionConcepto.Text = ""
|
||||
TxtCantMinima.Text = "1"
|
||||
@@ -423,6 +545,10 @@ Partial Class Ventas_Promociones
|
||||
Dr("CodigoPS") = If(String.IsNullOrEmpty(DdlPS.SelectedText), "Todos", DdlPS.SelectedText)
|
||||
Dr("PUAnterior") = LbPUActual.Text.ToDecimal
|
||||
|
||||
Dr("UltimoCosto") = LblUltimoCosto.Text.ToDecimal
|
||||
Dr("CostoPromedio") = LblCostoPromedio.Text.ToDecimal
|
||||
|
||||
|
||||
Dr("CveTipoPromocion") = DdlTipoPromocion.SelectedValue.ToEntero
|
||||
Dr("TipoPromocion") = DdlTipoPromocion.SelectedItem.Text
|
||||
Dr("Promocion") = TxtPromocionConcepto.Text
|
||||
@@ -478,7 +604,68 @@ Partial Class Ventas_Promociones
|
||||
|
||||
CargaGrid()
|
||||
RegistraScript("$('#DivAgregar').modal('hide')")
|
||||
|
||||
ValidaPromosiones(True)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub ValidaPromosiones(Bloquear As Boolean)
|
||||
|
||||
|
||||
If Not EmpresaFnc382 Then
|
||||
BloqueadoPromocionPorcentaje = False
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
If PorMinMasCostoVentaFnc129 > 0 Then
|
||||
|
||||
For Each dRow As DataRow In TempDT.Rows
|
||||
|
||||
Dim CvePS As Integer = dRow("CvePS").ToString.ToEntero
|
||||
Dim UltimoCosto As Decimal = dRow("UltimoCosto").ToString.ToDecimal
|
||||
Dim CveTipoPromocion As Integer = dRow("CveTipoPromocion").ToString.ToEntero ' 1 importe 2 % descuento
|
||||
Dim Promocion As Decimal = dRow("Promocion").ToString.ToDecimal
|
||||
|
||||
If UltimoCosto = 0 Then
|
||||
UltimoCosto = DTPSUltimoCosto.FiltroPrimeroValor("UltimoCosto", $"CvePS = {CvePS}").ToDecimal
|
||||
End If
|
||||
|
||||
If CvePS > 0 AndAlso UltimoCosto > 0 AndAlso CveTipoPromocion.Contiene(1, 2) Then
|
||||
|
||||
If CveTipoPromocion = 1 Then 'importe
|
||||
|
||||
'Sacamos el porcentaje
|
||||
Dim PorDescuento As Decimal = 100 - ((Promocion * 100) / UltimoCosto)
|
||||
|
||||
If PorDescuento > PorMinMasCostoVentaFnc129 Then
|
||||
BloqueadoPromocionPorcentaje = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
ElseIf CveTipoPromocion = 2 Then '% descuento
|
||||
If Promocion > PorMinMasCostoVentaFnc129 Then
|
||||
BloqueadoPromocionPorcentaje = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
|
||||
If BloqueadoPromocionPorcentaje AndAlso Bloquear Then
|
||||
ChkEstatus.Checked = False
|
||||
ChkEstatus.Enabled = False
|
||||
End If
|
||||
|
||||
UpGenerales.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub ChkRestricciones_CheckedChanged(sender As Object, e As EventArgs)
|
||||
DivRestricciones.Visible = ChkRestricciones.Checked
|
||||
End Sub
|
||||
@@ -509,6 +696,9 @@ Partial Class Ventas_Promociones
|
||||
End If
|
||||
|
||||
LbPUActual.Text = Gvr.DataKey("PUAnterior").FormatoNumero
|
||||
LblUltimoCosto.Text = Gvr.DataKey("UltimoCosto").FormatoNumero
|
||||
LblCostoPromedio.Text = Gvr.DataKey("CostoPromedio").FormatoNumero
|
||||
|
||||
DdlTipoPromocion.SelectedValue = Gvr.DataKey("CveTipoPromocion")
|
||||
'DdlTipoPromocion_SelectedIndexChanged(sender, Nothing)
|
||||
TxtPromocionConcepto.Text = Gvr.DataKey("Promocion").FormatoNumero(4)
|
||||
@@ -560,6 +750,9 @@ Partial Class Ventas_Promociones
|
||||
|
||||
|
||||
Private Sub GuardaPromocion()
|
||||
|
||||
ValidaPromosiones(True)
|
||||
|
||||
Dim CveCliente As Integer = If(DdlClientes.SelectedValue = "", -1, DdlClientes.SelectedValue.ToEntero)
|
||||
Dim ObjVentas As New ClsVentas
|
||||
Dim TieneError As Boolean = False
|
||||
@@ -847,6 +1040,15 @@ Partial Class Ventas_Promociones
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
If EmpresaFnc382 AndAlso EstatusOriginal = False AndAlso ChkEstatus.Checked And BloqueadoPromocionPorcentaje Then
|
||||
|
||||
Dim objGeneral As New ClsGenerales(ObjVentas.IniciaTransacSQL)
|
||||
If Not objGeneral.AddHistorialBitacora(360, -1, -1, -1, -1, -1, -1, -1, "Si Autoriza con bloqueo", "No", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", "", "", CvePromocion:=CvePromocion) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(563) <> "" Then
|
||||
|
||||
If Not ObjVentas.SincronizarPromocionesClonar(CvePromocion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 2) Then
|
||||
@@ -1198,4 +1400,16 @@ Partial Class Ventas_Promociones
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Protected Sub DdlPS_selectedindexchange(sender As Object, e As EventArgs)
|
||||
|
||||
|
||||
|
||||
LblUltimoCosto.Text = DTPSUltimoCosto.FiltroPrimeroValor("UltimoCosto", $"CvePS = {DdlPS.SelectedValue}").FormatoNumero
|
||||
LblCostoPromedio.Text = DTPSUltimoCosto.FiltroPrimeroValor("CostoPromedio", $"CvePS = {DdlPS.SelectedValue}").FormatoNumero
|
||||
|
||||
UpAgregar.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user