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 = ''; var Facturas = '';
var RNCAutocheck = true;
function FnSuma(t, txt, importe) { 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,46 +658,50 @@
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_', '');
Facturas = Facturas + (Importe == 0 ? '' : ', ') + $get("C_GvCxP_HplF_" + idd).innerText; let chk = $('#C_GvCxP_Chk_'+idd) //C_GvCxP_Chk_
let importeFactura = 0;
if(chk.is(':checked')){
Facturas = Facturas + (Importe == 0 ? '' : ', ') + $get("C_GvCxP_HplF_" + idd).innerText;
let importeFactura = 0;
if (cveMonedaPago == 0) { if (cveMonedaPago == 0) {
if (aplicaTC && $get('TxtTC') != null) { if (aplicaTC && $get('TxtTC') != null) {
importeFactura = parseFloat(FormatoNumero(parseFloat(textBoxes[i].value.split(',').join('')) * parseFloat($get('TxtTC').value), 2).split(',').join('')); importeFactura = parseFloat(FormatoNumero(parseFloat(textBoxes[i].value.split(',').join('')) * parseFloat($get('TxtTC').value), 2).split(',').join(''));
} else { } else {
importeFactura = parseFloat(textBoxes[i].value.split(',').join('')); importeFactura = parseFloat(textBoxes[i].value.split(',').join(''));
} }
} else { } else {
let cveMonedaCompra = textBoxes[i].getAttribute("cvemoneda"); let cveMonedaCompra = textBoxes[i].getAttribute("cvemoneda");
switch (cveMonedaPago) { switch (cveMonedaPago) {
case 1: //PAGO CON PESOS case 1: //PAGO CON PESOS
//SI SON DOLARES MULTIPLICAR POR TC
if (cveMonedaCompra == '2') {
importeFactura = parseFloat(FormatoNumero(parseFloat(textBoxes[i].value.split(',').join('')) * parseFloat($get('TxtTC').value), 2).split(',').join(''));
//MISMA MONEDA DEBE SOLO SUMAR
} else if (cveMonedaCompra == '1') {
importeFactura = parseFloat(textBoxes[i].value.split(',').join(''));
}
break;
case 2: //PAGO CON DOLARES
//SI SON DOLARES MULTIPLICAR POR TC
if (cveMonedaCompra == '2') {
importeFactura = parseFloat(FormatoNumero(parseFloat(textBoxes[i].value.split(',').join('')) * parseFloat($get('TxtTC').value), 2).split(',').join(''));
//MISMA MONEDA DEBE SOLO SUMAR //MISMA MONEDA DEBE SOLO SUMAR
} else if (cveMonedaCompra == '1') { if (cveMonedaCompra == '2') {
importeFactura = parseFloat(textBoxes[i].value.split(',').join('')); importeFactura = parseFloat(textBoxes[i].value.split(',').join(''));
} //SI SON PESOS DIVIDIR ENTRE EL TC
} else if (cveMonedaCompra == '1') {
break; importeFactura = parseFloat(FormatoNumero(parseFloat(textBoxes[i].value.split(',').join('')) / parseFloat($get('TxtTC').value), 2).split(',').join(''));
case 2: //PAGO CON DOLARES }
break;
//MISMA MONEDA DEBE SOLO SUMAR }
if (cveMonedaCompra == '2') {
importeFactura = parseFloat(textBoxes[i].value.split(',').join(''));
//SI SON PESOS DIVIDIR ENTRE EL TC
} else if (cveMonedaCompra == '1') {
importeFactura = parseFloat(FormatoNumero(parseFloat(textBoxes[i].value.split(',').join('')) / parseFloat($get('TxtTC').value), 2).split(',').join(''));
}
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 != '') {
chk.checked = true; if( RNCAutocheck){
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,62 +932,81 @@ Partial Class Bancos_ProveedoresAbonar
'INICIO Descuento Remision Nota de credito 'INICIO Descuento Remision Nota de credito
Dim descuentoParts As String() = gvr.FCTextBox("TxtDescuento").Text.Split("+"c) If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso UsuarioActual.Empresa.Funcionalidad(574) = "1" And ChkGeneraRNC.Checked Then
Dim Descuento As Decimal = 0 Dim descuentoParts As String() = gvr.FCTextBox("TxtDescuento").Text.Split("+"c)
Dim TotalTemp As Decimal = gvr.DataKey("Saldo").ToDecimal Dim Descuento As Decimal = 0
Dim TotalTemp As Decimal = gvr.DataKey("Saldo").ToDecimal
If descuentoParts.Length = 0 Then If descuentoParts.Length = 0 Then
Descuento = 0 Descuento = 0
Else Else
For i As Integer = 0 To descuentoParts.Length - 1
Dim descuentoPart As Decimal = descuentoParts(i).Trim().ToDecimal
If descuentoPart > 0 Then
Descuento = Descuento + ((TotalTemp - Descuento) * (descuentoPart / 100))
Else
Continue For
End If
Next
End If
If Descuento > 0 Then
Dim PorcentajeIVA As Decimal = gvr.DataKey("PorcentajeIVA").ToDecimal
Dim serieFolioArray As String() = gvr.DataKey("SerieFolio").ToString.Split("-"c)
Dim SerieRNC As String = ""
Dim FolioRNC As String = ""
Dim SerieFolioRNC As String = serieFolioArray(0)
If serieFolioArray.Length = 2 Then
SerieRNC = serieFolioArray(0)
FolioRNC = serieFolioArray(1)
SerieFolioRNC = $"{FolioRNC}-D-{SerieRNC = serieFolioArray(0)}"
For i As Integer = 0 To descuentoParts.Length - 1
Dim descuentoPart As Decimal = descuentoParts(i).Trim().ToDecimal
If descuentoPart > 0 Then
Descuento = Descuento + ((TotalTemp - Descuento) * (descuentoPart / 100))
Else Else
Continue For FolioRNC = serieFolioArray(0)
End If End If
Next
End If Descuento = Descuento.RoundSQL(2)
If PorcentajeIVA > 0 Then
If Descuento > 0 Then Descuento = ((Descuento) / (1 + PorcentajeIVA))
'Descuento = ((Descuento) / (1 + PorcentajeIVA)).RoundSQL(2)
Dim PorcentajeIVA As Decimal = gvr.DataKey("PorcentajeIVA").ToDecimal Dim saldo As Decimal = gvr.DataKey("Saldo").ToDecimal
Dim serieFolioArray As String() = gvr.DataKey("SerieFolio").ToString.Split("-"c) Dim abonado As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
Dim SerieRNC As String = "" Dim TotalRNC = Descuento + (Descuento * PorcentajeIVA).RoundSQL
Dim FolioRNC As String = "" Dim dif As Decimal = saldo - (TotalRNC + abonado)
Dim SerieFolioRNC As String = serieFolioArray(0) If dif.Abs() >= 0.01 Then
If serieFolioArray.Length = 2 Then If dif > 0 Then
SerieRNC = serieFolioArray(0) 'Descuento = Descuento + 0.01D
FolioRNC = serieFolioArray(1) End If
SerieFolioRNC = $"{FolioRNC}-D-{SerieRNC = serieFolioArray(0)}"
Else If dif < 0 Then
FolioRNC = serieFolioArray(0) 'Descuento = Descuento - 0.01D
End If End If
End If
Descuento = Descuento.RoundSQL(2) End If
If PorcentajeIVA > 0 Then
Descuento = (Descuento) / (1 + PorcentajeIVA)
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, 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)
If CveCompraRNC > 0 Then If CveCompraRNC > 0 Then
sbRNC.AppendLine($"<a class='Texto' href='../Compras/Compras.aspx?CveCompra={CveCompraRNC}' > {SerieFolioRNC}</a><br>") sbRNC.AppendLine($"<a class='Texto' href='../Compras/Compras.aspx?CveCompra={CveCompraRNC}' > {SerieFolioRNC}</a><br>")
Else Else
'TieneError = True 'TieneError = True
MsgError = $"Error al Generar Remisión de Nota de Crédito de factura {gvr.DataKey("SerieFolio").ToString}" MsgError = $"Error al Generar Remisión de Nota de Crédito de factura {gvr.DataKey("SerieFolio").ToString}"
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