Generacion automatica del virtual
This commit is contained in:
@@ -1908,12 +1908,26 @@ Partial Class Inventarios_EntradasSalidas
|
|||||||
' End If
|
' End If
|
||||||
'End If
|
'End If
|
||||||
|
|
||||||
|
Dim RetornoVirtual As MMovimientoVirtual = Nothing
|
||||||
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
||||||
|
RetornoVirtual = GenerarMovimientoVirtual(CveMovimiento, ObjInventario)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If RetornoVirtual IsNot Nothing Then
|
||||||
|
ErrorMovInv = RetornoVirtual.TieneError
|
||||||
|
End If
|
||||||
|
|
||||||
If Not ErrorAC And Not ErrorMovInv Then
|
If Not ErrorAC And Not ErrorMovInv Then
|
||||||
Dim Msg As New StringBuilder
|
Dim Msg As New StringBuilder
|
||||||
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b>{0}</b>", ObjInventario.Folio)
|
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b>{0}</b>", ObjInventario.Folio)
|
||||||
Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
|
Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
|
||||||
|
|
||||||
|
If RetornoVirtual IsNot Nothing Then
|
||||||
|
If RetornoVirtual.CveMovimientoVirtual > 0 Then
|
||||||
|
Msg.AppendFormat("<br/><br/>Se generó el movimiento virtual con el folio: <b><a class=""Texto"" target='_blank' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">{1}</a></b>", RetornoVirtual.CveMovimientoVirtual, RetornoVirtual.FolioVirtual)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza)
|
If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza)
|
||||||
If IDPoliza > 0 Then Msg = Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza)
|
If IDPoliza > 0 Then Msg = Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza)
|
||||||
|
|
||||||
@@ -5039,60 +5053,12 @@ Partial Class Inventarios_EntradasSalidas
|
|||||||
|
|
||||||
Protected Sub LnkGenerarVirtual_Click(sender As Object, e As EventArgs)
|
Protected Sub LnkGenerarVirtual_Click(sender As Object, e As EventArgs)
|
||||||
If CveMovimiento > 0 Then
|
If CveMovimiento > 0 Then
|
||||||
Dim DtPSVirtual As New DataTable("DtTamanios")
|
|
||||||
Dim ErrorMovInv As Boolean = False
|
|
||||||
|
|
||||||
Dim CveMovimientoVirtual As Integer = -1
|
|
||||||
Dim FolioVirtual As Integer = -1
|
|
||||||
|
|
||||||
Dim tCveAlmacen As Integer = -1
|
|
||||||
Dim tOrigen As Integer = -1
|
|
||||||
Dim ObjInventario As New ClsInventarios
|
Dim ObjInventario As New ClsInventarios
|
||||||
ObjInventario.IniciaTransacSQL()
|
ObjInventario.IniciaTransacSQL()
|
||||||
|
|
||||||
Try
|
Dim Retorno = GenerarMovimientoVirtual(Me.CveMovimiento, ObjInventario)
|
||||||
If ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
||||||
tCveAlmacen = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen").ToEntero()
|
|
||||||
tOrigen = ObjInventario.DtResultados.FiltroPrimeroValor("Origen").ToEntero()
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero()
|
If Retorno.TieneError Then
|
||||||
|
|
||||||
'VERIFICA SI TIENE ALMACEN VIRTUAL
|
|
||||||
If CveAlmacenVirtual > 0 Then
|
|
||||||
If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
||||||
DtPSVirtual = ObjInventario.DtResultados
|
|
||||||
End If
|
|
||||||
|
|
||||||
If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 Then
|
|
||||||
|
|
||||||
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, If(tOrigen > 0, 36, 37), 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimiento, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="ES/GV")
|
|
||||||
FolioVirtual = ObjInventario.Folio
|
|
||||||
|
|
||||||
For Each RowUsado As DataRow In DtPSVirtual.Rows
|
|
||||||
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
|
||||||
Dim CantidadUsado As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
|
|
||||||
Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal()
|
|
||||||
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
|
|
||||||
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
||||||
ErrorMovInv = True
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
Else
|
|
||||||
ErrorMovInv = True
|
|
||||||
Alert("No hay usados para generar el virtual", TipoMensaje.MsgAdvertencia)
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
ErrorMovInv = True
|
|
||||||
Alert("El almacen no tiene vinculado un almacen virtual", TipoMensaje.MsgAdvertencia)
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
ErrorMovInv = True
|
|
||||||
End Try
|
|
||||||
|
|
||||||
If ErrorMovInv Then
|
|
||||||
ObjInventario.RollBack()
|
ObjInventario.RollBack()
|
||||||
Else
|
Else
|
||||||
ObjInventario.Commit()
|
ObjInventario.Commit()
|
||||||
@@ -5100,14 +5066,65 @@ Partial Class Inventarios_EntradasSalidas
|
|||||||
|
|
||||||
ObjInventario.Dispose()
|
ObjInventario.Dispose()
|
||||||
|
|
||||||
If CveMovimientoVirtual > 0 AndAlso Not ErrorMovInv Then
|
If Retorno.CveMovimientoVirtual > 0 AndAlso Not Retorno.TieneError Then
|
||||||
Alert($"Se generó el movimiento virtual con el folio:<b>{FolioVirtual}<b/>")
|
Alert($"Se generó el movimiento virtual con el folio:<b>{Retorno.FolioVirtual}<b/>")
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Function GenerarMovimientoVirtual(CveMovimiento As Integer, ObjInventario As ClsInventarios) As MMovimientoVirtual
|
||||||
|
Dim ErrorMovInv As Boolean = False
|
||||||
|
|
||||||
|
Dim DtPSVirtual As New DataTable("DtTamanios")
|
||||||
|
Dim CveMovimientoVirtual As Integer = -1
|
||||||
|
Dim FolioVirtual As Integer = -1
|
||||||
|
|
||||||
|
Dim tCveAlmacen As Integer = -1
|
||||||
|
Dim tOrigen As Integer = -1
|
||||||
|
|
||||||
|
Try
|
||||||
|
If ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
||||||
|
tCveAlmacen = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen").ToEntero()
|
||||||
|
tOrigen = ObjInventario.DtResultados.FiltroPrimeroValor("Origen").ToEntero()
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero()
|
||||||
|
|
||||||
|
'VERIFICA SI TIENE ALMACEN VIRTUAL
|
||||||
|
If CveAlmacenVirtual > 0 Then
|
||||||
|
If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
||||||
|
DtPSVirtual = ObjInventario.DtResultados
|
||||||
|
End If
|
||||||
|
|
||||||
|
If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 Then
|
||||||
|
|
||||||
|
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, If(tOrigen > 0, 36, 37), 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimiento, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="ES/GV")
|
||||||
|
FolioVirtual = ObjInventario.Folio
|
||||||
|
|
||||||
|
For Each RowUsado As DataRow In DtPSVirtual.Rows
|
||||||
|
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
||||||
|
Dim CantidadUsado As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
|
||||||
|
Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal()
|
||||||
|
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
|
||||||
|
|
||||||
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||||
|
ErrorMovInv = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
ErrorMovInv = True
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return New MMovimientoVirtual With {.TieneError = ErrorMovInv, .CveMovimientoVirtual = CveMovimientoVirtual, .FolioVirtual = FolioVirtual.ToString()}
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Protected Sub LnkGenerarPDF_Click(sender As Object, e As EventArgs)
|
Protected Sub LnkGenerarPDF_Click(sender As Object, e As EventArgs)
|
||||||
GeneraPDFFactura()
|
GeneraPDFFactura()
|
||||||
End Sub
|
End Sub
|
||||||
@@ -5299,5 +5316,9 @@ Partial Class Inventarios_EntradasSalidas
|
|||||||
Next
|
Next
|
||||||
Return Timbre
|
Return Timbre
|
||||||
End Function
|
End Function
|
||||||
|
Private Class MMovimientoVirtual
|
||||||
|
Public Property CveMovimientoVirtual As Integer
|
||||||
|
Public Property FolioVirtual As String
|
||||||
|
Public Property TieneError As Boolean
|
||||||
|
End Class
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Reference in New Issue
Block a user