--validación de condiciones comerciales, en PV. cuando es distribuidor.
--al crear una nueva y agregar un usuario, marca error.
This commit is contained in:
@@ -454,6 +454,7 @@ Partial Class Bancos_CuentasBancariasDetalle
|
|||||||
Row("CveCuenta") = DTUsuarios.Rows.Count + 1
|
Row("CveCuenta") = DTUsuarios.Rows.Count + 1
|
||||||
Row("CveUsuario") = DdlUsuarios.SelectedValue.ToEntero
|
Row("CveUsuario") = DdlUsuarios.SelectedValue.ToEntero
|
||||||
Row("Nombre") = DdlUsuarios.SelectedItem.Text.ToString
|
Row("Nombre") = DdlUsuarios.SelectedItem.Text.ToString
|
||||||
|
Row("Usuario") = DdlUsuarios.SelectedItem.Text.ToString
|
||||||
DTUsuarios.Rows.Add(Row)
|
DTUsuarios.Rows.Add(Row)
|
||||||
End If
|
End If
|
||||||
GVU.DataSource = DTUsuarios
|
GVU.DataSource = DTUsuarios
|
||||||
@@ -493,6 +494,7 @@ Partial Class Bancos_CuentasBancariasDetalle
|
|||||||
DTUsuarios.Columns.Add("CveCuenta", GetType(Integer)) ' Consecutivo en este caso
|
DTUsuarios.Columns.Add("CveCuenta", GetType(Integer)) ' Consecutivo en este caso
|
||||||
DTUsuarios.Columns.Add("CveUsuario", GetType(Integer))
|
DTUsuarios.Columns.Add("CveUsuario", GetType(Integer))
|
||||||
DTUsuarios.Columns.Add("Nombre", GetType(String))
|
DTUsuarios.Columns.Add("Nombre", GetType(String))
|
||||||
|
DTUsuarios.Columns.Add("Usuario", GetType(String))
|
||||||
End Sub
|
End Sub
|
||||||
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVU.RowDeleting
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVU.RowDeleting
|
||||||
Dim ObjBancos As New ClsBancos
|
Dim ObjBancos As New ClsBancos
|
||||||
|
|||||||
@@ -3455,6 +3455,110 @@ Partial Class PV
|
|||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region "E M I T I R - F A C T U R A"
|
#Region "E M I T I R - F A C T U R A"
|
||||||
|
|
||||||
|
Public Function ValidaPorcentajeMarcas(CvePS As Integer, Cantidad As Decimal, PU As Decimal, DescPS As Decimal) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
|
||||||
|
Dim Descuento As Decimal = 0
|
||||||
|
|
||||||
|
Dim ValidaCondicionesComerciales As Boolean = True
|
||||||
|
|
||||||
|
Dim CveMarcaPS As Integer = -1
|
||||||
|
Dim CveClasifPS As Integer = -1
|
||||||
|
Dim CveRinTamañoPS As Integer = -1
|
||||||
|
Dim PSCodigo As String = ""
|
||||||
|
|
||||||
|
Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
||||||
|
If DrPS IsNot Nothing Then
|
||||||
|
|
||||||
|
CveMarcaPS = DrPS("CveMarca").ToString().ToEntero()
|
||||||
|
CveClasifPS = DrPS("CveClasificacion").ToString().ToEntero()
|
||||||
|
CveRinTamañoPS = DrPS("CveRinTamaño").ToString().ToEntero()
|
||||||
|
PSCodigo = DrPS("PSCodigo").ToString()
|
||||||
|
|
||||||
|
If CveClasifPS = 20636 Then
|
||||||
|
ValidaCondicionesComerciales = False
|
||||||
|
End If
|
||||||
|
|
||||||
|
'CAMBIO DE VIGENCIA NO SE APLICAN DESCUENTOS
|
||||||
|
If CveClasifPS = 20637 Then
|
||||||
|
Descuento = 0
|
||||||
|
Retorno = True
|
||||||
|
Return Retorno
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
If ValidaCondicionesComerciales Then
|
||||||
|
'VERIFICA SI APLICAN CONDICIONES COMERCIALES
|
||||||
|
If DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then
|
||||||
|
'VERIFICA SI EL PRODUCTO TIENE ESPECIFICADA UNA MARCA
|
||||||
|
If Not String.IsNullOrEmpty(DrPS("CveMarca").ToString()) AndAlso DrPS("CveMarca").ToString().ToEntero() > 0 Then
|
||||||
|
Dim RowPorcentaje As DataRow = DtPorcentajeMarcas.FiltroPrimero($"CveMarca={DrPS("CveMarca").ToString()}")
|
||||||
|
'REALIZA LOS DESCUENTOS DE ACUERDO AL PORCENTAJE POR MARCA
|
||||||
|
If RowPorcentaje IsNot Nothing Then
|
||||||
|
'(AHORA LOS DESCUENTOS SON ACUMULABLES)
|
||||||
|
'Descuento = 0
|
||||||
|
Dim PorcentajeProducto As Decimal = RowPorcentaje("PorcentajeProducto").ToString().ToDecimal() / 100D
|
||||||
|
Dim PorcentajeProducto2 As Decimal = RowPorcentaje("PorcentajeProducto2").ToString().ToDecimal() / 100D
|
||||||
|
Dim PorcentajeProducto3 As Decimal = RowPorcentaje("PorcentajeProducto3").ToString().ToDecimal() / 100D
|
||||||
|
|
||||||
|
Dim TotalInicial As Decimal = (Cantidad * (PU)) '- Descuento
|
||||||
|
Dim TotalFinal As Decimal = TotalInicial
|
||||||
|
'SI APLICA EL PRIMER DESCUENTO
|
||||||
|
If PorcentajeProducto > 0 Then
|
||||||
|
Dim Descuento1 As Decimal = (TotalInicial * PorcentajeProducto).RoundSQL(2)
|
||||||
|
Dim Total2 As Decimal = (TotalInicial - Descuento1)
|
||||||
|
|
||||||
|
'SI APLICA EL SEGUNDO DESCUENTO
|
||||||
|
If PorcentajeProducto2 > 0 Then
|
||||||
|
Dim Descuento2 As Decimal = (Total2 * PorcentajeProducto2).RoundSQL(2)
|
||||||
|
Dim Total3 As Decimal = (Total2 - Descuento2)
|
||||||
|
|
||||||
|
'SI APLICA EL TERCER DESCUENTO
|
||||||
|
If PorcentajeProducto3 > 0 Then
|
||||||
|
Dim Descuento3 As Decimal = (Total3 * PorcentajeProducto3).RoundSQL(2)
|
||||||
|
TotalFinal = Total3 - Descuento3
|
||||||
|
Else
|
||||||
|
TotalFinal = Total3
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TotalFinal = Total2
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TotalFinal = TotalInicial
|
||||||
|
End If
|
||||||
|
|
||||||
|
If PorcentajeProducto > 0 Then
|
||||||
|
Descuento += ((Cantidad * PU) - TotalFinal)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Descuento.RoundSQL(2) <> DescPS.RoundSQL(2) Then
|
||||||
|
Retorno = False
|
||||||
|
Else
|
||||||
|
Retorno = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
Retorno = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Retorno = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Retorno = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
Retorno = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Not Retorno Then
|
||||||
|
Alert($"No coinciden las condiciones comerciales con el descuento.<br/> Cantidad: {Cantidad.FormatoNumero()} <br/>Producto: <span style='font-weight: bold;'>'{PSCodigo}'</span><br/>Precio: {PU.FormatoNumero()} <br/>Descuento: <span style='color:red;'>{DescPS.FormatoNumero()}</span><br/> Descuento por condiciones comerciales: {Descuento.FormatoNumero()}", TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
Protected Sub EmitirImprimirNew()
|
Protected Sub EmitirImprimirNew()
|
||||||
|
|
||||||
If ValidaPagosContado() Then
|
If ValidaPagosContado() Then
|
||||||
@@ -3469,6 +3573,36 @@ Partial Class PV
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
'VALIDAR CONDICONES COMERCIALES
|
||||||
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot") AndAlso TrEsDistribuidor.Visible Then
|
||||||
|
CargaPorcentajeMarcas()
|
||||||
|
Dim ValidoDescuentos As Boolean = True
|
||||||
|
|
||||||
|
If DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then
|
||||||
|
For Each Row As DataRow In TmpDT.Rows
|
||||||
|
Dim CvePS As Integer = Row("CvePS").ToString().ToEntero()
|
||||||
|
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
|
||||||
|
Dim PU As Decimal = Row("PU").ToString().ToDecimal()
|
||||||
|
Dim Descuento As Decimal = Row("Descuento").ToString().ToDecimal()
|
||||||
|
|
||||||
|
Dim EsGarantia As Boolean = ObjFactura.EsGarantia OrElse Row("Obs").ToString().Contains("Descuento por garantía")
|
||||||
|
|
||||||
|
If Not EsGarantia Then
|
||||||
|
If Not ValidaPorcentajeMarcas(CvePS, Cantidad, PU, Descuento) Then
|
||||||
|
ValidoDescuentos = False
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Not ValidoDescuentos Then
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
If ObjFactura.CveCliente > 0 Then
|
If ObjFactura.CveCliente > 0 Then
|
||||||
If TmpDT.Rows.Count > 0 Then
|
If TmpDT.Rows.Count > 0 Then
|
||||||
|
|
||||||
|
|||||||
@@ -10591,7 +10591,7 @@ Partial Class Ventas
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
'VALIDAR CONDICONES COMERCIALES
|
'VALIDAR CONDICONES COMERCIALES
|
||||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot") Then
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot") AndAlso ClienteEsDistribuidor Then
|
||||||
CargaPorcentajeMarcas()
|
CargaPorcentajeMarcas()
|
||||||
Dim ValidoDescuentos As Boolean = True
|
Dim ValidoDescuentos As Boolean = True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user