From 6332a2ba4f6fa83528a672892ed92a0613078ce2 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 10 Jun 2024 19:01:46 -0700 Subject: [PATCH] =?UTF-8?q?--Ventas.aspx.=20%=20de=20descuento=20limitado?= =?UTF-8?q?=20por=20clasificaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sistemas/UsuarioDetalle.aspx.vb | 4 ++++ Ventas/Ventas.aspx | 40 ++++++++++++++++++++------------- Ventas/Ventas.aspx.vb | 11 ++++++++- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index b8980a3bd..2ba7e488a 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -462,6 +462,10 @@ Partial Class Sistemas_UsuarioDetalle DivDatosAutorizacion.Visible = True End If + If UsuarioActual.Empresa.Funcionalidad(109).ToString = "1" Then + TrDescuentoAutorizado.Visible = True + End If + If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then TrCodigoAcceso.Visible = True End If diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 2c702be69..2a402319a 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -4409,6 +4409,7 @@ + @@ -10083,16 +10084,21 @@ function CalculaDescPS() { console.log("evento descuento"); + let ivaPor = parseFloat($get("HdnIVADescPS").value) ; + if ($get("TxtPorPS").value != "") { let PorcentajeDescuento = parseFloat($get("TxtPorPS").value); - if (PorcentajeDescuento < 0 || PorcentajeDescuento > 100) { - alert("No se puede aplicar ese porcentaje de descuento"); + let PorcentajeMaximoDescuento = parseFloat($get("HdnPorcentajeMaxDescPS").value); + + if (PorcentajeDescuento < 0 || PorcentajeDescuento > PorcentajeMaximoDescuento) { + alert("No se puede aplicar ese porcentaje de descuento. El porcentaje máximo permitido es del " + PorcentajeMaximoDescuento.toFixed(2) + "%."); $get("TxtPorPS").value = "0"; + $get("HdnDescPS").value = "0"; + LimpiarTotalDescPS(ivaPor); recalcularUtilidad(0); return; } - let ivaPor = parseFloat($get("HdnIVADescPS").value) ; - + let subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", "")); $get("LblDescPS").innerText = formato_numero(((subTotal * PorcentajeDescuento) / 100), 2, '.', ','); @@ -10111,20 +10117,24 @@ recalcularUtilidad(descuento) } else { - let subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", "")); - $get("LblIVADescPS").innerText = formato_numero((subTotal * ivaPor), 2, '.', ','); - let importeIVA =parseFloat($get("LblIVADescPS").innerText.replace(",", "").replace(",", "")); - let Total = (subTotal) + importeIVA; - - $get("LblTotalFinalDescPS").innerText = formato_numero(Total, 2, '.', ','); - $get("LblDescPS").innerText = "0.00"; - $get("LblUtilidadPorcentaje").innerText = "0.00"; - $get("HdnDescPS").innerText = "0.00"; + LimpiarTotalDescPS(ivaPor); recalcularUtilidad(0); } } + function LimpiarTotalDescPS(ivaPor){ + let subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", "")); + $get("LblIVADescPS").innerText = formato_numero((subTotal * ivaPor), 2, '.', ','); + let importeIVA =parseFloat($get("LblIVADescPS").innerText.replace(",", "").replace(",", "")); + let Total = (subTotal) + importeIVA; + + $get("LblTotalFinalDescPS").innerText = formato_numero(Total, 2, '.', ','); + $get("LblDescPS").innerText = "0.00"; + $get("LblUtilidadPorcentaje").innerText = "0.00"; + $get("HdnDescPS").innerText = "0.00"; + } + function recalcularUtilidad(descuento){ let totalCompra = parseFloat($get("HdnTotalCompra").value); if (totalCompra > 0) { @@ -10667,7 +10677,7 @@ var td; let idxHeader = 0; for (var key in item) { - if (idxHeader == 0 && '<%= UsuarioActual.Empresa.Funcionalidad(382) %>' == '1') { + if (idxHeader == 0 && '<%= "" %>' == '1') { tr.append(''); tr.append(''); tr.append(''); @@ -10685,7 +10695,7 @@ let idxColumn = 0; for (var key in item) { - if (idxColumn == 0 && '<%= UsuarioActual.Empresa.Funcionalidad(382) %>' == '1') { + if (idxColumn == 0 && '<%= "" %>' == '1') { let tdExistencia = ' select').select2('close');" + '"> '; tr.append(''); diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 09e217cda..b68ac498e 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -3228,7 +3228,7 @@ Partial Class Ventas ' End If 'End If - If UsuarioActual.Empresa.Funcionalidad(301) <> "" Then + If UsuarioActual.Empresa.Funcionalidad(301) = "1" Then TxtFecha.Enabled = True ImgFecha.Visible = True Else @@ -25024,6 +25024,15 @@ Partial Class Ventas LblIVADescPS.Text = GvRow.DataKey("ImporteIVA").FormatoNumero() HdnIVADescPS.Value = GvRow.DataKey("IVA").FormatoNumero() + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=GvRow.DataKey("CvePS").ToEntero()).FiltroPrimero("") + If DrPS IsNot Nothing Then + If DrPS("PorMaximoDescuento").ToString().ToDecimal() > 0 Then + HdnPorcentajeMaxDescPS.Value = DrPS("PorMaximoDescuento").ToString() + Else + HdnPorcentajeMaxDescPS.Value = UsuarioActual.DescuentoAutorizado.ToString() + End If + End If + Using ObjPS As New ClsProductosServicios Dim PrecioCompra = ObjPS.GetUltimoPrecioCompra(UsuarioActual.CveEmpresa, GvRow.DataKey("CvePS").ToEntero()) If PrecioCompra > 0 Then
SubTotal ' + tdExistencia + '