Cambios al Finalizar OP
This commit is contained in:
@@ -505,7 +505,7 @@
|
||||
<asp:TemplateField>
|
||||
<ItemTemplate>
|
||||
<asp:LinkButton ID="BtnEliminar" runat="server"
|
||||
CommandArgument='<%# Eval("Clave") %>'
|
||||
CommandArgument='<%# Eval("CvePS") %>'
|
||||
OnClick="BtnEliminarProducto_Click"
|
||||
CssClass="btn btn-circle btn-xs red"
|
||||
Text="<i class='icon-trash'></i>" />
|
||||
@@ -591,7 +591,7 @@
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="productoMateriaPrima" HeaderText="Producto" />
|
||||
<asp:BoundField DataField="Cantidad" HeaderText="Costo" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
<asp:BoundField DataField="ImporteCostoIndirecto" HeaderText="Costo" DataFormatString="{0:#,##0.####}" ItemStyle-HorizontalAlign="Right" />
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</div>
|
||||
@@ -842,7 +842,7 @@
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="section-title">Materia Prima</div>
|
||||
<asp:GridView ID="GvMPUtilizada" runat="server" AutoGenerateColumns="False" DataKeyNames="CvePSMateriaPrima, CveUMMateriaPrima"
|
||||
<asp:GridView ID="GvMPUtilizada" runat="server" AutoGenerateColumns="False" DataKeyNames="CvePS, CvePSMateriaPrima, CveUMMateriaPrima"
|
||||
CssClass="table table-striped table-hover" GridLines="None" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="PSCodigo" HeaderText="Producto" />
|
||||
|
||||
133
OP/OP.aspx.vb
133
OP/OP.aspx.vb
@@ -41,15 +41,7 @@ Partial Class OP_OP
|
||||
|
||||
Private Property DtMO As DataTable
|
||||
Get
|
||||
If ViewState("DtMO") Is Nothing Then
|
||||
DtMO = New DataTable()
|
||||
DtMO.Columns.Add("CvePS", GetType(Integer)) ' Producto asociado
|
||||
DtMO.Columns.Add("CvePuesto", GetType(Integer))
|
||||
DtMO.Columns.Add("Puesto", GetType(String))
|
||||
DtMO.Columns.Add("CostoHora", GetType(Decimal))
|
||||
DtMO.Columns.Add("Total", GetType(Decimal))
|
||||
End If
|
||||
Return CType(ViewState("DtMO"), DataTable)
|
||||
Return DirectCast(ViewState("DtMO"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtMO") = value
|
||||
@@ -58,16 +50,7 @@ Partial Class OP_OP
|
||||
|
||||
Private Property DtCI As DataTable
|
||||
Get
|
||||
If ViewState("DtCI") Is Nothing Then
|
||||
DtCI = New DataTable()
|
||||
DtCI.Columns.Add("CvePS", GetType(Integer)) ' Producto asociado
|
||||
DtCI.Columns.Add("CvePSMateriaPrima", GetType(Integer))
|
||||
DtCI.Columns.Add("productoMateriaPrima", GetType(String))
|
||||
DtCI.Columns.Add("Cantidad", GetType(Decimal))
|
||||
DtCI.Columns.Add("PU", GetType(Decimal))
|
||||
DtCI.Columns.Add("Total", GetType(Decimal))
|
||||
End If
|
||||
Return CType(ViewState("DtCI"), DataTable)
|
||||
Return DirectCast(ViewState("DtCI"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtCI") = value
|
||||
@@ -87,7 +70,7 @@ Partial Class OP_OP
|
||||
Get
|
||||
If ViewState("DtMPAgregados") Is Nothing Then
|
||||
DtMPAgregados = New DataTable()
|
||||
DtMPAgregados.Columns.Add("Clave", GetType(Integer))
|
||||
DtMPAgregados.Columns.Add("CvePS", GetType(Integer))
|
||||
DtMPAgregados.Columns.Add("PSCodigo", GetType(String))
|
||||
DtMPAgregados.Columns.Add("CveUM", GetType(Integer))
|
||||
DtMPAgregados.Columns.Add("UnidadMedida", GetType(String))
|
||||
@@ -129,7 +112,7 @@ Partial Class OP_OP
|
||||
Private Sub CreaPS()
|
||||
DtPS = New DataTable()
|
||||
DtPS.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
DtPS.Columns.Add("Clave", GetType(Integer))
|
||||
DtPS.Columns.Add("CvePS", GetType(Integer))
|
||||
DtPS.Columns.Add("PSCodigo", GetType(String))
|
||||
DtPS.Columns.Add("UnidadMedida", GetType(String))
|
||||
DtPS.Columns.Add("Cantidad", GetType(Decimal))
|
||||
@@ -139,7 +122,7 @@ Partial Class OP_OP
|
||||
|
||||
DtMP = New DataTable()
|
||||
DtMP.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
DtMP.Columns.Add("Clave", GetType(Integer))
|
||||
DtMP.Columns.Add("CvePS", GetType(Integer))
|
||||
DtMP.Columns.Add("CvePSMateriaPrima", GetType(Integer))
|
||||
DtMP.Columns.Add("CveUM", GetType(Integer))
|
||||
DtMP.Columns.Add("CveUMMateriaPrima", GetType(Integer))
|
||||
@@ -152,7 +135,7 @@ Partial Class OP_OP
|
||||
|
||||
DtMO = New DataTable()
|
||||
DtMO.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
DtMO.Columns.Add("Clave", GetType(Integer))
|
||||
DtMO.Columns.Add("CvePS", GetType(Integer))
|
||||
DtMO.Columns.Add("CveUM", GetType(Integer))
|
||||
DtMO.Columns.Add("CvePuesto", GetType(Integer))
|
||||
DtMO.Columns.Add("Puesto", GetType(String))
|
||||
@@ -163,10 +146,12 @@ Partial Class OP_OP
|
||||
|
||||
DtCI = New DataTable()
|
||||
DtCI.Columns.Add("Tipo", GetType(String)) ' Producto, MP, MO, CI
|
||||
DtCI.Columns.Add("Clave", GetType(Integer))
|
||||
DtCI.Columns.Add("CvePS", GetType(Integer))
|
||||
DtCI.Columns.Add("productoMateriaPrima", GetType(String))
|
||||
DtCI.Columns.Add("CvePSProducto", GetType(Integer))
|
||||
DtCI.Columns.Add("Cantidad", GetType(Decimal))
|
||||
DtCI.Columns.Add("PU", GetType(Decimal))
|
||||
'DtCI.Columns.Add("Costo", GetType(Decimal))
|
||||
DtCI.Columns.Add("ImporteCostoIndirecto", GetType(Decimal))
|
||||
DtCI.Columns.Add("Total", GetType(Decimal))
|
||||
|
||||
|
||||
@@ -262,7 +247,7 @@ Partial Class OP_OP
|
||||
For Each rowProducto As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtPS.NewRow()
|
||||
newRow("Tipo") = "Producto"
|
||||
newRow("Clave") = rowProducto("CvePS").ToString.ToEntero
|
||||
newRow("CvePS") = rowProducto("CvePS").ToString.ToEntero
|
||||
newRow("PSCodigo") = rowProducto("Producto").ToString
|
||||
|
||||
newRow("UnidadMedida") = rowProducto("UnidadMedida").ToString
|
||||
@@ -277,9 +262,9 @@ Partial Class OP_OP
|
||||
For Each rowMP As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtMP.NewRow()
|
||||
newRow("Tipo") = "MP"
|
||||
newRow("Clave") = rowMP("CvePS").ToString.ToEntero
|
||||
newRow("CvePS") = rowMP("CvePS").ToString.ToEntero
|
||||
newRow("PSCodigo") = rowMP("Producto").ToString
|
||||
newRow("CvePSMateriaPrima") = rowMP("CvePS").ToString.ToEntero
|
||||
newRow("CvePSMateriaPrima") = rowMP("CvePSMateriaPrima").ToString.ToEntero
|
||||
newRow("CveUMMateriaPrima") = rowMP("CveUM").ToString.ToEntero
|
||||
newRow("UnidadMedida") = rowMP("UnidadMedida").ToString
|
||||
newRow("Cantidad") = rowMP("Cantidad").ToString.ToDecimal
|
||||
@@ -294,8 +279,11 @@ Partial Class OP_OP
|
||||
For Each rowMO As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtMO.NewRow()
|
||||
newRow("Tipo") = "MO"
|
||||
newRow("CvePS") = rowMO("CvePS").ToString().ToEntero()
|
||||
newRow("Puesto") = rowMO("Puesto").ToString
|
||||
newRow("Cantidad") = rowMO("Cantidad").ToString.ToDecimal
|
||||
newRow("CostoHora") = rowMO("precioHora").ToString.ToDecimal()
|
||||
newRow("Total") = rowMO("Cantidad").ToString().ToDecimal() * rowMO("precioHora").ToString().ToDecimal()
|
||||
DtMO.Rows.Add(newRow)
|
||||
Next
|
||||
End If
|
||||
@@ -306,8 +294,12 @@ Partial Class OP_OP
|
||||
For Each rowCI As DataRow In ObjOP.DtResultados.Rows
|
||||
Dim newRow As DataRow = DtCI.NewRow()
|
||||
newRow("Tipo") = "CI"
|
||||
newRow("CvePS") = rowCI("CvePS").ToString().ToEntero()
|
||||
newRow("CvePSProducto") = rowCI("CvePSProducto").ToString().ToEntero()
|
||||
'newRow("CvePSMateriaPrima") = rowCI("CvePSMateriaPrima").ToString().ToEntero()
|
||||
newRow("productoMateriaPrima") = rowCI("producto").ToString
|
||||
newRow("Costo") = rowCI("Costo").ToString.ToDecimal
|
||||
newRow("ImporteCostoIndirecto") = rowCI("ImporteCostoIndirecto").ToString.ToDecimal()
|
||||
newRow("Total") = rowCI("ImporteCostoIndirecto")
|
||||
DtCI.Rows.Add(newRow)
|
||||
|
||||
Next
|
||||
@@ -353,7 +345,7 @@ Partial Class OP_OP
|
||||
Dim DrPS As DataRow = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
||||
|
||||
newRow("Tipo") = "Producto"
|
||||
newRow("Clave") = CvePS
|
||||
newRow("CvePS") = CvePS
|
||||
newRow("PSCodigo") = DrPS("PSCodigo")
|
||||
newRow("UnidadMedida") = DrPS("UnidadMedida")
|
||||
newRow("Cantidad") = 1
|
||||
@@ -371,14 +363,14 @@ Partial Class OP_OP
|
||||
For Each drMP As DataRow In ObjMP.DtResultados.Rows
|
||||
Dim rowMP As DataRow = DtMP.NewRow()
|
||||
rowMP("Tipo") = "MP"
|
||||
rowMP("Clave") = CvePS
|
||||
rowMP("CvePSMateriaPrima") = CvePS
|
||||
rowMP("CvePS") = CvePS
|
||||
rowMP("CvePSMateriaPrima") = drMP("CvePSMateriaPrima").ToString().ToEntero()
|
||||
rowMP("CveUM") = CveUM
|
||||
rowMP("CveUMMateriaPrima") = CveUM 'drMP("CveUMMateriaPrima").ToString().ToEntero()
|
||||
rowMP("CveUMMateriaPrima") = drMP("CveUMMateriaPrima").ToString().ToEntero()
|
||||
rowMP("PSCodigo") = drMP("productoMateriaPrima").ToString()
|
||||
rowMP("UnidadMedida") = drMP("UnidadMedidaMateriaPrima").ToString()
|
||||
rowMP("Cantidad") = drMP("Cantidad").ToString().ToDecimal()
|
||||
'rowMP("CvePSProducto") = CvePS
|
||||
|
||||
rowMP("Surtido") = 0
|
||||
DtMP.Rows.Add(rowMP)
|
||||
Next
|
||||
@@ -390,7 +382,7 @@ Partial Class OP_OP
|
||||
For Each drMO As DataRow In ObjMO.DtResultados.Rows
|
||||
Dim rowMO As DataRow = DtMO.NewRow()
|
||||
rowMO("Tipo") = "MO"
|
||||
rowMO("Clave") = CvePS
|
||||
rowMO("CvePS") = CvePS
|
||||
rowMO("Puesto") = drMO("Puesto").ToString()
|
||||
rowMO("Cantidad") = drMO("Cantidad").ToString().ToDecimal()
|
||||
rowMO("CostoHora") = drMO("precioHora").ToString.ToDecimal()
|
||||
@@ -406,12 +398,12 @@ Partial Class OP_OP
|
||||
For Each drCI As DataRow In ObjCI.DtResultados.Rows
|
||||
Dim rowCI As DataRow = DtCI.NewRow()
|
||||
rowCI("Tipo") = "CI"
|
||||
rowCI("Clave") = CvePS
|
||||
rowCI("CvePS") = CvePS
|
||||
rowCI("CvePSProducto") = drCI("CvePSProducto").ToString()
|
||||
'rowCI("CvePSMateriaPrima") = drCI("CvePSMateriaPrima").ToString().ToEntero()
|
||||
rowCI("productoMateriaPrima") = drCI("productoMateriaPrima").ToString()
|
||||
rowCI("Cantidad") = drCI("Cantidad").ToString().ToDecimal()
|
||||
rowCI("PU") = drCI("ImporteCostoIndirecto").ToString().ToDecimal()
|
||||
rowCI("Total") = rowCI("Cantidad").ToString().ToDecimal() * rowCI("PU").ToString().ToDecimal()
|
||||
rowCI("ImporteCostoIndirecto") = drCI("ImporteCostoIndirecto").ToString().ToDecimal()
|
||||
rowCI("Total") = rowCI("ImporteCostoIndirecto")
|
||||
DtCI.Rows.Add(rowCI)
|
||||
Next
|
||||
End If
|
||||
@@ -429,7 +421,7 @@ Partial Class OP_OP
|
||||
Dim btnEliminar As LinkButton = DirectCast(sender, LinkButton)
|
||||
Dim CveProducto As Integer = btnEliminar.CommandArgument.ToEntero()
|
||||
|
||||
Dim filasProducto As DataRow() = DtPS.Select($"Clave = {CveProducto}")
|
||||
Dim filasProducto As DataRow() = DtPS.Select($"CvePS = {CveProducto}")
|
||||
If filasProducto.Length > 0 Then
|
||||
DtPS.Rows.Remove(filasProducto(0))
|
||||
EliminarDatosRelacionados(CveProducto)
|
||||
@@ -440,19 +432,19 @@ Partial Class OP_OP
|
||||
Private Sub EliminarDatosRelacionados(CveProducto As Integer)
|
||||
|
||||
' Materia Prima
|
||||
Dim filasMP As DataRow() = DtMP.Select($"Clave = {CveProducto}")
|
||||
Dim filasMP As DataRow() = DtMP.Select($"CvePS = {CveProducto}")
|
||||
For Each fila As DataRow In filasMP
|
||||
DtMP.Rows.Remove(fila)
|
||||
Next
|
||||
|
||||
' Mano de Obra
|
||||
Dim filasMO As DataRow() = DtMO.Select($"Clave = {CveProducto}")
|
||||
Dim filasMO As DataRow() = DtMO.Select($"CvePS = {CveProducto}")
|
||||
For Each fila As DataRow In filasMO
|
||||
DtMO.Rows.Remove(fila)
|
||||
Next
|
||||
|
||||
' Costos Indirectos
|
||||
Dim filasCI As DataRow() = DtCI.Select($"Clave = {CveProducto}")
|
||||
Dim filasCI As DataRow() = DtCI.Select($"CvePS = {CveProducto}")
|
||||
For Each fila As DataRow In filasCI
|
||||
DtCI.Rows.Remove(fila)
|
||||
Next
|
||||
@@ -791,7 +783,7 @@ Partial Class OP_OP
|
||||
Alert("Orden creada con Folio: " & FolioGenerado, TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
Else ' Modo EDICIÓN
|
||||
Dim CvePS As Integer = DtPS.Rows(0)("Clave").ToString.ToEntero()
|
||||
Dim CvePS As Integer = DtPS.Rows(0)("CvePS").ToString.ToEntero()
|
||||
Dim Cantidad As Integer = DtPS.Rows(0)("Cantidad").ToString.ToEntero()
|
||||
BtnFinalizarOP.Visible = True
|
||||
If Not clsOP.UpdateOP(
|
||||
@@ -832,7 +824,7 @@ Partial Class OP_OP
|
||||
|
||||
For Each row As DataRow In dt.Rows
|
||||
Dim producto As XmlElement = xmlDoc.CreateElement("Producto")
|
||||
producto.InnerXml = $"<CvePS>{row("Clave")}</CvePS><Cantidad>{row("Cantidad")}</Cantidad><CveUM>{row("CveUM")}</CveUM>"
|
||||
producto.InnerXml = $"<CvePS>{row("CvePS")}</CvePS><Cantidad>{row("Cantidad")}</Cantidad><CveUM>{row("CveUM")}</CveUM>"
|
||||
xmlDoc.DocumentElement.AppendChild(producto)
|
||||
Next
|
||||
|
||||
@@ -1004,7 +996,7 @@ Partial Class OP_OP
|
||||
|
||||
Try
|
||||
'Salida de MP
|
||||
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida")
|
||||
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigenSalidaMP.SelectedValue.ToEntero(), TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPSalida", CveOP:=CveOP)
|
||||
FolioEntrada = ObjInventario.Folio
|
||||
Dim DtMPAlmacen As DataTable = Nothing
|
||||
If CveMovimientoSalida > 0 Then
|
||||
@@ -1014,6 +1006,7 @@ Partial Class OP_OP
|
||||
Dim CveUM As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero
|
||||
Dim Cantidad As Decimal = rowMP("Cantidad").ToString.ToDecimal
|
||||
|
||||
|
||||
' Registrar detalle
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0) Then
|
||||
ErrorMovInv = True
|
||||
@@ -1031,35 +1024,44 @@ Partial Class OP_OP
|
||||
|
||||
' 1. Recorrer cada Producto Terminado en la OP
|
||||
For Each rowProducto As DataRow In DtPS.Select("Tipo = 'Producto'")
|
||||
Dim CvePSProducto As Integer = rowProducto("Clave").ToString.ToEntero()
|
||||
Dim CvePSProducto As Integer = rowProducto("CvePS").ToString.ToEntero()
|
||||
Dim CantidadProducto As Decimal = rowProducto("Cantidad").ToString.ToDecimal()
|
||||
Dim MPProducto As Decimal = 0
|
||||
Dim MOProducto As Decimal = 0
|
||||
Dim CIProducto As Decimal = 0
|
||||
|
||||
' 2. Calcular Costo de Materias Primas por Producto
|
||||
For Each rowMP As DataRow In DtMP.Select($"Clave = {CvePSProducto}")
|
||||
For Each rowMP As DataRow In DtMP.FiltraParametros($"CvePS = {CvePSProducto}").Rows
|
||||
Dim CvePSMP As Integer = rowMP("CvePSMateriaPrima").ToString.ToEntero()
|
||||
Dim CveUMMP As Integer = rowMP("CveUMMateriaPrima").ToString.ToEntero()
|
||||
Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePSMP} AND CveUM = {CveUMMP}").ToDecimal()
|
||||
TotalMPProducto += rowMP("Cantidad").ToString().ToDecimal() * PU
|
||||
Dim PU As Decimal = DtMPAlmacen.FiltroPrimeroValor("PU", $"CvePS = {CvePSMP}").ToDecimal()
|
||||
MPProducto += rowMP("Cantidad").ToString().ToDecimal() * PU
|
||||
Next
|
||||
|
||||
' 3. Calcular Mano de Obra por Producto
|
||||
For Each rowMO As DataRow In DtMO.Select($"Clave = {CvePSProducto}")
|
||||
TotalMOProducto += rowMO("Total").ToString.ToDecimal()
|
||||
For Each rowMO As DataRow In DtMO.FiltraParametros($"CvePS = {CvePSProducto}").Rows
|
||||
MOProducto += rowMO("Total").ToString.ToDecimal()
|
||||
Next
|
||||
|
||||
' 4. Calcular Costos Indirectos por Producto
|
||||
For Each rowCI As DataRow In DtCI.Select($"Clave = {CvePSProducto}")
|
||||
TotalCIProducto += rowCI("Total").ToString.ToDecimal()
|
||||
For Each rowCI As DataRow In DtCI.FiltraParametros($"CvePSProducto = {CvePSProducto}").Rows
|
||||
CIProducto += rowCI("Total").ToString.ToDecimal()
|
||||
Next
|
||||
' 5. Determinar las devoluciones del Producto
|
||||
Dim TotalDevPT As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Where($"datakey.cvepspt = {CvePSProducto}").Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal())
|
||||
Dim TotalDevPT As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Where(Function(row) GvMPUtilizada.DataKeys(row.RowIndex).Values(0).ToString().ToEntero() = CvePSProducto).Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal())
|
||||
|
||||
' 6. Sumar Total por Producto (MP + MO + CI)
|
||||
Dim TotalProducto As Decimal = TotalMPProducto + TotalMOProducto + TotalCIProducto - TotalDevPT
|
||||
Dim TotalProducto As Decimal = MPProducto + MOProducto + CIProducto - TotalDevPT
|
||||
|
||||
rowProducto("Costo") = TotalProducto
|
||||
|
||||
TotalMPProducto += MPProducto
|
||||
TotalMOProducto += MOProducto
|
||||
TotalCIProducto += CIProducto
|
||||
Next
|
||||
|
||||
DtPS.AcceptChanges()
|
||||
|
||||
' 2. PROCESAR DEVOLUCIONES SI EXISTEN
|
||||
If Not ErrorMovInv Then
|
||||
Dim TotalDevoluciones As Decimal = GvMPUtilizada.Rows.Cast(Of GridViewRow)().Sum(Function(row) DirectCast(row.FindControl("TxtDevolucionMP"), TextBox).Text.ToDecimal())
|
||||
@@ -1070,7 +1072,7 @@ Partial Class OP_OP
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
CveMovimientoDev = ObjInventario.AddMovimiento(DdlAlmacenDevolucion.SelectedValue.ToEntero(), TipoMovimientoDev, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=$"Devolución OP #{LblFolio.Text}", Modulo:="OP/Devoluciones", CveMovimientoRelacionado:=CveMovimientoSalida)
|
||||
CveMovimientoDev = ObjInventario.AddMovimiento(DdlAlmacenDevolucion.SelectedValue.ToEntero(), TipoMovimientoDev, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=$"Devolución OP #{LblFolio.Text}", Modulo:="OP/Devoluciones", CveMovimientoRelacionado:=CveMovimientoSalida, CveOP:=CveOP)
|
||||
|
||||
If CveMovimientoDev > 0 Then
|
||||
For Each row As GridViewRow In GvMPUtilizada.Rows
|
||||
@@ -1101,16 +1103,17 @@ Partial Class OP_OP
|
||||
|
||||
'ENTRADA DE PRODUCTO TERMINADO
|
||||
If Not ErrorMovInv Then
|
||||
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenTerminado.SelectedValue.ToEntero(), CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPEntrada", CveMovimientoRelacionado:=CveMovimientoSalida)
|
||||
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenTerminado.SelectedValue.ToEntero(), CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:="Finalización OP #" & LblFolio.Text, Modulo:="OP/FinalizarOPEntrada", CveMovimientoRelacionado:=CveMovimientoSalida, CveOP:=CveOP)
|
||||
End If
|
||||
|
||||
If CveMovimientoEntrada > 0 AndAlso Not ErrorMovInv Then
|
||||
Dim CostoPTAjustado As Decimal = TotalCostoMP - CostoDevoluciones
|
||||
Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(r) r.Field(Of Decimal)("Cantidad"))
|
||||
Dim PU_PT As Decimal = If(CantidadPT > 0, CostoPTAjustado / CantidadPT, 0)
|
||||
Dim CostoTotalProduccion As Decimal = TotalMPProducto + TotalMOProducto + TotalCIProducto
|
||||
Dim CostoPTAjustado As Decimal = CostoTotalProduccion - CostoDevoluciones
|
||||
'Dim CantidadPT As Decimal = DtPS.AsEnumerable().Sum(Function(r) r.Field(Of Decimal)("Cantidad"))
|
||||
'Dim PU_PT As Decimal = If(CantidadPT > 0, CostoPTAjustado / CantidadPT, 0)
|
||||
|
||||
For Each rowPT As DataRow In DtPS.Select("Tipo = 'Producto'")
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("Clave").ToString.ToEntero(), rowPT("Costo").ToString.ToDecimal()) Then
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, rowPT("Cantidad").ToString.ToDecimal(), rowPT("CveUM").ToString.ToEntero(), rowPT("CvePS").ToString.ToEntero(), rowPT("Costo").ToString.ToDecimal()) Then
|
||||
ErrorMovInv = True : TextoError = "x" : Exit For
|
||||
End If
|
||||
Next
|
||||
@@ -1129,15 +1132,15 @@ Partial Class OP_OP
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
'dev MP
|
||||
If Not ErrorMovInv AndAlso CostoDevoluciones <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoDevoluciones, CostoDevoluciones, 95, "", $"OP #{LblFolio.Text}", CveMovimientoAlmacen:=CveMovimientoDev) Then
|
||||
If Not ErrorMovInv AndAlso CostoDevoluciones <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, CostoDevoluciones, CostoDevoluciones, 68, "Devoluciones PT OP #" & LblFolio.Text, "Devoluciones PT OP #" & LblFolio.Text, CveMovimientoAlmacen:=CveMovimientoDev) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
'costo indirecto
|
||||
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalCIProducto, TotalCIProducto, 95, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text) Then
|
||||
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalCIProducto, TotalCIProducto, 95, "Costo Indirecto PT OP #" & LblFolio.Text, "Costo Indirecto PT OP #" & LblFolio.Text) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
'mano de obra
|
||||
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, TotalMOProducto, TotalCIProducto, 95, "Producción PT OP #" & LblFolio.Text, "Producción PT OP #" & LblFolio.Text) Then
|
||||
If Not ErrorMovInv AndAlso TotalCIProducto <> 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, TotalMOProducto, TotalMOProducto, 95, "Mano de Obra PT OP #" & LblFolio.Text, "Mano de Obra PT OP #" & LblFolio.Text) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user