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

@@ -510,7 +510,7 @@ Partial Class Bancos_ProveedoresAbonar
e.Row.Cells(9).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
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.FCTextBox("TxtComision").Visible = False
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("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("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(" 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
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.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
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
e.Row.FCTextBox("TxtDescuento").Visible = False
@@ -932,62 +932,81 @@ Partial Class Bancos_ProveedoresAbonar
'INICIO Descuento Remision Nota de credito
Dim descuentoParts As String() = gvr.FCTextBox("TxtDescuento").Text.Split("+"c)
Dim Descuento As Decimal = 0
Dim TotalTemp As Decimal = gvr.DataKey("Saldo").ToDecimal
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 Descuento As Decimal = 0
Dim TotalTemp As Decimal = gvr.DataKey("Saldo").ToDecimal
If descuentoParts.Length = 0 Then
Descuento = 0
Else
If descuentoParts.Length = 0 Then
Descuento = 0
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
Continue For
FolioRNC = serieFolioArray(0)
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 serieFolioArray As String() = gvr.DataKey("SerieFolio").ToString.Split("-"c)
Dim SerieRNC As String = ""
Dim FolioRNC As String = ""
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)
Dim SerieFolioRNC As String = serieFolioArray(0)
If serieFolioArray.Length = 2 Then
SerieRNC = serieFolioArray(0)
FolioRNC = serieFolioArray(1)
SerieFolioRNC = $"{FolioRNC}-D-{SerieRNC = serieFolioArray(0)}"
If dif.Abs() >= 0.01 Then
If dif > 0 Then
'Descuento = Descuento + 0.01D
End If
Else
FolioRNC = serieFolioArray(0)
End If
If dif < 0 Then
'Descuento = Descuento - 0.01D
End If
End If
Descuento = Descuento.RoundSQL(2)
If PorcentajeIVA > 0 Then
Descuento = (Descuento) / (1 + PorcentajeIVA)
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,
$"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)
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,
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
'TieneError = True
MsgError = $"Error al Generar Remisión de Nota de Crédito de factura {gvr.DataKey("SerieFolio").ToString}"
Exit For
Else
'TieneError = True
MsgError = $"Error al Generar Remisión de Nota de Crédito de factura {gvr.DataKey("SerieFolio").ToString}"
Exit For
End If
End If
End If
'FIN Descuento Remision Nota de credito
@@ -1855,6 +1874,7 @@ Partial Class Bancos_ProveedoresAbonar
GvCxP.Columns(11).Visible = chkaplicaDescuento.Checked
TxtDescuenoMasivo.Visible = chkaplicaDescuento.Checked
ChkGeneraRNC.Visible = chkaplicaDescuento.Checked
UPCompras.Update()
End Sub
@@ -1986,12 +2006,14 @@ Partial Class Bancos_ProveedoresAbonar
Dim PS As String = PSRow("PSCodigo").ToString
Dim CveUM As Integer = PSRow("CveUnidadMedida").ToString.ToEntero
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
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
Pago.ImportePago = tImporteRNC
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
CveCompraRNC = CompraRNC.CveCompra
respuesta = Not AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta)
If Not respuesta Then
Dim error_ As Boolean = True
End If
Else
respuesta = False
End If