ajustes en aplicar lote/caducidad

This commit is contained in:
2021-03-09 20:12:25 -07:00
parent e980d5a798
commit b42ba99dab
2 changed files with 101 additions and 26 deletions

View File

@@ -443,6 +443,7 @@
<asp:TextBox ID="TxtnLote" CssClass="form-control input-sm" runat="server" Width="80px" Visible="false"></asp:TextBox>
</td>
<td runat="server" id="TdFechaCaducidad" visible="false">
<asp:CheckBox ID="ChkSugiereFechaCaducidad" runat="server" Text="Auto Sugiere" ToolTip="Auto Sugiere Fecha de caducidad" AutoPostBack="true" OnCheckedChanged="ChkSugiereFechaCaducidad_CheckedChanged" />
<asp:TextBox ID="TxtnFechaCaducidad" CssClass="form-control input-sm" runat="server" Width="80px" Visible="false"></asp:TextBox>
</td>
<td align="center">
@@ -456,7 +457,7 @@
<asp:GridView ID="GvDatos" DataKeyNames="No,PS,CvePS,CveUM,Serie,Cantidad" runat="server" ShowHeader="false" AutoGenerateColumns="False" EmptyDataText="" ToolTip="Listado de Movimientos" CssClass="Widthall table table-striped table-hover" GridLines="None">
<Columns>
<asp:BoundField HeaderText="#" DataField="No" ItemStyle-Width="23px" />
<asp:TemplateField ItemStyle-Width="93px">
<asp:TemplateField ItemStyle-Width="93px" ItemStyle-HorizontalAlign ="Right">
<ItemTemplate>
<asp:Literal runat="server" Text='<%# Eval("Cantidad") %>' ID="ltlCantidad"></asp:Literal>
<asp:TextBox runat="server" ID="TxtCantidad2" Text='<%# Eval("Cantidad", "{0:###,###,###,##0.##}") %>' Width="50px" Visible="false"></asp:TextBox>

View File

@@ -526,6 +526,8 @@ Partial Class Inventarios_TraspasoAlmacen
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveProducto).FiltroPrimero("") ' Estado = -1
If DrPS IsNot Nothing Then
If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then
@@ -534,12 +536,64 @@ Partial Class Inventarios_TraspasoAlmacen
End If
End If
Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, If(TxtnSerie.Visible, TxtnSerie.Text, "-1"), If(TxtnLote.Visible, TxtnLote.Text, "-1"), If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha))
'codigo provisional.
Dim CveSubP As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenOrigen.selectedvalue.toentero).FiltroPrimeroValor("CveSubProyecto", "").ToEntero
If DrPS("AplicaCaducidad").ToString = "True" AndAlso ChkSugiereFechaCaducidad.checked And CveSubP.Contiene(10276) Then
Dim ObjInventarios As New ClsInventarios
If ObjInventarios.GetExistenciasCaducidad(CveProducto, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.selectedvalue) Then
Dim dtt As DataTable = ObjInventarios.DtResultados
If Cantidad > dtt.SUMD("Cantidad") Then
Alert("No se cuenta con la cantidad requerida")
Else
'recorro las existencias para tomar la cantidad
Dim i As Decimal = 0
Dim CantidadRestante As Decimal = Cantidad
For Each drr As DataRow In dtt.Rows
If drr("Cantidad").ToString.ToDecimal < CantidadRestante Then
i = drr("Cantidad").ToString.ToDecimal
Else
i = CantidadRestante
End If
AgregarPS(i, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Lote:=drr("Lote").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie)
CantidadRestante -= i
If CantidadRestante <= 0 Then Exit For
Next
End If
End If
ObjInventarios.Dispose()
Else
'codigo temporal
Dim tLote As String
Dim tCaducidad As Date
tLote = If(TxtnLote.Visible, TxtnLote.Text, "-1")
tCaducidad = If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha)
If CveSubP <> 10276 Then
tLote = "-1"
tCaducidad = MinFecha
End If
Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, If(TxtnSerie.Visible, TxtnSerie.Text, "-1"), tLote, tCaducidad)
If Valido Then
AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, ""), Lote:=If(TxtnLote.Visible, TxtnLote.Text, ""), FechaCaducidad:=If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha), CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie)
AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, ""), Lote:=If(tLote = "-1", "", tLote), FechaCaducidad:=tCaducidad, CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie)
End If
End If
End If
End If
End Sub
Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, CveSeccionAlmacen As Integer, Serie As String, Lote As String, FechaCaducidad As Date) As Boolean
@@ -550,25 +604,38 @@ Partial Class Inventarios_TraspasoAlmacen
Dim Inv As New ClsInventarios
Dim Existencia As Decimal = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), PendientePorSurtir:=1)
If Existencia > 0 Then
'la primera vez valida, que la existencia global, cumpla, considerando lo pendiente por surtir
'las segunda consulta, que tenga existencia, ya con los parametros especificos
If FechaCaducidad > MinFecha OrElse Serie <> "" OrElse Lote <> "" Then
If (FechaCaducidad > MinFecha OrElse Serie <> "" OrElse Lote <> "") Then
ExistenciaEspecificada = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=-1)
Else
ExistenciaEspecificada = Existencia
End If
Inv.Dispose()
Dim StrB As New stringbuilder
StrB.appendformat("CvePS = {0} AND CveUM = {1} ", CvePS, CveUnidadMedida)
If Serie <> "" Then StrB.appendformat(" AND Serie = '{0}' ", Serie)
If Lote <> "" Then StrB.appendformat(" AND Lote = '{0}' ", Lote)
If FechaCaducidad.ToDate > MinFecha Then StrB.appendformat(" AND FechaCaducidad = '{0}' ", FechaCaducidad.ToShortDateString)
Dim CantidadEspecificaEnGrid As Decimal = DtMovimientos.SUMD("Cantidad", StrB.tostring)
If Existencia - Cantidad - CantidadEnGrid < 0 OrElse ExistenciaEspecificada - Cantidad - CantidadEnGrid < 0 Then
If Existencia < 0 OrElse ExistenciaEspecificada < 0 Then
Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
If ExistenciaEspecificada - Cantidad - CantidadEspecificaEnGrid < 0 Then
Alert(String.Format("Solo hay en existencia: {0:#,###.##}", ExistenciaEspecificada), TipoMensaje.MsgAdvertencia)
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
Else
Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia)
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
End If
Retorno = False
End If
Else
ExistenciaEspecificada = Existencia
If Existencia - Cantidad - CantidadEnGrid < 0 Then
Alert(String.Format("Solo hay en existencia: {0:#,###.##}", ExistenciaEspecificada), TipoMensaje.MsgAdvertencia)
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
Retorno = False
End If
End If
Else
Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
End If
Inv.Dispose()
Return Retorno
End Function
@@ -1482,6 +1549,13 @@ Partial Class Inventarios_TraspasoAlmacen
' CargaGvDatos()
'End Sub
Protected Sub ChkSugiereFechaCaducidad_CheckedChanged(sender As Object, e As EventArgs)
TxtnFechaCaducidad.visible = Not ChkSugiereFechaCaducidad.checked
TxtnLote.visible = Not ChkSugiereFechaCaducidad.checked
End Sub
#End Region