Correcion en prepolizas de traspasos

This commit is contained in:
2021-06-03 17:55:33 -07:00
parent 18ff1d5137
commit 28c7b2288f

View File

@@ -644,8 +644,14 @@ Partial Class Inventarios_EntregaAlmacen
End If End If
End If End If
If UsuarioActual.CveEmpresa = 119 AndAlso CveSubProyecto = 10276 Then If UsuarioActual.CveEmpresa = 119 Then
Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveSubProyecto", "").ToEntero
If CveSubProyectoAlmacen = 10276 Then
ValidaLoteCaducidad = True ValidaLoteCaducidad = True
Else
ValidaLoteCaducidad = False
End If
End If End If
If Not DtDatos.Columns.Contains("Serie") Then DtDatos.Columns.Add("Serie", GetType(String)) If Not DtDatos.Columns.Contains("Serie") Then DtDatos.Columns.Add("Serie", GetType(String))
@@ -966,7 +972,8 @@ Partial Class Inventarios_EntregaAlmacen
If CBool(e.Row.DBCampo("AplicaCaducidad")) Then If CBool(e.Row.DBCampo("AplicaCaducidad")) Then
e.Row.FCTextBox("TxtCaducidad").Visible = True e.Row.FCTextBox("TxtCaducidad").Visible = True
e.Row.FCLinkButton("LnkCaducidad").Visible = True e.Row.FCLinkButton("LnkCaducidad").Visible = True
e.Row.FCTextBox("TxtCaducidad").readonly = True e.Row.FCTextBox("TxtCaducidad").ReadOnly = True
CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False
' e.Row.FCTextBox("TxtCaducidad").enabled = True ' e.Row.FCTextBox("TxtCaducidad").enabled = True
Else Else
e.Row.FCTextBox("TxtCaducidad").Visible = False e.Row.FCTextBox("TxtCaducidad").Visible = False
@@ -975,7 +982,7 @@ Partial Class Inventarios_EntregaAlmacen
If CBool(e.Row.DBCampo("AplicaLote")) Then If CBool(e.Row.DBCampo("AplicaLote")) Then
e.Row.FCTextBox("TxtLote").Visible = True e.Row.FCTextBox("TxtLote").Visible = True
e.Row.FCTextBox("TxtLote").readonly = True e.Row.FCTextBox("TxtLote").ReadOnly = True
'e.Row.FCTextBox("TxtLote").enabled = True 'e.Row.FCTextBox("TxtLote").enabled = True
Else Else
e.Row.FCTextBox("TxtLote").Visible = False e.Row.FCTextBox("TxtLote").Visible = False
@@ -2253,6 +2260,8 @@ Partial Class Inventarios_EntregaAlmacen
Next Next
If ErrorMovInv Then Exit For If ErrorMovInv Then Exit For
Else Else
ErrorMovInv = True ErrorMovInv = True
End If End If
@@ -2300,6 +2309,7 @@ Partial Class Inventarios_EntregaAlmacen
End If End If
End If End If
'' TERMINA: APARTADOS '' TERMINA: APARTADOS
Dim TotalGarantia As Decimal = 0
' COMIENZA: GARANTIAS ' COMIENZA: GARANTIAS
If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then
@@ -2326,6 +2336,7 @@ Partial Class Inventarios_EntregaAlmacen
TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.") TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
Exit For Exit For
End If End If
TotalGarantia += (RowGarantia("Cantidad").ToString().ToDecimal() * PU)
Next Next
End If End If
End If End If
@@ -2576,6 +2587,11 @@ Partial Class Inventarios_EntregaAlmacen
Dim CveAlmacenApartado = -1 Dim CveAlmacenApartado = -1
Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero()) Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero())
Dim CveSeccionAlmacen As Integer = 0 Dim CveSeccionAlmacen As Integer = 0
Dim ValorTraspaso As Decimal = 0
'SI TIENE APARTADOS DEBE GENERAR LOS TRASPASOS
If DtTempApartados.Rows.Count > 0 Then
For Each Dr As DataRow In DtTempApartados.Rows For Each Dr As DataRow In DtTempApartados.Rows
If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString().ToEntero() Then If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString().ToEntero() Then
@@ -2598,12 +2614,6 @@ Partial Class Inventarios_EntregaAlmacen
TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados") TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados")
Exit For Exit For
End If End If
'If CBool(Dr("AplicaSeccion")) Then
' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenOrigen, Dr("CvePS").ToString().ToEntero()).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero()
' Dim a As String = String.Format("CveAlmacen={0}-CvePS:{1}-CveseccionAlmacen={2}", CveAlmacenOrigen, Dr("CvePS"), CveSeccionAlmacen)
'Else
' CveSeccionAlmacen = -1
'End If
CveSeccionAlmacen = -3 CveSeccionAlmacen = -3
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then
@@ -2614,6 +2624,10 @@ Partial Class Inventarios_EntregaAlmacen
Next Next
If Not ErrorMovInv Then If Not ErrorMovInv Then
Dim CvePrePolizaTraspaso As Integer = ObjConta.AddPrePolizas("EA/Apart", 53, 0, 0, 1, TxtFecha.Text.ToDate, "Traspaso Apartado", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CvePrePolizaTraspaso > 0 Then
For Each Dr1 As DataRow In DtTraspasos.Rows For Each Dr1 As DataRow In DtTraspasos.Rows
CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString().ToEntero() CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString().ToEntero()
@@ -2633,13 +2647,9 @@ Partial Class Inventarios_EntregaAlmacen
Dr1("FolioEntrada") = FolioEntrada Dr1("FolioEntrada") = FolioEntrada
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
ValorTraspaso = ObjInventario.DtResultados.SUMD("Total").RoundSQL
For Each Dr As DataRow In ObjInventario.DtResultados.Rows For Each Dr As DataRow In ObjInventario.DtResultados.Rows
'If CBool(Dr("AplicaSeccion")) Then
' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, Dr1("CveAlmacen").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero()).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero()
' Dim a As String = String.Format("CveAlmacen={0}-CvePS:{1}-CveseccionAlmacen={2}", Dr1("CveAlmacen").ToString().ToEntero(), Dr("CvePS"), CveSeccionAlmacen)
'Else
' CveSeccionAlmacen = -1
'End If
CveSeccionAlmacen = -3 CveSeccionAlmacen = -3
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then
@@ -2652,7 +2662,22 @@ Partial Class Inventarios_EntregaAlmacen
If ErrorMovInv Then Exit For If ErrorMovInv Then Exit For
If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, True, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, TxtFecha.Text.ToDate, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then
ErrorMovInv = True
End If
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, False, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, TxtFecha.Text.ToDate, -1, -1, CveMovimientoAlmacen:=CveMovimientoEntradaApartado, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then
ErrorMovInv = True
End If
Next Next
Else
ErrorMovInv = True
End If
End If
End If End If
End If End If
@@ -2701,6 +2726,7 @@ Partial Class Inventarios_EntregaAlmacen
ErrorMovInv = True ErrorMovInv = True
End If End If
End If End If
Dim TotalVirtual As Decimal = 0
' COMIENZA: VIRTUAL ' COMIENZA: VIRTUAL
If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then
@@ -2758,7 +2784,7 @@ Partial Class Inventarios_EntregaAlmacen
If CveMovimientoVirtual > 0 Then If CveMovimientoVirtual > 0 Then
For Each RowUsado As DataRow In DtPSVirtual.Rows For Each RowUsado As DataRow In DtPSVirtual.Rows
Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() Dim CantidadUsado As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal()
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
@@ -2767,7 +2793,14 @@ Partial Class Inventarios_EntregaAlmacen
TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.") TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.")
Exit For Exit For
End If End If
TotalVirtual += (CantidadUsado * PU)
Next Next
'insertar en prepóliza de la salida virtual
If Not ErrorMovInv Then
ErrorMovInv = Not GenerarPrePoliza(ObjInventario, ObjVentas, ObjConta, CveMovimientoVirtual, TextoError)
End If
Else Else
ErrorMovInv = True ErrorMovInv = True
End If End If
@@ -2920,7 +2953,6 @@ Partial Class Inventarios_EntregaAlmacen
Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero() Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero()
'Dim CveCuentaAlmacen As Integer = 0 'GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero() 'Dim CveCuentaAlmacen As Integer = 0 'GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero()
Dim IdCtaContable As Integer = 0 Dim IdCtaContable As Integer = 0
Dim CveCuenta As Integer = 0
If tmpCostos.Rows.Count > 0 Then If tmpCostos.Rows.Count > 0 Then
@@ -2929,7 +2961,7 @@ Partial Class Inventarios_EntregaAlmacen
Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString().ToEntero() Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString().ToEntero()
Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString() Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString()
Dim Serie As String = ObjVentas.DtResultados(0)("SerieFolio").ToString() Dim Serie As String = ObjVentas.DtResultados(0)("SerieFolio").ToString()
Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundAD() Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL()
Dim TotalCostoAcumulado As Decimal = 0 Dim TotalCostoAcumulado As Decimal = 0
Dim cont As Integer = 1 Dim cont As Integer = 1
@@ -2949,7 +2981,7 @@ Partial Class Inventarios_EntregaAlmacen
If CvePrePoliza > 0 Then If CvePrePoliza > 0 Then
For Each RowInv As DataRow In tmpCostos.Rows For Each RowInv As DataRow In tmpCostos.Rows
ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundAD() ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL()
TotalCostoAcumulado += ValorInventario TotalCostoAcumulado += ValorInventario
'cuando es el último movimiento y hay diferencias en los importes 'cuando es el último movimiento y hay diferencias en los importes
@@ -2959,10 +2991,9 @@ Partial Class Inventarios_EntregaAlmacen
'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString(), Row2("SubProyecto").ToString()) 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString(), Row2("SubProyecto").ToString())
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero()
CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero()
If Not ErrorMovInv Then If Not ErrorMovInv Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, Serie, 69, Serie, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero()) Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, Serie, 69, Serie, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero()) Then
ErrorMovInv = True ErrorMovInv = True
End If End If
End If End If