diff --git a/Bancos/CuentasBancariasDetalle.aspx.vb b/Bancos/CuentasBancariasDetalle.aspx.vb index 5aee71c2e..ce0870a00 100644 --- a/Bancos/CuentasBancariasDetalle.aspx.vb +++ b/Bancos/CuentasBancariasDetalle.aspx.vb @@ -454,6 +454,7 @@ Partial Class Bancos_CuentasBancariasDetalle Row("CveCuenta") = DTUsuarios.Rows.Count + 1 Row("CveUsuario") = DdlUsuarios.SelectedValue.ToEntero Row("Nombre") = DdlUsuarios.SelectedItem.Text.ToString + Row("Usuario") = DdlUsuarios.SelectedItem.Text.ToString DTUsuarios.Rows.Add(Row) End If GVU.DataSource = DTUsuarios @@ -492,7 +493,8 @@ Partial Class Bancos_CuentasBancariasDetalle DTUsuarios = New DataTable DTUsuarios.Columns.Add("CveCuenta", GetType(Integer)) ' Consecutivo en este caso 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 Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVU.RowDeleting Dim ObjBancos As New ClsBancos diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index f0351a9a0..b307f28ef 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -8,6 +8,7 @@ Imports Microsoft.Reporting.WebForms Imports System.Globalization Imports System.Data.SqlTypes Imports DocumentFormat.OpenXml.Drawing.Diagrams +Imports Microsoft.AspNet.SignalR.Infrastructure Partial Class RH_Personal Inherits ClsPaginas @@ -1058,11 +1059,42 @@ Partial Class RH_Personal DVDdlTipoSangre.Visible = True End If + If Not CvePersonal > 0 Then + AsignaSiguienteCodigo() + End If + + End If AgregarEventosAsincronosGvVacaciones() End Sub + Private Sub AsignaSiguienteCodigo() + Dim ObjPersonal As New ClsRH() + If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then + Dim MaxCodigo As Integer = 1 + + If ObjPersonal.DtResultados.Rows.Count > 0 Then + MaxCodigo = ObjPersonal.DtResultados.AsEnumerable() _ + .Select(Function(row) + Dim codigoStr As String = row.Field(Of String)("Codigo") + If Not String.IsNullOrWhiteSpace(codigoStr) Then + Dim codigo As Integer + If Integer.TryParse(codigoStr, codigo) Then + Return codigo + End If + End If + Return 0 + End Function) _ + .DefaultIfEmpty(0) _ + .Max() + End If + + TxtCodigo.Text = (MaxCodigo + 1).ToString("000") + + End If + ObjPersonal.Dispose() + End Sub Private Sub LoadDefaultValues() DdlDepartamento.SelectedIndex = 1 diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 6b97372c0..1c5944b5a 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -3455,6 +3455,110 @@ Partial Class PV #End Region #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.
Cantidad: {Cantidad.FormatoNumero()}
Producto: '{PSCodigo}'
Precio: {PU.FormatoNumero()}
Descuento: {DescPS.FormatoNumero()}
Descuento por condiciones comerciales: {Descuento.FormatoNumero()}", TipoMensaje.MsgError) + End If + + Return Retorno + End Function + Protected Sub EmitirImprimirNew() If ValidaPagosContado() Then @@ -3469,6 +3573,36 @@ Partial Class PV Exit Sub 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 TmpDT.Rows.Count > 0 Then diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 4c2c82c2a..6b9e29f30 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -10591,7 +10591,7 @@ Partial Class Ventas End If '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() Dim ValidoDescuentos As Boolean = True @@ -11736,7 +11736,13 @@ Partial Class Ventas Else 'SI TIENE MODULO DE COBRANZA, NO MARDAR AL CLIENTE, DEBE SEGUIR REGISTRANDO If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then - Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga, TextoConfirmacion:="Seguir Registrando", ShowCloseButton:=False) + + If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") Then + Liga2 = $"document.location.href=""/Ventas/Ventas.aspx?CveVenta={ObjFactura.CveVenta}"";" + Alert(MensajeAlert.ToString(), TipoMensaje.MsgDosBotones, Liga, TextoConfirmacion:="Seguir Registrando", TextoSegundoBoton:="Ver cotización", JSBtn2:=Liga2, ShowCloseButton:=False) + Else + Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga, TextoConfirmacion:="Seguir Registrando", ShowCloseButton:=False) + End If Else Alert(MensajeAlert.ToString(), TipoMensaje.MsgDosBotones, Liga, TextoConfirmacion:="Seguir Registrando", TextoSegundoBoton:="Ir al Cliente", JSBtn2:=Liga2, ShowCloseButton:=False) End If