From 7ff86b07b2016066d347fe7c26d588679df6977f Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 10 Feb 2023 18:26:15 -0700 Subject: [PATCH] Cancelacion del traspaso por cantidad especificada --- Inventarios/TraspasoAlmacen.aspx.vb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index e651739bc..2394c7a2c 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -1647,9 +1647,9 @@ Partial Class Inventarios_TraspasoAlmacen 'DEBE CONSIDERAR SOLO LAS FILAS QUE TENGA PRODUCTOS, NO EL TOTALIZADOR If CvePS > 0 Then CveMovimientoDetalleSalida = GvRow.DataKey("CveMovimientoDetalle").ToEntero - Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal + Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidad").Text.ToString.ToDecimal - If ChkRealizarDevolucion.Checked Then Cantidad = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal + 'If ChkRealizarDevolucion.Checked Then Cantidad = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal Dim PrecioUnitario As Decimal = GvRow.DataKey("PU").ToDecimal If CveMovimientoDetalleSalida <= 0 Then @@ -1657,7 +1657,16 @@ Partial Class Inventarios_TraspasoAlmacen TextoError = "Ocurrió un error al guardar los movimientos de salida" Exit For End If - If Cantidad <> 0 Then + + Dim cantidadDisponibleValidacion As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtCantidad").Text.ToString.ToDecimal + + If cantidadDisponibleValidacion < 0 Then + ErrorMovInv = True + TextoError = $"La cantidad a cancelar del producto '{GvRow.DataKey("Codigo")}-{GvRow.DataKey("PS")}' excede la del traspaso" + Exit For + End If + + If Cantidad > 0 Then If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, GvRow.DataKey("CveUM").ToEntero, CvePS, PrecioUnitario, -1, -1, Serie:=GvRow.DataKey("Serie"), Lote:=GvRow.DataKey("Lote"), FechaCaducidad:=GvRow.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then ErrorMovInv = True TextoError = "Ocurrió un error al guardar los movimientos de entrada"