-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeedData_Inventory.sql
More file actions
227 lines (181 loc) · 7.56 KB
/
Copy pathSeedData_Inventory.sql
File metadata and controls
227 lines (181 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
-- ============================================================
-- Script de Datos de Prueba - Módulo de Inventory
-- ============================================================
-- Este script inserta datos de ejemplo para probar RF03:
-- Consulta en Tiempo Real de Disponibilidad de Productos
-- ============================================================
USE PoliMarketDb;
GO
-- ============================================================
-- PROVEEDORES (Suppliers)
-- ============================================================
IF NOT EXISTS (SELECT 1 FROM Inventory.Suppliers WHERE Id = 1)
BEGIN
SET IDENTITY_INSERT Inventory.Suppliers ON;
INSERT INTO Inventory.Suppliers (Id, Name, Email)
VALUES
(1, 'Tech Distributors Inc.', 'ventas@techdist.com'),
(2, 'Global Computer Supplies', 'info@globalcomp.com'),
(3, 'Office Equipment Pro', 'contacto@officeequip.com'),
(4, 'Digital Hardware Solutions', 'sales@digitalhw.com'),
(5, 'Premium Tech Imports', 'orders@premiumtech.com');
SET IDENTITY_INSERT Inventory.Suppliers OFF;
PRINT 'Proveedores insertados correctamente';
END
ELSE
BEGIN
PRINT 'Los proveedores ya existen, omitiendo inserción';
END
GO
-- ============================================================
-- PRODUCTOS (Products)
-- ============================================================
IF NOT EXISTS (SELECT 1 FROM Inventory.Products WHERE Id = 1)
BEGIN
SET IDENTITY_INSERT Inventory.Products ON;
INSERT INTO Inventory.Products (Id, Code, Name, Description, SalePrice, QuantityAvailable, MinStockLevel)
VALUES
-- Productos con Stock Normal (para CA 3.2 - Validación Positiva)
(1, 'PROD-001', 'Laptop Dell XPS 13',
'Laptop ultraliviana con procesador Intel i7, 16GB RAM, 512GB SSD',
1299.99, 15, 5),
(2, 'PROD-002', 'Monitor LG 27" 4K',
'Monitor profesional 27 pulgadas, resolución 4K, panel IPS',
399.99, 25, 10),
(3, 'PROD-003', 'Teclado Mecánico Logitech MX Keys',
'Teclado mecánico retroiluminado, conexión USB y Bluetooth',
129.99, 50, 15),
-- Productos con Stock Bajo (para alertas)
(4, 'PROD-004', 'Mouse Logitech MX Master 3',
'Mouse ergonómico inalámbrico con 7 botones programables',
99.99, 3, 10),
(5, 'PROD-005', 'Webcam Logitech Brio 4K',
'Cámara web profesional con resolución 4K y HDR',
199.99, 5, 8),
-- Productos Sin Stock (para CA 3.3 - Validación Negativa)
(6, 'PROD-006', 'Auriculares Sony WH-1000XM5',
'Auriculares premium con cancelación de ruido activa',
349.99, 0, 5),
(7, 'PROD-007', 'Tablet Samsung Galaxy Tab S9',
'Tablet Android 13", 8GB RAM, 256GB almacenamiento',
599.99, 0, 3),
-- Más productos con stock variado
(8, 'PROD-008', 'Impresora HP LaserJet Pro',
'Impresora láser monocromática, 40 ppm, WiFi',
279.99, 12, 4),
(9, 'PROD-009', 'Disco Duro Externo Seagate 2TB',
'Disco duro portátil USB 3.0, 2TB de capacidad',
79.99, 40, 20),
(10, 'PROD-010', 'Router TP-Link AX3000',
'Router WiFi 6 de doble banda, 3000 Mbps',
149.99, 18, 8);
SET IDENTITY_INSERT Inventory.Products OFF;
PRINT 'Productos insertados correctamente';
END
ELSE
BEGIN
PRINT 'Los productos ya existen, omitiendo inserción';
END
GO
-- ============================================================
-- RELACIÓN PRODUCTOS-PROVEEDORES (ProductSuppliers)
-- ============================================================
IF NOT EXISTS (SELECT 1 FROM Inventory.ProductSuppliers WHERE ProductId = 1)
BEGIN
INSERT INTO Inventory.ProductSuppliers (ProductId, SupplierId, LastPurchasePrice, SupplierProductCode)
VALUES
-- Laptop Dell XPS 13
(1, 1, 999.99, 'DELL-XPS13-2024'),
(1, 2, 1050.00, 'XPS-13-I7-16-512'),
-- Monitor LG 27"
(2, 1, 320.00, 'LG-27UK850'),
(2, 4, 315.00, 'MON-27-4K-IPS'),
-- Teclado Mecánico
(3, 3, 95.00, 'LOG-MXKEYS-BLK'),
(3, 5, 98.00, 'KEYB-MX-MECH'),
-- Mouse Logitech
(4, 1, 75.00, 'LOG-MXM3-GY'),
(4, 3, 72.50, 'MOUSE-MX-MASTER-3'),
-- Webcam
(5, 2, 150.00, 'LOG-BRIO-4K'),
(5, 5, 155.00, 'WEBCAM-4K-HDR'),
-- Auriculares Sony
(6, 4, 280.00, 'SONY-WH1000XM5-BLK'),
(6, 5, 275.00, 'ANC-HEADPHONES-PREMIUM'),
-- Tablet Samsung
(7, 2, 480.00, 'SAM-TABS9-256-BLK'),
(7, 4, 490.00, 'TABLET-ANDROID-13'),
-- Impresora HP
(8, 1, 220.00, 'HP-LJ-PRO-M404DN'),
(8, 3, 225.00, 'PRINT-LASER-MONO'),
-- Disco Duro
(9, 2, 60.00, 'SEA-EXT-2TB-USB3'),
(9, 4, 58.00, 'HDD-PORTABLE-2TB'),
-- Router
(10, 1, 115.00, 'TPL-AX3000-WIFI6'),
(10, 4, 120.00, 'ROUTER-WIFI6-DUAL');
PRINT 'Relaciones Productos-Proveedores insertadas correctamente';
END
ELSE
BEGIN
PRINT 'Las relaciones ya existen, omitiendo inserción';
END
GO
-- ============================================================
-- RESUMEN DE DATOS INSERTADOS
-- ============================================================
PRINT '';
PRINT '============================================================';
PRINT 'RESUMEN DE DATOS DE PRUEBA - MÓDULO INVENTORY';
PRINT '============================================================';
PRINT '';
-- Contar registros
DECLARE @TotalSuppliers INT, @TotalProducts INT, @TotalRelations INT;
SELECT @TotalSuppliers = COUNT(*) FROM Inventory.Suppliers;
SELECT @TotalProducts = COUNT(*) FROM Inventory.Products;
SELECT @TotalRelations = COUNT(*) FROM Inventory.ProductSuppliers;
PRINT 'Total Proveedores: ' + CAST(@TotalSuppliers AS VARCHAR(10));
PRINT 'Total Productos: ' + CAST(@TotalProducts AS VARCHAR(10));
PRINT 'Total Relaciones Productos-Proveedores: ' + CAST(@TotalRelations AS VARCHAR(10));
PRINT '';
-- Estadísticas de stock
PRINT '--- Estadísticas de Stock ---';
SELECT
'Productos con stock disponible' AS Categoria,
COUNT(*) AS Cantidad
FROM Inventory.Products
WHERE QuantityAvailable > 0
UNION ALL
SELECT
'Productos sin stock' AS Categoria,
COUNT(*) AS Cantidad
FROM Inventory.Products
WHERE QuantityAvailable = 0
UNION ALL
SELECT
'Productos con stock bajo' AS Categoria,
COUNT(*) AS Cantidad
FROM Inventory.Products
WHERE QuantityAvailable > 0 AND QuantityAvailable <= MinStockLevel;
PRINT '';
PRINT '============================================================';
PRINT 'PRODUCTOS PARA TESTING DE RF03';
PRINT '============================================================';
PRINT '';
PRINT '✓ CA 3.2 (Validación Positiva - Stock Suficiente):';
PRINT ' - Producto ID 1: Laptop Dell (Stock: 15 unidades)';
PRINT ' - Producto ID 2: Monitor LG (Stock: 25 unidades)';
PRINT ' - Producto ID 3: Teclado (Stock: 50 unidades)';
PRINT '';
PRINT '⚠ Productos con Stock Bajo (Alertas):';
PRINT ' - Producto ID 4: Mouse (Stock: 3 unidades, Mínimo: 10)';
PRINT ' - Producto ID 5: Webcam (Stock: 5 unidades, Mínimo: 8)';
PRINT '';
PRINT '✗ CA 3.3 (Validación Negativa - Sin Stock):';
PRINT ' - Producto ID 6: Auriculares Sony (Stock: 0)';
PRINT ' - Producto ID 7: Tablet Samsung (Stock: 0)';
PRINT '';
PRINT '============================================================';
PRINT 'Scripts completados exitosamente';
PRINT '============================================================';
GO