From 13d28b74620dfb7aaaef69be6dea37b3e8db3a73 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 25 Feb 2021 15:19:45 -0700 Subject: [PATCH] ajustes d elote/caducidad --- Inventarios/AjustesSeccionAlmacen.aspx | 2 +- Inventarios/AjustesSeccionAlmacen.aspx.vb | 45 ++++++++++++++++++----- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Inventarios/AjustesSeccionAlmacen.aspx b/Inventarios/AjustesSeccionAlmacen.aspx index 9fa2e1466..f0856d143 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx +++ b/Inventarios/AjustesSeccionAlmacen.aspx @@ -88,7 +88,7 @@ <%----%> - + diff --git a/Inventarios/AjustesSeccionAlmacen.aspx.vb b/Inventarios/AjustesSeccionAlmacen.aspx.vb index e782f0758..dce146164 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx.vb +++ b/Inventarios/AjustesSeccionAlmacen.aspx.vb @@ -42,7 +42,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen If ObjInv.DtResultados.FiltraParametros("Serie <> '' ").Rows.Count = 0 Then GvD.columns(2).visible = False If ObjInv.DtResultados.FiltraParametros("Lote <> ''").Rows.Count = 0 Then GvD.columns(3).visible = False - If ObjInv.DtResultados.FiltraParametros("FechaCaducidad <> ''").Rows.Count = 0 Then GvD.columns(4).visible = False + If ObjInv.DtResultados.FiltraParametros("FechaCaducidad IS NOT NULL ").Rows.Count = 0 Then GvD.columns(4).visible = False If ObjInv.DtResultados.FiltraParametros("CveSeccionAlmacen > 0").Rows.Count = 0 Then GvD.columns(5).visible = False End If @@ -368,6 +368,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen Dim ObjInventario As New ClsInventarios() Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL()) + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL) Try Dim DtExistenciasSecciones As DataTable = Nothing @@ -381,10 +382,11 @@ Partial Class Inventarios_AjustesSeccionAlmacen 'ENTRADA ALMACÉN Dim CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 2, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="", TipoCambio:=-1, - MovimientoFijo:=False, Modulo:="ASA/EA") + MovimientoFijo:=False, Modulo:="ASA/EA", CveMovimientoRelacionado:=CveMovimientoSalida) Dim dtSecciones As DataTable = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, CveAlmacen) dtSecciones.CaseSensitive = False + Dim resultado As DataTable = Nothing For Each RowExcel As DataRow In DtExcel.Rows @@ -415,9 +417,9 @@ Partial Class Inventarios_AjustesSeccionAlmacen Dim RowExistencia As DataRow = DtExistenciasSecciones.FiltroPrimero($"CvePS={CvePS} and ISNULL(Serie,'') = '{Serie}'") - If RowExistencia IsNot Nothing AndAlso CveSeccionAlmacen > 0 Then + If RowExistencia IsNot Nothing Then Dim CveSeccionAlmacenSalida As Integer = RowExistencia("CveSeccionAlmacen").ToString().ToEntero() - Dim CantidadSalida As Decimal = RowExistencia("Existencia").ToString().ToDecimal() + Dim CantidadSalida As Decimal = RowExcel("Cantidad").ToString().ToDecimal() Dim SerieSalida As String = RowExistencia("Serie").ToString() Dim LoteSalida As String = RowExistencia("Lote").ToString() Dim FechaCaducidadSalida As Date = IfNull(RowExistencia("FechaCaducidad"), MinFecha).ToString.ToDate @@ -440,9 +442,11 @@ Partial Class Inventarios_AjustesSeccionAlmacen ErrorMovInv = CveMovimientoDetalleSalida <= 0 - 'GENERA LA ENTRADA DE LOS PRODUCTOS QUE SE DIERON ENTRADA + 'GENERA LA ENTRADA DE LOS PRODUCTOS QUE SE DIERON SALIDA If Not ErrorMovInv Then If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa, CveMovimientoDetalle:=CveMovimientoDetalleSalida) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + + resultado = ObjInventario.DtResultados Dim RowEntrada As DataRow = ObjInventario.DtResultados.Rows(0) Dim CvePSEntrada = RowEntrada("CvePS").ToString().ToEntero() @@ -452,9 +456,12 @@ Partial Class Inventarios_AjustesSeccionAlmacen Dim CostoIndirecto As Decimal = RowEntrada("CostoIndirecto").ToString().ToDecimal() 'ACTUALIZAMOS EL PS, PARA QUE TENGA EL APLICA SECCION - ErrorMovInv = Not ObjPS.UpdateAplicaSeccionAlmacen(CvePS, UsuarioActual.CveEmpresa, True) - If Not ObjInventario.AddProductosServiciosAlmacenSeccion(CvePS, CveAlmacen, CveSeccionAlmacen) Then - ErrorMovInv = True + + If CveSeccionAlmacen > 0 Then + ErrorMovInv = Not ObjPS.UpdateAplicaSeccionAlmacen(CvePS, UsuarioActual.CveEmpresa, True) + If Not ObjInventario.AddProductosServiciosAlmacenSeccion(CvePS, CveAlmacen, CveSeccionAlmacen) Then + ErrorMovInv = True + End If End If If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, CantidadEntrada, CveUMEntrada, CvePSEntrada, PUEntrada, -1, CostoIndirecto:=CostoIndirecto, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -475,7 +482,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen ErrorMovInv = True End If - If CveSeccionAlmacen <= 0 Then + If CveSeccionAlmacen <= 0 And SeccionAlmacen <> "" Then SeccionesNoEncontradas.AppendFormat("{0},", SeccionAlmacen) ErrorMovInv = True End If @@ -489,6 +496,26 @@ Partial Class Inventarios_AjustesSeccionAlmacen Next dtSecciones.Dispose() + 'inserto la prepoliza + If CveMovimientoEntrada > 0 AndAlso CveMovimientoSalida > 0 Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + + resultado = ObjInventario.DtResultados + + Dim Concepto As String = "Ajuste Sección" + Dim IdCtaContableOrigen As Integer = 0 + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/AjusteAlmacen", 53, 0, 0, 1, Now, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim importe As Decimal = resultado.SUMD("Total").RoundSQL + Dim contabilizable As Boolean = False + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, Concepto, 68, Concepto, Now, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, Concepto, 68, Concepto, Now, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + End If + End If + Catch ex As Exception ErrorMovInv = True OnError("Ocurrió un error al agregar el inventario", ex)