-- mejora en cambio de preciosugerido, en la carga por excel
This commit is contained in:
@@ -16800,84 +16800,14 @@ Partial Class Ventas
|
||||
End If
|
||||
|
||||
'SUGIERE PRECIO
|
||||
Dim PrecioSugerido = 0.0
|
||||
PrecioSugerido = drPS("Precio").ToString().ToDouble
|
||||
Dim PrecioSugerido As Decimal = 0
|
||||
Dim tPrecioSugerido As Decimal = 0
|
||||
tPrecioSugerido = drPS("Precio").ToString().ToDecimal
|
||||
PrecioSugerido = CalculaPrecioSugerido(CvePSParametro, drPS("CveClasificacion").ToString().ToEntero())
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(1) Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPorcentajeProductos(CveCliente) Then
|
||||
Dim PrecioAplicado = ObjPS.DtResultados.FiltraParametros($"CvePS = {CvePSParametro}").FiltroPrimeroValor("PrecioA").ToDouble
|
||||
If PrecioAplicado > 0 Then
|
||||
PrecioSugerido = PrecioAplicado
|
||||
End If
|
||||
End If
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(404).ToEntero > 0 Then 'cuando el valor es 10.- secuencia Cliente/Sucursal, 20 - sucursal/cliente
|
||||
Dim TipoPrecioLista As Integer = UsuarioActual.Empresa.Funcionalidad(404).ToEntero
|
||||
' si es 10. primero el cliente
|
||||
Dim CvePrecioListaPS As Integer
|
||||
Dim PorcentajePrecio As Double = 0
|
||||
|
||||
If TipoPrecioLista = 10 Then
|
||||
|
||||
CvePrecioListaPS = Me.CvePrecioListaCliente 'GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=CveCliente).FiltroPrimeroValor("CvePrecioLista").ToEntero()
|
||||
If CvePrecioListaPS <= 0 Then
|
||||
|
||||
CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero()
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero()
|
||||
If CvePrecioListaPS <= 0 Then
|
||||
|
||||
CvePrecioListaPS = Me.CvePrecioListaCliente 'GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=CveCliente).FiltroPrimeroValor("CvePrecioLista").ToEntero()
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If CvePrecioListaPS > 0 Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then
|
||||
PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDouble
|
||||
PorcentajePrecio = ObjPS.DtResultados.FiltroPrimeroValor("Porcentaje").ToDouble
|
||||
End If
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
|
||||
If PrecioSugerido = 0 Then
|
||||
Dim ObjInventarios As New ClsInventarios
|
||||
Dim CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1)
|
||||
'si el costo es cero, puede ser que no halla movimientos del producto, en esa sucursal. y se volverá a sacar sin especificar sucursal
|
||||
If CostoPS = 0 Then CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1)
|
||||
ObjInventarios.Dispose()
|
||||
If CostoPS > 0 And PorcentajePrecio > 0 Then
|
||||
PrecioSugerido = ((PorcentajePrecio / 100) + 1) * CostoPS
|
||||
End If
|
||||
End If
|
||||
CvePrecioLista = CvePrecioListaPS
|
||||
End If
|
||||
|
||||
|
||||
'Dim ObjClasificaciones As New ClsClasificaciones
|
||||
'If ObjClasificaciones.GetClasificaciones() Then
|
||||
' PrecioBaseCosto = ObjClasificaciones.DtResultados.FiltroPrimeroValor("PrecioBaseCosto", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveClasificacion = {drPS("CveClasificacion")}").ToDecimal
|
||||
'End If
|
||||
|
||||
If PrecioSugerido > 0 Then
|
||||
Dim PrecioBaseCosto As Decimal = 0
|
||||
PrecioBaseCosto = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=drPS("CveClasificacion").ToString().ToEntero()).FiltroPrimeroValor("PrecioBaseCosto", "").ToDecimal
|
||||
|
||||
If PrecioBaseCosto > 0 Then
|
||||
PrecioSugerido = PrecioSugerido * ((PrecioBaseCosto / 100) + 1)
|
||||
End If
|
||||
TxtPrecio.Text = PrecioSugerido.ToString("#,###.####") ' que muestre hasta los 4 digitos si lo requiere
|
||||
End If
|
||||
If PrecioSugerido <= 0 Then PrecioSugerido = tPrecioSugerido
|
||||
|
||||
TxtPrecio.Text = PrecioSugerido.ToString("#,###.####") ' que muestre hasta los 4 digitos si lo requiere
|
||||
|
||||
If IsNumeric(TxtCantidad.Text.Trim) Then
|
||||
LblTotalPS.Text = (TxtCantidad.Text.Trim.ToDouble * TxtPrecio.Text.ToDouble).ToString().FormatoNumero(2)
|
||||
@@ -16912,6 +16842,76 @@ Partial Class Ventas
|
||||
UpPS.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function CalculaPrecioSugerido(CvePSParametro As Integer, CveClasificacion As Integer) As Decimal
|
||||
Dim PrecioSugerido As Decimal = 0
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(1) Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPorcentajeProductos(CveCliente) Then
|
||||
Dim PrecioAplicado = ObjPS.DtResultados.FiltraParametros($"CvePS = {CvePSParametro}").FiltroPrimeroValor("PrecioA").ToDecimal
|
||||
If PrecioAplicado > 0 Then
|
||||
PrecioSugerido = PrecioAplicado
|
||||
End If
|
||||
End If
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(404).ToEntero > 0 Then 'cuando el valor es 10.- secuencia Cliente/Sucursal, 20 - sucursal/cliente
|
||||
Dim TipoPrecioLista As Integer = UsuarioActual.Empresa.Funcionalidad(404).ToEntero
|
||||
' si es 10. primero el cliente
|
||||
Dim CvePrecioListaPS As Integer
|
||||
Dim PorcentajePrecio As Decimal = 0
|
||||
|
||||
If TipoPrecioLista = 10 Then
|
||||
|
||||
CvePrecioListaPS = Me.CvePrecioListaCliente
|
||||
If CvePrecioListaPS <= 0 Then
|
||||
CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero()
|
||||
|
||||
End If
|
||||
Else
|
||||
CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero()
|
||||
If CvePrecioListaPS <= 0 Then
|
||||
CvePrecioListaPS = Me.CvePrecioListaCliente 'GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=CveCliente).FiltroPrimeroValor("CvePrecioLista").ToEntero()
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If CvePrecioListaPS > 0 Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then
|
||||
PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDecimal
|
||||
PorcentajePrecio = ObjPS.DtResultados.FiltroPrimeroValor("Porcentaje").ToDecimal
|
||||
End If
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
|
||||
If PrecioSugerido = 0 Then
|
||||
Dim ObjInventarios As New ClsInventarios
|
||||
Dim CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1)
|
||||
'si el costo es cero, puede ser que no halla movimientos del producto, en esa sucursal. y se volverá a sacar sin especificar sucursal
|
||||
If CostoPS = 0 Then CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1)
|
||||
ObjInventarios.Dispose()
|
||||
If CostoPS > 0 And PorcentajePrecio > 0 Then
|
||||
PrecioSugerido = ((PorcentajePrecio / 100) + 1) * CostoPS
|
||||
End If
|
||||
End If
|
||||
CvePrecioLista = CvePrecioListaPS
|
||||
End If
|
||||
|
||||
|
||||
If PrecioSugerido > 0 Then
|
||||
Dim PrecioBaseCosto As Decimal = 0
|
||||
PrecioBaseCosto = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion).FiltroPrimeroValor("PrecioBaseCosto", "").ToDecimal
|
||||
|
||||
If PrecioBaseCosto > 0 Then
|
||||
PrecioSugerido = PrecioSugerido * ((PrecioBaseCosto / 100) + 1)
|
||||
End If
|
||||
End If
|
||||
Return PrecioSugerido
|
||||
End Function
|
||||
Protected Sub DdlPS_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlPS.selectedindexchange
|
||||
DdlPSIndexChange(DdlPS.SelectedValue.ToEntero(), DdlPS)
|
||||
End Sub
|
||||
@@ -18127,15 +18127,6 @@ Partial Class Ventas
|
||||
Row("Orden") = ConsecutivoActual + 1
|
||||
End If
|
||||
|
||||
Row("Cantidad") = Cantidad
|
||||
Row("CveUM") = CveUM
|
||||
Row("UM") = UM
|
||||
Row("CveClasificacion") = CveClasificacion
|
||||
Row("Clasificacion") = Clasificacion
|
||||
Row("CvePS") = CvePS
|
||||
Row("Obs") = Obs
|
||||
|
||||
|
||||
Dim DrPS As DataRow = Nothing
|
||||
|
||||
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1
|
||||
@@ -18179,6 +18170,14 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
Row("Cantidad") = Cantidad
|
||||
Row("CveUM") = CveUM
|
||||
Row("UM") = DrPS("UnidadMedida")
|
||||
Row("CveClasificacion") = DrPS("CveClasificacion")
|
||||
Row("Clasificacion") = DrPS("Clasificacion")
|
||||
Row("CvePS") = CvePS
|
||||
Row("Obs") = Obs
|
||||
|
||||
'VERIFICA SI EN LA FACTURA PADRE SE DESGLOSO EL IEPS
|
||||
Dim FacturaDesglosoIEPS As Boolean = ((CveDevolucion > 0 AndAlso NuevaFactura = 1) AndAlso (Me.ObjFacturaNC IsNot Nothing AndAlso Not Me.ObjFacturaNC.VentaDesglosaIEPS))
|
||||
|
||||
@@ -24284,6 +24283,7 @@ Partial Class Ventas
|
||||
Dim Observaciones As String = Row("Observaciones").ToString().Trim.ToUpper
|
||||
Dim TiempoEntrega As String = Row("Tiempo Entrega").ToString()
|
||||
Dim CvePS As Integer = 0
|
||||
Dim CveClasificacion As Integer = 0
|
||||
Dim CveUM As Integer = 0
|
||||
Dim CodigoPS As Integer = 0
|
||||
Dim DrProyecto As DataRow
|
||||
@@ -24311,7 +24311,7 @@ Partial Class Ventas
|
||||
If ObjPS.CvePS > 0 Then
|
||||
CvePS = ObjPS.CvePS
|
||||
CveUM = ObjPS.CveUnidadMedida
|
||||
|
||||
CveClasificacion = ObjPS.CveClasificacion
|
||||
Else
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
@@ -24320,14 +24320,6 @@ Partial Class Ventas
|
||||
End If
|
||||
End Using
|
||||
|
||||
'Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c)
|
||||
'If StrArray.Length > 0 Then
|
||||
' If CBool(StrArray(0)) = True Then
|
||||
' CvePS = StrArray(1).ToEntero()
|
||||
' Else
|
||||
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
' End If
|
||||
'End If
|
||||
ElseIf CodigoBarras <> "" Then
|
||||
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
@@ -24335,7 +24327,7 @@ Partial Class Ventas
|
||||
If ObjPS.CvePS > 0 Then
|
||||
CvePS = ObjPS.CvePS
|
||||
CveUM = ObjPS.CveUnidadMedida
|
||||
|
||||
CveClasificacion = ObjPS.CveClasificacion
|
||||
Else
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
@@ -24343,14 +24335,7 @@ Partial Class Ventas
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
End Using
|
||||
'Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c)
|
||||
'If StrArray.Length > 0 Then
|
||||
' If CBool(StrArray(0)) = True Then
|
||||
' CvePS = StrArray(1).ToEntero()
|
||||
' Else
|
||||
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
' End If
|
||||
'End If
|
||||
|
||||
ElseIf ProductoServicio <> "" Then
|
||||
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
@@ -24358,6 +24343,7 @@ Partial Class Ventas
|
||||
If ObjPS.CvePS > 0 Then
|
||||
CvePS = ObjPS.CvePS
|
||||
CveUM = ObjPS.CveUnidadMedida
|
||||
CveClasificacion = ObjPS.CveClasificacion
|
||||
Else
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
@@ -24365,50 +24351,23 @@ Partial Class Ventas
|
||||
RowNoEncontrados = String.Format("{3} - No se encontró {0} en la fila {1}, columna {2}<\BR>(NoBD)", Codigo, NumRow, "Codigo", RowNoEncontrados)
|
||||
End If
|
||||
End Using
|
||||
'Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c)
|
||||
'If StrArray.Length > 0 Then
|
||||
' If CBool(StrArray(0)) = True Then
|
||||
' CvePS = StrArray(1).ToEntero()
|
||||
' Else
|
||||
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
||||
' End If
|
||||
'End If
|
||||
Else
|
||||
RowNoEncontrados &= "<\BR> - En la fila " & NumRow & " no se especificó código, código de barras ó descripción."
|
||||
End If
|
||||
|
||||
If CvePS > 0 Then
|
||||
'CveUM = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString().ToEntero()
|
||||
|
||||
If PrecioUnitario <= 0 Then
|
||||
PrecioUnitario = CalculaPrecioSugerido(CvePS, CveClasificacion)
|
||||
End If
|
||||
|
||||
AgregarProductoServicio(Cantidad, CveUM, UM, -1, "",
|
||||
CvePS, HdnPS.Value, Observaciones, PrecioUnitario, HdnDescuento.Value.ToDecimal,
|
||||
CveProyecto, Proyecto, CveSubProyecto, SubProyecto,
|
||||
TiempoEntrega:=TiempoEntrega)
|
||||
|
||||
|
||||
'If TmpDT IsNot Nothing Then
|
||||
' Dim dr As DataRow = TmpDT.NewRow
|
||||
' TxtCantidad.Text = Cantidad.ToString()
|
||||
' DdlPS.SelectedValue = CvePS.ToString()
|
||||
' DdlPS_SelectedIndexChanged(Nothing, Nothing)
|
||||
' DdlUnidadMedida.SelectedValueExist(CveUM.ToString())
|
||||
' TxtObsPS.Text = Observaciones
|
||||
' DdlProyecto.SelectedValue = CveProyecto.ToString()
|
||||
' DdlProyecto_SelectedIndexChanged(Nothing, Nothing)
|
||||
' DdlSubProyecto.SelectedValue = CveSubProyecto.ToString()
|
||||
' TxtPrecio.Text = PrecioUnitario.ToString()
|
||||
' TxtTiempoEntrega.Text = TiempoEntrega.ToString()
|
||||
' RegistraScript("Recalcula();")
|
||||
' LbAgregar_Click(Nothing, Nothing)
|
||||
' NumAgregados = NumAgregados + 1
|
||||
'End If
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
|
||||
|
||||
|
||||
CalculaTotalesVenta()
|
||||
|
||||
If RowNoEncontrados.Length > 0 Then
|
||||
|
||||
Reference in New Issue
Block a user