modificacion para buscar usuario ingresado
This commit is contained in:
353
Ashx/E48.ashx
353
Ashx/E48.ashx
@@ -39,12 +39,15 @@ Public Class E48 : Implements IHttpHandler, IRequiresSessionState
|
|||||||
Dim RespuestaError As New FidelityAppsResponseError
|
Dim RespuestaError As New FidelityAppsResponseError
|
||||||
Dim TieneError As Boolean = False
|
Dim TieneError As Boolean = False
|
||||||
Dim JsonRequest As JObject = Nothing
|
Dim JsonRequest As JObject = Nothing
|
||||||
Dim UsuarioActual As Usuario = ValidaUsuarioSistema(100, CveEmpresa)
|
|
||||||
Dim ObjInventario As New ClsInventarios
|
Dim ObjInventario As New ClsInventarios
|
||||||
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
||||||
Dim CveMovimiento As Integer = 0
|
Dim CveMovimiento As Integer = 0
|
||||||
Dim Mensaje As String = ""
|
Dim Mensaje As String = ""
|
||||||
Dim SinExistencia As String = "No hay existencias suficientes del producto: "
|
Dim SinExistencia As String = "No hay existencias suficientes del producto: "
|
||||||
|
Dim ObjUsuarios As New ClsSisUsuarios
|
||||||
|
Dim CveUsuario As Integer
|
||||||
|
Dim UsuarioActual As Usuario = ValidaUsuarioSistema(100, CveEmpresa)
|
||||||
|
|
||||||
|
|
||||||
Dim ErrorAC As Boolean = False
|
Dim ErrorAC As Boolean = False
|
||||||
Dim ErrorMovInv As Boolean = False
|
Dim ErrorMovInv As Boolean = False
|
||||||
@@ -68,238 +71,240 @@ Public Class E48 : Implements IHttpHandler, IRequiresSessionState
|
|||||||
RespuestaError.Message = "Ocurrió un error al obtener el cuerpo de los parametros"
|
RespuestaError.Message = "Ocurrió un error al obtener el cuerpo de los parametros"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Not TieneError AndAlso Not String.IsNullOrEmpty(JsonRequest("fecha")) AndAlso Not String.IsNullOrEmpty(JsonRequest("usuario")) AndAlso Not String.IsNullOrEmpty(JsonRequest("almacen")) AndAlso Not String.IsNullOrEmpty(JsonRequest("entrega")) AndAlso
|
If Not TieneError AndAlso Not String.IsNullOrEmpty(JsonRequest("fecha")) Then
|
||||||
Not String.IsNullOrEmpty(JsonRequest("observaciones")) AndAlso Not String.IsNullOrEmpty(JsonRequest("productos")) Then
|
|
||||||
Dim Inv As New ClsInventarios
|
Dim Inv As New ClsInventarios
|
||||||
Dim ObjProductosServicios As New ClsProductosServicios()
|
Dim ObjProductosServicios As New ClsProductosServicios()
|
||||||
Dim ObjContaAC As ClsContPAQi = Nothing
|
Dim ObjContaAC As ClsContPAQi = Nothing
|
||||||
Dim tFolio As Integer = Inv.GetFolioSiguiente(3, CveEmpresa)
|
Dim tFolio As Integer = Inv.GetFolioSiguiente(3, CveEmpresa)
|
||||||
Dim observaciones As String = JsonRequest("observaciones").ToString()
|
Dim observaciones As String = IIf(JsonRequest("observaciones").ToString() <> "", JsonRequest("observaciones").ToString(), "Salida Almacen")
|
||||||
Dim CveAlmacen As Integer = 7
|
Dim CveAlmacen As Integer = 7
|
||||||
Dim IDPoliza As Integer = 0
|
Dim IDPoliza As Integer = 0
|
||||||
|
|
||||||
Dim Fecha As Date = JsonRequest("fecha").ToString().ToDate
|
|
||||||
Dim usuario As String = JsonRequest("usuario").ToString()
|
Dim usuario As String = JsonRequest("usuario").ToString()
|
||||||
|
If ObjUsuarios.GetUsuariosEmpresas(-1) Then
|
||||||
|
CveUsuario = ObjUsuarios.DtResultados.FiltroPrimeroValor("CveUsuario", String.Format("Usuario = '{0}' ", usuario)).ToEntero
|
||||||
|
If CveUsuario > 0 Then
|
||||||
|
UsuarioActual = ValidaUsuarioSistema(CveUsuario, CveEmpresa)
|
||||||
|
Else
|
||||||
|
Mensaje = "No se encontro el usuario ingresado"
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Dim Fecha As Date = JsonRequest("fecha").ToString().ToDate
|
||||||
Dim almacen As String = JsonRequest("almacen").ToString()
|
Dim almacen As String = JsonRequest("almacen").ToString()
|
||||||
Dim Recibe As String = JsonRequest("entrega").ToString()
|
Dim Recibe As String = JsonRequest("entrega").ToString()
|
||||||
Dim GlobalDTInvConceptos As DataTable
|
Dim GlobalDTInvConceptos As DataTable
|
||||||
Dim CveModalidad As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveModalidad").ToEntero()
|
Dim EsContabilizable As Boolean = True
|
||||||
|
|
||||||
Dim EsContabilizable As Boolean = (CveModalidad = 1)
|
|
||||||
If Inv.GetConceptos Then GlobalDTInvConceptos = Inv.DtResultados Else GlobalDTInvConceptos = Nothing
|
If Inv.GetConceptos Then GlobalDTInvConceptos = Inv.DtResultados Else GlobalDTInvConceptos = Nothing
|
||||||
Try
|
If Not TieneError Then
|
||||||
|
Try
|
||||||
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("ASHX/E48", 53, 0, 0, 1, Fecha, observaciones, UsuarioActual.CveUsuario, CveEmpresa, CveTipoPoliza:=3)
|
||||||
|
CveMovimiento = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Fecha, tFolio, UsuarioActual.CveUsuario, CveEmpresa, -1, -1, -1, -1, Observaciones:=observaciones, Recibio:=Recibe, Modulo:="ASHX/E48")
|
||||||
|
|
||||||
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("ASHX/E48", 53, 0, 0, 1, Fecha, observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
If CveMovimiento <= 0 OrElse CvePrePoliza <= 0 Then
|
||||||
CveMovimiento = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=observaciones, Recibio:=Recibe, Modulo:="ASHX/E48")
|
RespuestaError.Message = "No se pudo almacenar el movimiento correctamente"
|
||||||
|
TieneError = True
|
||||||
If CveMovimiento <= 0 OrElse CvePrePoliza <= 0 Then
|
ObjInventario.RollBack() 'deshace lo insertado
|
||||||
RespuestaError.Message = "No se pudo almacenar el movimiento correctamente"
|
|
||||||
TieneError = True
|
|
||||||
ObjInventario.RollBack() 'deshace lo insertado
|
|
||||||
Else
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
''VALIDA EXISTENCIAS
|
|
||||||
Dim Cont As Integer = 0
|
|
||||||
Dim ListaPS = JArray.Parse(JsonRequest("productos").ToString())
|
|
||||||
|
|
||||||
For Each JsonPS As JObject In ListaPS
|
|
||||||
|
|
||||||
Dim Cantidad As Double = JsonPS("cantidad").ToString.ToDouble()
|
|
||||||
Dim CvePS As Integer = GlobalDTPSSimplificado(Codigo:=JsonPS("codigo").ToString()).FiltroPrimeroValor("CvePS").ToEntero()
|
|
||||||
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
||||||
Dim CveUM As Integer
|
|
||||||
If ObjProductosServicios.GetPS(CvePS, -1, CveEmpresa) Then
|
|
||||||
If ObjProductosServicios.DtResultados.Rows.Count > 0 Then
|
|
||||||
CveUM = ObjProductosServicios.CveUnidadMedida.ToString.ToEntero
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
If ObjInventario.GetExistenciasPS(CvePS, CveUM, CveEmpresa, CveAlmacen, FechaMovto:=String.Format("{0} 00:00", Fecha.ToString("yyyy/MM/dd"))) >= Cantidad Then
|
|
||||||
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, 0, Observaciones:=observaciones, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
||||||
Mensaje = "Error al guardar los movimientos"
|
|
||||||
RespuestaError.Message = Mensaje
|
|
||||||
|
|
||||||
ErrorMovInv = True
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Else
|
Else
|
||||||
If UsuarioActual.TienePermisoProceso(114) Then
|
|
||||||
If ObjInventario.GetExistenciasPS(CvePS, CveUM, CveEmpresa, CveAlmacen, FechaMovto:=String.Format("{0} 00:00", Fecha.ToString("yyyy/MM/dd"))) >= Cantidad Then
|
End If
|
||||||
|
|
||||||
|
''VALIDA EXISTENCIAS
|
||||||
|
Dim Cont As Integer = 0
|
||||||
|
Dim ListaPS = JArray.Parse(JsonRequest("productos").ToString())
|
||||||
|
|
||||||
|
For Each JsonPS As JObject In ListaPS
|
||||||
|
|
||||||
|
Dim Cantidad As Double = JsonPS("cantidad").ToString.ToDouble()
|
||||||
|
Dim CvePS As Integer = GlobalDTPSSimplificado(Codigo:=JsonPS("codigo").ToString()).FiltroPrimeroValor("CvePS").ToEntero()
|
||||||
|
Dim DrPS As DataRow = GlobalDTPS(CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
||||||
|
Dim CveUM As Integer
|
||||||
|
If ObjProductosServicios.GetPS(CvePS, -1, CveEmpresa) Then
|
||||||
|
If ObjProductosServicios.DtResultados.Rows.Count > 0 Then
|
||||||
|
CveUM = ObjProductosServicios.CveUnidadMedida.ToString.ToEntero
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
If ObjInventario.GetExistenciasPS(CvePS, CveUM, CveEmpresa, CveAlmacen, FechaMovto:=String.Format("{0} 00:00", Fecha.ToString("yyyy/MM/dd"))) >= Cantidad Then
|
||||||
|
|
||||||
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, 0, Observaciones:=observaciones, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||||
Mensaje = "Error al guardar los movimientos"
|
Mensaje = "Error al guardar los movimientos"
|
||||||
RespuestaError.Message = Mensaje
|
|
||||||
ErrorMovInv = True
|
ErrorMovInv = True
|
||||||
Exit For
|
Exit For
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
SinExistencia += String.Format("{0}, ", JsonPS("codigo").ToString())
|
If UsuarioActual.TienePermisoProceso(114) Then
|
||||||
RespuestaError.Message = SinExistencia
|
If ObjInventario.GetExistenciasPS(CvePS, CveUM, CveEmpresa, CveAlmacen, FechaMovto:=String.Format("{0} 00:00", Fecha.ToString("yyyy/MM/dd"))) >= Cantidad Then
|
||||||
ErrorMovInv = True : Exit For
|
Mensaje = "Error al guardar los movimientos"
|
||||||
|
ErrorMovInv = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
SinExistencia += String.Format("{0}, ", JsonPS("codigo").ToString())
|
||||||
|
ErrorMovInv = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Cont += 1
|
||||||
|
Next
|
||||||
|
Mensaje = SinExistencia
|
||||||
|
'Registro la prepóliza
|
||||||
|
If Not ErrorMovInv AndAlso ObjInventario.GetMovimientosDetalle(CveMovimiento, CveEmpresa) Then
|
||||||
|
Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL()
|
||||||
|
Dim tValorOtro As Decimal = tValorInventario
|
||||||
|
Dim idCtaContable As Integer = 0
|
||||||
|
Dim IdCtaContableOtro As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
||||||
|
Dim TipoMovtoAlmacen As Boolean = False
|
||||||
|
Dim TipoMovtoOtro As Boolean = True
|
||||||
|
Dim tCveSubProyecto As Integer = -1
|
||||||
|
|
||||||
|
Dim drA2 As DataRow = GlobalDTAlmacen(CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", CveAlmacen))
|
||||||
|
If drA2 IsNot Nothing Then
|
||||||
|
idCtaContable = drA2("IdCtaContable").ToString.ToEntero
|
||||||
|
tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero
|
||||||
End If
|
End If
|
||||||
|
|
||||||
End If
|
|
||||||
Cont += 1
|
|
||||||
Next
|
|
||||||
'Registro la prepóliza
|
|
||||||
If Not ErrorMovInv AndAlso ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
||||||
Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL()
|
|
||||||
Dim tValorOtro As Decimal = tValorInventario
|
|
||||||
Dim idCtaContable As Integer = 0
|
|
||||||
Dim IdCtaContableOtro As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
|
||||||
Dim TipoMovtoAlmacen As Boolean = False
|
|
||||||
Dim TipoMovtoOtro As Boolean = True
|
|
||||||
Dim tCveSubProyecto As Integer = -1
|
|
||||||
|
|
||||||
Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", CveAlmacen))
|
|
||||||
If drA2 IsNot Nothing Then
|
|
||||||
idCtaContable = drA2("IdCtaContable").ToString.ToEntero
|
|
||||||
tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & 3).ToEntero
|
||||||
|
If OrigenMov = 1 Then TipoMovtoAlmacen = False Else TipoMovtoAlmacen = True
|
||||||
|
TipoMovtoOtro = Not TipoMovtoAlmacen
|
||||||
|
|
||||||
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & 3).ToEntero
|
Dim CveConceptoContable As Integer = 78
|
||||||
If OrigenMov = 1 Then TipoMovtoAlmacen = False Else TipoMovtoAlmacen = True
|
Dim CveClasificacion As Integer = -1
|
||||||
TipoMovtoOtro = Not TipoMovtoAlmacen
|
|
||||||
|
|
||||||
Dim CveConceptoContable As Integer = 78
|
|
||||||
Dim CveClasificacion As Integer = -1
|
|
||||||
|
|
||||||
|
|
||||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAlmacen, tValorInventario, observaciones, 68, observaciones, Fecha, idCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorInventario, CveClasificacion:=CveClasificacion, Contabilizable:=EsContabilizable) Then
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAlmacen, tValorInventario, observaciones, 68, observaciones, Fecha, idCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorInventario, CveClasificacion:=CveClasificacion, Contabilizable:=EsContabilizable) Then
|
||||||
ErrorMovInv = True
|
|
||||||
Else
|
|
||||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoOtro, tValorOtro, observaciones, CveConceptoContable, observaciones, Fecha, IdCtaContableOtro, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorOtro, CveSubProyecto:=tCveSubProyecto, CveClasificacion:=CveClasificacion, Contabilizable:=EsContabilizable) Then
|
|
||||||
ErrorMovInv = True
|
ErrorMovInv = True
|
||||||
End If
|
|
||||||
'End Select
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
ErrorMovInv = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
'------------------------------------------------
|
|
||||||
If Not ErrorMovInv Then
|
|
||||||
'DEVENGAR
|
|
||||||
Dim TotalPorDevengar As Double = 0
|
|
||||||
|
|
||||||
'cuando tiene AC y es salida de almacen, se manda al gasto, solo aplica si el almacen es contable
|
|
||||||
If UsuarioActual.Empresa.UsaAC AndAlso EsContabilizable Then
|
|
||||||
Dim DtII As DataTable = Nothing
|
|
||||||
Dim TotalDetalle As Double = 0.0
|
|
||||||
Dim Importe As Decimal = 0
|
|
||||||
'NOTA. CUANDO ES SALIDA, EN AUTOMATICO NO TENEMOS LOS VALORES DE LA SALIDA TODAVIA, Y POR ESO IMPORTE ES CERO, ES RECARGAR CON LOS DATOS YA INSERTADOS
|
|
||||||
|
|
||||||
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
||||||
DtII = ObjInventario.DtResultados
|
|
||||||
End If
|
|
||||||
|
|
||||||
TotalPorDevengar += Importe ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4))
|
|
||||||
TotalPorDevengar = Math.Round(TotalPorDevengar, 4)
|
|
||||||
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
|
||||||
ObjContaAC.IniciaTransacSQL()
|
|
||||||
|
|
||||||
Dim AC As New ClsAC
|
|
||||||
Dim DtPresupuestos As DataTable = Nothing
|
|
||||||
If AC.GetPresupuestoEgresos(-1, True, UsuarioActual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then
|
|
||||||
DtPresupuestos = AC.DtResultados.Copy
|
|
||||||
Else
|
Else
|
||||||
Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError)
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoOtro, tValorOtro, observaciones, CveConceptoContable, observaciones, Fecha, IdCtaContableOtro, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorOtro, CveSubProyecto:=tCveSubProyecto, CveClasificacion:=CveClasificacion, Contabilizable:=EsContabilizable) Then
|
||||||
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
ErrorMovInv = True
|
||||||
|
End If
|
||||||
|
'End Select
|
||||||
End If
|
End If
|
||||||
AC.Dispose()
|
Else
|
||||||
|
ErrorMovInv = True
|
||||||
|
End If
|
||||||
|
|
||||||
IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, Fecha)
|
'------------------------------------------------
|
||||||
|
If Not ErrorMovInv Then
|
||||||
|
'DEVENGAR
|
||||||
|
Dim TotalPorDevengar As Double = 0
|
||||||
|
|
||||||
If IDPoliza > 0 Then
|
'cuando tiene AC y es salida de almacen, se manda al gasto, solo aplica si el almacen es contable
|
||||||
Dim CuentaCargoCOG As Integer
|
If UsuarioActual.Empresa.UsaAC AndAlso EsContabilizable Then
|
||||||
Dim CuentaAbonoAlmacen As Integer = 0
|
Dim DtII As DataTable = Nothing
|
||||||
Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", CveAlmacen))
|
Dim TotalDetalle As Double = 0.0
|
||||||
|
Dim Importe As Decimal = 0
|
||||||
|
'NOTA. CUANDO ES SALIDA, EN AUTOMATICO NO TENEMOS LOS VALORES DE LA SALIDA TODAVIA, Y POR ESO IMPORTE ES CERO, ES RECARGAR CON LOS DATOS YA INSERTADOS
|
||||||
|
|
||||||
If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
||||||
If UsuarioActual.CveEmpresa = 48 Then ' APH
|
DtII = ObjInventario.DtResultados
|
||||||
CuentaCargoCOG = 1386
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim ConceptoRenglon As String = "Salida de Almacen"
|
TotalPorDevengar += Importe ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4))
|
||||||
|
TotalPorDevengar = Math.Round(TotalPorDevengar, 4)
|
||||||
|
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
||||||
|
ObjContaAC.IniciaTransacSQL()
|
||||||
|
|
||||||
|
Dim AC As New ClsAC
|
||||||
|
Dim DtPresupuestos As DataTable = Nothing
|
||||||
|
If AC.GetPresupuestoEgresos(-1, True, UsuarioActual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then
|
||||||
|
DtPresupuestos = AC.DtResultados.Copy
|
||||||
|
Else
|
||||||
|
Mensaje = "Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página"
|
||||||
|
End If
|
||||||
|
AC.Dispose()
|
||||||
|
|
||||||
|
IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, Fecha)
|
||||||
|
|
||||||
If IDPoliza > 0 Then
|
If IDPoliza > 0 Then
|
||||||
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
Dim CuentaCargoCOG As Integer
|
||||||
Dim DtMovtos = ObjInventario.DtResultados
|
Dim CuentaAbonoAlmacen As Integer = 0
|
||||||
Importe = DtMovtos.SUMD("Total", "Estatus = ''")
|
Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", CveAlmacen))
|
||||||
|
|
||||||
If Importe > 0 Then
|
If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero
|
||||||
If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then
|
If UsuarioActual.CveEmpresa = 48 Then ' APH
|
||||||
If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
CuentaCargoCOG = 1386
|
||||||
'actualizo el idcuenta del presupuesto
|
End If
|
||||||
If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
|
||||||
|
Dim ConceptoRenglon As String = "Salida de Almacen"
|
||||||
|
|
||||||
|
If IDPoliza > 0 Then
|
||||||
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
||||||
|
Dim DtMovtos = ObjInventario.DtResultados
|
||||||
|
Importe = DtMovtos.SUMD("Total", "Estatus = ''")
|
||||||
|
|
||||||
|
If Importe > 0 Then
|
||||||
|
If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then
|
||||||
|
If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
||||||
|
'actualizo el idcuenta del presupuesto
|
||||||
|
If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
||||||
|
ErrorAC = True
|
||||||
|
Mensaje = "No se pudo insertar movimiento en la poliza 2."
|
||||||
|
End If
|
||||||
|
Else
|
||||||
ErrorAC = True
|
ErrorAC = True
|
||||||
Mensaje = "No se pudo insertar movimiento en la poliza 2."
|
Mensaje = "No se pudo insertar movimiento en la poliza 1."
|
||||||
End If
|
End If
|
||||||
Else
|
|
||||||
ErrorAC = True
|
|
||||||
Mensaje = "No se pudo insertar movimiento en la poliza 1."
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
|
|
||||||
If IDPoliza > 0 Then
|
If IDPoliza > 0 Then
|
||||||
ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa)
|
ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
ErrorAC = True
|
||||||
|
Mensaje = "No se pudo insertar la poliza"
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
If Not ErrorAC And Not ErrorMovInv Then
|
||||||
|
Dim Msg As New StringBuilder
|
||||||
|
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)))
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
ObjInventario.Commit() ' aplica los movimientos insertados
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
|
||||||
|
|
||||||
|
|
||||||
|
'Limpia Valores cuando inserta de campos especiales
|
||||||
|
|
||||||
Else
|
Else
|
||||||
ErrorAC = True
|
ObjInventario.RollBack()
|
||||||
Mensaje = "No se pudo insertar la poliza"
|
CveMovimiento = 0
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
If Not ErrorAC And Not ErrorMovInv Then
|
|
||||||
Dim Msg As New StringBuilder
|
|
||||||
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)))
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
ObjInventario.Commit() ' aplica los movimientos insertados
|
|
||||||
If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
|
|
||||||
|
|
||||||
|
|
||||||
'Limpia Valores cuando inserta de campos especiales
|
|
||||||
|
|
||||||
Else
|
Else
|
||||||
ObjInventario.RollBack()
|
ObjInventario.RollBack() 'deshace lo insertado
|
||||||
CveMovimiento = 0
|
CveMovimiento = 0
|
||||||
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
Else
|
Catch ex As Exception
|
||||||
ObjInventario.RollBack() 'deshace lo insertado
|
Try 'por si ya le habian dado rollback o commit
|
||||||
|
ObjInventario.RollBack() 'deshace lo insertad
|
||||||
|
Catch exx As Exception
|
||||||
|
|
||||||
|
End Try
|
||||||
CveMovimiento = 0
|
CveMovimiento = 0
|
||||||
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||||
End If
|
GuardaLog("Ocurrió un Error inesperado en el registro" & ex.ToString())
|
||||||
|
Mensaje = "Ocurrió un Error inesperado en el registro" & ex.ToString()
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Try 'por si ya le habian dado rollback o commit
|
|
||||||
ObjInventario.RollBack() 'deshace lo insertad
|
|
||||||
Catch exx As Exception
|
|
||||||
|
|
||||||
|
TieneError = True
|
||||||
End Try
|
End Try
|
||||||
CveMovimiento = 0
|
End If
|
||||||
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
|
||||||
GuardaLog("Ocurrió un Error inesperado en el registro" & ex.ToString())
|
|
||||||
Mensaje = "Ocurrió un Error inesperado en el registro" & ex.ToString()
|
|
||||||
|
|
||||||
TieneError = True
|
|
||||||
End Try
|
|
||||||
|
|
||||||
ObjInventario.Dispose() 'elimino la instancia
|
ObjInventario.Dispose() 'elimino la instancia
|
||||||
If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose()
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose()
|
||||||
|
|||||||
Reference in New Issue
Block a user