diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 0c7e15e77..2ef2ff065 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -5272,35 +5272,30 @@ -
- <%-- <%-- - - - - - - - - - - - --%> - +
-
- +
+
+
+ + +
+
+
+ <%--
+
+
--%>
-
+
@@ -5308,7 +5303,7 @@

- +
@@ -5328,12 +5323,23 @@
-
- - - - +
+
+
+ + + + +
+
+
+
+ + +
+
+
@@ -7016,17 +7022,17 @@ function SetDisabledTxtTotal(valor) { DisabledTxtTotal = valor; $('#<%= TxtTotal.ClientID %>').prop('readonly', DisabledTxtTotal); - } + } - function loadpage() { - $('.AjustaT').each(function () { - AjustaTotales($(this)); - }) - $('.AjustaT').change(function () { - AjustaTotales($(this)); - }); + function loadpage() { + $('.AjustaT').each(function () { + AjustaTotales($(this)); + }) + $('.AjustaT').change(function () { + AjustaTotales($(this)); + }); - $('#<%= TxtTotal.ClientID %>').prop('readonly', DisabledTxtTotal); + $('#<%= TxtTotal.ClientID %>').prop('readonly', DisabledTxtTotal); } @@ -7050,9 +7056,9 @@ $get(Row).style.backgroundColor = "#82b6db"; $get(Obj).focus(); var total = parseFloat($('#<%= HplSaldoAuxiliar.ClientID%>').text().replace(',', '')); - $get(Obj).value = 0; - var suma = 0; - $('#<%= GVAnticipos.ClientID%> input[type="text"]').each(function (index) { + $get(Obj).value = 0; + var suma = 0; + $('#<%= GVAnticipos.ClientID%> input[type="text"]').each(function (index) { var currentsaldo = parseFloat($(this).val()) if (isNaN(currentsaldo)) { currentsaldo = 0 } suma = currentsaldo + suma; @@ -7068,7 +7074,7 @@ $get(Obj).value = ""; $get(Row).style.backgroundColor = "#ffffff"; } - //if ($("input:checkbox:not(:checked)")) + //if ($("input:checkbox:not(:checked)")) SetText2($get("LblTotalAnticipos"), formato_numero($get("HdnAnticipos").value, 2, '.', ',')); } function imprimircotizacion() { @@ -7346,6 +7352,8 @@ } $('.DdlPS').on("select2:open", function (e) { $('.select2-container.select2-container--default .select2-dropdown .select2anothertable').remove(); }); + $('.DdlPSPyME').on("select2:open", function (e) { $('.select2-container.select2-container--default .select2-dropdown .select2anothertable').remove(); }); + $("body").on("mouseenter", ".select2-container.select2-container--default.select2-container--open .select2-dropdown li", function (event) { var $this = $(this); var ind = $this.index(); diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 92e6bd6e0..71c5d88eb 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2446,7 +2446,7 @@ Partial Class Ventas End If - If UsuarioActual.Empresa.CvePlataforma = 2 Then + If UsuarioActual.Empresa.CvePlataforma = 2 OrElse UsuarioActual.CveRol = 1 Then ImgOtrosConceptos.Visible = False TrFormaEntrega.Visible = False TabDetalleVentas.Visible = False @@ -2461,6 +2461,9 @@ Partial Class Ventas Next LnkAddVenta.Visible = True divproyectos.Visible = False + + DivAddClasificacionPyME.Visible = False + DivAddUMPyME.Visible = False End If TabVentaAF.Visible = False @@ -5824,9 +5827,9 @@ Partial Class Ventas 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 + 'If PrecioMinimo > 0 Then + ' Costo = PrecioMinimo + 'End If End If objPS.Dispose() @@ -5835,7 +5838,7 @@ Partial Class Ventas If ValidaExistencia AndAlso DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False AndAlso Not RegistroxOC Then 'VALIDA EXISTENCIA If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) Then - If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS}") < TxtCantidad.Text.ToDouble 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 @@ -13642,6 +13645,10 @@ Partial Class Ventas CargarAlmacenes() DdlPS.Attributes.Remove("data-cvesubproyecto") DdlPS.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) + + DdlPSPyME.Attributes.Remove("data-cvesubproyecto") + DdlPSPyME.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) + UpPS.Update() End Sub Private Sub CargaFolios() @@ -14014,9 +14021,14 @@ Partial Class Ventas Dim PU As Decimal = If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal) Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 + Dim ValidaCondicionesComerciales As Boolean = True + + If DrPS IsNot Nothing AndAlso DrPS("CveClasificacion").ToString.ToEntero = 20636 Then + ValidaCondicionesComerciales = False + End If 'VERIFICA SI APLICAN CONDICIONES COMERCIALES - If DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then + If ValidaCondicionesComerciales AndAlso DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then 'VERIFICA SI EL PRODUCTO TIENE ESPECIFICADA UNA MARCA If Not String.IsNullOrEmpty(DrPS("CveMarca").ToString()) AndAlso DrPS("CveMarca").ToString().ToEntero() > 0 Then Dim RowPorcentaje = DtPorcentajeMarcas.FiltroPrimero($"CveMarca={DrPS("CveMarca").ToString()}") @@ -14100,9 +14112,65 @@ Partial Class Ventas Dim CveSubProyecto As Integer = IIf(DdlSubProyectoPyME.SelectedValue <> "-1", DdlSubProyectoPyME.SelectedValue, "0").ToString.ToEntero Dim SubProyecto As String = IIf(DdlSubProyectoPyME.SelectedValue <> "-1", DdlSubProyectoPyME.SelectedItem.Text, "").ToString - AgregarProductoServicio(TxtCantidadPyME.Text.ToDecimal, DdlUMPyME.SelectedValue.ToEntero, DdlUMPyME.SelectedItem.Text, DdlClasificacionPyME.SelectedValue.ToEntero, DdlClasificacionPyME.SelectedItem.Text, - DdlPSPyME.SelectedValue.ToEntero, DdlPSPyME.SelectedText, TxtObsPyME.Text, TxtPrecioPyME.Text.ToDecimal, 0, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + Dim Descuento As Decimal = 0 + Dim PU As Decimal = TxtPrecioPyME.Text.ToDecimal() + Dim Cantidad As Decimal = TxtCantidadPyME.Text.ToDecimal() + Dim CvePS As Integer = DdlPSPyME.SelectedValue.ToEntero + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 + Dim ValidaCondicionesComerciales As Boolean = True + + If DrPS IsNot Nothing AndAlso DrPS("CveClasificacion").ToString.ToEntero = 20636 Then + ValidaCondicionesComerciales = False + End If + 'VERIFICA SI APLICAN CONDICIONES COMERCIALES + If ValidaCondicionesComerciales AndAlso DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then + 'VERIFICA SI EL PRODUCTO TIENE ESPECIFICADA UNA MARCA + If Not String.IsNullOrEmpty(DrPS("CveMarca").ToString()) AndAlso DrPS("CveMarca").ToString().ToEntero() > 0 Then + Dim RowPorcentaje = DtPorcentajeMarcas.FiltroPrimero($"CveMarca={DrPS("CveMarca").ToString()}") + 'REALIZA LOS DESCUENTOS DE ACUERDO AL PORCENTAJE POR MARCA + If RowPorcentaje IsNot Nothing Then + Dim PorcentajeProducto = RowPorcentaje("PorcentajeProducto").ToString().ToDecimal() / 100D + Dim PorcentajeProducto2 = RowPorcentaje("PorcentajeProducto2").ToString().ToDecimal() / 100D + Dim PorcentajeProducto3 = RowPorcentaje("PorcentajeProducto3").ToString().ToDecimal() / 100D + + Dim TotalInicial As Decimal = (Cantidad * (PU)) - Descuento + Dim TotalFinal = TotalInicial + 'SI APLICA EL PRIMER DESCUENTO + If PorcentajeProducto > 0 Then + Dim Descuento1 As Decimal = (TotalInicial * PorcentajeProducto).RoundSQL(2) + Dim Total2 = (TotalInicial - Descuento1) + + 'SI APLICA EL SEGUNDO DESCUENTO + If PorcentajeProducto2 > 0 Then + Dim Descuento2 As Decimal = (Total2 * PorcentajeProducto2).RoundSQL(2) + Dim Total3 = (Total2 - Descuento2) + + 'SI APLICA EL TERCER DESCUENTO + If PorcentajeProducto3 > 0 Then + Dim Descuento3 As Decimal = (Total3 * PorcentajeProducto3).RoundSQL(2) + TotalFinal = Total3 - Descuento3 + Else + TotalFinal = Total3 + End If + Else + TotalFinal = Total2 + End If + Else + TotalFinal = TotalInicial + End If + + Descuento += ((Cantidad * PU) - TotalFinal) + + End If + End If + + End If + + AgregarProductoServicio(Cantidad, DdlUMPyME.SelectedValue.ToEntero, DdlUMPyME.SelectedItem.Text, DdlClasificacionPyME.SelectedValue.ToEntero, DdlClasificacionPyME.SelectedItem.Text, + CvePS, DdlPSPyME.SelectedText, TxtObsPyME.Text, PU, Descuento, CveProyecto, Proyecto, CveSubProyecto, SubProyecto) + + CalculaUsados() CalculaTotalesVenta() @@ -14624,7 +14692,7 @@ Partial Class Ventas TmpDT.Columns.Add("CveConcepto", GetType(Integer)) TmpDT.Columns.Add("EsOutSourcing", GetType(Boolean)) - TmpDT.Columns.Add("EsUsado", GetType(Boolean)) + TmpDT.Columns.Add("EsCargo", GetType(Boolean)) End Sub Private Sub CreaDTmpC() @@ -19545,9 +19613,10 @@ Partial Class Ventas Private Sub LnkAddVenta_Click(sender As Object, e As EventArgs) Handles LnkAddVenta.Click Modalidad = "A" LnkAgregarPyME.Text = "Agregar" - TxtCantidadPyME.Text = "" + TxtCantidadPyME.Text = "1" TxtObsPyME.Text = "" TxtPrecioPyME.Text = "0.00" + TxtDescuentoPyME.Text = "0.00" LblTotalPyME.Text = "0.00" If Not UsuarioActual.Empresa.Funcionalidad(141).ToString = "1" Then DdlPSPyME.SelectedValue = "-1" @@ -19631,18 +19700,12 @@ Partial Class Ventas Private Sub CargaPSPyME(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost) - DdlPSPyME.setEsWebService(If(UsuarioActual.Empresa.Funcionalidad(141).ToString = "1", True, False)) + DdlPSPyME.setEsWebService(True) - If Not UsuarioActual.Empresa.Funcionalidad(141).ToString = "1" Then - Objeto.ddl.Items.Clear() - 'Objeto.ddl.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, AplicaParaVenta:=1, Estatus:=1) - Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, AplicaParaVenta:=1, Estatus:=1) - Objeto.ddl.DataBind() - Objeto.ddl.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2")) - Objeto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) - Else - DdlPSPyME.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) - End If + DdlPSPyME.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) + DdlPSPyME.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString) + DdlPSPyME.ddlWS.Attributes.Add("data-pagina", "ventas/ventas") + DdlPSPyME.ddlWS.Attributes.Add("data-Estatus", "1") End Sub @@ -19673,6 +19736,62 @@ Partial Class Ventas 'LblUnidadMedida.Text = PS.Rows(0)("UnidadMedida").ToString TxtPrecioPyME.Text = drPS("Precio").ToString.FormatoNumero(2).Replace(","c, "") + Dim Cantidad As Decimal = TxtCantidadPyME.Text.ToDecimal() + Dim PU As Decimal = TxtPrecioPyME.Text.ToDecimal() + Dim Descuento As Decimal = 0 + Dim ValidaCondicionesComerciales As Boolean = True + + If drPS IsNot Nothing AndAlso drPS("CveClasificacion").ToString.ToEntero = 20636 Then + ValidaCondicionesComerciales = False + End If + 'VERIFICA SI APLICAN CONDICIONES COMERCIALES + If ValidaCondicionesComerciales AndAlso DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then + 'VERIFICA SI EL PRODUCTO TIENE ESPECIFICADA UNA MARCA + If Not String.IsNullOrEmpty(drPS("CveMarca").ToString()) AndAlso drPS("CveMarca").ToString().ToEntero() > 0 Then + Dim RowPorcentaje = DtPorcentajeMarcas.FiltroPrimero($"CveMarca={drPS("CveMarca").ToString()}") + 'REALIZA LOS DESCUENTOS DE ACUERDO AL PORCENTAJE POR MARCA + If RowPorcentaje IsNot Nothing Then + Dim PorcentajeProducto = RowPorcentaje("PorcentajeProducto").ToString().ToDecimal() / 100D + Dim PorcentajeProducto2 = RowPorcentaje("PorcentajeProducto2").ToString().ToDecimal() / 100D + Dim PorcentajeProducto3 = RowPorcentaje("PorcentajeProducto3").ToString().ToDecimal() / 100D + + Dim TotalInicial As Decimal = (Cantidad * (PU)) - Descuento + Dim TotalFinal = TotalInicial + 'SI APLICA EL PRIMER DESCUENTO + If PorcentajeProducto > 0 Then + Dim Descuento1 As Decimal = (TotalInicial * PorcentajeProducto).RoundSQL(2) + Dim Total2 = (TotalInicial - Descuento1) + + 'SI APLICA EL SEGUNDO DESCUENTO + If PorcentajeProducto2 > 0 Then + Dim Descuento2 As Decimal = (Total2 * PorcentajeProducto2).RoundSQL(2) + Dim Total3 = (Total2 - Descuento2) + + 'SI APLICA EL TERCER DESCUENTO + If PorcentajeProducto3 > 0 Then + Dim Descuento3 As Decimal = (Total3 * PorcentajeProducto3).RoundSQL(2) + TotalFinal = Total3 - Descuento3 + Else + TotalFinal = Total3 + End If + Else + TotalFinal = Total2 + End If + Else + TotalFinal = TotalInicial + End If + + Descuento += ((Cantidad * PU) - TotalFinal) + + End If + End If + + End If + + TxtDescuentoPyME.Text = Descuento.FormatoNumero(2).Replace(","c, "") + + LblTotalPyME.Text = ((Cantidad * PU) - Descuento).FormatoNumero(2).Replace(","c, "") + If UsuarioActual.CveEmpresa = 80 Then 'busca el precio de la sucursal Dim ObjPS As New ClsProductosServicios @@ -21765,7 +21884,7 @@ Partial Class Ventas Dim AplicaPUEditado As Boolean = UsuarioActual.TienePermisoProceso(253) - Dim DtUsados As DataTable = TmpDT.FiltraParametros("EsUsado = True") + Dim DtUsados As DataTable = TmpDT.FiltraParametros("EsCargo = True") TmpDT.Clear() For Each Gv As GridViewRow In GvAplicaDevolucion.Rows @@ -23939,6 +24058,10 @@ Partial Class Ventas Private Sub CalculaUsados(Optional DtUsadosDevolucion As DataTable = Nothing) If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot", "Dev") Then + If ViewState("CargoUsado").ToString = "False" Then + Exit Sub + End If + Dim DTTamanios As DataTable = GlobalDTAcumTamaños() Dim DTCvePSCostos As DataTable @@ -23948,7 +24071,17 @@ Partial Class Ventas TmpDT.Columns.Add("Eliminar", GetType(Integer)) End If - For Each drow As DataRow In TmpDT.Rows + + Dim TmpDTCalculo As DataRow() = Nothing + 'SI ES VENTA NUEVA O SI VA SER DEVOLUCION CONSIDERAR TODOS + If Me.CveVenta <= 0 OrElse DtUsadosDevolucion IsNot Nothing Then + TmpDTCalculo = TmpDT.Rows.Cast(Of DataRow).ToArray() + 'SI ES EDICION DE REMISION SOLO CONSIDERAR LOS PRODUCTOS NUEVOS + ElseIf Me.CveVenta > 0 AndAlso DtUsadosDevolucion Is Nothing AndAlso DdlTipoComprobante.SelectedValue = "Rem" Then + TmpDTCalculo = TmpDT.Select("CveVentaDetalle IS NULL OR CveVentaDetalle <=0") + End If + + For Each drow As DataRow In TmpDTCalculo If DTCvePSCostos IsNot Nothing Then For Each drow2 As DataRow In DTCvePSCostos.Rows If drow("CvePS").ToString.ToEntero = drow2("CvePSCargo").ToString.ToEntero Then @@ -23957,7 +24090,6 @@ Partial Class Ventas End If Next End If - Next Dim TmpDTView As New DataView(TmpDT) @@ -23967,11 +24099,19 @@ Partial Class Ventas dRowEliminar.Delete() Next - TmpDT.AcceptChanges() - If ViewState("CargoUsado").ToString = "False" Then - Exit Sub + 'SI ES VENTA NUEVA O SI VA SER DEVOLUCION CONSIDERAR TODOS + If Me.CveVenta <= 0 OrElse DtUsadosDevolucion IsNot Nothing Then + TmpDTCalculo = TmpDT.Rows.Cast(Of DataRow).ToArray() + 'SI ES EDICION DE REMISION SOLO CONSIDERAR LOS PRODUCTOS NUEVOS + ElseIf Me.CveVenta > 0 AndAlso DtUsadosDevolucion Is Nothing AndAlso DdlTipoComprobante.SelectedValue = "Rem" Then + TmpDTCalculo = TmpDT.Select("CveVentaDetalle IS NULL OR CveVentaDetalle <=0") End If + + + TmpDT.AcceptChanges() + + Dim CveUnidadMedidaPSA As Integer = -1 Dim UnidadMedidaPSA As String = "Unidad" Dim CveClasificacionPSA As Integer = -1 @@ -23996,7 +24136,7 @@ Partial Class Ventas DTPSTemp.Columns.Add("CveSubProyecto", GetType(Integer)) DTPSTemp.Columns.Add("SubProyecto", GetType(String)) - For Each DrowPartidas As DataRow In TmpDT.Rows + For Each DrowPartidas As DataRow In TmpDTCalculo Dim CveTamanioTemp As Integer = DrowPartidas("CveTamaño").ToString.ToEntero If CveTamanioTemp > 0 Then @@ -24527,26 +24667,26 @@ Partial Class Ventas ' Dim facBytes = DescargarFactura(Me.CveVenta, UsuarioActual.CveEmpresa) ' ImprimirbytesPDF(facBytes, "Factura") 'End Sub - 'Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer) As Byte() - ' Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", "https://sig.adssistemas.mx/", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta)))) - ' Dim File As Byte() = Nothing - ' Try - ' Using httpClient = New HttpClient() - ' httpClient.Timeout = New TimeSpan(0, 15, 0) - ' Using request = New HttpRequestMessage(HttpMethod.Get, Url) - ' request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO=100", CveEmpresa, DateTime.UtcNow.Ticks))) - ' Dim response = httpClient.SendAsync(request).Result - ' If response.StatusCode = Net.HttpStatusCode.OK Then - ' File = response.Content.ReadAsByteArrayAsync().Result - ' End If - ' End Using - ' End Using - ' Catch ex As Exception - ' File = Nothing - ' OnError("Ocurrió un error al descargar la factura", ex) - ' End Try - - ' Return File + 'Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer) As Byte() + ' Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", "https://sig.adssistemas.mx/", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta)))) + ' Dim File As Byte() = Nothing + ' Try + ' Using httpClient = New HttpClient() + ' httpClient.Timeout = New TimeSpan(0, 15, 0) + ' Using request = New HttpRequestMessage(HttpMethod.Get, Url) + ' request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO=100", CveEmpresa, DateTime.UtcNow.Ticks))) + ' Dim response = httpClient.SendAsync(request).Result + ' If response.StatusCode = Net.HttpStatusCode.OK Then + ' File = response.Content.ReadAsByteArrayAsync().Result + ' End If + ' End Using + ' End Using + ' Catch ex As Exception + ' File = Nothing + ' OnError("Ocurrió un error al descargar la factura", ex) + ' End Try + + ' Return File 'End Function 'Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, Optional GetBytes As Boolean = True) As Byte() ' Dim Url = New Uri(String.Format("http://{0}:{1}/Compras/PopUpVerFactura.aspx?P={2}", HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta)))) diff --git a/vwd.webinfo b/vwd.webinfo index 824b76cb0..0770194b6 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -17,6 +17,8 @@ + + \ No newline at end of file