diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index dbd45512d..acc5ca31d 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -5212,57 +5212,61 @@ Partial Class PV 'Alert("No se ha especificado producto a entregar") Exit Sub End If - - If DdlTipoUso.SelectedValue.ToEntero > 0 AndAlso DdlPSAjuste.SelectedValue.ToEntero > 0 AndAlso TxtMesesUso.Text <> "" AndAlso DdlPS.SelectedValue.ToEntero > 0 Then - Dim CveMarca As Integer = -1 - If GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).Rows.Count > 0 Then - CveMarca = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).Rows(0)("CveMarca").ToString.ToEntero - End If - Dim ObjAcum As New ClsAcumuladores - If ObjAcum.GarantiasMesesGet(-1, UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) Then - If ObjAcum.DtResultados.Rows.Count > 0 Then - TxtPorcentajeAjuste.Text = (ObjAcum.DtResultados.Rows(0)("Valor").ToString.ToDouble / 100).ToString - - TxtImporteAjuste.Text = (TxtPorcentajeAjuste.Text.ToDecimal * TxtPUFactura.Text.ToDecimal).FormatoNumero - - Dim CargoVendido As Decimal = 0 - Dim CargoGarantia As Decimal = 0 - Dim CveTamaño As Integer = 0 - - If DdlPSAjuste.SelectedValue.ToEntero > 0 Then - Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).Rows(0) - If Dr IsNot Nothing Then - CargoGarantia = Dr("Cargo").ToString.ToDecimal - End If - End If - - If DdlPS.SelectedValue.ToEntero > 0 Then - Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPS.SelectedValue.ToEntero).Rows(0) - If Dr IsNot Nothing Then - CveTamaño = Dr("CveTamaño").ToString.ToEntero - End If - End If - - If GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTamaño = {CveTamaño}").Rows(0) IsNot Nothing AndAlso GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTamaño = {CveTamaño}").Rows.Count > 0 Then - Dim DrCargo As DataRow = GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTamaño = {CveTamaño}").Rows(0) - If DrCargo IsNot Nothing Then - CargoVendido = DrCargo("Cargo").ToString.ToDecimal - End If - End If - - 'el ajuste no puede ser mayor al precio de lo vendido de nuevo - If (TxtPrecio.Text.ToDouble - ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia))) < 0 Then - - TxtImporteAjuste.Text = "0.00" - CargoGarantia = CargoVendido - End If - TxtImporteAjuste.ToolTip = $"La diferencia de ajuste fue: {(TxtPrecio.Text.ToDouble - TxtImporteAjuste.Text.ToDouble).FormatoNumero()}. La diferencia de tamaños fue: {(CargoVendido - CargoGarantia).FormatoNumero}." - TxtImporteAjuste.Text = ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia)).FormatoNumero - + Try + If DdlTipoUso.SelectedValue.ToEntero > 0 AndAlso DdlPSAjuste.SelectedValue.ToEntero > 0 AndAlso TxtMesesUso.Text <> "" AndAlso DdlPS.SelectedValue.ToEntero > 0 Then + Dim CveMarca As Integer = -1 + If GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).Rows.Count > 0 Then + CveMarca = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).Rows(0)("CveMarca").ToString.ToEntero End If + Dim ObjAcum As New ClsAcumuladores + If ObjAcum.GarantiasMesesGet(-1, UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) Then + If ObjAcum.DtResultados.Rows.Count > 0 Then + TxtPorcentajeAjuste.Text = (ObjAcum.DtResultados.Rows(0)("Valor").ToString.ToDouble / 100).ToString + + TxtImporteAjuste.Text = (TxtPorcentajeAjuste.Text.ToDecimal * TxtPUFactura.Text.ToDecimal).FormatoNumero + + Dim CargoVendido As Decimal = 0 + Dim CargoGarantia As Decimal = 0 + Dim CveTamaño As Integer = 0 + + If DdlPSAjuste.SelectedValue.ToEntero > 0 Then + Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).Rows(0) + If Dr IsNot Nothing Then + CargoGarantia = Dr("Cargo").ToString.ToDecimal + End If + End If + + If DdlPS.SelectedValue.ToEntero > 0 Then + Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPS.SelectedValue.ToEntero).Rows(0) + If Dr IsNot Nothing Then + CveTamaño = Dr("CveTamaño").ToString.ToEntero + End If + End If + + If GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTamaño = {CveTamaño}").Rows.Count > 0 Then + Dim DrCargo As DataRow = GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTamaño = {CveTamaño}").Rows(0) + If DrCargo IsNot Nothing Then + CargoVendido = DrCargo("Cargo").ToString.ToDecimal + End If + End If + + 'el ajuste no puede ser mayor al precio de lo vendido de nuevo + If (TxtPrecio.Text.ToDouble - ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia))) < 0 Then + + TxtImporteAjuste.Text = "0.00" + CargoGarantia = CargoVendido + End If + TxtImporteAjuste.ToolTip = $"La diferencia de ajuste fue: {(TxtPrecio.Text.ToDouble - TxtImporteAjuste.Text.ToDouble).FormatoNumero()}. La diferencia de tamaños fue: {(CargoVendido - CargoGarantia).FormatoNumero}." + TxtImporteAjuste.Text = ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia)).FormatoNumero + + End If + End If + ObjAcum.Dispose() End If - ObjAcum.Dispose() - End If + Catch ex As Exception + OnError("Ocurrió un error al recalcular el costo", ex) + End Try + UpAjuste.Update() End Sub