diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index e97a4095f..5248de51a 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -12162,9 +12162,33 @@ Partial Class Ventas 'Si es devolucion se agregan a la tabla de Vta_VentasDetalleDevolucion If factura.AplicaDevolucion Then - If Not ObjVentas.AddVentaDetalleDevolucion(Row("CveVentaDetalle").ToString().ToEntero(), ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDouble) Then + Try + Dim EsCargo As Integer = If(Row("EsCargo").ToString() = "True", 1, 0) + If EsCargo = 1 Then + If Me.ObjFacturaNC IsNot Nothing Then + Dim CveVentaDetalleUsado As Integer = -1 + For Each RowIng As DataRow In Me.ObjFacturaNC.DtDetalle.Rows + If RowIng("Cantidad").ToString().ToDecimal() = Row("Cantidad").ToString().ToDecimal() AndAlso RowIng("CvePS").ToString().ToEntero() = Row("CvePS").ToString().ToEntero() Then + CveVentaDetalleUsado = RowIng("CveVentaDetalle").ToString().ToEntero() + Exit Sub + End If + Next + If CveVentaDetalleUsado > 0 Then + If Not ObjVentas.AddVentaDetalleDevolucion(CveVentaDetalleUsado, ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDouble) Then + ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") + End If + End If + + End If + Else + If Not ObjVentas.AddVentaDetalleDevolucion(Row("CveVentaDetalle").ToString().ToEntero(), ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDouble) Then + ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") + End If + End If + Catch ex As Exception ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") - End If + End Try + If ErrorList.Count = 0 Then If Not ObjEventos.AddEventoBitacora(String.Format("Se aplicó una devolución en Folio: {1}", factura.CveVenta, factura.SerieFolio), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaDevolucion) Then ErrorList.Add("Ocurrió un error al agregar la bitacora de devolución.") @@ -21753,7 +21777,7 @@ Partial Class Ventas DdlCuentaCheque.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) End If - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(558) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlCuentaTarjetaCredito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) DdlCuentaTarjetaDebito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1 AND TieneTerminal = 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) Else @@ -29656,6 +29680,11 @@ Partial Class Ventas CargaVendedores() + If UsuarioActual.Empresa.Funcionalidad(572) = "1" AndAlso Not TbDescuentosRNC.Visible Then + TbDescuentosRNC.Visible = True + LnkDescuentosRNC.Visible = UsuarioActual.TienePermisoProceso(328) + End If + UpPS.Update() UPPDescuento.Update() UPObservaciones.Update() @@ -31529,6 +31558,11 @@ Partial Class Ventas End Function Private Sub EmitirDocumentoNuevo(TipoDoctoNuevo As String) + If DdlVendedor.SelectedValue.ToEntero() <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoDoctoNuevo = "Ing" Then + Alert("Debe seleccionar un vendedor.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + If (FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso String.IsNullOrEmpty(Me.ClienteSucursal.RFC))) Then Alert("La sucursal no tiene asignada un RFC.", TipoMensaje.MsgAdvertencia) Exit Sub