-- cambios en carta porte
This commit is contained in:
@@ -2381,6 +2381,85 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
|
||||
Private Function GeneraPrePolizaMovimientoAlmacen(CveMovimientoEntrada As Integer, CveMovimientoSalida As Integer, ByRef ObjInventario As ClsInventarios, ByRef ObjConta As ClsContabilidad, ByRef ObjContaContPAQ As ClsContPAQi, EsContabilizable As Boolean) As Boolean
|
||||
Dim Retorno As Boolean = True
|
||||
Try
|
||||
Dim DtCostos As DataTable = Nothing
|
||||
Dim ValorInventario As Decimal = 0
|
||||
Dim ValorInventarioME As Decimal = 0
|
||||
Dim CveConcepto As Integer = 3
|
||||
|
||||
ObjInventario.GetMovimientos(CveMovimientoEntrada, -1, -1, UsuarioActual.CveEmpresa)
|
||||
Dim CveVenta As Integer = ObjInventario.CveVenta
|
||||
Dim CveAlmacen As Integer = ObjInventario.CveAlmacen
|
||||
Dim SerieFolio As String = ObjInventario.DtResultados.Rows(0)("SerieFolioVenta").ToString
|
||||
Dim MovAlmacen As Boolean = True
|
||||
|
||||
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & CveConcepto).ToEntero
|
||||
If OrigenMov = 1 Then MovAlmacen = False Else MovAlmacen = True
|
||||
|
||||
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
|
||||
DtCostos = ObjInventario.DtResultados
|
||||
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
|
||||
Dim IdCtaContable As Integer = 0
|
||||
Dim ConceptoPoliza As String = String.Format("{0}-{1}", "Salida de Almacen", SerieFolio)
|
||||
|
||||
If tmpCostos.Rows.Count > 0 Then
|
||||
Dim Concepto As String = ConceptoPoliza
|
||||
Dim CvePrePoliza = ObjConta.AddPrePolizas("RA-01", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={CveAlmacen}").ToEntero
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ValorInventario, CveSubProyecto:=tCveSubProyecto, Contabilizable:=EsContabilizable) Then
|
||||
Retorno = False
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, ValorInventario, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=ValorInventario, Contabilizable:=If(CveTipoCompra = 10, False, EsContabilizable)) Then
|
||||
Retorno = False
|
||||
End If
|
||||
|
||||
|
||||
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 6) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
||||
Retorno = False
|
||||
End If
|
||||
End If
|
||||
|
||||
'CONTABILIZAR - SIMPLIFICAR
|
||||
If Retorno Then
|
||||
If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
|
||||
If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
||||
Retorno = False
|
||||
End If
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
|
||||
If ObjContaContPAQ Is Nothing Then
|
||||
ObjContaContPAQ = New ClsContPAQi(UsuarioActual.Empresa)
|
||||
ObjContaContPAQ.IniciaTransacSQL()
|
||||
End If
|
||||
|
||||
If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaContPAQ) Then
|
||||
Retorno = False
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
Else
|
||||
Retorno = False
|
||||
End If
|
||||
Else
|
||||
Retorno = False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al guadar la prepoliza", ex)
|
||||
Retorno = False
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Private Sub GuardaCompraOC()
|
||||
|
||||
Dim CveMovimiento As Integer
|
||||
@@ -2404,6 +2483,7 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL())
|
||||
Dim ObjContaAC As ClsContPAQi = Nothing
|
||||
Dim ObjContaContPAQ As ClsContPAQi = Nothing
|
||||
Dim MensajeOC As New StringBuilder
|
||||
|
||||
'ENTREGA DIRECTA
|
||||
|
||||
@@ -2603,6 +2683,8 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
Dim SumaTotal As Decimal = 0.0D
|
||||
Dim Cont As Integer = 0
|
||||
|
||||
Dim ListaOC As New List(Of DetalleOC)
|
||||
|
||||
For Each gvr As GridViewRow In GvInv.Rows
|
||||
If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
|
||||
|
||||
@@ -2664,17 +2746,46 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
End If
|
||||
|
||||
End If
|
||||
'If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
||||
' For Each Dr As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {gvr.RowIndex}").Rows
|
||||
' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("CantidadSeccionAlmacen").ToString.ToDecimal) Then
|
||||
' ErrorMovInv = True
|
||||
' Exit For
|
||||
' End If
|
||||
' Next
|
||||
'End If
|
||||
|
||||
Cont += 1
|
||||
End If
|
||||
If DdlTipo.SelectedValue = "2" Then
|
||||
ListaOC.Add(New DetalleOC With {.CveOCDetalle = gvr.DataKey("CveOrdenCompraDetalle").ToEntero,
|
||||
.Cantidad = gvr.FCTextBox("TbCantidadF").Text.ToDecimal,
|
||||
.CantidadOC = gvr.DataKey("CantidadF").ToDecimal,
|
||||
.PS = gvr.DataKey("PS")})
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
|
||||
'' SI ES ENTRADA POR OC. VERIFICA QUE SE RECIBA LA TOTALIDAD POR PARTIDA. SINO SE DIVIDE
|
||||
|
||||
'si es entrada por oc, se verifican las cantidades, si la cantidad recibida es menor, se ajusta la cantidad en la OC. y se genera una nueva partida con la diferencia
|
||||
If DdlTipo.SelectedValue = "2" Then
|
||||
'se actualiza ListaOC
|
||||
Dim resultsOC = ListaOC.GroupBy(
|
||||
Function(row) row.CveOCDetalle) _
|
||||
.Select(Function(group) New With
|
||||
{
|
||||
.CveOCDetalle = group.Key,
|
||||
.CantidadOC = group.Sum(Function(row) row.CantidadOC),
|
||||
.Cantidad = group.Sum(Function(row) row.Cantidad),
|
||||
.PS = group.Max(Function(row) row.PS),
|
||||
.Data = group
|
||||
})
|
||||
|
||||
|
||||
For Each oc In resultsOC
|
||||
If oc.Cantidad < oc.CantidadOC Then
|
||||
MensajeOC.AppendFormat("- {0}</br>", oc.PS)
|
||||
If Not ObjOC.UpdateOrdenCompraDetalleDivideCantidad(CveOCSurtir, oc.CveOCDetalle, oc.Cantidad, UsuarioActual.CveUsuario) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
Else
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
@@ -2849,6 +2960,13 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
|
||||
Next
|
||||
|
||||
If Not ErrorMovInv Then
|
||||
'registra la prepóliza en el traspaso
|
||||
If Not GeneraPrePolizaMovimientoAlmacen(CveMovtoEntradaActual, CveMovtoSalidaActual, ObjInventario, ObjConta, ObjContaContPAQ, False) Then
|
||||
ErrorMovInv = True
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -2877,7 +2995,7 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
Dim CveTipoAlmacenFiltro As Integer = If(CveTipoCompra = 9, 25, 24)
|
||||
|
||||
|
||||
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, If(TipoMovimiento > 1, 13, 2), 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompraSurtir, -1, -1, -1, CveMovimientoRelacionado:=CveMovimiento, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="RA/G4")
|
||||
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, If(TipoMovimiento > 1, 37, 36), 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompraSurtir, -1, -1, -1, CveMovimientoRelacionado:=CveMovimiento, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="RA/G4")
|
||||
FolioVirtual = ObjInventario.Folio
|
||||
|
||||
For Each RowUsado As DataRow In DtPSVirtual.Rows
|
||||
@@ -3589,6 +3707,9 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
If CveMovimiento > 0 AndAlso CveMovimientoSalidaTraspaso <= 0 Then
|
||||
Msg.AppendFormat("Movimiento Registrado: Folio: <b>{0}</b>", link)
|
||||
Msg.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
|
||||
If MensajeOC.Length > 0 Then
|
||||
Msg.AppendFormat("<br/>La Orden de Compra se dividió en los siguientes productos:<br/>{0}", MensajeOC)
|
||||
End If
|
||||
If UsuarioActual.CveEmpresa.Contiene(1, 119) Then
|
||||
Msg.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Etiqueta Individual</a> ", Encripta(String.Format("OP=Etiqueta&CveMovimiento={0}&Modalidad={1}", CveMovimiento, "Individual")))
|
||||
'Msg.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Etiqueta Por Caja</a> ", Encripta(String.Format("OP=Etiqueta&CveMovimiento={0}&Modalidad={1}", CveMovimiento, "Caja")))
|
||||
@@ -4192,6 +4313,14 @@ Partial Class Inventarios_RecepcionAlmacen
|
||||
|
||||
End Sub
|
||||
|
||||
Class DetalleOC
|
||||
Property CveOCDetalle As Integer
|
||||
Property CantidadOC As Decimal
|
||||
Property Cantidad As Decimal
|
||||
Property PS As String
|
||||
|
||||
End Class
|
||||
|
||||
#End Region
|
||||
|
||||
#Region " TIPO DE CAMBIO "
|
||||
|
||||
Reference in New Issue
Block a user