diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index d7134d6b8..c37e75652 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -898,7 +898,7 @@ Public Class ClsAcumuladores End Function #End Region - Public Function DistribuidorMovtosAdd(CveCliente As Integer, Cantidad As Integer, CveTamaño As Integer, CveConcepto As Integer, CveVenta As Integer, CveUsuario As Integer, + Public Function DistribuidorMovtosAdd(CveCliente As Integer, Cantidad As Decimal, CveTamaño As Integer, CveConcepto As Integer, CveVenta As Integer, CveUsuario As Integer, CveEmpresa As Integer, ImporteCompras As Decimal, Observaciones As String, Optional CveMovimiento As Integer = -1) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable @@ -907,7 +907,7 @@ Public Class ClsAcumuladores With SqlAdapter.SelectCommand.Parameters .Add("@CveCliente", SqlDbType.Int).Value = CveCliente - .Add("@Cantidad", SqlDbType.Int).Value = Cantidad + .Add("@Cantidad", SqlDbType.Decimal).Value = Cantidad .Add("@CveTamaño", SqlDbType.Int).Value = CveTamaño .Add("@CveConcepto", SqlDbType.Int).Value = CveConcepto .Add("@CveVenta", SqlDbType.Int).Value = CveVenta diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 9c2df14e1..1dead2777 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5129,7 +5129,7 @@ Namespace Modelos For Each RowUsado As DataRow In DtPSVirtual.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowUsado("PUOriginal").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then diff --git a/Ashx/E141.ashx b/Ashx/E141.ashx index 51b154202..ca6e8c319 100644 --- a/Ashx/E141.ashx +++ b/Ashx/E141.ashx @@ -49,7 +49,7 @@ Public Class E141 : Implements IHttpHandler Public ReadOnly Property TokenAutorizacion As String Get If EsProduccion Then - Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane" + Return "$2y$10$EZlXnFrhUc4aRVwjy5/v0.3JPdFNjyeANDc64YXJ5eHD8pMsv93Q." Else Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane" End If @@ -59,7 +59,7 @@ Public Class E141 : Implements IHttpHandler Public ReadOnly Property URLBase As String Get If EsProduccion Then - Return "https://econollantas-pruebas.fidelityapps.mx" + Return "https://services.fidelityapps.mx/" Else Return "https://econollantas-pruebas.fidelityapps.mx/" End If @@ -92,28 +92,31 @@ Public Class E141 : Implements IHttpHandler Else context.Response.ContentType = "text/html" - Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString()) + If Not String.IsNullOrEmpty(Metodo) Then + Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString()) - Dim respuesta As Boolean = False + Dim respuesta As Boolean = False - 'TAREAS PROGRAMADAS - Select Case Metodo - Case "CrearActualizarProductos" - respuesta = CrearActualizarProductos(If(FiltrarTodos = "1", True, False)) - Case "ActualizarPrecios" - respuesta = ActualizarPrecios(If(FiltrarTodos = "1", True, False)) - Case "ActualizarExistencias" - respuesta = ActualizarExistencias() - Case "ActualizarVendedores" - respuesta = ActualizarVendedores(If(FiltrarTodos = "1", True, False)) - End Select + 'TAREAS PROGRAMADAS + Select Case Metodo + Case "CrearActualizarProductos" + respuesta = CrearActualizarProductos(If(FiltrarTodos = "1", True, False)) + Case "ActualizarPrecios" + respuesta = ActualizarPrecios(If(FiltrarTodos = "1", True, False)) + Case "ActualizarExistencias" + respuesta = ActualizarExistencias() + Case "ActualizarVendedores" + respuesta = ActualizarVendedores(If(FiltrarTodos = "1", True, False)) + End Select - If respuesta Then - retorno = "True" - Else - retorno = "False" + If respuesta Then + retorno = "True" + Else + retorno = "False" + End If End If + End If context.Response.Write(retorno) @@ -202,7 +205,7 @@ Public Class E141 : Implements IHttpHandler Using httpClient = New HttpClient() httpClient.Timeout = New TimeSpan(0, 5, 0) Using request = New HttpRequestMessage(HttpMethod.Post, New Uri(url)) - request.Headers.Add("token", TokenAutorizacion) + request.Headers.Add("X-PUBLIC-AUTH", TokenAutorizacion) Using content = New StringContent(payload, Encoding.UTF8, "application/json") request.Content = content @@ -607,7 +610,7 @@ Public Class E141 : Implements IHttpHandler End Select If VendedorData.Length > 4 Then - Nombre = String.Concat(VendedorData(VendedorData.Length - 1), " ", VendedorData(VendedorData.Length)) + Nombre = String.Concat(VendedorData(VendedorData.Length - 2), " ", VendedorData(VendedorData.Length - 1)) Apellido = String.Concat(VendedorData(0), " ", VendedorData(1)) End If diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index 532f5c204..67bc6e154 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -2709,7 +2709,7 @@ Partial Class Inventarios_EntregaAlmacen For Each RowUsado As DataRow In DtPSVirtual.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU) Then diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 991f55859..097e61ba0 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -2377,7 +2377,7 @@ Partial Class Inventarios_RecepcionAlmacen Dim CveVendedorActual = -1 Dim CveClienteActual = -1 - Dim CveAlmacenDestino = CveAlmacen + Dim CveAlmacenDestino = CveAlmacenDevolucionProveedor Dim CveSeccionDestino As Integer = -1 'For Each RowAlmacen As DataRow In DtAlmacenesDevolucion.FiltraParametros("", DistinctColumns:={"CveAlmacenOrignal"}).Rows @@ -2884,6 +2884,66 @@ Partial Class Inventarios_RecepcionAlmacen End If Next End If + + If SumarImporteUsados Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) Then + ImporteIngresoAdicional = ObjInventario.DtResultados.SUMD("TotalOriginal") + End If + End If + + Else + If RealizarMovimientoVirtual Then + + Dim DtPSVirtual As New DataTable("DtTamanios") + + Dim CveMovimientoRef As Integer = -1 + If RealizarTraspasoAlmacenDevolucion Then + CveMovimientoRef = CveMovimientoSalidaTraspaso + Else + CveMovimientoRef = CveMovimiento + End If + + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoRef, UsuarioActual.CveEmpresa) Then + DtPSVirtual = ObjInventario.DtResultados + End If + + If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 Then + + Dim CveTipoAlmacenFiltro As Integer = 24 + + Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero()).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() + + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, 13, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCompraSurtir, -1, -1, -1, CveMovimientoRelacionado:=CveMovimientoRef, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="RA/VD") + + If CveMovimientoVirtual > 0 Then + FolioVirtual = ObjInventario.Folio + + For Each RowUsado As DataRow In DtPSVirtual.Rows + Dim CvePS = RowUsado("CvePS").ToString().ToEntero() + Dim CantidadUsado As Decimal = RowUsado("Cantidad").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() + Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + ErrorMovInv = True + Exit For + End If + Next + + If SumarImporteUsados Then + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) Then + ImporteIngresoAdicional = ObjInventario.DtResultados.SUMD("TotalOriginal") + End If + End If + + Else + ErrorMovInv = True + End If + + Else + ErrorMovInv = True + End If + End If End If End If diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index d3f2547ee..5146a4a86 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -882,13 +882,13 @@ Partial Class Inventarios_TraspasoAlmacen dtvirtual = ObjInventario.DtResultados If dtvirtual.Rows.Count > 0 Then - CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtual, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/V", CveMovimientoRelacionado:=CveMovimientoSalida) + CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtualSalida, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/V", CveMovimientoRelacionado:=CveMovimientoSalida) FolioVirtualSalida = ObjInventario.Folio For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() + Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualSalida, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -899,7 +899,7 @@ Partial Class Inventarios_TraspasoAlmacen End If Else ErrorMovInv = True - End If + End If End If AlmacenEntrada = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero) @@ -933,27 +933,23 @@ Partial Class Inventarios_TraspasoAlmacen If Not ChkTransitorio.Checked Then 'SI NO ES TRANSITORIO SE HACE LA RECEPCION DE INMEDIATO If Not ErrorMovInv Then - 'VIRTUAL ENTRADA If RealizarMovimientoVirtual Then - 'Dim CveSubProyecto As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen= {DdlAlmacenDestino.SelectedValue}").ToEntero() - 'SI EL ALMACEN DESTINO ES DE APOPYO LOGISTICO EL ALMACEN VIRTUAL DEBE SER DE APOYO LOGISTICO - Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveSubProyectoOrigen).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero() Dim dtvirtual As DataTable = Nothing If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then dtvirtual = ObjInventario.DtResultados If dtvirtual.Rows.Count > 0 Then ''hay que verificar que se se tengan movimeintos por registrar - CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtual, 36, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/S3") + CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtualEntrada, 36, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/S3") FolioVirtualEntrada = ObjInventario.Folio For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() + Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -965,70 +961,70 @@ Partial Class Inventarios_TraspasoAlmacen Else ErrorMovInv = True - End If - End If - Dim Concepto As String = TxtObservaciones.Text - If Concepto = "" Then Concepto = "Traspaso" - 'AGREGAMOS PREPOLIZAS TRASPASO DIRECTO: - If Not ErrorMovInv Then - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - - Dim resultado As DataTable = ObjInventario.DtResultados - Dim importe As Decimal = resultado.SUMD("Total").RoundSQL - 'Dim IdCtaContableSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue.ToEntero)).ToEntero - 'Dim IdCtaContableEntrada As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenDestino.SelectedValue.ToEntero)).ToEntero - Dim Contabilizable As Boolean = True - - If IdCtaContableOrigen = IdCtaContableDestino And TipoAlmacenDestino <> 26 Then Contabilizable = False - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then - ErrorMovInv = True - End If - - 'si el tipo de almacen de entrada es Almacen sin costo, se registra al costo, la salida. - If TipoAlmacenOrigen <> 26 AndAlso TipoAlmacenDestino = 26 Then - - Dim tCveClasificacion As Integer = DtMovimientos.MAX("CveClasificacion").ToEntero - Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=tCveClasificacion).FiltroPrimero("") - Dim IdCuentaCostos As Integer = -1 - If dr IsNot Nothing Then - IdCuentaCostos = dr("IdCuentaCostos").ToString.ToEntero End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 69, TxtObservaciones.Text, Fecha, IdCuentaCostos, -1, CveClasificacion:=tCveClasificacion, CveSubProyecto:=CveSubProyectoOrigen, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + End If + Dim Concepto As String = TxtObservaciones.Text + If Concepto = "" Then Concepto = "Traspaso" + 'AGREGAMOS PREPOLIZAS TRASPASO DIRECTO: + If Not ErrorMovInv Then + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + + Dim resultado As DataTable = ObjInventario.DtResultados + Dim importe As Decimal = resultado.SUMD("Total").RoundSQL + 'Dim IdCtaContableSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue.ToEntero)).ToEntero + 'Dim IdCtaContableEntrada As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenDestino.SelectedValue.ToEntero)).ToEntero + Dim Contabilizable As Boolean = True + + If IdCtaContableOrigen = IdCtaContableDestino And TipoAlmacenDestino <> 26 Then Contabilizable = False + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + + 'si el tipo de almacen de entrada es Almacen sin costo, se registra al costo, la salida. + If TipoAlmacenOrigen <> 26 AndAlso TipoAlmacenDestino = 26 Then + + Dim tCveClasificacion As Integer = DtMovimientos.MAX("CveClasificacion").ToEntero + Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=tCveClasificacion).FiltroPrimero("") + Dim IdCuentaCostos As Integer = -1 + If dr IsNot Nothing Then + IdCuentaCostos = dr("IdCuentaCostos").ToString.ToEntero + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 69, TxtObservaciones.Text, Fecha, IdCuentaCostos, -1, CveClasificacion:=tCveClasificacion, CveSubProyecto:=CveSubProyectoOrigen, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + Contabilizable = False + importe = 0 + End If + + If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableDestino, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + End If + End If + End If + Else + If Not ErrorMovInv Then + Dim Concepto As String = TxtObservaciones.Text + If Concepto = "" Then Concepto = "Traspaso" + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen2", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + + Dim resultado As DataTable = ObjInventario.DtResultados + Dim importe As Decimal = resultado.SUMD("Total").RoundSQL + Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorio.SelectedValue.ToEntero)).ToEntero + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=importe, Contabilizable:=False) Then ErrorMovInv = True End If - Contabilizable = False - importe = 0 - End If - If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableDestino, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable, ImporteMX:=importe) Then - ErrorMovInv = True + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=importe, Contabilizable:=False) Then + ErrorMovInv = True + End If End If End If End If - End If - Else - If Not ErrorMovInv Then - Dim Concepto As String = TxtObservaciones.Text - If Concepto = "" Then Concepto = "Traspaso" - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen2", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - - Dim resultado As DataTable = ObjInventario.DtResultados - Dim importe As Decimal = resultado.SUMD("Total").RoundSQL - Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorio.SelectedValue.ToEntero)).ToEntero - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=importe, Contabilizable:=False) Then - ErrorMovInv = True - End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=importe, Contabilizable:=False) Then - ErrorMovInv = True - End If - End If - End If - End If @@ -1945,7 +1941,7 @@ Partial Class Inventarios_TraspasoAlmacen For Each RowVirtual As DataRow In dtvirtual.Rows Dim CvePS = RowVirtual("CvePS").ToString().ToEntero() Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString().ToDecimal() - Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal() + Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then @@ -2851,7 +2847,7 @@ Partial Class Inventarios_TraspasoAlmacen Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - Dim excelFile As ExcelFile = excelFile.Load(flatFilePath) + Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) Dim unnamed As Integer = 0 Dim cols As Integer diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index b168f7b82..2f20bd2b4 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -4179,8 +4179,10 @@ AutoGenerateColumns="False" AllowPaging="False" ShowFooter="False"> - - + + + + @@ -4290,7 +4292,7 @@ --%> - + diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 791e4e1d0..18fb5bee9 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -2707,6 +2707,7 @@ Partial Class PV Else Objeto.ddlWS.Attributes.Add("data-pagina", "-1") End If + Objeto.ddlWS.Attributes.Add("data-aplicaparaventa", "1") Objeto.ddlWS.Attributes.Add("data-Estatus", "1") End If End Sub diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 4dc1dfa02..06fa7fab1 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -4570,7 +4570,7 @@
Contrato:
- +
Moneda:
@@ -6038,6 +6038,15 @@

-
-
-
-
- - -
-
-
@@ -7235,13 +7235,14 @@ TxtImporte.value = FormatoNumero(Saldo, 2); } } else { - if (SaldoMaximoUtilizable > 0) { - TxtImporte.value = ""; - Chk.checked = false; - } else { - TxtImporte.value = FormatoNumero(Saldo, 2); - } - + TxtImporte.value = ""; + Chk.checked = false; + //if (SaldoMaximoUtilizable > 0) { + // TxtImporte.value = ""; + // Chk.checked = false; + //} else { + // TxtImporte.value = FormatoNumero(Saldo, 2); + //} } } else { diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index bb45e35a0..69d5f99cf 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -3526,6 +3526,8 @@ Partial Class Ventas End If End If + CalculaUsados() + CalculaTotalesVenta() LbAgregar.Visible = False UpPS.Update() @@ -5690,7 +5692,7 @@ Partial Class Ventas DivVentasUsados.Visible = True Dim ObjClientes As New ClsClientes - If ObjClientes.GetHistorialVentas(CveCliente, 1000, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1, FechaI:=Now.AddMonths(-1)) Then + If ObjClientes.GetHistorialVentas(CveCliente, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1, FechaI:=Now.AddMonths(-1)) Then DdlVentaUsado.DataSource = ObjClientes.DtResultados.FiltraParametros("UsadoMarcado = 0") End If ObjClientes.Dispose() @@ -5789,7 +5791,7 @@ Partial Class Ventas UpFacturasRelacionadas.Update() End Sub Protected Sub CreaTmpFacturasRelacionadas() - If CveVenta <= 0 Then + If CveVenta <= 0 OrElse EsCreaApartirDe Then Me.TmpDTFacturasRelacionadas = New DataTable() Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("CveVenta", GetType(Integer))) Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("SerieFolio", GetType(String))) @@ -5797,7 +5799,7 @@ Partial Class Ventas End If End Sub Protected Sub LnkAgregarFacturaRelacionada_Click(sender As Object, e As EventArgs) - If CveVenta <= 0 Then + If CveVenta <= 0 OrElse EsCreaApartirDe Then If Me.TmpDTFacturasRelacionadas Is Nothing Then CreaTmpFacturasRelacionadas() End If @@ -5827,7 +5829,7 @@ Partial Class Ventas End Sub Protected Sub BtnAgregarFacturasRelaciondas_Click(sender As Object, e As EventArgs) - If CveVenta <= 0 Then + If CveVenta <= 0 OrElse EsCreaApartirDe Then If Me.TmpDTFacturasRelacionadas Is Nothing OrElse Me.TmpDTFacturasRelacionadas.Rows.Count = 0 Then Me.AplicaRelacionManual = False Alert("No hay facturas para relacionar", TipoMensaje.MsgAdvertencia) @@ -7002,7 +7004,7 @@ Partial Class Ventas End If If (CveVenta > 0 And DdlTipoComprobante.SelectedValue <> "Cot") AndAlso Not AplicaDevolucion Then - If e.Row.DBCampo("CveConcepto").ToEntero() = 3 Then CveAlmacenDevolucion = e.Row.DBCampo("CveAlmacen").ToEntero() + If e.Row.DBCampo("CveConcepto").ToEntero().Contiene(3, 40) Then CveAlmacenDevolucion = e.Row.DBCampo("CveAlmacen").ToEntero() e.Row.FCCheckBox("cbInv").Visible = False End If @@ -8197,7 +8199,7 @@ Partial Class Ventas 'MUESTA ALERT OK ' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-. - Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=3"";")) + Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=2"";")) Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga) MensajeAlert.Clear() @@ -10736,9 +10738,34 @@ Partial Class Ventas 'SI SE FACTURA UNA RNC SE MUESTRA If UsuarioActual.CveEmpresa = 140 AndAlso factura.TipoDocto = "Egs" Then If Row("CveVentaDetalleRNC").ToString().ToEntero() > 0 Then + If Not ObjVentas.AddVentaDetalleRNCFacturada(Row("CveVentaDetalleRNC").ToString().ToEntero(), ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDecimal()) Then ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") End If + + 'SI SE FACTURAN RNC DE CARGO, SE AGREGA EL CONCEPTO DE ACREDITAMIENTO + If ClienteEsDistribuidor AndAlso RblRNCTipo.SelectedValue = "1" Then + Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL()) + + Dim CvePSCargo As Integer = -1 + For Each RNC In ListaRemisionesNC + CvePSCargo = RNC.DtDetalle.FiltroPrimeroValor("CvePS", $"CveVentaDetalle={Row("CveVentaDetalleRNC").ToString()}").ToEntero() + If CvePSCargo > 0 Then + Exit For + End If + Next + + Dim CveTamanio As Integer = GlobalDTAcumTamaños().FiltroPrimeroValor("CveTamaño", $"CvePSCargo={CvePSCargo}").ToEntero() + + If CveTamanio > 0 Then + If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Row("Cantidad").ToString().ToDecimal(), CveTamanio, 6, factura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0D, "") Then + ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.") + Exit For + End If + End If + + End If + End If End If @@ -14666,7 +14693,7 @@ Partial Class Ventas 'MUESTA Alert OK 'MensajeAlert.Append("El Documento se generó correctamente") - Dim Liga = If(UsuarioActual.CveRol = 1165, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=3"";") + Dim Liga = If(UsuarioActual.CveRol = 1165, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=2"";") Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga) TrEmitir.Visible = False @@ -15728,7 +15755,13 @@ Partial Class Ventas TrVistaPrevia.Visible = True UpFacturar.Update() Else - Alert("No tiene registrados Folios para " & DdlTipoComprobante.SelectedItem.Text & " en esta sucursal.", TipoMensaje.MsgAdvertencia) + + If DdlTipoComprobante.Items.Count > 0 Then + Alert("No tiene registrados Folios para " & DdlTipoComprobante.SelectedItem.Text & " en esta sucursal.", TipoMensaje.MsgAdvertencia) + Else + Alert("No tiene permisos para generar ningun tipo de documento.", TipoMensaje.MsgAdvertencia) + End If + TrEmitir.Visible = False TrVistaPrevia.Visible = False BtnCrearApartirDe.Enabled = False @@ -17728,6 +17761,7 @@ Partial Class Ventas DtRemConceptosSurtidos = Nothing Dim TieneMovimientosSinCosto As Boolean = False + Dim TieneMovimientosContrato As Boolean = False 'Obtenemos los movimientos detalle If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then @@ -17765,6 +17799,8 @@ Partial Class Ventas TieneMovimientosSinCosto = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen=26") > 0 + TieneMovimientosContrato = DtMovimientosDetalles.COUNT("CveTipoAlmacen", "CveTipoAlmacen IN (11)") > 0 + For Each dr As DataRow In DtMovimientos.Rows 'Obtenemos los Movimientos de salida If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString().ToEntero(), ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then @@ -17787,7 +17823,12 @@ Partial Class Ventas If TieneMovimientosSinCosto Then MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") Else - MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (TieneSalidaxFactura IS NULL OR SaldoAlmacen > 0)")) + If TieneMovimientosContrato Then + MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}")) + Else + MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND (TieneSalidaxFactura IS NULL OR SaldoAlmacen > 0)")) + End If + End If Else MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") @@ -17841,10 +17882,6 @@ Partial Class Ventas 'Le damos salida normal If ConSalida AndAlso Not OcurrioError Then - If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then - OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura, ObjConta:=ObjConta) - End If - If Not OcurrioError Then GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenParaSalida, CveConceptoSalidaAlmacen, CveMoneda, ObjFactura.CveVenta, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 @@ -17852,6 +17889,10 @@ Partial Class Ventas OcurrioError = True Exit For End If + + If Not OcurrioError AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" Then + OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura, ObjConta:=ObjConta) + End If End If End If @@ -18225,26 +18266,43 @@ Partial Class Ventas Dim CveConceptoMovimientoVirtual As Integer = 37 Dim DtPSVirtual As DataTable = Nothing Dim DtTamanios As DataTable = Nothing - Dim CveMovimientoEntradaDev As Integer = -1 - Dim CveSubProyecto As Integer = -1 + Dim CveMovimientoReferencia As Integer = -1 + 'SI LA REMISION SE SURTIO CON USADOS UTILIZAR ESTE MOVIMIENTO If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then - Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND ((CveTipoAlmacen = 24 AND CveConcepto = 2) OR (CveTipoAlmacen = 1 AND CveConcepto = 8)) AND CveVenta > 0") + Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND (CveTipoAlmacen = 24 AND CveConcepto = 2) AND CveVenta > 0") If RowMovimiento IsNot Nothing Then - CveMovimientoEntradaDev = RowMovimiento("CveMovimiento").ToString().ToEntero() + CveMovimientoReferencia = RowMovimiento("CveMovimiento").ToString().ToEntero() Dim tCveAlmacen = RowMovimiento("CveAlmacen").ToString().ToEntero() - CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen= {tCveAlmacen}").ToEntero() CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() - - Else - OcurrioError = True End If Else OcurrioError = True End If - If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoEntradaDev, UsuarioActual.CveEmpresa) Then + + 'SI NO SE SURTIO LA REMSION CON USADOS, UTILIZAR EL MOVIMIENTO DE SALIDA DEL INGRESO + If CveMovimientoReferencia <= 0 Then + If ObjInventario.GetInv_Mov(ObjFactura.CveVenta, UsuarioActual.CveEmpresa) Then + Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND ( (CveTipoAlmacen = 1 AND CveConcepto = 3) OR (CveTipoAlmacen = 10 AND CveConcepto = 40) ) AND CveVenta > 0") + + If RowMovimiento IsNot Nothing Then + CveMovimientoReferencia = RowMovimiento("CveMovimiento").ToString().ToEntero() + Dim tCveAlmacen = RowMovimiento("CveAlmacen").ToString().ToEntero() + CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() + + Else + OcurrioError = True + End If + + Else + OcurrioError = True + End If + End If + + + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoReferencia, UsuarioActual.CveEmpresa) Then DtPSVirtual = ObjInventario.DtResultados.Copy() Else OcurrioError = True @@ -18252,13 +18310,13 @@ Partial Class Ventas If Not OcurrioError AndAlso DtPSVirtual.Rows.Count > 0 Then - CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/VV", CveMovimientoRelacionado:=CveMovimientoEntradaDev) + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/VV", CveMovimientoRelacionado:=CveMovimientoReferencia) If CveMovimientoVirtual > 0 Then For Each RowUsado As DataRow In DtPSVirtual.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then @@ -18328,6 +18386,123 @@ Partial Class Ventas OcurrioError = True End Try + Return Not OcurrioError + + End Function + Private Function GenerarMovimientoAlmacenVirtualConsignacion(CveVenta As Integer, CveAlmacenContrato As Integer, ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura, Optional ByRef ObjConta As ClsContabilidad = Nothing) As Boolean + Dim OcurrioError As Boolean = False + + If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then + Try + Dim CveMovimientoVirtual As Integer = -1 + Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenContrato).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() + + Dim CveConceptoMovimientoVirtual As Integer = 37 + Dim DtPSVirtual As DataTable = Nothing + Dim DtTamanios As DataTable = Nothing + Dim CveMovimientoReferencia As Integer = -1 + Dim CveSubProyecto As Integer = -1 + + + If ObjInventario.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then + Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND ((CveTipoAlmacen = 24 AND CveConcepto = 2) OR (CveTipoAlmacen = 17 AND CveConcepto = 8)) AND CveVenta > 0") + + If RowMovimiento IsNot Nothing Then + CveMovimientoReferencia = RowMovimiento("CveMovimiento").ToString().ToEntero() + Else + OcurrioError = True + End If + + Else + OcurrioError = True + End If + + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoReferencia, UsuarioActual.CveEmpresa) Then + DtPSVirtual = ObjInventario.DtResultados.Copy() + Else + OcurrioError = True + End If + + If Not OcurrioError AndAlso DtPSVirtual.Rows.Count > 0 Then + + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/VV", CveMovimientoRelacionado:=CveMovimientoReferencia) + + If CveMovimientoVirtual > 0 Then + For Each RowUsado As DataRow In DtPSVirtual.Rows + Dim CvePS = RowUsado("CvePS").ToString().ToEntero() + Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() + Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() + Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then + OcurrioError = True + Exit For + End If + Next + Else + OcurrioError = True + End If + + 'Agregamos las PrePolizas + If Not OcurrioError Then + If CveMovimientoVirtual > 0 Then + 'OcurrioError = Not GeneraPrePolizaMovimientoAlmacen(ObjInventario, ObjConta, ObjContPaq, ObjFactura, ObjFactura.CvePrePoliza, CveMovimientoInventario, CveAlmacen) + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim DtCostos = ObjInventario.DtResultados.Copy + Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim ValorInventario As Decimal + Dim TotalCostoAcumulado As Decimal = 0D + Dim Cont As Integer = 1 + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL + + For Each RowInv As DataRow In DtCostosDistinct.Rows + ValorInventario = DtCostos.SUMD("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).RoundSQL + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() + TotalCostoAcumulado += ValorInventario + + 'cuando es el último movimiento y hay diferencias en los importes + If Cont = DtCostosDistinct.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + Try + 'If ValorInventario <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ValorInventario, ObjFactura.SerieFolio, 69, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero(), CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + Exit For + End If + 'End If + Catch ex As Exception + OcurrioError = True + Alert("Error inesperado (15148). Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) + End Try + Cont += 1 + Next + + If Not OcurrioError Then + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacenVirtual)).ToEntero() + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, TotalCosto, ObjFactura.SerieFolio, 68, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + End If + End If + Else + OcurrioError = True + End If + End If + End If + + End If + + Catch ex As Exception + OnError("Ocurrió un error al generar el almacen virtual.", ex) + OcurrioError = True + End Try + End If + + Return Not OcurrioError End Function @@ -22359,7 +22534,7 @@ Partial Class Ventas Dim CveUnidad As Integer Dim Cantidad As Double Dim Existencia As Double - For Each Dr As DataRow In TmpDT.Rows + For Each Dr As DataRow In TmpDT.FiltraParametros("CveTipoPS=2").Rows CveProducto = Dr("CvePS").ToString().ToEntero() CveUnidad = Dr("CveUM").ToString().ToEntero() Cantidad = Dr("Cantidad").ToString().ToDouble @@ -22489,6 +22664,11 @@ Partial Class Ventas End If + If Not GenerarMovimientoAlmacenVirtualConsignacion(factura.CveVenta, CveAlmacenExistenciasContrato, ObjInventario, factura, ObjConta) Then + Return False + End If + + Return True End Function @@ -23956,10 +24136,18 @@ Partial Class Ventas If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2) DivSMU.Visible = True - HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() - LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) + + Dim SaldoMaximo As Decimal = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal() + If SaldoMaximo > 0 Then + HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() + LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) + Else + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If + Else - DivSMU.Visible = False + 'DivSMU.Visible = False HdnSaldoMaximoUsados.Value = "0" LtlSMU.Text = "0" End If @@ -23999,8 +24187,15 @@ Partial Class Ventas DivSMU.Visible = True Dim FacUsado As New Modelos.Factura(UsuarioActual, CveVentaUsado, UsuarioActual.CveEmpresa) Dim SaldoMaximoUsados As Decimal = FacUsado.DtDetalle.SUM("Total", "EsCargo = True").ToDecimal() + FacUsado.DtDetalle.SUM("ImporteIVA", "EsCargo = True").ToDecimal() - HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() - LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) + + If SaldoMaximoUsados > 0 Then + HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados) + Else + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If + Else Dim ObjAcum As New ClsAcumuladores If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then @@ -24009,7 +24204,7 @@ Partial Class Ventas HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString() LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2) Else - DivSMU.Visible = False + 'DivSMU.Visible = False HdnSaldoMaximoUsados.Value = "0" LtlSMU.Text = "0" End If @@ -24041,9 +24236,14 @@ Partial Class Ventas GvDescNCBonificaciones.DataBind() Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal() + If SaldoMaximoUsados > 0 Then + LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) + HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() + Else + HdnSaldoMaximoUsados.Value = "0" + LtlSMU.Text = "0" + End If - LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados) - HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString() UpDescNC.Update() End Sub @@ -27347,6 +27547,13 @@ Partial Class Ventas BloqueaCondiconesPago() + + DivDdlFacturaRela.Visible = True + BtnAgregarFacturasRelaciondas.Visible = True + DdlTipoRelacionARelacionar.Enabled = True + + GvFacturasRelacionadas.Columns(2).Visible = True + UpnTools.Update() UpCliente.Update() UpParametros.Update() @@ -27359,6 +27566,7 @@ Partial Class Ventas UpEstatus.Update() UpParametros.Update() UpINV.Update() + UpFacturasRelacionadas.Update() End Sub #End Region