Descuento definido por el porcentaje maximo autorizado

This commit is contained in:
2021-07-27 16:28:42 -07:00
parent e2578fd836
commit 71d8953cf7
2 changed files with 65 additions and 42 deletions

View File

@@ -1571,6 +1571,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<asp:HiddenField ID="HdnDescuento" runat="server" ClientIDMode="Static" Value="0" /> <asp:HiddenField ID="HdnDescuento" runat="server" ClientIDMode="Static" Value="0" />
<asp:HiddenField ID="HdnPorcentajeDescuentoMaximo" runat="server" ClientIDMode="Static" Value="0" />
<asp:HiddenField ID="HdnDescuentoGeneral" runat="server" ClientIDMode="Static" Value="-1" /> <asp:HiddenField ID="HdnDescuentoGeneral" runat="server" ClientIDMode="Static" Value="-1" />
<asp:HiddenField ID="HdnTipoDescuento" runat="server" ClientIDMode="Static" Value="-1" /> <asp:HiddenField ID="HdnTipoDescuento" runat="server" ClientIDMode="Static" Value="-1" />
<table> <table>
@@ -3344,6 +3345,15 @@
} }
var Descuento = parseFloat($get("TxtPorDescP").value); var Descuento = parseFloat($get("TxtPorDescP").value);
var PorcentajeDescuentoMaximo = parseFloat($get("HdnPorcentajeDescuentoMaximo").value);
if (PorcentajeDescuentoMaximo > 0 && Descuento > PorcentajeDescuentoMaximo) {
$get("TxtDescP").value = "0";
$get("TxtPorDescP").value = "0";
Descuento = 0;
alert("No puede exceder el descuento maximo autorizado.");
}
$get("LblPrecioFinal").innerText = formato_numero(Monto - ((Monto * Descuento) / 100), 2, '.', ','); $get("LblPrecioFinal").innerText = formato_numero(Monto - ((Monto * Descuento) / 100), 2, '.', ',');
$get("LblTotalPS").innerText = formato_numero(parseFloat($get("LblPrecioFinal").innerText.replace(",", "").replace(",", "")), 2, '.', ','); $get("LblTotalPS").innerText = formato_numero(parseFloat($get("LblPrecioFinal").innerText.replace(",", "").replace(",", "")), 2, '.', ',');
var Total = Monto - parseFloat($get("LblPrecioFinal").innerText.replace(",", "").replace(",", "")); var Total = Monto - parseFloat($get("LblPrecioFinal").innerText.replace(",", "").replace(",", ""));
@@ -3354,6 +3364,7 @@
if (TipoDescuento == 2) { if (TipoDescuento == 2) {
$get("LblDescuentos").innerText = formato_numero(Total, 2, '.', ','); $get("LblDescuentos").innerText = formato_numero(Total, 2, '.', ',');
} }
} }
else { else {
$get("LblPrecioFinal").innerText = "0.00"; $get("LblPrecioFinal").innerText = "0.00";
@@ -3383,6 +3394,17 @@
} }
var Descuento = parseFloat($get("TxtDescP").value); var Descuento = parseFloat($get("TxtDescP").value);
var PorcentajeDescuento = (Descuento * 100 / Monto)
var PorcentajeDescuentoMaximo = parseFloat($get("HdnPorcentajeDescuentoMaximo").value);
if (PorcentajeDescuentoMaximo > 0 && PorcentajeDescuento > PorcentajeDescuentoMaximo) {
$get("TxtDescP").value = "0";
$get("TxtPorDescP").value = "0";
Descuento = 0;
alert("No puede exceder el descuento maximo autorizado.");
}
$get("TxtPorDescP").value = formato_numero((Descuento * 100 / Monto), 2, '.', ','); $get("TxtPorDescP").value = formato_numero((Descuento * 100 / Monto), 2, '.', ',');
$get("LblPrecioFinal").innerText = formato_numero(Monto - Descuento, 2, '.', ','); $get("LblPrecioFinal").innerText = formato_numero(Monto - Descuento, 2, '.', ',');
$get("LblTotalPS").innerText = formato_numero(parseFloat($get("LblPrecioFinal").innerText.replace(",", "").replace(",", "")), 2, '.', ','); $get("LblTotalPS").innerText = formato_numero(parseFloat($get("LblPrecioFinal").innerText.replace(",", "").replace(",", "")), 2, '.', ',');

View File

@@ -1062,6 +1062,7 @@ Partial Class PV
ViewState("ClienteRetIVA") = 0 ViewState("ClienteRetIVA") = 0
ViewState("ClienteRetISR") = 0 ViewState("ClienteRetISR") = 0
ViewState("EnviarCorreoCliente") = False ViewState("EnviarCorreoCliente") = False
HdnPorcentajeDescuentoMaximo.Value = UsuarioActual.DescuentoAutorizado.ToString()
CveVentaDetalle = -1 CveVentaDetalle = -1
EstablecioFolio = False EstablecioFolio = False
EstatusCliente = False EstatusCliente = False
@@ -5102,52 +5103,52 @@ Partial Class PV
End Sub End Sub
Protected Sub BtnAplicarDescG_Click(sender As Object, e As System.EventArgs) Handles BtnAplicarDescG.Click Protected Sub BtnAplicarDescG_Click(sender As Object, e As System.EventArgs) Handles BtnAplicarDescG.Click
If HdnTipoDescuento.Value = "2" Then 'If HdnTipoDescuento.Value = "2" Then
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then ' If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then
Dim IVAPromedio As Double = Math.Round(TmpDT.SUM("IVA") / TmpDT.COUNT("Consec"), 2) ' Dim IVAPromedio As Double = Math.Round(TmpDT.SUM("IVA") / TmpDT.COUNT("Consec"), 2)
Dim IVA As Double = TmpDT.Rows(0)("IVA").ToString.ToDouble ' Dim IVA As Double = TmpDT.Rows(0)("IVA").ToString.ToDouble
If IVAPromedio <> IVA Then ' If IVAPromedio <> IVA Then
Alert("No se puede aplicar descuento general a la factura ya tiene conceptos con diferente tasa de IVA", TipoMensaje.MsgError) ' Alert("No se puede aplicar descuento general a la factura ya tiene conceptos con diferente tasa de IVA", TipoMensaje.MsgError)
Else ' Else
AplicarDescuentos() ' AplicarDescuentos()
'Dim Descuento As Double = HdnDescuento.Value.Trim.Replace(",", "").ToDouble ' 'Dim Descuento As Double = HdnDescuento.Value.Trim.Replace(",", "").ToDouble
CalculaTotalesVenta() ' CalculaTotalesVenta()
'LblDescuentos.Text = Descuento.FormatoNumero(2) ' 'LblDescuentos.Text = Descuento.FormatoNumero(2)
'TxtIVA.Text = ((TxtSubTotal.Text.Trim.Replace(",", "").ToDouble - Descuento - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble) * IVAPromedio).FormatoNumero(2) ' 'TxtIVA.Text = ((TxtSubTotal.Text.Trim.Replace(",", "").ToDouble - Descuento - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble) * IVAPromedio).FormatoNumero(2)
'HdnIVAOriginal.Value = TxtIVA.Text ' 'HdnIVAOriginal.Value = TxtIVA.Text
'CalculaTotales(True) ' 'CalculaTotales(True)
HdnTipoDescuento.Value = "-1" ' HdnTipoDescuento.Value = "-1"
HdnDescuento.Value = "0" ' HdnDescuento.Value = "0"
RegistraScript("BorraDescuentos();") ' RegistraScript("BorraDescuentos();")
End If ' End If
End If ' End If
UpPS.Update() ' UpPS.Update()
ElseIf HdnTipoDescuento.Value = "3" Then 'ElseIf HdnTipoDescuento.Value = "3" Then
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then ' If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then
Dim IVAPromedio As Double = Math.Round(TmpDT.SUM("IVA") / TmpDT.COUNT("Consec"), 2) ' Dim IVAPromedio As Double = Math.Round(TmpDT.SUM("IVA") / TmpDT.COUNT("Consec"), 2)
Dim IVA As Double = TmpDT.Rows(0)("IVA").ToString.ToDouble ' Dim IVA As Double = TmpDT.Rows(0)("IVA").ToString.ToDouble
If IVAPromedio <> IVA Then ' If IVAPromedio <> IVA Then
Alert("No se puede aplicar descuento general a la factura ya tiene conceptos con diferente tasa de IVA", TipoMensaje.MsgError) ' Alert("No se puede aplicar descuento general a la factura ya tiene conceptos con diferente tasa de IVA", TipoMensaje.MsgError)
Else ' Else
AplicarDescuentos() ' AplicarDescuentos()
'Dim Amortizacion As Decimal = HdnDescuento.Value.Trim.Replace(",", "").ToDecimal ' 'Dim Amortizacion As Decimal = HdnDescuento.Value.Trim.Replace(",", "").ToDecimal
'LblAmortizacion.Text = Amortizacion.FormatoNumero(2) ' 'LblAmortizacion.Text = Amortizacion.FormatoNumero(2)
'TxtIVA.Text = ((TxtSubTotal.Text.Trim.Replace(",", "").ToDouble - Amortizacion - LblDescuentos.Text.Trim.Replace(",", "").ToDouble) * IVAPromedio).FormatoNumero(2) ' 'TxtIVA.Text = ((TxtSubTotal.Text.Trim.Replace(",", "").ToDouble - Amortizacion - LblDescuentos.Text.Trim.Replace(",", "").ToDouble) * IVAPromedio).FormatoNumero(2)
'HdnIVAOriginal.Value = TxtIVA.Text ' 'HdnIVAOriginal.Value = TxtIVA.Text
'CalculaTotales(True) ' 'CalculaTotales(True)
CalculaTotalesVenta() ' CalculaTotalesVenta()
HdnTipoDescuento.Value = "-1" ' HdnTipoDescuento.Value = "-1"
HdnDescuento.Value = "0" ' HdnDescuento.Value = "0"
RegistraScript("BorraDescuentos();") ' RegistraScript("BorraDescuentos();")
End If ' End If
End If ' End If
UpPS.Update() ' UpPS.Update()
End If 'End If
RegistraScript("$('#ModalDescuento').modal('hide')", "hidemodal") RegistraScript("$('#ModalDescuento').modal('hide')", "hidemodal")
End Sub End Sub
@@ -6463,7 +6464,7 @@ Partial Class PV
Else Else
'TxtPUFactura.Enabled = True 'TxtPUFactura.Enabled = True
'TxtPUFactura.Text = "" 'TxtPUFactura.Text = ""
DdlPSAjuste.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, AplicaParaVenta:=1) DdlPSAjuste.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
End If End If
DdlPSAjuste.DataBind() DdlPSAjuste.DataBind()
' DdlPSAjuste.Items.Insert(0, New ListItem("Seleccione", "-1")) ' DdlPSAjuste.Items.Insert(0, New ListItem("Seleccione", "-1"))