-- unificación de productos iguales en definición de mat utilizado
This commit is contained in:
@@ -3262,19 +3262,7 @@ Partial Class OS_OrdenesServicios
|
||||
If Respuesta.CveVenta > 0 Then
|
||||
|
||||
CveVentaRemisionGenerada = Respuesta.CveVenta
|
||||
If ObjV.GetVentaDetalle(Respuesta.CveVenta) Then
|
||||
Dim dtClon As DataTable = ObjV.DtResultados.Copy
|
||||
dtClon.DefaultView.Sort = "CveVentaDetalle ASC"
|
||||
Dim dtmat As DataTable = dtClon.DefaultView.ToTable()
|
||||
'una vez registrada, asocia los lotes/cad con el cveventadetalle para que se surta así
|
||||
DtVentaDetalle = Respuesta.dtdetalle
|
||||
For i = 0 To dtmat.Rows.Count - 1
|
||||
If DtVentaDetalle.Rows(i)("CvePS").ToString = dtmat.Rows(i)("CvePS").ToString Then
|
||||
DtVentaDetalle.Rows(i)("CveVentaDetalle") = dtmat.Rows(i)("CveVentaDetalle")
|
||||
DtVentaDetalle.Rows(i)("CveUM") = dtmat.Rows(i)("CveUM")
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
DtVentaDetalle = Respuesta.dtdetalle
|
||||
Else
|
||||
ProcesoOK = False
|
||||
End If
|
||||
@@ -3537,7 +3525,6 @@ Partial Class OS_OrdenesServicios
|
||||
PuEnCero = True
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
If PuEnCero Then
|
||||
@@ -3551,7 +3538,7 @@ Partial Class OS_OrdenesServicios
|
||||
Respuesta.CveVenta = -1
|
||||
Respuesta.SerieFolio = ""
|
||||
Respuesta.dtdetalle = New DataTable
|
||||
Alert("Remision sin detalles.", TipoMensaje.MsgAdvertencia)
|
||||
Alert("Remisión sin detalles.", TipoMensaje.MsgAdvertencia)
|
||||
Return Respuesta
|
||||
End If
|
||||
|
||||
@@ -3589,40 +3576,23 @@ Partial Class OS_OrdenesServicios
|
||||
TmpDTMat.Columns.Add("FechaCaducidad", GetType(Date))
|
||||
TmpDTMat.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||
'unificar en un solo producto, y generar las salidas a esa relación
|
||||
Dim tdtt As DataTable = AgrupadoProductos(GvMU)
|
||||
'se recorren los renglones agrupados por producto y acumuladas las cantidades
|
||||
For Each drr As DataRow In tdtt.Rows
|
||||
Dim CvePS As Integer = drr("CvePS").ToString.ToEntero
|
||||
Dim CantidadRegistro As Decimal = drr("Cantidad").ToString.ToDecimal
|
||||
Dim PU As Decimal = drr("PU").ToString.ToDecimal
|
||||
Dim Descuento As Decimal = drr("Descuento").ToString.ToDecimal
|
||||
Dim Obs As String = ""
|
||||
If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=drr("CveVentaDetallePadre").ToString.ToEntero) Then
|
||||
|
||||
|
||||
Respuesta.CveVenta = -1
|
||||
Respuesta.SerieFolio = ""
|
||||
Respuesta.dtdetalle = New DataTable
|
||||
Alert("Remision sin detalles.", TipoMensaje.MsgAdvertencia)
|
||||
Return Respuesta
|
||||
|
||||
For Each GvRow As GridViewRow In GvMU.Rows
|
||||
|
||||
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
|
||||
Dim CantidadRegistro As Decimal = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal
|
||||
Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal
|
||||
Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
|
||||
Dim Obs As String = GvRow.DataKey("Observaciones")
|
||||
|
||||
If CantidadRegistro > 0 Then
|
||||
If ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then
|
||||
Dim drp As DataRow = TmpDTMat.NewRow
|
||||
drp("CvePS") = CvePS
|
||||
drp("Cantidad") = CantidadRegistro
|
||||
drp("PU") = PU
|
||||
drp("Serie") = GvRow.DataKey("Serie")
|
||||
drp("Lote") = GvRow.DataKey("Lote")
|
||||
drp("FechaCaducidad") = GvRow.DataKey("FechaCaducidad").ToDate
|
||||
TmpDTMat.Rows.Add(drp)
|
||||
Else
|
||||
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
|
||||
ProcesoOK = False
|
||||
Exit For
|
||||
End If
|
||||
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
|
||||
ProcesoOK = False
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
If ProcesoOK Then
|
||||
ObjFactura.CalculaTotales()
|
||||
Dim Resp As New Modelos.Factura.MMensajeFactura
|
||||
@@ -3631,6 +3601,32 @@ Partial Class OS_OrdenesServicios
|
||||
If Resp.CveVenta > 0 Then
|
||||
Respuesta.CveVenta = Resp.CveVenta
|
||||
Respuesta.SerieFolio = Resp.SerieFolio
|
||||
|
||||
'genero el dt con los lotes/caducidades y cveventadetalle
|
||||
'se registran los movimientos que serán de almacen.
|
||||
For Each GvRow As GridViewRow In GvMU.Rows
|
||||
|
||||
If GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal > 0 Then
|
||||
Dim drp As DataRow = TmpDTMat.NewRow
|
||||
drp("CvePS") = GvRow.DataKey("CvePS").ToEntero
|
||||
drp("CveUM") = GvRow.DataKey("CveUM").ToDecimal
|
||||
drp("Cantidad") = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal
|
||||
drp("PU") = GvRow.DataKey("PU").ToDecimal
|
||||
drp("Serie") = GvRow.DataKey("Serie")
|
||||
drp("Lote") = GvRow.DataKey("Lote")
|
||||
drp("FechaCaducidad") = GvRow.DataKey("FechaCaducidad").ToDate
|
||||
TmpDTMat.Rows.Add(drp)
|
||||
End If
|
||||
Next
|
||||
|
||||
If ObjVentas.GetVentaDetalle(Respuesta.CveVenta) Then
|
||||
Dim dtDetalle As DataTable = ObjVentas.DtResultados.Copy
|
||||
'se les actualiza el cveventadetalle
|
||||
For Each drt As DataRow In TmpDTMat.Rows
|
||||
drt("CveVentaDetalle") = dtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CvePS = { drt("CvePS")}")
|
||||
Next
|
||||
End If
|
||||
|
||||
Respuesta.dtdetalle = TmpDTMat
|
||||
Else
|
||||
ProcesoOK = False
|
||||
@@ -3651,26 +3647,36 @@ Partial Class OS_OrdenesServicios
|
||||
Where row.RowType = DataControlRowType.DataRow
|
||||
Group row By
|
||||
CvePS = gridView.DataKeys(row.RowIndex)("CvePS").ToString(),
|
||||
CveUM = gridView.DataKeys(row.RowIndex)("CveUM").ToString()
|
||||
PU = gridView.DataKeys(row.RowIndex)("PU").ToString(),
|
||||
Descuento = gridView.DataKeys(row.RowIndex)("Descuento").ToString()
|
||||
Into Group
|
||||
Select New With {
|
||||
.CvePS = CvePS,
|
||||
.CveUM = CveUM,
|
||||
.ValorAcumulado = Group.Sum(Function(r) Convert.ToDecimal(r.Cells(5).Text))
|
||||
.PU = PU,
|
||||
.Descuento = Descuento,
|
||||
.CveVentaDetallePadre = Group.Max(Function(r) r.DataKey("CveVentaDetalle").ToEntero()),
|
||||
.Cantidad = Group.Sum(Function(r) Convert.ToDecimal(r.FCTextBox("TxtUtilizado").Text.ToDecimal)),
|
||||
.Lotes = String.Join(", ", Group.Select(Function(r) gridView.DataKeys(r.RowIndex)("Lote").ToString()).Distinct())
|
||||
}
|
||||
|
||||
' Crear un nuevo DataTable para almacenar los resultados agrupados
|
||||
Dim resultTable As New DataTable()
|
||||
resultTable.Columns.Add("CvePS")
|
||||
resultTable.Columns.Add("CveUM")
|
||||
resultTable.Columns.Add("PU")
|
||||
resultTable.Columns.Add("Descuento")
|
||||
resultTable.Columns.Add("CveVentaDetallePadre")
|
||||
resultTable.Columns.Add("Cantidad", GetType(Decimal))
|
||||
|
||||
For Each item In groupedData
|
||||
Dim newRow As DataRow = resultTable.NewRow()
|
||||
newRow("CvePS") = item.CvePS
|
||||
newRow("CveUM") = item.CveUM
|
||||
newRow("Cantidad") = item.ValorAcumulado
|
||||
resultTable.Rows.Add(newRow)
|
||||
If item.Cantidad > 0 Then
|
||||
Dim newRow As DataRow = resultTable.NewRow()
|
||||
newRow("CvePS") = item.CvePS
|
||||
newRow("PU") = item.PU
|
||||
newRow("Descuento") = item.Descuento
|
||||
newRow("CveVentaDetallePadre") = item.CveVentaDetallePadre
|
||||
newRow("Cantidad") = item.Cantidad
|
||||
resultTable.Rows.Add(newRow)
|
||||
End If
|
||||
Next
|
||||
|
||||
Return resultTable
|
||||
|
||||
Reference in New Issue
Block a user