diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx
index 317269edc..cdad14650 100644
--- a/Ventas/Ventas.aspx
+++ b/Ventas/Ventas.aspx
@@ -775,7 +775,7 @@
-
+
@@ -1215,13 +1215,16 @@
-
+
-
+
-
-
-
-
-
- Código
-
-
-
-
-
- Nombre
-
-
-
-
-
- RFC
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ Código
+
+
+
+
+
+ Nombre
+
+
+
+
+
+ RFC
+
+
+
+
+
+
+
+
+
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index bb4823d88..77aa2d0ef 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -1396,6 +1396,15 @@ Partial Class Ventas
End Property
#End Region
+ Private Property ObjDescuentoGral As Modelos.VentaDescuentos
+ Get
+ Return If(IsNothing(ViewState("ObjDescuentoGral")), Nothing, CType(ViewState("ObjDescuentoGral"), Modelos.VentaDescuentos))
+ End Get
+ Set(value As Modelos.VentaDescuentos)
+ ViewState("ObjDescuentoGral") = value
+ End Set
+ End Property
+
#Region "Propiedades PuntoVenta"
Private Property CveCorte As Integer
@@ -7436,6 +7445,13 @@ Partial Class Ventas
DdlMetodoPago33.Enabled = True
DdlFormaPago33.Enabled = True
End If
+
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetPromocionesPS(-1, TxtFecha.Text.ToDateTime, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveCliente, DdlVendedor.SelectedValue.ToEntero(), 1, UsuarioActual.CveEmpresa) Then
+ DtPromociones = ObjVentas.DtResultados.Copy()
+ End If
+ ObjVentas.Dispose()
+
'If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then
' Using ObjVentas As New ClsVentas
' If ObjVentas.GetLineasAdicionales(-1, CveCliente, -1, -1, DdlMoneda.SelectedValue.ToEntero(), MinFecha, MaxFecha, 0, UsuarioActual.CveEmpresa) Then
@@ -9064,8 +9080,9 @@ Partial Class Ventas
End Sub
Protected Sub GvPS_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvPS.RowUpdating
'Dim TipoDescuento As Integer
+ Dim CvePSNuevo As Integer = GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedValue.ToEntero()
- Dim Cantidad, PU, CantidadInventario As Decimal
+ Dim Cantidad, PU As Decimal
Dim ObjDescuento As New Modelos.VentaDescuentos
Dim CuentaPredial As String
Cantidad = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDecimal
@@ -9101,234 +9118,17 @@ Partial Class Ventas
Exit Sub
End If
+ Dim DdlUM As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida")
+ Dim DdlCla As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlClasificacion")
+ Dim DdlSP As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto")
+
Dim CantidadOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Cantidad").ToDecimal()
Dim TotalOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Total").ToDecimal()
- Dim DatarowPS As DataRow = Nothing
- DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("") ' Estado = -1
+ Dim DrProducto = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePSNuevo).FiltroPrimero("")
- If UsuarioActual.Empresa.Funcionalidad(601) = "1" Then 'valida anticipo que tenga conceptos válidos
- If DdlTipoComprobante.SelectedValue = "Ant" Then
- Dim PSCodigoSAT As String = DatarowPS("SATClavePS").ToString
- If PSCodigoSAT <> "84111506" Then
- Alert($"El producto y/o servicio no es válido para generar anticipos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- End If
- End If
-
- Dim PrecioLibre As Boolean = False
- If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
- If DdlTipoComprobante.SelectedValue = "Cot" Then
- If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
- Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- End If
-
- PrecioLibre = CBool(DatarowPS("PrecioLibre"))
- End If
-
- 'verifica si tiene ventaminima
- If Cantidad > 0 AndAlso DatarowPS("VentaMinima").ToString().ToDecimal > 0 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA")) Then
- 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
- If Cantidad Mod DatarowPS("VentaMinima").ToString().ToDecimal <> 0 Then
- Alert(String.Format("El producto se vende solo en cantidades de {0}", DatarowPS("VentaMinima").ToString()))
- Exit Sub
- End If
- End If
-
- 'si es remisión, ingreso, anticipo debe de considerar el preciominimo
-
- If Not UsuarioActual.TienePermisoProceso(169) Then ' NO VALIDA EXISTENCIAS NI COSTO - PERMISO PARA NO VALIDAR
- Dim CvePS As Integer = DatarowPS("CvePS").ToString().ToEntero()
- Dim CveUM As Integer = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedValue.ToEntero() 'DatarowPS("CveUM").ToString().ToEntero()
- Dim CveTipoPS As Integer = DatarowPS("CveTipoPS").ToString().ToEntero()
-
- CantidadInventario = GvPS.Rows(e.RowIndex).DataKey("CantidadInventario").ToDecimal
- Dim CveUMInicial As Integer = GvPS.Rows(e.RowIndex).DataKey("CveUM").ToEntero
-
- Dim ValidaExistencia As Boolean = True
- If (CantidadInventario > 0) OrElse (Cantidad <= CantidadOriginal) Then 'si ya hay algo surtido, que no valide existencia
- ValidaExistencia = False
- End If
- If CveUM <> CveUMInicial Then ValidaExistencia = True
-
-
- 'SOLO VALIDA EXISTENCIAS Y COSTO: SI USA INVENTARIOS, SOLO PRODUCTOS TIPO PRODUCTO, SOLO REMISIONES E INGRESOS
- Dim ValidaExistenciasCosto As Boolean = UsuarioActual.Empresa.UsaInventarios AndAlso CveTipoPS = 2 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") Or (DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119)))
-
- 'VALIDA COSTO PARA LAS COTIZACIONES
- If Not ValidaExistenciasCosto Then
- If DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso (UsuarioActual.Empresa.Funcionalidad(382) = "1" OrElse UsuarioActual.CveEmpresa = 1) Then
- ValidaExistenciasCosto = True
- End If
- End If
-
- If ValidaExistenciasCosto Then
- Dim ObjInventarios As New ClsInventarios
- Dim Existencia As Decimal
- If ValidaExistencia Then
- Dim BuscarEnTabla As Boolean = If(UsuarioActual.Empresa.Funcionalidad(715) = "1", True, False)
- Existencia = ObjInventarios.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1, RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla)
- End If
- Dim Costo As Decimal
-
- If UsuarioActual.Empresa.Funcionalidad(602) = "UC" Then 'validación sobre el último costo
-
- If ObjInventarios.GetUltimoCosto(UsuarioActual.CveEmpresa, CvePS) Then
- Dim dr As DataRow = ObjInventarios.DtResultados.FiltroPrimero("")
- If dr IsNot Nothing Then
- Costo = dr("UltimoCosto").ToString.ToDecimal
- End If
- End If
- Else
- Costo = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -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 Costo <= 0 Then Costo = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1)
- End If
- ObjInventarios.Dispose()
- Dim PrecioMinimo As Decimal = 0
- 'RMF. condicion temporal, para reubicación, precio mínimo
- If UsuarioActual.CveEmpresa = 119 Then
- 'Dim CvePrecioLista As Integer = 38
- Dim objPS As New ClsProductosServicios
- If objPS.GetPSSucursalesALL(CvePS, UsuarioActual.CveEmpresa, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero()) Then
- PrecioMinimo = objPS.DtResultados.FiltroPrimeroValor("PrecioMinimo", "").ToDecimal
- 'If PrecioMinimo > 0 Then
- ' Costo = PrecioMinimo
- 'End If
- End If
- objPS.Dispose()
-
- End If
-
- If ValidaExistencia AndAlso DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False AndAlso Not RegistroxOC Then
- 'VALIDA EXISTENCIA
- If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 140, 153, 190, 192, 197, 189}) Then
- 'SI ES VENTA NUEVA TOMA EN CUENTA LO DEL TMPDT
- If CveVenta <= 0 Then
- If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then
- Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- Else
- If DdlTipoComprobante.SelectedValue = "Rem" Then
- Dim CantidadVenta As Double = 0
- Using ObjVentas As New ClsVentas
- If ObjVentas.GetVentaDetalle(CveVenta) Then
- CantidadVenta = ObjVentas.DtResultados.SUM("Cantidad", $"CvePS = {CvePS}")
- End If
- End Using
-
- 'SUMA LO YA RESTADO EN PENDIENTE POR SURTIR QUE PERTENESCA A LA VENTA.
- 'PARA QUE NO RESTE LA EXISTENCIA 2 VECES Y PUEDAS COMPARAR LO REAL
- If (Existencia + CantidadVenta) - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then
- Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- End If
-
- End If
-
- End If
- End If
-
- 'VALIDA COSTOS
- If Not CveContrato > 0 Then
-
- 'BANDERAS PARA VALIDACIONES
- Dim EsValido As Boolean = False
- Dim EsValidoMayor As Boolean = False
- Dim CostoMenor As Decimal = 0
- Dim CostoMayor As Decimal = 0
- Dim PorcentajeMinimoCostoEmpresa = UsuarioActual.Empresa.Funcionalidad(129).ToDecimal
-
- If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
- If DatarowPS IsNot Nothing Then
- If DatarowPS("PorcentajeMinimoUtilidad").ToString() <> "" AndAlso DatarowPS("PorcentajeMinimoUtilidad").ToString().ToDecimal() <> 0 Then
- PorcentajeMinimoCostoEmpresa = DatarowPS("PorcentajeMinimoUtilidad").ToString.ToDecimal
- End If
- End If
- End If
-
- 'PRECIO MINIMO
- If PorcentajeMinimoCostoEmpresa <> 0 AndAlso UsuarioActual.CveUsuario <> 1560 Then
- '' NOTA. si tiene preciominimo, debe de validarlos e ignorar el costo, pero se debe de considerar el TC, para el costo
- If PrecioMinimo > 0 Then
- 'SI EL PRECIO ES MAYOR AL COSTO, SI PASA
- If PU >= PrecioMinimo Then ' aqui se comparar los importes directos, sin el TC
- EsValido = True
- End If
- Else
- CostoMenor = Costo + ((PorcentajeMinimoCostoEmpresa / 100) * Costo)
- 'SI EL PRECIO ES MAYOR AL COSTO, SI PASA
- If PU * If(DdlMoneda.SelectedValue = "1", 1, TxtTipoCambio.Text.ToDecimal) >= CostoMenor Then
- EsValido = True
- End If
- End If
- Else
- EsValido = True
- End If
-
- 'PRECIO MAXIMO
- If UsuarioActual.Empresa.Funcionalidad(133).ToEntero() > 0 AndAlso UsuarioActual.CveUsuario <> 1560 Then
- CostoMayor = Costo + ((UsuarioActual.Empresa.Funcionalidad(133).ToDecimal / 100) * Costo)
- 'SI EL PRECIO ES MAYOR AL COSTO MAXIMO, SI PASA
- If PU * If(DdlMoneda.SelectedValue = "1", 1, TxtTipoCambio.Text.ToDecimal) <= CostoMayor Then
- EsValidoMayor = True
- End If
- Else
- EsValidoMayor = True
- End If
-
- ''VALIDA PROMOCION: SI TIENE PROMOCION Y EL PRECIO ES MENOR AL PRECIO DE PROMOCION, NO PASA | SI YA CUMPLE NO VUELVE A VALIDAR
- ''SIRVE PARA VALIDAR PRECIOS DEBAJO DEL PRECIO MINIMO PERMITIDO
- 'If Not EsValido Then
- ' If DtPromociones.FiltraParametros($"CvePS = {CvePS}").Rows.Count > 0 Then
- ' If PU * If(DdlMoneda.SelectedValue.ToEntero() = 1, 1, TxtTipoCambio.Text.ToDecimal) >= DtPromociones.FiltroPrimeroValor("PUPromocion", $"CvePS = {CvePS}").ToDecimal Then
- ' EsValido = True
- ' End If
- ' End If
- 'End If
-
- 'NO DEJA REGISTRAR MENOS AL PRECIO MINIMO
- Dim MensajeCosto As New StringBuilder
- Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
-
- If Not PrecioLibre Then
- If Not EsValido Then
- MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio menor de su Costo ", DatarowPS("CodigoPS").ToString())
- If TienePermisoImportes Then
- MensajeCosto.AppendFormat("El costo del producto es: ${0:#,###.00} ", Costo)
- MensajeCosto.AppendFormat("El rango menor aceptado es: {0:#,###.00}% ${1} ", PorcentajeMinimoCostoEmpresa, CostoMenor)
- MensajeCosto.AppendFormat("El precio indicado es: ${0:#,###.00} ({1}% de ganancia) ", PU.FormatoNumero, (If(Costo > 0, ((PU - Costo) * 100) / Costo, 0)).FormatoNumero)
- End If
-
- Alert(String.Format(MensajeCosto.ToString()), TipoMensaje.MsgAdvertencia)
- MensajeCosto.Clear()
- e.Cancel = True
- Exit Sub
- End If
-
- 'NO DEJA REGISTRAR MAS AL PRECIO MAXIMO
- If Not EsValidoMayor Then
- MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio mayor de su rango aceptado ", HdnPS.Value)
- If TienePermisoImportes Then
- MensajeCosto.AppendFormat("El costo del producto es: ${0:#,###.00} ", Costo)
- MensajeCosto.AppendFormat("El rango mayor aceptado es: {0}% ${1:#,###.00} ", UsuarioActual.Empresa.Funcionalidad(133).ToEntero(), CostoMayor)
- MensajeCosto.AppendFormat("El precio indicado es: ${0:#,###.00} ({1}% de ganancia) ", PU.FormatoNumero, (If(Costo > 0, ((PU - Costo) * 100) / Costo, 0)).FormatoNumero)
- End If
- Alert(MensajeCosto.ToString(), TipoMensaje.MsgAdvertencia)
- MensajeCosto.Clear()
- e.Cancel = True
- Exit Sub
- End If
- End If
-
-
- End If
- End If
+ If Not ValidaAgregarPS(Cantidad, CvePSNuevo, DdlUM.SelectedValue.ToEntero(), PU, DrProducto("CveTipoPS").ToString().ToEntero(), DdlCla.SelectedValue.ToEntero(), DdlSP.SelectedValue.ToEntero(), ObjDescuento) Then
+ Exit Sub
End If
If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ListaDescuentos IsNot Nothing AndAlso ObjDescuento IsNot Nothing Then
@@ -9343,8 +9143,6 @@ Partial Class Ventas
If TmpDT.Rows(e.RowIndex)("CvePS").ToString() <> GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedValue Then
'eliminar y cargar el ps ***
- Dim DdlUM As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida")
- Dim DdlCla As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlClasificacion")
If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then
ObjDescuento = CalcularDescuentos(GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedValue.ToEntero(), Cantidad, PU)
@@ -9355,27 +9153,6 @@ Partial Class Ventas
NumTurnos = GvPS.Rows(e.RowIndex).FCTextBox("TxtNumTurnosEditar").Text.ToDecimal()
End If
- DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedValue.ToEntero()).FiltroPrimero("") ' Estado = -1
-
- If UsuarioActual.Empresa.Funcionalidad(601) = "1" Then 'valida anticipo que tenga conceptos válidos
- If DdlTipoComprobante.SelectedValue = "Ant" Then
- Dim PSCodigoSAT As String = DatarowPS("SATClavePS").ToString
- If PSCodigoSAT <> "84111506" Then
- Alert($"El producto y/o servicio no es válido para generar anticipos.", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- End If
- End If
-
- If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
- If DdlTipoComprobante.SelectedValue = "Cot" Then
- If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
- Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
- End If
- End If
-
TmpDT.Rows.Remove(TmpDT.Rows(e.RowIndex))
CalculaUsados()
@@ -9420,8 +9197,7 @@ Partial Class Ventas
End If
Else
- Dim DrPS As DataRow = Nothing
- DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("")
+ Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("")
If Not ClienteDesglosaIEPS Then
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal)
@@ -10380,6 +10156,7 @@ Partial Class Ventas
EsValidoPU = False ' SI NO TIENE PROMOCION NO SE PUEDE VENDER A 0
End If
End If
+
'NO DEJA REGISTRAR CON VALIDACION DE COSTO ALMACEN O PROMOCION
Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
If Not EsValido Then
@@ -18606,6 +18383,21 @@ Partial Class Ventas
End If
End If
End If
+
+ End If
+
+ Me.ObjDescuentoGral = CalcularDescuentos(CvePSParametro, TxtCantidad.Text.Trim.ToDecimal, TxtPrecio.Text.ToDecimal())
+
+ If Me.ObjDescuentoGral IsNot Nothing Then
+
+ If ObjDescuentoGral.CvePromocionDetalle > 0 Then
+ TagPromocion.Visible = True
+ End If
+
+ If Me.ObjDescuentoGral.EsPUModificado Then
+ TxtPrecio.Text = Me.ObjDescuentoGral.PU.ToString()
+ End If
+
End If
If AgregarPSAutomaticamente Then
@@ -19240,6 +19032,12 @@ Partial Class Ventas
CargaListasPreciosSubProyectos(If(DdlPS.SelectedValue.ToEntero() <= 0, -1, DdlPS.SelectedValue.ToEntero()))
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetPromocionesPS(-1, TxtFecha.Text.ToDateTime, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveCliente, DdlVendedor.SelectedValue.ToEntero(), 1, UsuarioActual.CveEmpresa) Then
+ DtPromociones = ObjVentas.DtResultados.Copy()
+ End If
+ ObjVentas.Dispose()
+
UpDetalle.Update()
UpEmitirTransitorio.Update()
End Sub
@@ -19520,7 +19318,7 @@ Partial Class Ventas
Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbAgregar.Click
AgregarPS()
End Sub
- Private Function ValidaAgregarPS(CvePS As Integer, CveUM As Integer, PU As Double, CveTipoPS As Integer, Optional CantidadModal As Decimal = 0D, Optional PSValidarModal As String = "") As Boolean 'NO TOCAR - IPP
+ Private Function ValidaAgregarPS(Cantidad As Decimal, CvePS As Integer, CveUM As Integer, PU As Double, CveTipoPS As Integer, CveClasificacion As Integer, CveSubProyecto As Integer, ObjDescuento As Modelos.VentaDescuentos, Optional CantidadModal As Decimal = 0D, Optional PSValidarModal As String = "") As Boolean 'NO TOCAR - IPP
'VALIDA PARAMETROS
If CvePS <= 0 Or CveUM <= 0 Then
@@ -19532,19 +19330,19 @@ Partial Class Ventas
HdnPS.Value = PSValidarModal
End If
- If HdnPS.Value = "" Or HdnPS.Value = "-1" Then
- Alert("Es necesario seleccionar el Producto o Servicio a facturar.", TipoMensaje.MsgAdvertencia)
- Return False
- End If
+ 'If HdnPS.Value = "" Or HdnPS.Value = "-1" Then
+ ' Alert("Es necesario seleccionar el Producto o Servicio a facturar.", TipoMensaje.MsgAdvertencia)
+ ' Return False
+ 'End If
'SI USA CONTABILIDAD LA CLASIFICACION ES OBLIGATORIA
- If DdlClasificacion.SelectedValue.ToEntero() <= 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
+ If CveClasificacion <= 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
Alert("La Clasificación es obligatoria, favor de seleccionarla", TipoMensaje.MsgAdvertencia)
Return False
End If
'SUBPROYECTO OBLIGATORIO
- If DdlSubProyecto.SelectedValue.ToEntero() <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(120) = "1" Then
+ If CveSubProyecto <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(120) = "1" Then
Alert("El Subproyecto es obligatorio, favor de seleccionarlo", TipoMensaje.MsgAdvertencia)
Return False
End If
@@ -19556,8 +19354,6 @@ Partial Class Ventas
Dim PrecioLibre As Boolean = False
-
-
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
Dim DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DatarowPS IsNot Nothing Then
@@ -19588,18 +19384,20 @@ Partial Class Ventas
'SI NO VIENE DESDE EL MODAL
If CantidadModal = 0 Then
- If TxtCantidad.Text.ToDecimal() <= 0 Then
+ If Cantidad <= 0 Then
Alert("La cantidad debe ser mayor a cero", TipoMensaje.MsgAdvertencia)
Return False
End If
End If
'VALIDA PROMOCIONES
- Dim ObjVentas As New ClsVentas
- If ObjVentas.GetPromocionesPS(-1, TxtFecha.Text.ToDateTime, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveCliente, DdlVendedor.SelectedValue.ToEntero(), 1, UsuarioActual.CveEmpresa) Then
- DtPromociones = ObjVentas.DtResultados
- End If
- ObjVentas.Dispose()
+ 'If DtPromociones Is Nothing Then
+ ' Dim ObjVentas As New ClsVentas
+ ' If ObjVentas.GetPromocionesPS(-1, TxtFecha.Text.ToDateTime, CveSubProyecto, CveCliente, DdlVendedor.SelectedValue.ToEntero(), 1, UsuarioActual.CveEmpresa) Then
+ ' DtPromociones = ObjVentas.DtResultados.Copy()
+ ' End If
+ ' ObjVentas.Dispose()
+ 'End If
'VALIDA PRECIO CERO (0)
'If UsuarioActual.Empresa.Funcionalidad(139).ToString().ToEntero() > 0 And PU = 0 And DtPromociones.FiltroPrimeroValor("PUPromocion", $"CvePS = {CvePS}").ToDecimal > 0 Then
@@ -19645,9 +19443,9 @@ Partial Class Ventas
ObjInventarios.Dispose()
Else
Dim ObjInventarios As New ClsInventarios
- Costo = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1)
+ Costo = ObjInventarios.GetCostoPS(CvePS, Cantidad, -1, "-1", TxtFecha.Text.ToDate, CveSubProyecto, 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 Costo <= 0 Then Costo = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1)
+ If Costo <= 0 Then Costo = ObjInventarios.GetCostoPS(CvePS, Cantidad, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1)
ObjInventarios.Dispose()
End If
@@ -19656,7 +19454,7 @@ Partial Class Ventas
If UsuarioActual.CveEmpresa = 119 Then
'Dim CvePrecioLista As Integer = 38
Dim objPS As New ClsProductosServicios
- If objPS.GetPSSucursalesALL(CvePS, UsuarioActual.CveEmpresa, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero()) Then
+ If objPS.GetPSSucursalesALL(CvePS, UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyecto) Then
PrecioMinimo = objPS.DtResultados.FiltroPrimeroValor("PrecioMinimo", "").ToDecimal
End If
objPS.Dispose()
@@ -19685,14 +19483,14 @@ Partial Class Ventas
CveAlmacenConsulta = ddlAlmacen.SelectedValue.ToEntero()
End If
- Existencia = ObjInv2.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, CveAlmacenConsulta, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(),
+ Existencia = ObjInv2.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, CveAlmacenConsulta, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=CveSubProyecto,
CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1,
RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla)
End If
End Using
If CveVenta <= 0 OrElse Me.EsCreaApartirDe Then
- If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < (If(CantidadModal > 0, CantidadModal, TxtCantidad.Text.ToDouble)) Then
+ If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < (If(CantidadModal > 0, CantidadModal, Cantidad)) Then
Dim CveAlmacenConsulta As Integer = -1
Dim StrAlmacen As New StringBuilder
@@ -19718,7 +19516,7 @@ Partial Class Ventas
'SUMA LO YA RESTADO EN PENDIENTE POR SURTIR QUE PERTENESCA A LA VENTA.
'PARA QUE NO RESTE LA EXISTENCIA 2 VECES Y PUEDAS COMPARAR LO REAL
- If (Existencia + CantidadVenta) - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} And (EntregaDirecta Is NULL Or EntregaDirecta < 1)") < (If(CantidadModal > 0, CantidadModal, TxtCantidad.Text.ToDouble)) Then
+ If (Existencia + CantidadVenta) - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} And (EntregaDirecta Is NULL Or EntregaDirecta < 1)") < (If(CantidadModal > 0, CantidadModal, Cantidad)) Then
Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
Return False
End If
@@ -19728,8 +19526,21 @@ Partial Class Ventas
End If
End If
+ Dim VerificarCostos As Boolean = True
+ If ObjDescuento IsNot Nothing Then
+ If ObjDescuento.CvePromocionDetalle > 0 Then
+ VerificarCostos = False
+ End If
+ If ObjDescuento.ImporteDescuento > 0 Then
+ VerificarCostos = False
+ End If
+ If ObjDescuento.EsPUModificado Then
+ VerificarCostos = False
+ End If
+ End If
+
'VALIDA COSTOS
- If Not CveContrato > 0 Then
+ If Not CveContrato > 0 AndAlso VerificarCostos Then
'BANDERAS PARA VALIDACIONES
Dim EsValido As Boolean = False
@@ -19788,9 +19599,9 @@ Partial Class Ventas
Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
'valida sino tiene promocion la clasificacion
If DrPS IsNot Nothing Then
- If DtPromociones.FiltraParametros(String.Format("CveClasificacion = {0}", DdlClasificacion.SelectedValue.ToEntero())).Rows.Count > 0 Then
+ If DtPromociones.FiltraParametros(String.Format("CveClasificacion = {0}", CveClasificacion)).Rows.Count > 0 Then
''falta aplicar si tiene promocion
- Dim drPromo As DataRow = DtPromociones.FiltroPrimero(String.Format("CveClasificacion = {0}", DdlClasificacion.SelectedValue.ToEntero()))
+ Dim drPromo As DataRow = DtPromociones.FiltroPrimero(String.Format("CveClasificacion = {0}", CveClasificacion))
If drPromo IsNot Nothing Then
If drPromo("CveMarca").ToString() = DrPS("CveMarca").ToString() Then
@@ -19837,10 +19648,7 @@ Partial Class Ventas
End If
End If
-
-
Return True
-
End Function
Private Function CalcularDescuentos(CvePS As Integer, Cantidad As Decimal, PU As Decimal) As Modelos.VentaDescuentos
Dim Descuento As Decimal = HdnDescuento.Value.ToDecimal
@@ -20083,20 +19891,21 @@ Partial Class Ventas
CvePS = DdlPS.SelectedValue.ToEntero()
End If
- If ValidaAgregarPS(CvePS, DdlUnidadMedida.SelectedValue.ToEntero(), TxtPrecio.Text.Trim.ToDouble, HdnTipoPS.Value.ToEntero()) Then
+ Dim Cantidad As Decimal = TxtCantidad.Text.ToDecimal
+ Dim PU As Decimal = If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal)
+
+ Dim ObjDescuento As New Modelos.VentaDescuentos
+
+ If ObjDescuentoGral IsNot Nothing Then
+ ObjDescuento = ObjDescuentoGral
+ End If
+
+ If ValidaAgregarPS(Cantidad, CvePS, DdlUnidadMedida.SelectedValue.ToEntero(), PU, HdnTipoPS.Value.ToEntero(), DdlClasificacion.SelectedValue.ToEntero(), DdlSubProyecto.SelectedValue.ToEntero(), ObjDescuento) Then
If UsuarioActual.Empresa.Funcionalidad(507) = DdlPS.SelectedValue Then
CvePSAmortizacion = DdlPS.SelectedValue.ToEntero().ToEntero()
End If
- Dim Cantidad As Decimal = TxtCantidad.Text.ToDecimal
- Dim PU As Decimal = If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal)
-
- Dim ObjDescuento As Modelos.VentaDescuentos = CalcularDescuentos(CvePS, Cantidad, PU)
- If ObjDescuento.EsPUModificado Then
- PU = ObjDescuento.PU
- End If
-
Dim CvePrecioListaPS As Integer = -1
Dim PrecioListaPS As String = ""
@@ -20109,16 +19918,13 @@ Partial Class Ventas
Else
PrecioListaPS = DdlPrecioLista.SelectedItem.Text
End If
-
Else
-
Dim PermiteEdicion = UsuarioActual.CveEmpresa = 189 AndAlso TxtPrecio.Enabled
If Not PermiteEdicion Then
'sino es la seleccionada se recalcula de nuevo
CargaPrecioLista(DdlPS.SelectedValue.ToEntero)
Exit Sub
End If
-
End If
Else
If Me.CvePrecioLista > 0 Then
@@ -20377,6 +20183,7 @@ Partial Class Ventas
HdnPorcentajeIEPS.Value = "0"
HdnCodigo.Value = "-1"
TxtCuentaPredial.Text = ""
+ TagPromocion.Visible = False
' codigo comentado RMF. 2016.06.13, esto paa que respete el que tenga selecionado e nla sucursal
'DdlProyecto.SelectedIndex = 0
'DdlSubProyecto.Items.Clear()
@@ -20398,6 +20205,8 @@ Partial Class Ventas
TxtCodigoSerie.Text = ""
TxtTiempoEntrega.Text = ""
+ ObjDescuentoGral = Nothing
+
'FOCUS DEPENDIENDO MODALIDAD DE CODIGO BARRAS
If DIVCod.Visible Then
TxtCodigoBarras.Focus()
@@ -20818,6 +20627,7 @@ Partial Class Ventas
DrPoliza("SATClaveProdServ") = DrPSAdicional("SATClavePS")
DrPoliza("SATClaveUM") = DrPSAdicional("SATClaveUnidadMedida")
DrPoliza("CveActivoFijo") = -1
+ DrPoliza("CvePromocionDetalle") = -1
TmpDT.Rows.Add(DrPoliza)
End If
@@ -24337,7 +24147,7 @@ Partial Class Ventas
HdnIVARetAPS.Value = DrProducto("RetIVA").ToString()
HdnCodigo.Value = DrProducto("Codigo").ToString()
- If ValidaAgregarPS(DrProducto("CvePS").ToString().ToEntero(), DrProducto("CveUM").ToString().ToEntero(), TxtPrecio.Text.Trim.ToDouble, DrProducto("CveTipoPS").ToString().ToEntero()) Then
+ If ValidaAgregarPS(TxtCantidad.Text.ToDecimal(), DrProducto("CvePS").ToString().ToEntero(), DrProducto("CveUM").ToString().ToEntero(), TxtPrecio.Text.Trim.ToDouble, DrProducto("CveTipoPS").ToString().ToEntero(), DdlClasificacion.SelectedValue.ToEntero(), DdlSubProyectoDatos.SelectedValue.ToEntero(), Nothing) Then
If UsuarioActual.Empresa.Funcionalidad(507) = DdlPS.SelectedValue Then
CvePSAmortizacion = DdlPS.SelectedValue.ToEntero().ToEntero()
@@ -36425,6 +36235,12 @@ Partial Class Ventas
TFuenteRecaudacion.Visible = False
End If
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetPromocionesPS(-1, TxtFecha.Text.ToDateTime, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveCliente, DdlVendedor.SelectedValue.ToEntero(), 1, UsuarioActual.CveEmpresa) Then
+ DtPromociones = ObjVentas.DtResultados.Copy()
+ End If
+ ObjVentas.Dispose()
+
End Sub
Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, CveUsuarioCreo As Integer, Optional GetBytes As Boolean = True, Optional Regenerar As Boolean = False, Optional strURLHOST As String = "") As Byte()
@@ -39233,7 +39049,7 @@ Partial Class Ventas
Dim PU As Decimal = GvRow.FCTextBox("TxtPrecio").Text.ToDecimal
If Cantidad > 0 Then
- If Not ValidaAgregarPS(CvePS, CveUnidadMedida, PU, 2, Cantidad, CodigoPS) Then
+ If Not ValidaAgregarPS(0, CvePS, CveUnidadMedida, PU, 2, CveClasificacion, DdlSubProyectoDatos.SelectedValue.ToEntero(), Nothing, CantidadModal:=Cantidad, PSValidarModal:=CodigoPS) Then
Alert("No hay existencia.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
@@ -40200,5 +40016,23 @@ Partial Class Ventas
objV.Dispose()
End If
End Sub
+
+ Protected Sub DdlVendedor_SelectedIndexChanged(sender As Object, e As EventArgs)
+ 'RECARGAR PROMOCIONES
+ Dim ObjVentas As New ClsVentas
+ If ObjVentas.GetPromocionesPS(-1, TxtFecha.Text.ToDateTime, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveCliente, DdlVendedor.SelectedValue.ToEntero(), 1, UsuarioActual.CveEmpresa) Then
+ DtPromociones = ObjVentas.DtResultados.Copy()
+ End If
+ ObjVentas.Dispose()
+ End Sub
+
+ Protected Sub BtnCrearCliente_Click(sender As Object, e As EventArgs)
+ DivValidaRFC.Visible = True
+ DivValidaPorNombre.Visible = False
+ DivBusquedaCliente.Visible = False
+ TxtRFCCliente.Text = TxtRFCNombre.Text
+
+ BtnValidarRFC_Click(Nothing, EventArgs.Empty)
+ End Sub
End Class
|