diff --git a/OS/OrdenesServicios.aspx b/OS/OrdenesServicios.aspx
index dde2b56c3..a2feb17ca 100644
--- a/OS/OrdenesServicios.aspx
+++ b/OS/OrdenesServicios.aspx
@@ -1275,10 +1275,12 @@
-
+
+
+
diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb
index 08b091a33..e788c7d4d 100644
--- a/OS/OrdenesServicios.aspx.vb
+++ b/OS/OrdenesServicios.aspx.vb
@@ -5,6 +5,8 @@ Imports Extensiones
Imports System.IO
Imports System.Data
Imports Telerik.Web.UI
+Imports System.Data.SqlClient
+Imports Stimulsoft.Report.StiOptions.Export
Partial Class OS_OrdenesServicios
Inherits ClsPaginas
@@ -3121,6 +3123,8 @@ Partial Class OS_OrdenesServicios
Dim CveSubProyectoPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveSubProyecto").ToEntero
Dim CveVentaPedido As Integer = DTSolicitudDev.FiltroPrimeroValor("CveVenta").ToEntero
+
+
Dim CveAlmacenDestino As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, 10).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyectoPedido}").ToEntero
If Not CveAlmacenDestino > 0 Then
@@ -3130,55 +3134,61 @@ Partial Class OS_OrdenesServicios
- Dim SbErroresDev As New StringBuilder
+ 'Dim SbErroresDev As New StringBuilder
+ 'Dim CantidadSeleccion As Integer = 0
- For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
+ 'For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
- If GvRow.DataKey("Cantidad").ToDecimal > 0 Then
+ ' If GvRow.DataKey("Cantidad").ToDecimal > 0 Then
- Dim sbTemperror As New StringBuilder
- Dim ErrorCountDev As Integer = 0
+ ' Dim sbTemperror As New StringBuilder
+ ' Dim ErrorCountDev As Integer = 0
- sbTemperror.Append($"Producto: {GvRow.DataKey("CodigoPS") } requiere: ")
+ ' sbTemperror.Append($"Producto: {GvRow.DataKey("CodigoPS") } requiere: ")
- If Boolean.Parse(GvRow.DataKey("AplicaSerie")) Then
- If GvRow.FCTextBox("TxtSerie").Text.Trim = String.Empty Then
- sbTemperror.Append($" Serie, ")
- ErrorCountDev = ErrorCountDev + 1
- End If
- End If
+ ' If Boolean.Parse(GvRow.DataKey("AplicaSerie")) Then
+ ' If GvRow.FCTextBox("TxtSerie").Text.Trim = String.Empty Then
+ ' sbTemperror.Append($" Serie, ")
+ ' ErrorCountDev = ErrorCountDev + 1
+ ' End If
+ ' End If
- If Boolean.Parse(GvRow.DataKey("AplicaLote")) Then
- If GvRow.FCTextBox("TxtLote").Text = String.Empty Then
- sbTemperror.Append($" Lote, ")
- ErrorCountDev = ErrorCountDev + 1
- End If
- End If
+ ' If Boolean.Parse(GvRow.DataKey("AplicaLote")) Then
+ ' If GvRow.FCTextBox("TxtLote").Text = String.Empty Then
+ ' sbTemperror.Append($" Lote, ")
+ ' ErrorCountDev = ErrorCountDev + 1
+ ' End If
+ ' End If
- If Boolean.Parse(GvRow.DataKey("AplicaCaducidad")) Then
- If Not IsDate(GvRow.FCTextBox("TxtFechaCaducidad").Text) Then
- sbTemperror.Append($" Fecha de caducidad")
- ErrorCountDev = ErrorCountDev + 1
- End If
- End If
+ ' If Boolean.Parse(GvRow.DataKey("AplicaCaducidad")) Then
+ ' If Not IsDate(GvRow.FCTextBox("TxtFechaCaducidad").Text) Then
+ ' sbTemperror.Append($" Fecha de caducidad")
+ ' ErrorCountDev = ErrorCountDev + 1
+ ' End If
+ ' End If
- If ErrorCountDev > 0 Then
- sbTemperror.Append($"
")
- SbErroresDev.AppendLine(sbTemperror.ToString)
- End If
+ ' If ErrorCountDev > 0 Then
+ ' sbTemperror.Append($"
")
+ ' SbErroresDev.AppendLine(sbTemperror.ToString)
+ ' End If
+ ' CantidadSeleccion = CantidadSeleccion + 1
- End If
+ ' End If
- Next
+ 'Next
+ ''If CantidadSeleccion = 0 Then
+ '' Alert($"No se selecciono nigun producto", TipoMensaje.MsgAdvertencia)
+ '' Exit Sub
+ ''End If
- If SbErroresDev.ToString.Length > 0 Then
- Alert($"Se encontraron los siguientes errores:
{SbErroresDev.ToString}", TipoMensaje.MsgAdvertencia)
- Exit Sub
- End If
+ 'If SbErroresDev.ToString.Length > 0 Then
+ ' Alert($"Se encontraron los siguientes errores:
{SbErroresDev.ToString}", TipoMensaje.MsgAdvertencia)
+ ' Exit Sub
+ 'End If
Dim PropcesoOK As Boolean = True
Dim ObjV As New ClsVentas
@@ -3204,11 +3214,25 @@ Partial Class OS_OrdenesServicios
Next
End If
+
+ Dim Respuesta = New RespuestaFacturacion()
+
+ If PropcesoOK Then
+
+ Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL())
+ If Not Respuesta.CveVenta > 0 Then
+ PropcesoOK = False
+ End If
+
+ End If
+
+
+
If PropcesoOK Then
Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL())
- Dim CveMovimiento As Integer = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaPedido, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino)
+ Dim CveMovimiento As Integer = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino)
Dim Folio As Integer = ObjInventario.Folio
If CveMovimiento > 0 Then
@@ -3242,7 +3266,7 @@ Partial Class OS_OrdenesServicios
If PropcesoOK Then
- Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenDestino, 9, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaPedido, CveSubProyectoPedido, -1, CveOS:=CveOS, CveMovimientoRelacionado:=CveMovimiento)
+ Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenDestino, 9, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveMovimientoRelacionado:=CveMovimiento)
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
@@ -3272,7 +3296,7 @@ Partial Class OS_OrdenesServicios
Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL)
Dim LigaVenta As String = String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, "Material utilizado")
- If Not ObjEventos.AddEventoBitacora(LigaVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaPedido, CveOS:=CveOS) Then
+ If Not ObjEventos.AddEventoBitacora(LigaVenta, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Respuesta.CveVenta, CveOS:=CveOS) Then
PropcesoOK = False
End If
@@ -3285,7 +3309,7 @@ Partial Class OS_OrdenesServicios
End If
- Else
+ Else
PropcesoOK = False
End If
@@ -3293,9 +3317,11 @@ Partial Class OS_OrdenesServicios
If PropcesoOK Then
- 'ObjV.RollBack()
+
ObjV.Commit()
- Alert("La solicitud de Devolución de Almacén se guardó correctamente")
+
+ Alert($"Proceso finalizado correctamente Remision generada {Respuesta.SerieFolio} ")
+
RegistraScript("$('#DVModalSolicitarDevolucion').modal('hide');")
Else
ObjV.RollBack()
@@ -3307,4 +3333,92 @@ Partial Class OS_OrdenesServicios
End Sub
+ Private Function GeneraRemision(CveVentaPedido As Integer, ByRef TransaccionSQL As SqlTransaction) As RespuestaFacturacion
+
+ Dim Respuesta = New RespuestaFacturacion()
+
+ Dim CveRemiocionGenerada As Integer = -1
+
+ Dim ObjVentas As New ClsVentas(TransaccionSQL)
+ Dim ProcesoOK As Boolean = True
+
+ Dim CveSubProyectoPedido As Integer = -1
+ Dim CveMoneda As Integer = -1
+
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
+ Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Copy().Rows(0)
+ CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
+ CveSubProyectoPedido = DbRowVenta("CveSubProyecto").ToString().ToEntero()
+ End If
+
+ Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, CveSubProyectoPedido, CveCliente, CveMoneda, "Ped")
+
+ If ObjFactura IsNot Nothing Then
+
+ If ProcesoOK Then
+
+ For Each GvRow As GridViewRow In GvSolicitarDevolucion.Rows
+
+ Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
+ Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal
+ Dim CantidadDev As Decimal = GvRow.FCTextBox("TxtDev").Text.ToDecimal
+ Dim CantidadRegistro = Cantidad - CantidadDev
+ Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal
+ Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
+ Dim Obs As String = GvRow.DataKey("Observaciones")
+
+ If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido) Then
+ Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
+ ProcesoOK = False
+ Exit For
+ End If
+
+ Next
+
+ If ProcesoOK Then
+ ObjFactura.CalculaTotales()
+
+
+ Dim Resp As New Modelos.Factura.MMensajeFactura
+ Resp = ObjFactura.EmitirFactura(False, Transac:=TransaccionSQL)
+
+ If Resp.CveVenta > 0 Then
+ Respuesta.CveVenta = Resp.CveVenta
+ Respuesta.SerieFolio = Resp.SerieFolio
+ Else
+ ProcesoOK = False
+ End If
+
+ End If
+
+
+ End If
+
+ Else
+ ProcesoOK = False
+ End If
+
+ Return Respuesta
+
+ End Function
+
+
+
+
+
+
+
+ Friend Class RespuestaFacturacion
+ Public Property CveVenta As Integer = -1
+ Public Property SerieFolio As String = "-1"
+ Public Sub New()
+
+ End Sub
+ End Class
+
+
+
+
+
+
End Class
\ No newline at end of file