From 295f1884fa6b7a38790c46291b219dfe6aa5e604 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 1 Mar 2024 16:14:23 -0700 Subject: [PATCH] Ferretera. Recalculo de precios, segun es credito o contado --- Ventas/CatPreciosLista.aspx | 7 ++++- Ventas/Ventas.aspx.vb | 62 ++++++++++++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/Ventas/CatPreciosLista.aspx b/Ventas/CatPreciosLista.aspx index 15b3eb16f..d694e50f9 100644 --- a/Ventas/CatPreciosLista.aspx +++ b/Ventas/CatPreciosLista.aspx @@ -30,11 +30,16 @@ - + + + + + + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index d3dfe6ad5..ed75d8147 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -12955,13 +12955,13 @@ Partial Class Ventas 'si el codigo objeto impuesto es 02 y no tiene desglose de impuestos por el descuento, debe asignar el valor 04 - Si objeto de impuesto y no causa impuesto If concepto.Impuestos.Count = 0 AndAlso concepto.ObjetoImpuesto = "02" AndAlso (concepto.Importe - concepto.Descuento + concepto.ImporteGravaIVAAdicional).RoundSQL(2) = 0.00D Then concepto.ObjetoImpuesto = "04" - ''se ajusta a un centavo, para que se pueda emitir con un centavo. - 'If UsuarioActual.CveEmpresa = 140 Then - ' concepto.ObjetoImpuesto = "02" - ' concepto.Descuento = concepto.Descuento - 0.01D - ' Obj.SubTotal = Obj.SubTotal + 0.01D - ' Obj.Total = Obj.Total + 0.01D - 'End If + 'se ajusta a un centavo, para que se pueda emitir con un centavo. + If UsuarioActual.CveEmpresa = 140 Then + concepto.ObjetoImpuesto = "02" + concepto.Descuento = concepto.Descuento - 0.01D + Obj.SubTotal = Obj.SubTotal + 0.01D + Obj.Total = Obj.Total + 0.01D + End If End If Timbre.Conceptos.Add(concepto) @@ -17341,6 +17341,15 @@ Partial Class Ventas Alert("No hay una lista de precios predeterminada", TipoMensaje.MsgAdvertencia) End If + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If RBLPago.SelectedValue = "1" Then + Dim CvePrecioListaCredito = GlobalDTPrecioListas(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "ISNULL(Credito,False) = True").ToEntero() + If CvePrecioListaCredito > 0 Then + CvePrecioListaPS = CvePrecioListaCredito + End If + End If + End If + If CvePrecioListaPS > 0 Then Dim ObjPS As New ClsProductosServicios If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then @@ -23256,6 +23265,9 @@ Partial Class Ventas End Sub Private Sub RBLPago_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLPago.SelectedIndexChanged LimpiaEscondeContado() + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + RecalculaPrecios() + End If End Sub Private Function ValidaPagosContado(Optional MostrarAlertas As Boolean = True, Optional TipoDoctoViejo As String = "") As Boolean Dim Retorno As Boolean = False @@ -37414,5 +37426,41 @@ Partial Class Ventas RegistraScript("MuestraAnticipos();", "AE") End Sub + + Private Sub RecalculaPrecios() + If TmpDT IsNot Nothing Then + For Each Row As DataRow In TmpDT.Rows + Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal() + Dim CveClasificacion As Integer = Row("CveClasificacion").ToString().ToEntero + Dim CvePS As Integer = Row("CvePS").ToString().ToEntero + + Dim ObjPrecioSugerido As Modelos.MPrecioSugerido = CalculaPrecioSugerido(CvePS, CveClasificacion) + If ObjPrecioSugerido.PrecioSugerido > 0 Then + Dim PU As Decimal = ObjPrecioSugerido.PrecioSugerido.RoundSQL(6) + + Dim ObjDescuento As Modelos.VentaDescuentos = CalcularDescuentos(CvePS, Cantidad, PU) + If ObjDescuento.EsPUModificado Then + PU = ObjDescuento.PU + End If + + Row("PU") = PU + + Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (ObjDescuento.ImporteDescuento)) + Dim TotalCalculableImpuestosIVA As Decimal = 0 + TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + Row("PorcentajeIEPS").ToString().ToDecimal) + + Row("ImporteIVA") = (Row("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales) + + Row("Descuento") = (ObjDescuento.ImporteDescuento).RoundSQL(NumeroDecimales) + Row("Total") = (Cantidad * PU) + Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales) + End If + Next + + Me.CalculaTotalesVenta() + End If + + End Sub + End Class