From c1670b8c6639fa89ee1ad6ee6092d0bc9e754d45 Mon Sep 17 00:00:00 2001 From: rrene Date: Sat, 15 May 2021 18:38:25 -0700 Subject: [PATCH] Registro contable de traspaso --- Inventarios/EntregaAlmacen.aspx.vb | 88 ++++++++++++++++++------------ 1 file changed, 54 insertions(+), 34 deletions(-) diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index 3bf93937c..a64e7c2db 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -3075,7 +3075,8 @@ Partial Class Inventarios_EntregaAlmacen End If Dim ObjInventario As New ClsInventarios : ObjInventario.IniciaTransacSQL() - Dim ObjGeneral As New ClsGenerales(ObjInventario.IniciaTransacSQL()) + Dim ObjGeneral As New ClsGenerales(ObjInventario.IniciaTransacSQL()) + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) Dim CveMovimientoSalida As Integer Dim ConceptoMovimiento = 0 Dim FolioSalida As Integer @@ -3221,38 +3222,39 @@ Partial Class Inventarios_EntregaAlmacen TextoError = "Ocurrió un error al generar el movimiento de salida." ErrorMovInv = True End If - End If - + End If + + Dim ValorTraspaso As Decimal = 0 'ENTRADA POR TRASPASO - If Not ErrorMovInv Then - 'sino es transitorio, los transitorios, ya no se hace otro movimiento - If Not ChkTransitorio.Checked Then - ConceptoMovimiento = 27 ' If(ChkTransitorio.Checked, 2, 27) - Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero(), CveAlmacenTraspasoDestino) + If Not ErrorMovInv Then + 'sino es transitorio, los transitorios, ya no se hace otro movimiento + + ConceptoMovimiento = If(ChkTransitorio.Checked, 2, 27) + Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero(), CveAlmacenTraspasoDestino) CveMovimientoEntrada = ObjInventario.AddMovimiento(Almacen2, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalida, CveAlmacenDestino:=CveAlmacenTraspasoDestino, - Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT1", CveOP:=CveOP) - FolioEntrada = ObjInventario.Folio - If CveMovimientoEntrada > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - Dim CveSeccionAlmacen As Integer = -1 - For Each Dr As DataRow In ObjInventario.DtResultados.Rows + Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT1", CveOP:=CveOP) + FolioEntrada = ObjInventario.Folio + If CveMovimientoEntrada > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + Dim CveSeccionAlmacen As Integer = -1 + ValorTraspaso = ObjInventario.DtResultados.SUMD("Total").RoundSQL + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + + CveSeccionAlmacen = -3 + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString(), Lote:=Dr("Lote").ToString(), FechaCaducidad:=Dr("FechaCaducidad").ToString().ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero()) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al guardar los movimientos de entrada" + Exit For + End If + Next + End If + Else + TextoError = "Ocurrió un error al generar el movimiento de entrada" + ErrorMovInv = True + End If - CveSeccionAlmacen = -3 - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString(), Lote:=Dr("Lote").ToString(), FechaCaducidad:=Dr("FechaCaducidad").ToString().ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero()) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - End If - Next - End If - Else - TextoError = "Ocurrió un error al generar el movimiento de entrada" - ErrorMovInv = True - End If - End If - End If 'MARCA SOLICITUD CON EL MOVIMIENTO GENERADO @@ -3261,18 +3263,18 @@ Partial Class Inventarios_EntregaAlmacen TextoError = "Ocurrió un error al vincular los movimientos con la solicitud de traspaso. Por favor verifique y vuelva a intentar" ErrorMovInv = True End If - End If - + End If + + Dim Fecha As Date = TxtFecha.Text.ToDate 'Paqueterias Guias If RbEntregaInterna.Checked AndAlso Not ErrorMovInv Then - Dim CveEstatus As Integer = 0 ' DdlEstatus.SelectedValue.ToEntero() - Dim Fecha As String = Now.ToString() 'TxtFechaPaqInterna.Text + Dim CveEstatus As Integer = 0 ' DdlEstatus.SelectedValue.ToEntero() Dim FechaEstimada As String = "-1" 'If(TxtFechaEstimada.Text = "", "-1", TxtFechaEstimada.Text) Dim NoCajas As Integer = 0 'TxtNoCajas.Text.ToEntero() Dim Observaciones As String = "" 'TxtObservacionesPaqInterna.Text Dim CvePaqueteria As Integer = GlobalDTPaqueterias(UsuarioActual.CveEmpresa, 0).FiltroPrimeroValor("CvePaqueteria", "").ToEntero() - Dim CvePaqueteriaGuia As Integer = ObjGeneral.AddPaqueteriasGuias(CvePaqueteria, 9, CveEstatus, CveSubProyecto, Fecha, "-1", "-1", NoCajas, 0.00, "-1", FechaEstimada, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, EsEntregaInterna:=True) + Dim CvePaqueteriaGuia As Integer = ObjGeneral.AddPaqueteriasGuias(CvePaqueteria, 9, CveEstatus, CveSubProyecto, Fecha.ToShortDateString, "-1", "-1", NoCajas, 0.00, "-1", FechaEstimada, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, EsEntregaInterna:=True) If CvePaqueteriaGuia > 0 Then If CveVentaSurtir > 0 OrElse CveSubProyecto > 0 Then @@ -3286,8 +3288,26 @@ Partial Class Inventarios_EntregaAlmacen ErrorMovInv = True Alert("Error en el paqueteria guia", TipoMensaje.MsgError) End If + End If + + 'AGREGAMOS PREPOLIZAS TRASPASO DIRECTO: + + Dim CvePrePolizaTraspaso As Integer = ObjConta.AddPrePolizas("EA/GT", 53, 0, 0, 1, Fecha, "Traspaso", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePolizaTraspaso > 0 Then + + + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, True, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then + ErrorMovInv = True + End If + + If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, False, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then + ErrorMovInv = True + End If + Else + ErrorMovInv = True End If + If Not ErrorMovInv Then ObjInventario.Commit() ObjGeneral.Dispose()