considear la serie

This commit is contained in:
2022-09-23 16:23:00 -07:00
parent 495a74bf74
commit 52c498d331

View File

@@ -593,9 +593,6 @@ Partial Class Inventarios_TraspasoAlmacen
End If
End If
'codigo provisional.
Dim CveSubP As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenOrigen.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto", "").ToEntero
If DrPS("AplicaCaducidad").ToString = "True" Then
If Not ChkSugiereFechaCaducidad.Checked AndAlso (TxtnFechaCaducidad.Text = "" OrElse TxtnLote.Text = "") Then
Alert("Falta Especificar lote/Fecha del producto", TipoMensaje.MsgAdvertencia)
@@ -790,10 +787,10 @@ Partial Class Inventarios_TraspasoAlmacen
Private Sub LimpiaAgregar()
'DdlClasificacion.SelectedValue = "-1"
'DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty)
txtCantidad.Text = ""
txtCantidad.Text = "1"
TxtnObservaciones.Text = ""
TxtnSerie.Text = ""
TxtnSerie.Visible = False
'TxtnSerie.Visible = False
TxtnLote.Text = ""
TxtnFechaCaducidad.Text = ""
@@ -951,14 +948,33 @@ Partial Class Inventarios_TraspasoAlmacen
If ObjInventario.GetExistenciasProducto(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, Caducidad:=FechaCaducidad) Then
'si hay existencia en almacen costeado, lo tengo que sacar
' si tiene serie el producto, debe de
Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
Dim ExistenciaSinPendiente As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("Existencia", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
Dim PendienteporSurtir As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("PendientePorSurtir", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
' si la existencia es negativa y tiene serie ó lote, quiere decir que la consulta es específica, y si hay pendientes por surtir. puede generar negativos
' para asegurarnos que lo pendiente por surtir se pueda surtir con otras series, consultamos de nuevo, pero a nivel producto, para checar existencia
If ExistenciaSinPendiente > 0 AndAlso Existencia < 0 AndAlso PendienteporSurtir > 0 Then
If ObjInventario.GetExistenciasProducto(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd 23:59")) Then
'si hay existencia en almacen costeado, lo tengo que sacar
Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
'si la existencia del producto en general, supera a lo pendiente, entonces la serie si se puede sacar.
If Existencia > PendienteporSurtir Then
Existencia = ExistenciaSinPendiente
Else
Existencia = ExistenciaSinPendiente - PendienteporSurtir
End If
End If
End If
End If
Existencia -= gvr.FCTextBox("TxtCantidad2").Text.ToEntero()
If Existencia < 0 Then
ErrorExistencia = True
'gvr.FCTextBox("TxtCantidad2").Text = (Existencia + gvr.FCTextBox("TxtCantidad2").Text.ToEntero).ToString
TextoExistencia.AppendFormat("-<b>#{0}</b> {1} {2} &nbsp; Existencia: <b>{3}</b><br/>", gvr.DataKey("No"), gvr.DataKey("PS"), If(gvr.DataKey("Serie").ToString().Trim().Length > 0, $" &nbsp; Serie: <b>{gvr.DataKey("Serie")}</b>", ""), (Existencia + gvr.FCTextBox("TxtCantidad2").Text.ToEntero))
End If
Next
@@ -1224,8 +1240,6 @@ Partial Class Inventarios_TraspasoAlmacen
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
End If
' If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose()
'SI OCURRIO UN ERROR EN LA EXISTENCIA RECARGAMOS EL GRID PARA COLOREAR LOS DETALLES CON ERROR
If ErrorExistencia Then
CargaGvDatos()
@@ -1234,98 +1248,6 @@ Partial Class Inventarios_TraspasoAlmacen
ObjInventario.Dispose()
End Sub
'Function ConsumoInterno(TipoAlmacenOrigen As Integer, TipoAlmacenDestino As Integer) As Boolean
' Dim Retorno As Boolean = False
' Dim ErrorMovInv As Boolean = False
' Dim TextoError As String = ""
' Dim Fecha As Date = TxtFecha.Text.ToDate
' Dim ObjInventario As New ClsInventarios
' Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
' Dim CveMovimiento As Integer = 0
' Dim TipoMovto = If(TipoAlmacenOrigen = 14, -1, 1)
' Dim CveConceptoInventario As Integer = 8
' Dim CveAlmacenCI = If(TipoAlmacenOrigen = 14, DdlAlmacenOrigen.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero)
' Dim DtCostos As DataTable = Nothing
' Dim ValorInventario As Decimal = 0
' 'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN
' CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, CveConceptoInventario, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
' Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""),
' GastoIndirecto:=If(ChkTransitorio.Checked And TxtGastoIndirecto.Text.ToDouble > 0, TxtGastoIndirecto.Text, "-1").ToDouble, Modulo:="TA/G4")
' Dim FolioMov As Integer = ObjInventario.Folio
' If CveMovimiento <= 0 Then
' TextoError = "No se pudo generar el movimiento de salida correctamente"
' ErrorMovInv = True
' Else
' For Each Dr As DataRow In DtMovimientos.Rows
' If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, Dr("CveAF").ToString.ToEntero, -1, Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate) Then
' ErrorMovInv = True
' TextoError = "Ocurrió un error al guardar los movimientos de salida"
' Exit For
' End If
' Next
' End If
' If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
' DtCostos = ObjInventario.DtResultados
' Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
' Dim IdCtaContable As Integer = 0
' Dim CveCuenta As Integer = 0
' If tmpCostos.Rows.Count > 0 Then
' Dim Concepto As String = $"Consumo Interno: {ObjInventario.Folio} - {TxtObservaciones.Text}"
' Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv/ConsumoInterno", 53, DtCostos.SUM("Total") * TipoMovto, DtCostos.SUM("Total") * TipoMovto, 1, TxtFecha.Text.ToDate, $"Consumo Interno: {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
' For Each RowInv As DataRow In tmpCostos.Rows
' ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal
' IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
' CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorInventario * TipoMovto, Concepto, 181, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario * TipoMovto, CveCuenta:=CveCuenta) Then
' ErrorMovInv = True
' Exit For
' End If
' Next
' IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={CveAlmacenCI}").ToEntero
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DtCostos.SUM("Total").ToDecimal * TipoMovto, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUM("Total").ToDecimal * TipoMovto) Then
' ErrorMovInv = True
' End If
' End If
' End If
' If Not ErrorMovInv Then
' ObjInventario.Commit()
' Dim Mensaje As StringBuilder = New StringBuilder
' Mensaje.Append("Se realizó el consumo interno.")
' Mensaje.AppendFormat("<br/> Folio: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{0}</a></b>", FolioMov, CveMovimiento)
' Alert(Mensaje.ToString, TipoMensaje.MsgInformacion)
' Mensaje.Clear()
' LimpiaMovimiento()
' Else
' ObjInventario.RollBack()
' Alert(TextoError, TipoMensaje.MsgError)
' RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
' End If
' Return Retorno
'End Function
#End Region
@@ -1463,42 +1385,6 @@ Partial Class Inventarios_TraspasoAlmacen
TdFechaCaducidad.Visible = GvDatos.Columns(7).Visible : ThFechaCaducidad.Visible = GvDatos.Columns(7).Visible
GvDatos.Columns(8).Visible = DtTemp.MAX("CveSeccionAlmacen").ToString.ToEntero > 0
''TxtnSerie.Visible = False
''ThSerie.Visible = False
''TdSerie.Visible = False
'GvDatos.Columns(5).Visible = False
'TxtnLote.Visible = False
'ThLote.Visible = False
'TdLote.Visible = False
'GvDatos.Columns(6).Visible = False
'TxtnFechaCaducidad.Visible = False
'ThFechaCaducidad.Visible = False
'TdFechaCaducidad.Visible = False
'GvDatos.Columns(7).Visible = False
'If DtTemp.MAX("Serie").ToString <> "" Then
' TxtnSerie.Visible = True
' ThSerie.Visible = True
' TdSerie.Visible = True
' GvDatos.Columns(5).Visible = True
'End If
'If DtTemp.MAX("Lote").ToString <> "" Then
' TxtnLote.Visible = True
' ThLote.Visible = True
' TdLote.Visible = True
' GvDatos.Columns(6).Visible = True
'End If
'If DtTemp.MAX("FechaCaducidad").ToString.ToDate > MinFecha Then
' TxtnFechaCaducidad.Visible = True
' ThFechaCaducidad.Visible = True
' TdFechaCaducidad.Visible = True
' GvDatos.Columns(7).Visible = True
'End If
End Sub
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
@@ -1514,47 +1400,6 @@ Partial Class Inventarios_TraspasoAlmacen
e.Row.FCTextBox("TxtCantidad2").Attributes.Add("onblur", String.Format("ValidaCantidad(this,{0})", e.Row.DBCampo("Cantidad")))
End If
'If If(e.Row.DBCampo("Serie").ToString = "", "-1", e.Row.DBCampo("Serie").ToString) <> "-1" Then
' TxtnSerie.Visible = True
' ThSerie.Visible = True
' TdSerie.Visible = True
' GvDatos.Columns(4).Visible = True
' e.Row.Cells(4).Text = e.Row.DBCampo("Serie").ToString
'Else
' e.Row.Cells(4).Text = ""
'End If
'If If(e.Row.DBCampo("Lote").ToString = "", "-1", e.Row.DBCampo("Lote").ToString) <> "-1" Then
' TxtnLote.Visible = True
' ThLote.Visible = True
' TdLote.Visible = True
' GvDatos.Columns(5).Visible = True
' e.Row.Cells(5).Text = e.Row.DBCampo("Lote").ToString
' TxtnBatch.Visible = True
' ThBatch.Visible = True
' TdBatch.Visible = True
' GvDatos.Columns(6).Visible = True
'Else
' e.Row.Cells(5).Text = ""
' e.Row.Cells(6).Text = ""
'End If
'If e.Row.RowState = DataControlRowState.Edit Then
' e.Row.FCDropDownList("DdlUnidad").DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
' e.Row.FCDropDownList("DdlUnidad").DataBind()
' e.Row.FCDropDownList("DdlUnidad").SelectedValue = e.Row.DBCampo("CveUM")
' e.Row.FCDropDownList("DdlClasificacion").DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
' e.Row.FCDropDownList("DdlClasificacion").DataBind()
' e.Row.FCDropDownList("DdlClasificacion").SelectedValue = e.Row.DBCampo("CveClasificacion")
' e.Row.FCDropDownList("DdlProducto").DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa)
' e.Row.FCDropDownList("DdlProducto").DataBind()
' e.Row.FCDropDownList("DdlProducto").SelectedValue = e.Row.DBCampo("CvePS")
'End If
End If
End Sub
Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
@@ -1566,60 +1411,6 @@ Partial Class Inventarios_TraspasoAlmacen
CargaGvDatos()
End Sub
'Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvDatos.RowEditing
' GvDatos.EditIndex = e.NewEditIndex
' CargaGvDatos()
'End Sub
'Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
' Dim dr = GvDatos.Rows(e.RowIndex)
' Dim Cantidad = dr.FCTextBox("TxtCantidad").Text.ToDouble
' Dim CveUM = dr.FCDropDownList("DdlUnidad").SelectedValue.ToEntero
' Dim CveClasificacion = dr.FCDropDownList("DdlClasificacion").SelectedValue.ToEntero
' Dim CvePS = dr.FCDropDownList("DdlProducto").SelectedValue.ToEntero
' Dim No = dr.DataKey("No").ToEntero
' Dim Serie As String = dr.FCTextBox("TxtSerie").Text
' 'VALIDA EXISTENCIA
' Dim Valido = True
' Dim Inv As New ClsInventarios
' Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, -1, TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), If(Serie = "", "-1", Serie))
' Inv.Dispose()
' If Existencia - txtCantidad.Text.ToDouble < 0 Then
' If Existencia <= 0 Then
' Alert("No hay existencia del producto", TipoMensaje.MsgError)
' Else
' Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgError)
' End If
' Valido = False
' End If
' If Valido Then
' Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No))
' If Drs.Count = 1 Then
' Drs(0)("Cantidad") = Cantidad
' Drs(0)("CveUM") = CveUM
' Drs(0)("CveClasificacion") = CveClasificacion
' Drs(0)("CvePS") = CvePS
' Drs(0)("EstatusExistencia") = "1"
' End If
' DtMovimientos.AcceptChanges()
' GvDatos.EditIndex = -1
' End If
' CargaGvDatos()
'End Sub
'Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
' GvDatos.EditIndex = -1
' CargaGvDatos()
'End Sub
Protected Sub ChkSugiereFechaCaducidad_CheckedChanged(sender As Object, e As EventArgs)
TxtnFechaCaducidad.Visible = Not ChkSugiereFechaCaducidad.Checked