0 Descuentos por pronto pago en facturas de Admin, 0 BUG de ProveedoresAbonar descuento masivo

This commit is contained in:
rakcsle
2025-01-22 13:40:16 -07:00
parent 9d67927778
commit 19a1ccb248
2 changed files with 137 additions and 89 deletions

View File

@@ -345,6 +345,7 @@
<asp:CheckBox Text="Descuento" ID="chkaplicaDescuento" CssClass="md-checksd" runat="server" Checked="false" OnCheckedChanged="chkaplicaDescuento_CheckedChanged" AutoPostBack="true" Visible="false" /> <asp:CheckBox Text="Descuento" ID="chkaplicaDescuento" CssClass="md-checksd" runat="server" Checked="false" OnCheckedChanged="chkaplicaDescuento_CheckedChanged" AutoPostBack="true" Visible="false" />
<asp:TextBox runat="server" ID="TxtDescuenoMasivo" ClientIDMode="Static" onkeyup="DescuenoMasivo(this)" Visible="false" Width="60px"></asp:TextBox> <asp:TextBox runat="server" ID="TxtDescuenoMasivo" ClientIDMode="Static" onkeyup="DescuenoMasivo(this)" Visible="false" Width="60px"></asp:TextBox>
<ajax:FilteredTextBoxExtender runat="server" TargetControlID="TxtDescuenoMasivo" FilterType="Custom" ValidChars="1234567890+" /> <ajax:FilteredTextBoxExtender runat="server" TargetControlID="TxtDescuenoMasivo" FilterType="Custom" ValidChars="1234567890+" />
<asp:CheckBox Text="Generar Remisión" ID="ChkGeneraRNC" CssClass="md-checksd" runat="server" Checked="false" Visible="false" />
</td> </td>
</tr> </tr>
@@ -608,14 +609,27 @@
</asp:Content> </asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server"> <asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
var Facturas = '';
function FnSuma(t, txt, importe) { var Facturas = '';
var RNCAutocheck = true;
function FnSuma(t, txt, importe, idTxtDescuento) {
var chkPesosBancos = $get("ChkPagarPesos"); var chkPesosBancos = $get("ChkPagarPesos");
var chkDolaresBancos = $get("ChkPagarDolares"); var chkDolaresBancos = $get("ChkPagarDolares");
if (t.checked) { if (t.checked) {
txt.value = FormatoNumero(importe, 2); txt.value = FormatoNumero(importe, 2);
let txtDescuento = $("#" + idTxtDescuento)
if (typeof txtDescuento.val() === "string"){
let descuentoValue = $("#" + idTxtDescuento).val().trim();
if (descuentoValue.length > 0) {
calculaDescuentoEscalonado(importe, idTxtDescuento, txt, t, 'El Importe no debe de exceder el saldo',1);
}
}
} else { } else {
txt.value = ""; txt.value = "";
} }
@@ -644,7 +658,11 @@
if (textBoxes[i].id.indexOf('C_GvCxP_TxtAbonar') >= 0) { if (textBoxes[i].id.indexOf('C_GvCxP_TxtAbonar') >= 0) {
if (textBoxes[i].value != '') { if (textBoxes[i].value != '') {
idd = textBoxes[i].id.replace('C_GvCxP_TxtAbonar_', ''); idd = textBoxes[i].id.replace('C_GvCxP_TxtAbonar_', '');
let chk = $('#C_GvCxP_Chk_'+idd) //C_GvCxP_Chk_
if(chk.is(':checked')){
Facturas = Facturas + (Importe == 0 ? '' : ', ') + $get("C_GvCxP_HplF_" + idd).innerText; Facturas = Facturas + (Importe == 0 ? '' : ', ') + $get("C_GvCxP_HplF_" + idd).innerText;
let importeFactura = 0; let importeFactura = 0;
if (cveMonedaPago == 0) { if (cveMonedaPago == 0) {
@@ -679,11 +697,11 @@
} }
break; break;
} }
}
Importe = parseFloat(Importe) + importeFactura;
} }
Importe = parseFloat(Importe) + importeFactura;
} }
} }
if (textBoxes[i].id.indexOf('C_GvCxP_TxtComision') >= 0) { if (textBoxes[i].id.indexOf('C_GvCxP_TxtComision') >= 0) {
@@ -714,12 +732,14 @@
} }
function FnCambia(chk, txt, saldo, op, text, Tipo) { function FnCambia(chk, txt, saldo, op, text, Tipo) {
debugger;
var chkPesosBancos = $get("ChkPagarPesos"); var chkPesosBancos = $get("ChkPagarPesos");
var chkDolaresBancos = $get("ChkPagarDolares"); var chkDolaresBancos = $get("ChkPagarDolares");
if (op == 1) { if (op == 1) {
if (txt.value != '') { if (txt.value != '') {
if( RNCAutocheck){
chk.checked = true; chk.checked = true;
}
} else { } else {
chk.checked = false; chk.checked = false;
} }
@@ -831,7 +851,7 @@
var TipoCambioActual = 0.0; var TipoCambioActual = 0.0;
function CambiaTC(txt) { function CambiaTC(txt) {
debugger;
//let TipoCambioTxt = ToDouble(txt.value) //let TipoCambioTxt = ToDouble(txt.value)
//if (TipoCambioActual != TipoCambioTxt) { //if (TipoCambioActual != TipoCambioTxt) {
$get("BtnCambiaTipoMoneda").click(); $get("BtnCambiaTipoMoneda").click();
@@ -839,8 +859,8 @@
//} //}
} }
function calculaDescuentoEscalonado(saldo, TxtDescuento, TxtAbonar, chk, Text, Tipo) { function calculaDescuentoEscalonado(saldo, idTxtDescuento, TxtAbonar, chk, Text, Tipo) {
let idTxtDescuento = TxtDescuento.id; //let idTxtDescuento = TxtDescuento.id;
let idTxtAbonar = TxtAbonar.id; let idTxtAbonar = TxtAbonar.id;
let descuentoValue = $("#" + idTxtDescuento).val().trim(); let descuentoValue = $("#" + idTxtDescuento).val().trim();
@@ -870,6 +890,8 @@
function DescuenoMasivo(txt) { function DescuenoMasivo(txt) {
RNCAutocheck = false;
$(".selDescuento").val(txt.value); $(".selDescuento").val(txt.value);
$(".selDescuento").trigger("keyup"); $(".selDescuento").trigger("keyup");
} }

View File

@@ -510,7 +510,7 @@ Partial Class Bancos_ProveedoresAbonar
e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Right
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"))) e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format(" RNCAutocheck = true; FnSuma(this,{0},{1},'{2}');", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCTextBox("TxtDescuento").ClientID))
If FiltrarCuentas = 1 AndAlso e.Row.RowIndex = 0 Then If FiltrarCuentas = 1 AndAlso e.Row.RowIndex = 0 Then
e.Row.FCHyperLink("HplF").Text = (CType(GvCxP.DataSource, DataTable).Rows.Count - 1).ToString e.Row.FCHyperLink("HplF").Text = (CType(GvCxP.DataSource, DataTable).Rows.Count - 1).ToString
@@ -522,8 +522,8 @@ Partial Class Bancos_ProveedoresAbonar
e.Row.FCCheckBox("Chk").Visible = False e.Row.FCCheckBox("Chk").Visible = False
e.Row.FCTextBox("TxtComision").Visible = False e.Row.FCTextBox("TxtComision").Visible = False
Else Else
e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,'{2}',1);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo")) e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format(" RNCAutocheck = true; FnCambia({0},this,{1},1,'{2}',1);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo"))
e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},2,'{2}',2);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo")) e.Row.FCTextBox("TxtComision").Attributes.Add("onblur", String.Format(" RNCAutocheck = true;FnCambia({0},this,{1},2,'{2}',2);", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo"))
End If End If
If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(7).ForeColor = Drawing.Color.Red If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(7).ForeColor = Drawing.Color.Red
@@ -586,7 +586,7 @@ Partial Class Bancos_ProveedoresAbonar
e.Row.FCLiteral("LtlAux").Text = String.Format("<a Class=""Texto thickbox"" href=""/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=370&width=900"" />Ir</a>", e.Row.DBCampo("CveProveedor"), e.Row.DBCampo("CveCompra")) e.Row.FCLiteral("LtlAux").Text = String.Format("<a Class=""Texto thickbox"" href=""/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxPProveedor&CveProveedor={0}&CveCompra={1}&TB_iframe=true&height=370&width=900"" />Ir</a>", e.Row.DBCampo("CveProveedor"), e.Row.DBCampo("CveCompra"))
e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format("FnCambia({0},this,{1},1,'{2}',1);{3}", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo", FiltroInv)) e.Row.FCTextBox("TxtAbonar").Attributes.Add("onblur", String.Format(" RNCAutocheck = true; FnCambia({0},this,{1},1,'{2}',1);{3}", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), "El Importe no debe de exceder el saldo", FiltroInv))
@@ -623,7 +623,7 @@ Partial Class Bancos_ProveedoresAbonar
e.Row.FCCheckBox("Chk").Enabled = False e.Row.FCCheckBox("Chk").Enabled = False
End If End If
e.Row.FCTextBox("TxtDescuento").Attributes.Add("onkeyup", $"calculaDescuentoEscalonado({e.Row.DBCampo("Saldo")},{e.Row.FCTextBox("TxtDescuento").ClientID},{e.Row.FCTextBox("TxtAbonar").ClientID},{e.Row.FCCheckBox("Chk").ClientID},'El Importe no debe de exceder el saldo',1)") e.Row.FCTextBox("TxtDescuento").Attributes.Add("onkeyup", $" calculaDescuentoEscalonado({e.Row.DBCampo("Saldo")},'{e.Row.FCTextBox("TxtDescuento").ClientID}',{e.Row.FCTextBox("TxtAbonar").ClientID},{e.Row.FCCheckBox("Chk").ClientID},'El Importe no debe de exceder el saldo',1)")
Else Else
e.Row.FCTextBox("TxtDescuento").Visible = False e.Row.FCTextBox("TxtDescuento").Visible = False
@@ -932,6 +932,7 @@ Partial Class Bancos_ProveedoresAbonar
'INICIO Descuento Remision Nota de credito 'INICIO Descuento Remision Nota de credito
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(574) = "1" And ChkGeneraRNC.Checked Then
Dim descuentoParts As String() = gvr.FCTextBox("TxtDescuento").Text.Split("+"c) Dim descuentoParts As String() = gvr.FCTextBox("TxtDescuento").Text.Split("+"c)
Dim Descuento As Decimal = 0 Dim Descuento As Decimal = 0
Dim TotalTemp As Decimal = gvr.DataKey("Saldo").ToDecimal Dim TotalTemp As Decimal = gvr.DataKey("Saldo").ToDecimal
@@ -970,10 +971,28 @@ Partial Class Bancos_ProveedoresAbonar
Descuento = Descuento.RoundSQL(2) Descuento = Descuento.RoundSQL(2)
If PorcentajeIVA > 0 Then If PorcentajeIVA > 0 Then
Descuento = (Descuento) / (1 + PorcentajeIVA)
Descuento = ((Descuento) / (1 + PorcentajeIVA))
'Descuento = ((Descuento) / (1 + PorcentajeIVA)).RoundSQL(2)
Dim saldo As Decimal = gvr.DataKey("Saldo").ToDecimal
Dim abonado As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
Dim TotalRNC = Descuento + (Descuento * PorcentajeIVA).RoundSQL
Dim dif As Decimal = saldo - (TotalRNC + abonado)
If dif.Abs() >= 0.01 Then
If dif > 0 Then
'Descuento = Descuento + 0.01D
End If End If
Dim CveCompraRNC As Integer = GeneraRNC(Descuento.RoundSQL(2), ObjComp.IniciaTransacSQL, gvr.DataKey("CveCompra").ToEntero, CompraActual, ObjMov, CvePrePoliza, CveProveedor, HplProveedor.Text, TxtFechaDocumento.Text.ToDate, If dif < 0 Then
'Descuento = Descuento - 0.01D
End If
End If
End If
Dim CveCompraRNC As Integer = GeneraRNC(Descuento, ObjComp.IniciaTransacSQL, gvr.DataKey("CveCompra").ToEntero, CompraActual, ObjMov, CvePrePoliza, CveProveedor, HplProveedor.Text, TxtFechaDocumento.Text.ToDate,
$"Remisión Nota de Crédito pago {gvr.DataKey("SerieFolio").ToString}", gvr.DataKey("CveMoneda").ToEntero, TxtTC.Text.ToDecimal, SerieRNC, FolioRNC, PorcentajeIVA:=PorcentajeIVA, $"Remisión Nota de Crédito pago {gvr.DataKey("SerieFolio").ToString}", gvr.DataKey("CveMoneda").ToEntero, TxtTC.Text.ToDecimal, SerieRNC, FolioRNC, PorcentajeIVA:=PorcentajeIVA,
CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero) CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero)
@@ -987,7 +1006,7 @@ Partial Class Bancos_ProveedoresAbonar
Exit For Exit For
End If End If
End If End If
End If
'FIN Descuento Remision Nota de credito 'FIN Descuento Remision Nota de credito
@@ -1855,6 +1874,7 @@ Partial Class Bancos_ProveedoresAbonar
GvCxP.Columns(11).Visible = chkaplicaDescuento.Checked GvCxP.Columns(11).Visible = chkaplicaDescuento.Checked
TxtDescuenoMasivo.Visible = chkaplicaDescuento.Checked TxtDescuenoMasivo.Visible = chkaplicaDescuento.Checked
ChkGeneraRNC.Visible = chkaplicaDescuento.Checked
UPCompras.Update() UPCompras.Update()
End Sub End Sub
@@ -1986,12 +2006,14 @@ Partial Class Bancos_ProveedoresAbonar
Dim PS As String = PSRow("PSCodigo").ToString Dim PS As String = PSRow("PSCodigo").ToString
Dim CveUM As Integer = PSRow("CveUnidadMedida").ToString.ToEntero Dim CveUM As Integer = PSRow("CveUnidadMedida").ToString.ToEntero
Dim UM As String = PSRow("UnidadMedida").ToString Dim UM As String = PSRow("UnidadMedida").ToString
Dim IVARNC As Decimal = (ImporteRNC * PorcentajeIVA)
CompraRNC.ConfiguraRegistroRapido(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNC, IVARNC, (ImporteRNC + IVARNC), PorcentajeIVA) Dim IVARNC As Decimal = (ImporteRNC * PorcentajeIVA).RoundSQL(2)
Dim TotalRNC As Decimal = (ImporteRNC + IVARNC).RoundSQL(2)
CompraRNC.ConfiguraRegistroRapido(CvePS_RNC, CveUM, UM, CveClasificacion, Clasificacion, PS, CveSubProyectoPrincipal, SubProyecto, ImporteRNC.RoundSQL(2), IVARNC, TotalRNC, PorcentajeIVA)
If CompraRNC.AddCompra(sqltransaccion) Then If CompraRNC.AddCompra(sqltransaccion) Then
Dim tImporteRNC = ImporteRNC + IVARNC ' le agrego el importe del iva Dim tImporteRNC = (ImporteRNC + IVARNC).RoundSQL(2) ' le agrego el importe del iva
Dim Pago As New CompraPago Dim Pago As New CompraPago
Pago.ImportePago = tImporteRNC Pago.ImportePago = tImporteRNC
Pago.CveMonedaPago = CompraActual.CveMoneda Pago.CveMonedaPago = CompraActual.CveMoneda
@@ -2003,6 +2025,10 @@ Partial Class Bancos_ProveedoresAbonar
Pago.Fecha = CompraActual.Fecha 'toma la misma fecha de la provisión en el pago de NC Pago.Fecha = CompraActual.Fecha 'toma la misma fecha de la provisión en el pago de NC
CveCompraRNC = CompraRNC.CveCompra CveCompraRNC = CompraRNC.CveCompra
respuesta = Not AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta) respuesta = Not AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta)
If Not respuesta Then
Dim error_ As Boolean = True
End If
Else Else
respuesta = False respuesta = False
End If End If