From d377739ac91738e5d7c2ddd86218dbda73604060 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 28 Aug 2021 11:19:27 -0700 Subject: [PATCH] Autorizacion de cotizaciones, saldo de almacen en refacturacion --- Ventas/Ventas.aspx.vb | 86 +++++++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c18431878..d7df65f78 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -1834,6 +1834,15 @@ Partial Class Ventas ViewState("CveEstatus") = value End Set End Property + + Private Property CveEstatusCotizacion As Integer + Get + Return (IfNull(ViewState("CveEstatusCotizacion"), "-1", ViewState("CveEstatusCotizacion"))).ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("CveEstatusCotizacion") = value + End Set + End Property Private Property DiasCredito As Integer Get Return ViewState("DiasCredito").ToString().ToEntero() @@ -2939,6 +2948,18 @@ Partial Class Ventas End If End If + If Request("CveCotizacion") IsNot Nothing AndAlso IfNull(Request("CveCotizacion"), 0).ToString().ToEntero() > 0 Then + If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then + 'VERIFICA SI NO ESTA AUTORIZADA + If CveEstatusCotizacion <> 8 Then + BtnEmitirImprimir.Enabled = False + BtnEmitirImprimir.Visible = False + Alert("La cotización no esta autorizada", TipoMensaje.MsgAdvertencia) + End If + End If + + End If + End If ''EN REALIDAD SE OCUPAN ESTAS COSAS DENTRO DEL POSTABCK ??? @@ -4426,6 +4447,8 @@ Partial Class Ventas ' BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) ' BtnsFacturar.Visible = True 'End If + ElseIf DbRowVenta("TipoDocto").ToString() = "Cot" AndAlso CveCotizacion > 0 Then + CveEstatusCotizacion = DbRowVenta("CveEstatusFactura").ToString().ToEntero() End If @@ -8207,33 +8230,56 @@ Partial Class Ventas If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") End If - End If - 'MARCAR VENTA ANTERIOR - If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then - ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") - End If - - 'MARCA LO PENDIENTE A NIVEL DETALLE - Dim DtMovDetalles As DataTable = Nothing - If ObjInventario.GetSaldoVentaDetalle(CveDevolucion, UsuarioActual.CveEmpresa) Then - DtMovDetalles = ObjInventario.DtResultados.Copy() + 'MARCAR VENTA ANTERIOR + If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then + ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") + End If Else - ErrorList.Add("No se pudo verificar los movimientos de almacen de la factura") - End If + 'MARCA LO PENDIENTE A NIVEL DETALLE + Dim DtMovDetalles As DataTable = Nothing + If ObjInventario.GetSaldoVentaDetalle(CveDevolucion, UsuarioActual.CveEmpresa) Then + DtMovDetalles = ObjInventario.DtResultados.Copy() + Else + ErrorList.Add("No se pudo verificar los movimientos de almacen de la factura") + End If - If DtMovDetalles IsNot Nothing Then - For Each Row As DataRow In DtMovDetalles.Rows - Dim SaldoAlmacen As Decimal = Row("SaldoAlmacen").ToString().ToDecimal() - If SaldoAlmacen < 0 Then - If Not ObjInventario.UpdateEstatusAlmacen(Row("CveVentaDetalleNueva").ToString().ToEntero(), 1) Then - ErrorList.Add("No se pudo actualizar el movimiento de almacen de la factura") + 'MARCAR VENTA ANTERIOR + If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then + ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") + End If + + If DtMovDetalles IsNot Nothing Then + + Dim CantidadTotal As Decimal = 0 + Dim TotalSalida As Decimal = 0 + + For Each Row As DataRow In DtMovDetalles.Rows + Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal() + Dim SaldoAlmacen As Decimal = Row("SaldoAlmacen").ToString().ToDecimal() + Cantidad += Cantidad + + If SaldoAlmacen < 0 AndAlso Cantidad = Math.Abs(SaldoAlmacen) Then + TotalSalida += Math.Abs(SaldoAlmacen) + If Not ObjInventario.UpdateEstatusAlmacen(Row("CveVentaDetalleNueva").ToString().ToEntero(), 1) Then + ErrorList.Add("No se pudo actualizar el movimiento de almacen de la factura") + End If + End If + Next + + 'SI SE VERIFICA QUE TODO ESTA SURTIDO, SE MARCA TODA LA FACTURA + If CantidadTotal = Total Then + If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then + ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura") End If End If - Next + End If + + DtMovDetalles.Dispose() + End If - DtMovDetalles.Dispose() + End If End If