SELECT Obj.name AS Nombre, Obj.type AS Tipo, Obj.type_desc AS nTiop, Modu.definition AS Consulta FROM CAEY.sys.objects Obj INNER JOIN CAEY.sys.sql_modules Modu ON Obj.object_id = Modu.object_id WHERE (Obj.name IN (SELECT Ats_Sp FROM Afectar_Tabla_Sp WHERE At_Tabla = 'DETALLE_MOVIMIENTO' AND Es_Cve_Estado <> 'BA') ) AND Obj.type = 'P' ORDER BY Obj.name ASC SELECT @@VERSION AS xVersion SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM EMPRESAS..Configuracion WHERE Cf_Variable = 'GEN_VERSION_SQL_AFECTAR' INSERT INTO Comentario(Objeto, Clave, ID, Operador, Fecha, Comentario) VALUES('Producto', '0000001846', '0000000005', 'CONFIG', '2019-06-26 10:40:57', 'Cambio el ultimo costo: Valor anterior: 44.128205129') SELECT GetDate() as Fecha SELECT ISNULL(MAX(ID), 0) as ID FROM Comentario WHERE Objeto = 'Producto' AND Clave = '0000001846' UPDATE Producto SET Pr_Costo_Promedio = 40.8025345168269 ,Pr_Ultimo_Costo = 0 WHERE Pr_Cve_Producto = '0000001846' SELECT Pr_Ultimo_Costo, Pr_Costo_Estandar FROM Producto WHERE Pr_Cve_Producto = '0000001846' SELECT ISNULL(SUM(Ex_Importe_Costo),0) as Ex_Costo, ISNULL(SUM(Ex_Cantidad_Costo),0) as Ex_Cantidad_Costo FROM Existencia WHERE Ex_Cantidad_Costo > 0 and Pr_Cve_Producto = '0000001846' UPDATE Existencia SET Ex_Ultimo_Costo = 0, Ex_Costo_Promedio = 0, Oper_Ult_Modif = 'CONFIG', Fecha_Ult_Modif = '2019-06-26 10:40:57' WHERE Sc_Cve_Sucursal = '0001' AND Al_Cve_Almacen = '0001' AND Pr_Cve_Producto = '0000001846' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' UPDATE Existencia SET Ex_Cantidad_Control_1 = 1, Ex_Cantidad_Control_2 = 1, Ex_Cantidad_Costo = 1, Ex_Cantidad_Disponible_Control_1 = Ex_Cantidad_Disponible_Control_1 + 1, Ex_Cantidad_Disponible_Control_2 = Ex_Cantidad_Disponible_Control_2 + 1, Ex_Importe_Costo = 0, Ex_Cantidad_Kit = 0, Oper_Ult_Modif = 'CONFIG', Fecha_Ult_Modif = '2019-06-26 10:40:57' WHERE Sc_Cve_Sucursal = '0001' AND Al_Cve_Almacen = '0001' AND Pr_Cve_Producto = '0000001846' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' SELECT Ex_Cantidad_Control_1, Ex_Cantidad_Control_2, Ex_Cantidad_Costo, Ex_Costo_Promedio, Ex_Importe_Costo, Ex_Cantidad_Kit FROM Existencia WHERE Sc_Cve_Sucursal = '0001' AND Al_Cve_Almacen = '0001' AND Pr_Cve_Producto = '0000001846' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' INSERT INTO Movimiento (Mv_Folio, Mv_ID, Mv_Fecha, Mv_Tabla, Mv_Documento, Mv_Referencia, Mv_Comentario, Sc_Cve_Sucursal, Al_Cve_Almacen, Tm_Cve_Tipo_Movimiento, Pr_Cve_Producto, Tl_Cve_Talla, Cl_Cve_Color, Mv_Ubicacion, Mv_Cantidad_1, Mv_Unidad_1, Mv_Cantidad_Control_1, Mv_Unidad_Control_1, Mv_Cantidad_Control_2, Mv_Unidad_Control_2, Mv_Cantidad_Costo, Mv_Unidad_Costo, Mv_Costo, Mv_Costo_Importe, Lt_Cve_Lote, Lt_Fecha_Caducidad, Lt_Pedimento, Lt_Fecha_Pedimento, Mk_Id, Oper_Alta, Fecha_Alta, Oper_Ult_Modif, Fecha_Ult_Modif) VALUES ('01-0000065', '0002', '2019-06-26', 'TRANSFERENCIA', '01-0000003', '01-0000003', 'Reversa automática', '0001', '0001', '104', '0000001846', '00', '00', '', 1, 'PZ', 1, 'PZ', 1, 'PZ', 1, 'PZ', 0, 0, '', '1899-12-30', '', '1899-12-30', '', 'CONFIG', '2019-06-26 10:40:57', 'CONFIG', '2019-06-26 10:40:57') SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_FORMATO_FACTOR_CONVERSION' SELECT Un_Descripcion AS Nombre FROM Unidad WHERE Un_Cve_Unidad = 'PZ' AND Es_Cve_Estado <> 'BA' SELECT Pr_Cve_Producto FROM Producto_Talla_Color WHERE Pr_Cve_Producto = '0000001846' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' SELECT Pr_Descripcion AS Nombre FROM Producto WHERE Pr_Cve_Producto = '0000001846' AND Es_Cve_Estado <> 'BA' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_FORMATO_FACTOR_CONVERSION' SELECT Un_Permite_Fracciones FROM Unidad WHERE Un_Cve_Unidad = 'PZ' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_FORMATO_FACTOR_CONVERSION' SELECT Producto.Pr_Tipo_Producto, Producto.Pr_Tipo_Costeo, Producto.Pr_Unidad_Control_1, Producto.Pr_Unidad_Control_2, Producto.Pr_Unidad_Costo, Producto.Pr_Costo_Estandar, Producto.Pr_Porcentaje_Variacion FROM Producto WHERE Producto.Pr_Cve_Producto = '0000001846' SELECT Pr_Equivalencia_Producto AS Nombre FROM Producto WHERE Pr_Cve_Producto = '0000001846' AND Pr_Equivalencia_Inventario = 'SI' SELECT Ex_Costo_Promedio FROM Existencia WHERE Sc_Cve_Sucursal = '0005' AND Al_Cve_Almacen = 'TRAN' AND Pr_Cve_Producto = '0000001846' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' SELECT Pr_Tipo_Costeo FROM Producto WHERE Pr_Cve_Producto = '0000001846' SELECT Ex_Costo_Promedio FROM Existencia WHERE Sc_Cve_Sucursal = '0005' AND Al_Cve_Almacen = 'TRAN' AND Pr_Cve_Producto = '0000001846' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' SELECT Pr_Tipo_Costeo FROM Producto WHERE Pr_Cve_Producto = '0000001846' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_FORMATO_FACTOR_CONVERSION' SELECT Un_Permite_Fracciones FROM Unidad WHERE Un_Cve_Unidad = 'PZ' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_FORMATO_FACTOR_CONVERSION' SELECT Producto.Pr_Tipo_Producto, Producto.Pr_Tipo_Costeo, Producto.Pr_Unidad_Control_1, Producto.Pr_Unidad_Control_2, Producto.Pr_Unidad_Costo, Producto.Pr_Costo_Estandar, Producto.Pr_Porcentaje_Variacion FROM Producto WHERE Producto.Pr_Cve_Producto = '0000001846' SELECT Pr_Equivalencia_Producto AS Nombre FROM Producto WHERE Pr_Cve_Producto = '0000001846' AND Pr_Equivalencia_Inventario = 'SI' SELECT Producto.Pr_Unidad_Control_1, Producto.Pr_Unidad_Control_2, Lote.Lt_Cve_Lote, Lote.Lt_Fecha_Caducidad, Lote.Lt_Pedimento, Lote.Lt_Fecha_Pedimento, Lote.Lt_Aduana, Existencia_Lote.Lt_Cantidad_Control_1, Existencia_Lote.Lt_Cantidad_Control_2 From Existencia_Lote inner join lote on lote.lt_cve_lote = Existencia_Lote.lt_cve_lote and lote.pr_cve_producto = Existencia_Lote.pr_cve_producto inner join producto on producto.pr_cve_producto = Existencia_Lote.pr_cve_producto Where (Existencia_Lote.Lt_Cantidad_Control_1 > 0 or Existencia_Lote.Lt_Cantidad_Control_2 > 0 ) and (Existencia_Lote.Lt_Cantidad_Control_1 >= 0 and Existencia_Lote.Lt_Cantidad_Control_2 >= 0 ) and (Lote.Pr_Cve_Producto = '0000001846' or Lote.Pr_Cve_Producto = '' ) and Existencia_Lote.Sc_Cve_Sucursal = '0005' and Existencia_Lote.Al_Cve_Almacen = 'TRAN' and Existencia_Lote.Tl_Cve_Talla = '00' and Existencia_Lote.Cl_Cve_Color = '00' ORDER BY lote.Lt_Fecha_Caducidad ASC SELECT Pr_Cve_Producto, Pr_Descripcion, Pr_Equivalencia_Producto, Pr_Unidad_Control_1, Pr_Unidad_Control_2 FROM Producto WHERE Pr_Cve_Producto = '0000001846' SELECT Sr_Cve_Serie FROM Serie_Documento where Sd_Documento IN (SELECT Tr_Folio FROM Transferencia WHERE Tr_Folio = '01-0000003' AND Tr_Tipo = 'EN' ) AND Sd_Tabla = 'TRANSFERENCIA' AND Pr_Cve_Producto = '0000001846' AND Sr_Cve_Serie NOT IN ( SELECT Sr_Cve_Serie FROM Serie_Documento where Sd_Documento IN (SELECT Tr_Folio FROM Transferencia WHERE Tr_Referencia = '01-0000003' AND Tr_Tipo = 'RC' ) AND Sd_Tabla = 'TRANSFERENCIA' AND Pr_Cve_Producto = '0000001846' ) SELECT Obj.name AS Nombre, Obj.type AS Tipo, Obj.type_desc AS nTiop, Modu.definition AS Consulta FROM CAEY.sys.objects Obj INNER JOIN CAEY.sys.sql_modules Modu ON Obj.object_id = Modu.object_id WHERE (Obj.name IN (SELECT Ats_Sp FROM Afectar_Tabla_Sp WHERE At_Tabla = 'DETALLE_MOVIMIENTO' AND Es_Cve_Estado <> 'BA') ) AND Obj.type = 'P' ORDER BY Obj.name ASC SELECT @@VERSION AS xVersion SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM EMPRESAS..Configuracion WHERE Cf_Variable = 'GEN_VERSION_SQL_AFECTAR' INSERT INTO Comentario(Objeto, Clave, ID, Operador, Fecha, Comentario) VALUES('Producto', '0000000529', '0000000002', 'CONFIG', '2019-06-26 10:40:57', 'Cambio el ultimo costo: Valor anterior: 140') SELECT GetDate() as Fecha SELECT ISNULL(MAX(ID), 0) as ID FROM Comentario WHERE Objeto = 'Producto' AND Clave = '0000000529' UPDATE Producto SET Pr_Costo_Promedio = 56 ,Pr_Ultimo_Costo = 0 WHERE Pr_Cve_Producto = '0000000529' SELECT Pr_Ultimo_Costo, Pr_Costo_Estandar FROM Producto WHERE Pr_Cve_Producto = '0000000529' SELECT ISNULL(SUM(Ex_Importe_Costo),0) as Ex_Costo, ISNULL(SUM(Ex_Cantidad_Costo),0) as Ex_Cantidad_Costo FROM Existencia WHERE Ex_Cantidad_Costo > 0 and Pr_Cve_Producto = '0000000529' UPDATE Existencia SET Ex_Ultimo_Costo = 0, Ex_Costo_Promedio = 0, Oper_Ult_Modif = 'CONFIG', Fecha_Ult_Modif = '2019-06-26 10:40:57' WHERE Sc_Cve_Sucursal = '0001' AND Al_Cve_Almacen = '0001' AND Pr_Cve_Producto = '0000000529' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' UPDATE Existencia SET Ex_Cantidad_Control_1 = 3, Ex_Cantidad_Control_2 = 3, Ex_Cantidad_Costo = 3, Ex_Cantidad_Disponible_Control_1 = Ex_Cantidad_Disponible_Control_1 + 3, Ex_Cantidad_Disponible_Control_2 = Ex_Cantidad_Disponible_Control_2 + 3, Ex_Importe_Costo = 0, Ex_Cantidad_Kit = 0, Oper_Ult_Modif = 'CONFIG', Fecha_Ult_Modif = '2019-06-26 10:40:57' WHERE Sc_Cve_Sucursal = '0001' AND Al_Cve_Almacen = '0001' AND Pr_Cve_Producto = '0000000529' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' SELECT Ex_Cantidad_Control_1, Ex_Cantidad_Control_2, Ex_Cantidad_Costo, Ex_Costo_Promedio, Ex_Importe_Costo, Ex_Cantidad_Kit FROM Existencia WHERE Sc_Cve_Sucursal = '0001' AND Al_Cve_Almacen = '0001' AND Pr_Cve_Producto = '0000000529' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00' INSERT INTO Movimiento (Mv_Folio, Mv_ID, Mv_Fecha, Mv_Tabla, Mv_Documento, Mv_Referencia, Mv_Comentario, Sc_Cve_Sucursal, Al_Cve_Almacen, Tm_Cve_Tipo_Movimiento, Pr_Cve_Producto, Tl_Cve_Talla, Cl_Cve_Color, Mv_Ubicacion, Mv_Cantidad_1, Mv_Unidad_1, Mv_Cantidad_Control_1, Mv_Unidad_Control_1, Mv_Cantidad_Control_2, Mv_Unidad_Control_2, Mv_Cantidad_Costo, Mv_Unidad_Costo, Mv_Costo, Mv_Costo_Importe, Lt_Cve_Lote, Lt_Fecha_Caducidad, Lt_Pedimento, Lt_Fecha_Pedimento, Mk_Id, Oper_Alta, Fecha_Alta, Oper_Ult_Modif, Fecha_Ult_Modif) VALUES ('01-0000065', '0001', '2019-06-26', 'TRANSFERENCIA', '01-0000003', '01-0000003', 'Reversa automática', '0001', '0001', '104', '0000000529', '00', '00', '', 3, 'PZ', 3, 'PZ', 3, 'PZ', 3, 'PZ', 0, 0, '', '1899-12-30', '', '1899-12-30', '', 'CONFIG', '2019-06-26 10:40:57', 'CONFIG', '2019-06-26 10:40:57') SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_FORMATO_FACTOR_CONVERSION' SELECT Un_Descripcion AS Nombre FROM Unidad WHERE Un_Cve_Unidad = 'PZ' AND Es_Cve_Estado <> 'BA' SELECT Pr_Cve_Producto FROM Producto_Talla_Color WHERE Pr_Cve_Producto = '0000000529' AND Tl_Cve_Talla = '00' AND Cl_Cve_Color = '00'